Commons JXPath
  1. Commons JXPath
  2. JXPATH-93

Binary operators behaviour involving node-sets is incorrect

    Details

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

      1.2, SVN version

      Description

      According to XPath specification:
      "If both objects to be compared are node-sets, then the comparison will be true if and only if there is a node in the first node-set and a node in the second node-set such that the result of performing the comparison on the string-values of the two nodes is true. If one object to be compared is a node-set and the other is a number, then the comparison will be true if and only if there is a node in the node-set such that the result of performing the comparison on the number to be compared and on the result of converting the string-value of that node to a number using the number function is true."

      But following example illustrates, that this is not a JXPath behaviour:

      JXPathContext pathContext = JXPathContext
      .newContext(DocumentBuilderFactory.newInstance()
      .newDocumentBuilder().parse(
      new InputSource(new StringReader(
      "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\r\n"
      + "<doc/>"))));
      Boolean result = (Boolean) pathContext.getValue("2.0 > child1",
      Boolean.class);
      assertFalse(result.booleanValue());

      "child1" is not found - right operand node set is empty, but result is TRUE, instead of FALSE.

      Please, check greaterThan(), lesserThan(), etc methods of org.apache.xpath.objects.XObject for possible solution

      1. testcase-patch.txt
        2 kB
        Sergey Vladimirov

        Activity

        Hide
        Matt Benson added a comment -

        Fixed in trunk. Thanks, Sergey!

        Show
        Matt Benson added a comment - Fixed in trunk. Thanks, Sergey!
        Hide
        Sergey Vladimirov added a comment -

        Doesn't work from trunk

        Show
        Sergey Vladimirov added a comment - Doesn't work from trunk
        Hide
        Sergey Vladimirov added a comment -

        Test case update

        Show
        Sergey Vladimirov added a comment - Test case update
        Hide
        Matt Benson added a comment -

        tried again--check svn trunk. Thanks!

        Show
        Matt Benson added a comment - tried again--check svn trunk. Thanks!

          People

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

            Dates

            • Created:
              Updated:
              Resolved:

              Development