I'm learning about XML and XPath in my university course (XPath 1.0 to be exact) and I stumbled upon something. F.e. if I write an expression:
NaN < true()
it returns true. Which is very weird. When I do.
NaN < 1
it returns false. AFAIK XPath 1.0 comparisons (without node-sets) first convert the values to numbers and only then compares them. So, in the first expression it goes like this
NaN < number(true())
-> NaN < 1
and in the second
NaN < 1
I'd like to get to the bottom of this, so any information would be helpful. I didn't find anything concerning this situation in the docs. Maybe I missed something.
Thanks in advance!
The token NaN does not represent the double value NaN, it is short for
child::NaN
which returns an empty node-set (unless of course your XML document contains an element named NaN).I'm a little surprised that a university should be teaching XPath 1.0 which has long been superseded by new versions. Of course lots of people are still using it, but I would have thought a university would teach a newer version.