[jdom-interest] Namespaces and XMLOutputter

Christian Knorr christian.knorr at gmx.de
Thu Jan 18 03:59:46 PST 2001


I experience the same effect as Thomas does. The point is, if I create a
new JDOM document with namespace declarations in the root-element it
will be written as expected, but if I read this document in again and
write it back without any changes, the root-element looses its
additional namespace declarations and they appear in each element where
they are used. 

Christian Knorr

P.S.: I also downloaded the CVS-version a couple of days ago. 

Jason Hunter schrieb:
> 
> 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
> 
> _______________________________________________
> 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