Details
Description
When calling declareDefaultNamespace() on a parent node, AXIOM assignes a blank namespace on the first level's child element. So if XML is passed to AXIOM that looks like this:
<outerTag>
<innerTag>
<node1>Hello</node1>
<node2>Hello</node2>
</innerTag>
</outerTag>
And then declareDefaultNamespace() of "http://someNamespace" is called on the <outerTag>, the resulting XML will be this:
<outerTag xmlns="http://someNamespace">
<innerTag xmlns="">
<node1>Hello</node1>
<node2>Hello</node2>
</innerTag>
</outerTag>
Notice the xmlns="" declared in the <innerTag>. According to my understanding of XML namespaces, the <innerTag> and its child nodes will no longer belong to the parent namespace of "http://someNamespace", since it explicitly overrides it with an empty namespace. So <innerTag> and its child nodes will in fact not belong to any namespace! Here is a small program to illustrate:
import org.apache.axiom.om.*;
import org.apache.axiom.om.impl.llom.util.*;
public class Test2 {
public static void main(String [] args) {
try
catch(Exception e)
{ e.printStackTrace(); } }
}
The output of this program is this (I added line breaks in the XML for easier readability):
<outerTag xmlns="http://someNamespace">
<innerTag xmlns="">
<node1>Hello</node1>
<node2>Hello</node2>
</innerTag>
</outerTag>
As you can see, the <innerTag> was assigned xmlns="" by AXIOM.
Attachments
Issue Links
- relates to
-
AXIOM-376 Axiom should report conflicting namespace declarations
- Open