Bonjour à tous,
J'ai un xml de départ :
et j'aimerais simplement extraire le noeud <XEditorValue> (+ les noeuds fils) et rajouter un namespace à cette balise <XEditorValue> pour au final avoir ce xml :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 <element ref="AETITLE" sn="4496" unit="texte" type="char" default-type="combobox" xmlns="http://www.eppocratic.com/xml-definition/1.0"> <label>AETITLE</label> <e> <JUniversGrid/> </e> <XEditorValue> <JUniversGrid> <RequestBinding> <Request connectionSId="gips"> <Source entitySId="Rub:AETITLE" mainSource="true"/> </Request> <Order implementationSId="code"/> </RequestBinding> <Component bind="code"/> </JUniversGrid> </XEditorValue> <option>Radio</option> </element>
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12 <XEditorValue xmlns="http://www.eppocratic.com/xml-definition/1.0"> <JUniversGrid> <RequestBinding> <Request connectionSId="gips"> <Source entitySId="Rub:AETITLE" mainSource="true"/> </Request> <Order implementationSId="code"/> </RequestBinding> <Component bind="code"/> </JUniversGrid> </XEditorValue>
J'ai essayé ceci (script avec sortie OWA) :
Mais le résultat est louche, il me met 2 fois l'attribut xmlns pour la balise <XEditorValue> (une fois vide et une fois correct) et également un attribut xmlns vide pour la balise <JUniversGrid>
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48 DECLARE d dbms_xmldom.DOMDocument; dn dbms_xmldom.DOMElement; xml XMLTYPE; l_clob clob; l_len PLS_INTEGER := 255; l_idx PLS_INTEGER := 1; BEGIN xml := XMLTYPE('<element ref="AETITLE" sn="4496" unit="texte" type="char" default-type="combobox" xmlns="http://www.eppocratic.com/xml-definition/1.0"> <label>AETITLE</label> <e> <JUniversGrid/> </e> <XEditorValue> <JUniversGrid> <RequestBinding> <Request connectionSId="gips"> <Source entitySId="Rub:AETITLE" mainSource="true"/> </Request> <Order implementationSId="code"/> </RequestBinding> <Component bind="code"/> </JUniversGrid> </XEditorValue> <option>Radio</option> </element>'); xml := DP_STUDIO_EXPORT.removeNS(xml); select extract(xml,'element/XEditorValue') into xml from dual; d := dbms_xmldom.newDOMDocument(xml); dn := dbms_xmldom.getDocumentElement(d); dbms_xmldom.setAttribute(dn,'xmlns','http://www.monnamespace.com/definition'); l_clob := xml.getClobVal(); -- OUTPUT RESULTS owa_util.mime_header('application/xml', false); owa_util.http_header_close; for i in 1..ceil(dbms_lob.getlength(l_clob)/l_len) loop htp.prn(substr(l_clob,l_idx,l_len)); l_idx := l_idx + l_len; end loop; END;
Résultat :
Qqun peut-il m'aider svp ?
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11 <XEditorValue xmlns="" xmlns="http://www.monnamespace.com/definition"> <JUniversGrid xmlns=""> <RequestBinding> <Request connectionSId="gips"> <Source entitySId="Rub:AETITLE" mainSource="true"/> </Request> <Order implementationSId="code"/> </RequestBinding> <Component bind="code"/> </JUniversGrid> </XEditorValue>
Merci
Partager