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 "dian hina (Jira)" <xe...@xml.apache.org> on 2021/06/26 20:29:02 UTC
[jira] [Updated] (XERCESJ-793) When using serializer in 'content
handler' mode, duplicate namespace delcarations are missed
[ https://issues.apache.org/jira/browse/XERCESJ-793?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
dian hina updated XERCESJ-793:
------------------------------
oke finish
> When using serializer in 'content handler' mode, duplicate namespace delcarations are missed
> --------------------------------------------------------------------------------------------
>
> Key: XERCESJ-793
> URL: https://issues.apache.org/jira/browse/XERCESJ-793
> Project: Xerces2-J
> Issue Type: Bug
> Components: Serialization
> Affects Versions: 2.5.0
> Environment: Operating System: Windows NT/2K
> Platform: PC
> Reporter: Sander Bos
>
> 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).
--
This message was sent by Atlassian Jira
(v8.3.4#803005)
---------------------------------------------------------------------
To unsubscribe, e-mail: j-dev-unsubscribe@xerces.apache.org
For additional commands, e-mail: j-dev-help@xerces.apache.org