Axiom
  1. Axiom
  2. AXIOM-400

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

    Details

    • Type: Bug Bug
    • Status: Resolved
    • Priority: Minor Minor
    • Resolution: Fixed
    • Affects Version/s: 1.2.12
    • Fix Version/s: 1.2.13
    • Component/s: DOOM, LLOM
    • Labels:
      None

      Description

      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.

        Activity

        Hide
        Hudson added a comment -

        Integrated in ws-axiom-trunk #708 (See https://builds.apache.org/job/ws-axiom-trunk/708/)
        AXIOM-400: Make sure that OMFactory#createOMElement(String, OMNamespace, OMContainer) generates a namespace declaration if necessary for a null OMNamespace.

        veithen :
        Files :

        • /webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/om/OMFactory.java
        • /webservices/commons/trunk/modules/axiom/modules/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/ElementImpl.java
        • /webservices/commons/trunk/modules/axiom/modules/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/factory/OMDOMFactory.java
        • /webservices/commons/trunk/modules/axiom/modules/axiom-impl/src/main/java/org/apache/axiom/om/impl/llom/OMElementImpl.java
        • /webservices/commons/trunk/modules/axiom/modules/axiom-impl/src/main/java/org/apache/axiom/om/impl/llom/OMSourcedElementImpl.java
        • /webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/OMTestSuiteBuilder.java
        • /webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/element/TestGetDefaultNamespace.java
        • /webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/element/TestGetDefaultNamespace2.java
        • /webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/factory/TestCreateOMElementWithoutNamespace.java
        • /webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/factory/TestCreateOMElementWithoutNamespace2.java
        Show
        Hudson added a comment - Integrated in ws-axiom-trunk #708 (See https://builds.apache.org/job/ws-axiom-trunk/708/ ) AXIOM-400 : Make sure that OMFactory#createOMElement(String, OMNamespace, OMContainer) generates a namespace declaration if necessary for a null OMNamespace. veithen : Files : /webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/om/OMFactory.java /webservices/commons/trunk/modules/axiom/modules/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/ElementImpl.java /webservices/commons/trunk/modules/axiom/modules/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/factory/OMDOMFactory.java /webservices/commons/trunk/modules/axiom/modules/axiom-impl/src/main/java/org/apache/axiom/om/impl/llom/OMElementImpl.java /webservices/commons/trunk/modules/axiom/modules/axiom-impl/src/main/java/org/apache/axiom/om/impl/llom/OMSourcedElementImpl.java /webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/OMTestSuiteBuilder.java /webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/element/TestGetDefaultNamespace.java /webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/element/TestGetDefaultNamespace2.java /webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/factory/TestCreateOMElementWithoutNamespace.java /webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/factory/TestCreateOMElementWithoutNamespace2.java

          People

          • Assignee:
            Andreas Veithen
            Reporter:
            Andreas Veithen
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development