You are viewing a plain text version of this content. The canonical link for it is here.
Posted to j-dev@xerces.apache.org by Julian Reschke <ju...@gmx.de> on 2001/05/08 21:15:46 UTC
Serializer problem (Xerces 1.3.1)
Hi,
I'm trying to serialize a document that has been built using the DOM-Level-2
namespace aware methods:
public static void main(String[] args)
throws java.io.IOException {
main main1 = new main();
Document doc = new org.apache.xerces.dom.DocumentImpl ();
Element root = doc.createElementNS ("ns1", "bar");
doc.appendChild (root);
root.setAttributeNS ("ns2", "attr", "val");
org.apache.xml.serialize.OutputFormat of =
new org.apache.xml.serialize.OutputFormat (doc, "xml", true);
java.io.StringWriter out = new java.io.StringWriter();
org.apache.xml.serialize.XMLSerializer ser =
new org.apache.xml.serialize.XMLSerializer(out, of);
ser.serialize (doc);
System.out.println (out.toString());
}
The result is:
<?xml version="1.0" encoding="xml"?>
<bar attr="val"/>
However, this is clearly wrong, it should be something like:
<?xml version="1.0" encoding="xml"?>
<bar xmlns="ns1" prefix:attr="val" xmlns:prefix="ns2" />
I reported the problem three months ago, but received no feedback:
<http://nagoya.apache.org/bugzilla/show_bug.cgi?id=596>.
Is there something wrong with my code, or does the serializer indeed not
able to serialize namespace declarations properly? I find this surprising
because the changelog for XMLSerializer.java shows that there have been
fixes applied regarding namespace handling.
Any feedback appreciated,
Julian
---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-j-dev-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-j-dev-help@xml.apache.org