You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@xalan.apache.org by David Patow <dp...@anchorsilk.com> on 2000/12/08 19:48:00 UTC
Xalan-J 1 bug : XPath relational op "<=" must be numeric
Greetings, Xalan-J Developers,
A bug in the XPath expression processing, I think, ...
According to the XPath spec, at link <http://www.w3.org/TR/xpath#booleans>
http://www.w3.org/TR/xpath#booleans, 7th paragraph, ...
"
When neither object to be compared is a node-set and the operator is <=, <,
>= or >, then the objects are compared by converting both objects to numbers
and comparing the numbers according to IEEE 754.
"
If you look at file XPath.java, method lte(), it does not appear to be
performing the conversion to numeric.
It performs a lexical comparison, which is incorrect.
Thus, code like this, which is looking for no following sibling nodes OR a
following sibling with a lower @LEVEL:
<xsl:when test="count(following-sibling::*)=0 or
number(following-sibling::*[1]/@LEVEL) <= number(@LEVEL)">
fails when the follow-sibling level is 10 and the current node's level is 9,
because the lexical comparison is not the same as the numeric comparison.
Have fun!
++ David Patow
++ mailto: David_Patow@AnchorSilk.com <ma...@AnchorSilk.com>
Re: Xalan-J 1 bug : XPath relational op "<=" must be numeric
Posted by Gary L Peskin <ga...@firstech.com>.
> David Patow wrote:
>
> Greetings, Xalan-J Developers,
>
> A bug in the XPath expression processing, I think, ...
>
> According to the XPath spec, at link
> http://www.w3.org/TR/xpath#booleans, 7th paragraph, ...
> "
> When neither object to be compared is a node-set and the operator is
> <=, <, >= or >, then the objects are compared by converting both
> objects to numbers and comparing the numbers according to IEEE 754.
> "
>
> If you look at file XPath.java, method lte(), it does not appear to be
> performing the conversion to numeric.
>
> It performs a lexical comparison, which is incorrect.
As I read the code, it looks fine.
XPath.lte() returns expr1.lessThanOrEqual(expr2) ? m_true : m_false
where expr1 and expr2 are both XObjects.
XObject.lessThanOrEqual() for non-node-sets returns this.num() <=
obj2.num().
This calls to num() should accomplish the numeric conversion.
If you have XML and XSLT which demonstrates this problem, please forward
the complete examples to the list.
Thanks,
Gary