In XPath 1.0, a comparison operator other than equality comparison works only for numbers. This is because in XML you are dealing with UNICODE. Thus, to make a string a fully ordered data type, you need the concept of mappings, which was added in XPath 2.0.
The first expression is obviusly correct. Why does the second work? Because the more than operator passes both arguments using the number() function.
From http://www.w3.org/TR/xpath/#booleans
First, comparisons that include node sets are defined in terms of comparisons that are not related to node sets; it is determined evenly for = ,! =, <=, <,> = and>.
And after describing the existing comparison for the node sets (the comparison is true only if there is a node in the node set for which the comparison is performed):
If there is no object to compare, a node-set and the operator <= , < , >= or > , then the objects are compared by converting both objects to numbers and comparing numbers in accordance with IEEE 754
user357812
source share