Details
-
Bug
-
Status: Resolved
-
Major
-
Resolution: Fixed
-
1.1
-
None
Description
Assignment uses Xerces importNode to get a node from one tree and copy it into another. More specifically it recreates an element and imports all its child nodes (attributes and elements). However Xerces doesn't carry the full namespace context on import, it just clones and sets the proper owner. When it clones, it also takes the namespace property so the cloned element is in the proper namespace even without namespace declaration. Then internally Xerces knows hoe to deal with that and eventually adds a namespace declaration when needed.
However when we take that sort-of-messed-up tree as is and send it to the IL (to ServiceMix for example), we don't know who or what is eventually going to marshal the tree. And some of those marshallers don't really like Xerces tricks and end up with a node using a namespace prefix that has never been declared. Which of course can't be unmarshalled anymore as it's invalid. Nasty stuff.
As an example if you take those from and to:
"<ns2:detail xmlns:ns=\"http://www.etnic.be/janus/fault/desc\" xmlns:ns2=\"http://www.etnic.be/janus/fault\">" +
"<ns:description ns:lang=\"fr\">foo bar</ns:description>" +
"</ns2:detail>";
"<janusResponse xmlns=\"http://www.etnic.be/janus\" xmlns:janus=\"http://www.etnic.be/janus\">" +
"<fault:detail xmlns:fault=\"http://www.etnic.be/janus/fault\">" +
"<fault:description/>" +
"</fault:detail>" +
"</janusResponse>";
And assign the destination node of the first in the second, you end up with:
<janusResponse xmlns="http://www.etnic.be/janus" xmlns:janus="http://www.etnic.be/janus">
<fault:detail xmlns:fault="http://www.etnic.be/janus/fault">
<description ns:lang="fr">foo bar</description>
</fault:detail>
</janusResponse>
Note that there's no declaration for the prefix ns used by the lang attributes and also that the namespace for the description element has changed.