XPATH Grammar

expr or‑expr
or‑expr and‑expr (name and‑expr)*
and‑expr equality‑expr (name equality‑expr)*
equality‑expr relational‑expr ((= | !=) relational‑expr)*
relational‑expr additive‑expr ((<= | >= | < | >) additive‑expr)*
additive‑expr multiplicative‑expr ((+ | -) multiplicative‑expr)*
multiplicative‑expr unary‑expr ((* | name) unary‑expr)*
unary‑expr - unary‑expr | union‑expr
union‑expr path‑expr (| path‑expr)*
path‑expr location‑pathfunction‑call | filter‑expr ((// | /) relative‑location‑path)?
filter‑expr primary‑expr predicate*
location‑path absolute‑location‑path | relative‑location‑path
absolute‑location‑path abbreviated‑absolute‑location‑path | / relative‑location‑path?
abbreviated‑absolute‑location‑path // relative‑location‑path
relative‑location‑path step ((// | /) step)*
step axis‑specifier node‑test predicate* | abbreviated‑step
axis‑specifier axis‑name :: | abbreviated‑axis‑specifier
axis‑name name
abbreviated‑axis‑specifier @ | <empty>
node‑test name ( literal ) | node‑type ( ) | name‑test
node‑type name
name‑test * | ncname : * | qname
abbreviated‑step .. | .
literal dq‑string | sq‑string
number num
predicate [ predicate‑expr ]
predicate‑expr expr
primary‑expr function‑call | variable‑reference | ( expr ) | literal | number
variable‑reference $ qname
function‑call function‑name ( (argument % ,)? )
function‑name qnamenode‑type
argument expr
qname prefixed‑name | unprefixed‑name
prefixed‑name prefix : local‑part
prefix ncname
unprefixed‑name local‑part
local‑part ncname
ncname name