Comparison Expressions
Comparison expressions are used to compare values. There are three kinds of comparison expressions: general, value, and node.
General Comparisons
General comparisons
are used for comparing atomic values or nodes that contain atomic values. Table 32 shows some examples of general comparisons. They use the operators =
(equal to), !=
(not equal to), <
(less than), <=
(less than or equal to), >
(greater than), and >=
(greater than or equal to). Unlike in XSLT, you don't need to escape the <
operator as <
; in fact, it won't be recognized if you do.
Table 32. General comparisons
Example 
Value 












Type error 
If either operand is the empty sequence, the expression evaluates to false
.
General comparisons on multiitem sequences
General comparisons can operate on sequences of more than one item, as well as empty sequences. If one or both of the operands is a sequence of more than one item, the expression evaluates to true
if the corresponding value comparison is true for any combination of two items from the two sequences. For example, the expression (2, 5) < (1, 3)
returns true
if one or more of the following conditions is true:
2 is less than 1
2 is less than 3
5 is less than 1
5 is less than 3
This example returns true
because 2 is less than ...
Get XQuery now with O’Reilly online learning.
O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.