Commons JXPath
  1. Commons JXPath
  2. JXPATH-97

Incomplete handling of undefined namespaces

    Details

    • Type: Bug Bug
    • Status: Resolved
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 1.2 Final, Nightly Builds
    • Fix Version/s: 1.3
    • Labels:
      None

      Description

      Mcduffey, Joe <jdmcduf@nsa.gov>

      Can someone tell me how to register namespaces so that attributes with namespaces does not cause the exception

      org.apache.common.ri.model.dom.DOMNodePointer.createAttribute
      unknown namespace prefix: xsi

      For example the following
      <ElementA A:myAttr="Mytype">
      <B:ElementB>MY VALUE</B:ElementB>
      </ElementA>

      Would result in the following exception:
      org.apache.common.ri.model.dom.DOMNodePointer.createAttribute
      unknown namespace prefix: A

      FYI: In this example there was a namespace decaration in the file and I also manually called the
      registerNamespace(A,"/http...");
      registerNamespace(B,"/http...");

      There was no problem encountered for elements. Only attributes. Can someone help? Thanks.

      1. NamespacesTest.java
        1.0 kB
        Sergey Vladimirov
      2. patch.txt
        19 kB
        Sergey Vladimirov

        Activity

        Sergey Vladimirov created issue -
        Sergey Vladimirov made changes -
        Field Original Value New Value
        Attachment patch.txt [ 12362286 ]
        Sergey Vladimirov made changes -
        Attachment NamespacesTest.java [ 12362287 ]
        Matt Benson made changes -
        Comment [ Sergey, could you resubmit your patch without all those formatting changes? It makes it difficult to see where the "meat" of the change is.

        Thanks,
        Matt ]
        Hide
        Matt Benson added a comment -

        This should work in trunk. Thanks all!

        Show
        Matt Benson added a comment - This should work in trunk. Thanks all!
        Matt Benson made changes -
        Status Open [ 1 ] Resolved [ 5 ]
        Resolution Fixed [ 1 ]
        Hide
        Matt Benson added a comment -

        reopening... elements still don't work apparently for prefixes that are only declared externally?

        Show
        Matt Benson added a comment - reopening... elements still don't work apparently for prefixes that are only declared externally?
        Matt Benson made changes -
        Status Resolved [ 5 ] Reopened [ 4 ]
        Resolution Fixed [ 1 ]
        Hide
        Sergey Vladimirov added a comment -

        Matt,

        sorry for the bad patch. But one of the main point is change in DOMNodePointer:

        @@ -102,9 +107,12 @@
        return true;
        }

        • if (wildcard
        • testName.getName()
        • .equals(DOMNodePointer.getLocalName(node))) {
          + // the same as for attribute ( DOMAttributeIterator::testAttr() )
          + if (equalStrings(nodePrefix, testPrefix)) { + return true; + }

          +
          + if (wildcard || testName.getName().equals(nodeLocalName))

          { String nodeNS = DOMNodePointer.getNamespaceURI(node); return equalStrings(namespaceURI, nodeNS); }
        Show
        Sergey Vladimirov added a comment - Matt, sorry for the bad patch. But one of the main point is change in DOMNodePointer: @@ -102,9 +107,12 @@ return true; } if (wildcard testName.getName() .equals(DOMNodePointer.getLocalName(node))) { + // the same as for attribute ( DOMAttributeIterator::testAttr() ) + if (equalStrings(nodePrefix, testPrefix)) { + return true; + } + + if (wildcard || testName.getName().equals(nodeLocalName)) { String nodeNS = DOMNodePointer.getNamespaceURI(node); return equalStrings(namespaceURI, nodeNS); }
        Hide
        Matt Benson added a comment -

        elements handled.

        Show
        Matt Benson added a comment - elements handled.
        Matt Benson made changes -
        Resolution Fixed [ 1 ]
        Status Reopened [ 4 ] Resolved [ 5 ]
        Hide
        Matt Benson added a comment -

        reopening to note that Joe McD also reported that createPathAndSetValue() wasn't working for ext-reg'd ns'd attrs.

        Show
        Matt Benson added a comment - reopening to note that Joe McD also reported that createPathAndSetValue() wasn't working for ext-reg'd ns'd attrs.
        Matt Benson made changes -
        Status Resolved [ 5 ] Reopened [ 4 ]
        Resolution Fixed [ 1 ]
        Hide
        Matt Benson added a comment -

        fixed createPathAndSetValue() in trunk.

        Show
        Matt Benson added a comment - fixed createPathAndSetValue() in trunk.
        Matt Benson made changes -
        Status Reopened [ 4 ] Resolved [ 5 ]
        Resolution Fixed [ 1 ]
        Transition Time In Source Status Execution Times Last Executer Last Execution Date
        Open Open Resolved Resolved
        2d 5h 24m 1 Matt Benson 23/Jul/07 20:34
        Resolved Resolved Reopened Reopened
        1d 22h 13m 2 Matt Benson 25/Jul/07 20:48
        Reopened Reopened Resolved Resolved
        2h 4m 2 Matt Benson 25/Jul/07 20:52

          People

          • Assignee:
            Unassigned
            Reporter:
            Sergey Vladimirov
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development