Precedence
The XQuery grammar defines a built-in precedence among operators and expressions. If an expression that has a lower precedence is used as an operand of an expression that has a higher precedence, the expression that has a lower precedence must be enclosed in parentheses.
The following table lists XQuery operators and expressions in order of their precedence from lowest to highest. The associativity column indicates the order in which operators or expressions of equal precedence are applied.
Operator or expression | Associativity |
---|---|
, (comma) | left-to-right |
:= (assignment) | right-to-left |
FLWOR, some, every, if | left-to-right |
or | left-to-right |
and | left-to-right |
eq, ne, lt, le, gt, ge, =, !=, <, <=, >, >=, is, <<, >> | left-to-right |
to | left-to-right |
+, - | left-to-right |
*, div, idiv, mod | left-to-right |
union, | | left-to-right |
intersect, except | left-to-right |
castable | left to right |
cast | left-to-right |
-(unary), +(unary) | right-to-left |
? | left-to-right |
/, // | left-to-right |
[ ], ( ), {} | left-to-right |