OMFactory#createOMElement doesn't generate namespace declaration if the 
OMNamespace argument is null
----------------------------------------------------------------------------------------------------

                 Key: AXIOM-400
                 URL: https://issues.apache.org/jira/browse/AXIOM-400
             Project: Axiom
          Issue Type: Bug
          Components: DOOM, LLOM
    Affects Versions: 1.2.12
            Reporter: Andreas Veithen


Consider the following code:

OMFactory factory = OMAbstractFactory.getOMFactory();
OMNamespace ns = factory.createOMNamespace("urn:test", "");
OMElement root = factory.createOMElement("root", ns);
OMElement child = factory.createOMElement("child", null, root);
System.out.println("child has namespace declarations: " + 
child.getAllDeclaredNamespaces().hasNext());
System.out.println("xml = " + root.toString());
System.out.println("default namespace on child = '" + 
child.getDefaultNamespace().getNamespaceURI() + "'");

With the current Axiom code, the output is:

child has namespace declarations: false
xml = <root xmlns="urn:test"><child xmlns="" /></root>
default namespace on child = 'urn:test'

That means that the call to createOMElement that creates the child element 
doesn't generate a namespace declaration. The serialized XML is still correct 
because the serializer performs namespace repairing. However, because of the 
absence of a namespace declaration on the child OMElement, the result of 
getDefaultNamespace is incorrect.

The createOMElement method is supposed to create a namespace declaration if no 
corresponding declaration is in scope on the parent element. This should also 
be the case if the OMNamespace argument is null and there is a default 
namespace declaration with a non empty namespace URI.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: 
https://issues.apache.org/jira/secure/ContactAdministrators!default.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]

Reply via email to