Binary operators behaviour involving node-sets is incorrect
-----------------------------------------------------------
Key: JXPATH-93
URL: https://issues.apache.org/jira/browse/JXPATH-93
Project: Commons JXPath
Issue Type: Bug
Affects Versions: 1.2 Final
Environment: 1.2, SVN version
Reporter: Sergey Vladimirov
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 :)
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]