Hi Kohsuke
Thanks for finding this bug.
The logic in org.dom4j.tree.NamespaceStack was incorrect, it was not
correctly handling the redefinition of prefixes and default namespaces when
serializing documents. I've fixed this now and made the test cases
(org.dom4j.TestXMLWriter and org.dom4.TestNamespaces) much more rigorous,
doing DOM and SAX round trips as well to test both the parsing and
serialization parts of dom4j so that we maintain valid namespace handling.
The fix is in CVS and the daily build. I'll be doing a new release soon
which will contain these recent patches.
James
----- Original Message -----
From: "Kohsuke KAWAGUCHI" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Thursday, September 20, 2001 4:42 AM
Subject: [dom4j-user] Namespace serialization problem
>
> Hi,
>
> It seems to me that there is a problem in XMLWriter regarding the
> serialization of XML with namespaces.
>
> The following code:
> ----------------------------------------------------------------------
> import org.dom4j.*;
> import org.dom4j.io.*;
>
> public class Main
> {
> public static void main( String[] args ) throws Exception {
> Document dom = DocumentHelper.createDocument();
>
> Element root = dom.addElement("root","ns1");
> Element child1 = root.addElement("joe","ns2");
> child1.addElement("zot","ns1");
>
> XMLWriter writer = new XMLWriter(
> System.out,
> OutputFormat.createPrettyPrint() );
> writer.write(dom);
> }
> }
> ----------------------------------------------------------------------
>
> produces the following output:
> ----------------------------------------------------------------------
> <?xml version="1.0" encoding="UTF-8"?>
> <root xmlns="ns1">
> <joe xmlns="ns2">
> <zot/>
> </joe>
> </root>
> ----------------------------------------------------------------------
>
> although it should produce:
> ----------------------------------------------------------------------
> <?xml version="1.0" encoding="UTF-8"?>
> <root xmlns="ns1">
> <joe xmlns="ns2">
> <zot xmlns="ns1"/>
> </joe>
> </root>
> ----------------------------------------------------------------------
>
>
> I'm using dom4j version 1.0. Is this a known problem? or am I missing
> something?
>
> regards,
> ----------------------
> K.Kawaguchi
> E-Mail: [EMAIL PROTECTED]
>
>
> _______________________________________________
> dom4j-user mailing list
> [EMAIL PROTECTED]
> https://lists.sourceforge.net/lists/listinfo/dom4j-user
>
_________________________________________________________
Do You Yahoo!?
Get your free @yahoo.com address at http://mail.yahoo.com
_______________________________________________
dom4j-user mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/dom4j-user