[
https://issues.apache.org/jira/browse/WSCOMMONS-175?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12482822
]
Ryan Nelsestuen commented on WSCOMMONS-175:
-------------------------------------------
After looking at this for a while, I think the problem is that some
XMLStreamWriters are pushing an additional default namespace declaration onto
its internal stack when Axiom calls
writer.writeStartElement("", localName, eNamespace);
In other words, it is repeating the work done by the
generateSetPrefix(prefix, namespace, writer, true);
(If you look at the OMSerializerUtil class you can see why woodstox is treated
differently).
The point of contention is probably whether the writeStartElement method should
in fact implicitly add to the namespace context or not. An alternate
work-around might be to change
if (setPrefixFirst) {
if (eNamespace != null) {
if (ePrefix == null) {
writer.writeStartElement("", localName, eNamespace);
} else {
writer.writeStartElement(ePrefix, localName, eNamespace);
}
} else {
writer.writeStartElement(localName);
}
}
to use a different version of the writeStartElement method, and/or to pull the
namespace context and check for the existence of the NS/prefix combo and decide
which writeStartElement to call based on that.
> Serialization: Namespace declarations only output on first iteration
> ---------------------------------------------------------------------
>
> Key: WSCOMMONS-175
> URL: https://issues.apache.org/jira/browse/WSCOMMONS-175
> Project: WS-Commons
> Issue Type: Bug
> Components: AXIOM
> Environment: Sun JDK 1.6, Axiom 1.2.2, Linux 2.6 (Fedora Core 5)
> Reporter: Adam Constabaris
> Attachments: DeclTest.java
>
>
> When serializing a document that contains many child nodes using the same
> namespace that is NOT declared on the root,
> only the first namespace declaration is output, even if multiple elements
> require it;
> e.g. document contains root element "root" and two children "foo" and "bar",
> both in the namespace "http://example.com/ns", which is NOT
> declarted on root, should be serialized as:
> <root>
> <ns:foo xmlns:ns="http://example.com/ns">foo contents</ns:foo>
> <ns:bar xmlns:ns="http://example.com/ns">bar contents</ns:foo>
> </root>
> but w/AXIOM 1.2.2 and default StAX parser shipped w/Sun JDK 1.6.0 (SJSXP
> 1.0?), output is:
> <root>
> <ns:foo xmlns:ns="http://example.com/ns">foo contents</ns:foo>
> <ns:bar>bar contents</ns:foo>
> </root>
> I have further verified that the problem does not occur if Woodstox 2.0.5 is
> used as the StAX implementation.
> I am not able to verify whether this is due to a bug in Sun's StAX
> implementation, or in the use AXIOM makes of the various classes. Possible
> reference issue for SJXSP:
> https://sjsxp.dev.java.net/issues/show_bug.cgi?id=31
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]