[ http://issues.apache.org/jira/browse/WSCOMMONS-99?page=all ]
Toshiro Takase updated WSCOMMONS-99:
------------------------------------
Attachment: UnprefixedTest.java
unprefixed.xml
I attach one more test code.
Input XML (unprefixed.xml) is here.
-----
<?xml version="1.0" encoding="utf-8"?>
<local1 xmlns="ns1">
<pre2:local2 xmlns:pre2="ns2" attrLocal="attrValue">
<local3 />
</pre2:local2>
</local1>
-----
Then, the test code (UnprefixedTest) just parses, builds AXIOM, and serializes
the input XML.
The output XML is here.
-----
<?xml version='1.0' encoding='utf-8'?>
<local1 xmlns="ns1">
<pre2:local2 xmlns:pre2="ns2" xmlns="" attrLocal="attrValue">
<local3 xmlns="ns1" />
</pre2:local2>
</local1>
-----
In the input XML (unprefixed.xml), the namespace URI for "attrLocal" is not
ns1, but null.
You can see the XMLStreamReader reports that by test3() method in the test code.
So, AXIOM serializer should not print xmlns="".
Actually, this serializer breaks XML signature sometimes. I found some examples.
I hope this bug is fixed as soon as possible.
Thanks in advance.
> Incorrect default namespace serialization for un-prefixed attribute.
> --------------------------------------------------------------------
>
> Key: WSCOMMONS-99
> URL: http://issues.apache.org/jira/browse/WSCOMMONS-99
> Project: WS-Commons
> Issue Type: Bug
> Components: AXIOM
> Environment: Windows
> Reporter: Toshiro Takase
> Priority: Critical
> Attachments: diff.txt, unprefixed.xml, UnprefixedTest.java
>
>
> Current serialization prints default namespace declaration for un-prefixed
> attributes.
> According to "Namespaces in XML 1.0",
> http://www.w3.org/TR/REC-xml-names/#defaulting
> "Default namespace declarations do not apply directly to attribute
> names."
> "The namespace name for an unprefixed attribute name always has no
> value."
> So the default namespace declaration should not be printed.
> I am afraid that this serialization sometimes breaks XML signature and XML
> Infoset.
> This is my test code.
> ----------
> OMFactory factory = OMAbstractFactory.getOMFactory();
> OMDocument doc = factory.createOMDocument();
> OMElement elem1 = factory.createOMElement("local1", "ns1", "");
> doc.addChild(elem1);
> OMElement elem2 = factory.createOMElement("local2", "ns2", "pre2");
> elem1.addChild(elem2);
> elem2.addAttribute("attrLocal", "attrValue", null);
> OMElement elem3 = factory.createOMElement("local3",
> elem1.getNamespace());
> elem2.addChild(elem3);
> doc.serialize(System.out);
> ----------
> The result is here. (indented for readability)
> ----------
> <?xml version="1.0" encoding="utf-8"?>
> <local1 xmlns="ns1">
> <pre2:local2 xmlns="" xmlns:pre2="ns2" attrLocal="attrValue">
> <local3 xmlns="ns1"/>
> </pre2:local2>
> </local1>
> ----------
> In my understanding, this should be the following.
> ----------
> <?xml version="1.0" encoding="utf-8"?>
> <local1 xmlns="ns1">
> <pre2:local2 xmlns:pre2="ns2" attrLocal="attrValue">
> <local3/>
> </pre2:local2>
> </local1>
> ----------
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]