[jdom-interest] Namespaces and XMLOutputter
Jason Hunter
jhunter at collab.net
Fri Jan 19 11:29:39 PST 2001
Thanks for sending in the code for me to try. I think you're still
running against beta5 somehow. I fixed this exact xmlns placement bug
in DOMBuilder about 2-3 weeks ago and daily snapshot I have behaves
correctly:
C:/tmp/jdom 64 % java TestClass ns.xml
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE a:messagelist><a:messagelist xmlns:a="http://www.a.com"
xmlns:b="http:
//www.b.com" xmlns:c="http://www.c.com">
<b:message1>
<c:item1 value="500" />
</b:message1>
</a:messagelist>
I see also you don't have the recent XMLOutputter fix to move the
<!DOCTYPE> after the decl line. Pretty clear your output was generated
by beta5 code.
-jh-
P.S. Anyone out there using DOMBuilder should switch to SAXBuilder
where possible. It's far faster, as the DOMBuilder docs warn.
"Knorr, Christian" wrote:
>
> Your code worked perfectly with my file, the output was exactly like the
> input. But I realized that I used DOMBuilder instead of SAXBuilder and
> this reproduces the error.
>
> Here is my code:
>
> import java.io.*;
> import java.util.*;
> import org.jdom.*;
> import org.jdom.input.*;
> import org.jdom.output.*;
>
> public class TestClass {
>
> public static void main(String[] args) throws Exception {
> try {
> FileInputStream in = new FileInputStream(args[0]);
> Document d = new DOMBuilder().build(in);
> XMLOutputter outp = new XMLOutputter("", false);
> outp.output(d, System.out);
>
> } catch (Exception e) {
> e.printStackTrace();
> }
> }
> }
>
> And the output:
>
> <?xml version="1.0" encoding="UTF-8"?><!DOCTYPE
> a:messagelist><a:messagelist xml
> ns:a="http://www.a.com">
> <b:message1 xmlns:b="http://www.b.com">
> <c:item1 xmlns:c="http://www.c.com" value="500" />
> </b:message1>
> </a:messagelist>
> C:\usr\ck\prj\vadis\prototype\bin>
More information about the jdom-interest
mailing list