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

Binary operators behaviour involving node-sets is incorrect

Attach filesAttach ScreenshotVotersWatch issueWatchersCreate sub-taskLinkCloneUpdate Comment AuthorReplace String in CommentUpdate Comment VisibilityDelete Comments
    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Major
    • Resolution: Fixed
    • 1.2 Final
    • 1.3
    • None
    • 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

      Attachments

        Activity

          This comment will be Viewable by All Users Viewable by All Users
          Cancel

          People

            Unassigned Unassigned
            bsp Sergey Vladimirov
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Slack

                Issue deployment