Uploaded image for project: 'Commons JXPath'
  1. Commons JXPath
  2. JXPATH-125

JXPathContext.iteratePointers() does not work with multiple prefixes for a single namespace URI

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Major
    • Resolution: Fixed
    • 1.2 Final, 1.3
    • 1.4
    • None
    • JXPath 1.2
      Sun JDK 1.5.0_13

    Description

      Have a look at the following document:

      <a:doc xmlns:a="ns">
      <a:elem />
      <b:elem xmlns:b="ns" />
      </a:doc>

      We have two elements 'elem' in the same namespace 'ns'.
      They have a different prefix, however.

      When we use JXPathContext.iteratePointers() to iterate over them, the first element is returned two times. The second element is not returned.

      This is because
      in class org.apache.commons.jxpath.ri.model.dom.DOMNodePointer
      in method getRelativePositionByName() (line 546)
      we have:

      if (nm.equals(node.getNodeName()))

      In the example, we have
      nm == "a:elem" and node == "b:elem"

      Thus, equals() returns false. But since 'a' and 'b' are just different prefixes for the same namespace URI, we should have 'true'.

      I attached a testcase which reproduces the bug.

      Attachments

        1. TestcaseJXPathIterateBug.java
          2 kB
          Christian Koppen

        Activity

          People

            Unassigned Unassigned
            ck1 Christian Koppen
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: