[jdom-interest] Namespaces and XMLOutputter
Jason Hunter
jhunter at collab.net
Wed Jan 17 10:21:10 PST 2001
It works on my machine. I saved your file to ns.xml, and ran this code
on it:
import java.util.*;
import org.jdom.*;
import org.jdom.input.*;
import org.jdom.output.*;
public class Tester2 {
public static void main(String[] args) throws Exception {
Document d = new SAXBuilder().build(args[0]);
XMLOutputter outp = new XMLOutputter("", false);
outp.output(d, System.out);
}
}
Here's the output:
% java Tester2 ns.xml
<?xml version="1.0" encoding="UTF-8"?>
<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>C:/tmp/jdom 30 %
-jh-
Thomas Riessler wrote:
>
> Hi,
> if I build a JDOM Document object from the following XML source (using SAXBuilder):
>
> <?xml version="1.0" encoding="ISO-8859-1"?>
> <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>
>
> and printout this unchanged Document with the output method of XMLOutputter, I do not get the same XML source returned. Instead output() writes the following code:
>
> <?xml version="1.0" encoding="ISO-8859-1"?>
> <a:messagelist xmlns: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 xmlns:b="http://www.b.com">
> </a:messagelist xmlns:a="http://www.a.com">
>
> Note that the namespace declarations (including URLs) have moved from the root element to all Elements affected by a namespace prefix.
>
> This occurs with beta 5 and the nightly build I downloaded today.
> This is kind of a suprise to me since this problem (among others) was adressed by Kesav Kumar in his post on "Namespace prefix" (Fri, 13 Oct 2000 15:11:46 -0700 ) and has been reported to be fixed.
>
> This presents a big jdom usability problem to our project (we're currently evaluating it) since our XML docs are large and the namespace declarations would have a huge performance impact.
> Besides that, the target application we want to communicate with, cannot handle these declarations. Whats the current status of the problem?
>
> Thomas Riessler
>
> --
>
> Diese E-Mail enthält vertrauliche und/oder rechtlich geschützte Informationen. Wenn Sie nicht der richtige Adressat sind oder diese E-Mail irrtümlich erhalten haben, informieren Sie bitte sofort den Absender und vernichten Sie diese Mail. Das unerlaubte Kopieren sowie die unbefugte Weitergabe dieser Mail ist nicht gestattet.
>
> This e-mail may contain confidential and/or privileged information. If you are not the intended recipient (or have received this e-mail in error) please notify the sender immediately and destroy this e-mail. Any unauthorised copying, disclosure or distribution of the material in this e-mail is strictly forbidden.
>
> _______________________________________________
> To control your jdom-interest membership:
> http://lists.denveronline.net/mailman/options/jdom-interest/youraddr@yourhost.com
More information about the jdom-interest
mailing list