From: Paulo F. Sarli <pfsarli@gm...> - 2004-10-18 12:41:56
I am processing a group of rather large XML files using SAXON 8.1. An
interesting situation has arised. The following XPath expressions
produce diferente results on the same input:
1) //b[matches( text(), '^\d+$' )]
The first expression returns a larger number os nodes in the result
set than the second expression. My question is: shouldn=B4t these two
XPaths return exactly the same node set?
Thanks a lot in advance...
A coisa certa dita na hora errada
=E9 pior do que
a coisa errada dita na hora certa...
From: Michael Kay <mhk@mh...> - 2004-10-18 14:28:14
> Hello all:
> I am processing a group of rather large XML files using SAXON 8.1. An
> interesting situation has arised. The following XPath expressions
> produce diferente results on the same input:
> 1) //b[matches( text(), '^\d+$' )]
> 2) //b[number()]
number() does not test whether the context node is a number, it converts it
to a number. Moreover, when a number is used in a predicate, it selects the
n'th item in the sequence.
Another difference is that text() does not necessarily select the string
value of the node b: it would give different results if there are comments
and processing instructions.
Using //b[boolean(number())] would also be wrong because it wouldn't select
You could use //b[. castable as xs:integer]
Or //b[number() = number()], which relies on the fact that NaN != NaN.
These will still not be quite the same as your first expression, because ".
castable as xs:integer" allows a leading + or - sign, as well as leading and
Like taxi-drivers and waiters, we like to be rewarded if we provide good
Get latest updates about Open Source Projects, Conferences and News.