empty xmlns attribute in child elements [message #91709] |
Fri, 17 January 2003 04:37 |
Phil
Messages: 32 Registered: March 2001
|
Member |
|
|
Hi,
I have a strange problem creating a dom document using the xdk for pl/sql.
When I define a xmlns="http://www.whatever.com" attribute in the root element, the parser adds
a xmlns="" attribute to each child element.
This behaviour started when I upgraded to the latest xdk (oracle.xml.parser.v2.XMLParser.getReleaseVersion() returns "Oracle XDK Java 9.2.0.4.0 Production").
The following code sample produces the output below (I used [[]] instead of <>, cause otherwise the code would not show.):
domdoc := xmldom.newDOMDocument;
xmldom.setVersion(domdoc, '1.0');
node_main := xmldom.makeNode(domdoc);
elmt_Test := xmldom.createElement(domdoc, 'TestTag');
xmldom.setAttribute(elmt_Test,'xmlns','http://www.foo.bar');
node_Test := xmldom.appendChild(node_main, xmldom.makeNode(elmt_Test));
elmt_Child1 := xmldom.createElement(domdoc, 'Child1');
node_Child1 := xmldom.appendChild(node_Test, xmldom.makeNode(elmt_Child1));
elmt_Child2 := xmldom.createElement(domdoc, 'Child2');
node_Child2 := xmldom.appendChild(node_Test, xmldom.makeNode(elmt_Child2));
elmt_Child3 := xmldom.createElement(domdoc, 'Child3');
node_Child3 := xmldom.appendChild(node_Child1, xmldom.makeNode(elmt_Child3));
xmldom.WRITETOBUFFER(domdoc, v_xml);
DBMS_OUTPUT.PUT_LINE(v_xml);
[[?xml version = '1.0'?]]
[[TestTag xmlns="http://www.foo.bar"]]
[[Child1 xmlns=""]]
[[Child3/]]
[[/Child1]]
[[Child2 xmlns=""/]]
[[/TestTag]]
Whereas in another database, where oracle.xml.parser.v2.XMLParser.getReleaseVersion() returns "Oracle XML Parser 2.0.2.9.0 Production",
the same PL/SQL block produces this output:
[[?xml version = '1.0'?]]
[[TestTag xmlns="http://www.foo.bar"]]
[[Child1 sdg="sdf"]]
[[Child3/]]
[[/Child1]]
[[Child2/]]
[[/TestTag]]
Some guy encountered the same problem using msxml parser, reported so on
http://www.experts-exchange.com/Web/Web_Languages/XML/Q_20362254.html . The solution he said worked for him
can unfortunately not be applied in my situation.
Any advice appreciated, I'm having a little "time problem" on my job right now, and the documents created with those stupid
empty xmlns attributes won't validate against my schema (which i cannot edit/change).
Thanks a lot whoever can help me out.
Cheers
Phil
|
|
|
|
|
|