DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG 
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://nagoya.apache.org/bugzilla/show_bug.cgi?id=22978>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND 
INSERTED IN THE BUG DATABASE.

http://nagoya.apache.org/bugzilla/show_bug.cgi?id=22978

When using serializer in 'content handler' mode, duplicate namespace delcarations are 
missed

           Summary: When using serializer in 'content handler' mode,
                    duplicate namespace delcarations are missed
           Product: Xerces2-J
           Version: 2.5.0
          Platform: PC
        OS/Version: Windows NT/2K
            Status: NEW
          Severity: Normal
          Priority: Other
         Component: Serialization
        AssignedTo: [EMAIL PROTECTED]
        ReportedBy: [EMAIL PROTECTED]


Hi there,

when running the code:

  StringWriter writer = new StringWriter();
  XMLSerializer serializer = new XMLSerializer(writer, null);
  serializer.setNamespaces(true);
  serializer.startDocument();
  AttributesImpl attrs = new AttributesImpl();
  attrs.addAttribute
("http://www.w3.org/2000/xmlns/";, "ns1", "xmlns:ns1", "CDATA", "http://url";);
  attrs.addAttribute
("http://www.w3.org/2000/xmlns/";, "ns2", "xmlns:ns2", "CDATA", "http://url";);
  attrs.addAttribute
("http://www.w3.org/2000/xmlns/";, "ns3", "xmlns:ns3", "CDATA", "http://otherurl";
);
  attrs.addAttribute("http://url";, "attr1", "ns1:attr1", "CDATA", "value1");
  attrs.addAttribute("http://url";, "attr2", "ns2:attr2", "CDATA", "value2");
  serializer.startElement(null, "root", "root", attrs);
  serializer.endElement(null, "root", "root");
  serializer.endDocument();
  System.out.println("writer.toString() = \n" + writer.toString());

I get as a result:
  writer.toString() =
  <?xml version="1.0"?>
  <root ns1:attr1="value1" ns2:attr2="value2" xmlns:ns3="http://otherurl"; 
xmlns:ns1="http://url"/>

In words, the second namespace declaration for http://url is not serialized, 
and as a result the output is not namespace wellformed.

Tested against Xerces 2.4 and 2.5.

Work-arounds (not involving changing the input) would be very welcome (DOM 
serialization does not seem to have this problem, but is not an option for us).

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to