[jdom-interest] Help at XMLOutputter!!
Itoh, Kazuhiro
kazuhiro-i at kajima.com
Thu Oct 23 00:57:22 PDT 2003
Dear All:
I am Kazuhiro from Japan.
I met strange outcome using XMLOutputter.(JDOM version is beta9, JDK
version is 1.4.1_03, OS Win2k)
Here is the portion of my program.
//Create JDOM using Namespace declaration
SAXBuilder builder = new SAXBuilder();
Document jdom = new Document();
Namespace ns= Namespace.getNamespace("myspace", "fooBar");
jdom.setRootElement(new Element("return", ns));
jdom.getRootElement().setText("Foo Bar");
//Write this JDOM
XMLOutputter xmlOut = new XMLOutputter(" ",true);
xmlOut.output(jdom, new FileWriter("c:\\temp\\fooBarJDOM.xml"));
Then let me show you the output by above statement.
<?xml version="1.0" encoding="UTF-8"?>
<myspace:return xmlns:myspace="fooBar">Foo Bar</myspace:return>
Then I translated jdom to w3c Document like following...
//JDOM->W3C
DOMOutputter outPutter = new DOMOutputter();
org.w3c.dom.Document doc = null;
doc = outPutter.output(jdom);
//Write w3c Document using AXIS Utility(This fragment from certain Web
Services)
org.apache.axis.utils.XMLUtils.DocumentToWriter(doc, new
FileWriter("c:\\temp\\fooBarDOM.xml"));
The above output is here.
<?xml version="1.0" encoding="UTF-8"?>
<myspace:return xmlns:myspace="fooBar" xmlns:myspace="fooBar">Foo
Bar</myspace:return>
There is duplicate Namespace declaration in the root-tag<return>.
Is this Bug? or is my way wrong?
Please help me.
More information about the jdom-interest
mailing list