Uploaded image for project: 'Axiom'
  1. Axiom
  2. AXIOM-374

Behavior of OMFactory#createOMElement(QName [, OMContainer]) is inconsistent between LLOM and DOOM

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Open
    • Major
    • Resolution: Unresolved
    • 1.2.12
    • None
    • DOOM
    • None

    Description

      The createOMElement(String, OMNamespace), createOMElement(String, OMNamespace, OMContainer) and createOMElement(String, String, String) methods support auto-generating a namespace prefix (by passing a null prefix) and creating an element in the default namespace (by passing an empty string as prefix). This choice doesn't exist for the createOMElement(QName) and createOMElement(QName, OMContainer) methods because the prefix in a QName object can never be null. There is an inconsistency in the behavior of LLOM and DOOM when an empty prefix is passed in the QName object. LLOM will auto-generate a prefix, while DOOM will create an element in the default namespace.

      In the case of DOOM, this appears to be a bug because the corresponding createOMElement method contains the following condition:

      qname.getPrefix() != null

      However, the return value of QName#getPrefix() is never null, and the code that would auto-generate a prefix is unreachable.

      On the other hand, the desired behavior depends on the use case, and there are situations where one would like to create an element in the default namespace if the prefix in the QName is an empty string.

      Proposed solution:

      1. Make sure that DOOM has the same behavior as LLOM, i.e. auto-generate a prefix if QName#getPrefix() returns an empty string.
      2. Add additional methods to OMFactory that create an element from a QName, but that allow to specify the intended behavior.

      Attachments

        1. prefix.patch
          0.9 kB
          isuru janith ranawaka
        2. Testcaseenabled.patch
          2 kB
          isuru janith ranawaka

        Activity

          People

            veithen Andreas Veithen
            veithen Andreas Veithen
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated: