Precedence of Query Operators

The precedence of query operators varies for XPath 1.0 and XPath 2.0, as shown in the following tables. In these tables, operators are listed in order of precedence, with highest precedence being first; operators in a given row have the same precedence.

Operation Type
XPath Operators
Grouping
( )
               

            
Filter
[ ]
               

            
Unary minus

              - 
               

            
Multiplication
*, div, mod
               

            
Addition
+, -
               

            
Relational (Comparison)
= != < <= > >=
               

            
Union
|
               

            
Negation
not
               

            
Conjunction
and
               

            
Disjunction
or
               

            
Table 64. Query Operator Precedence - XPath 1.0

Operation Type
XPath Operators
Sequence separator
,
               

            
Conjunction
and
               

            
Type matching

              instance of
               

            
Assertion
treat
               

            
Conversion test
castable
               

            
Conversion
cast
               

            
Relational (Comparison)
eg, ne, lt, le, gt, ge, =, !=, <, <=, >, >=, 
is, <<, >>
               

            
Range
to
               

            
Addition
+, -
               

            
Multiplication
*, div, idiv, mod
               

            
Unary
unary -, unary +
               

            
Union
union, |
               

            
Select set
intersect, except
               

            
Navigation
/, //
               

            
Filter
[ ]
               

            
Table 65. Query Operator Precedence - XPath 2.0

 
Free Stylus Studio XML Training:
W3C Member