Pattern syntax for XSLT 2.0
Saxon supports the full XSLT syntax for patterns. The rules below describe a
simplified form of this syntax (for example, it omits the legal but useless pattern
@comment()
):
Note: not all combinations are allowed. If the anchor is //
then the
remainder is mandatory.
The form of a literal is as defined in expressions; and a predicate is itself a
boolean or numeric expression. As with predicates in expressions, a numeric
predicate [P]
is shorthand for the boolean predicate
[position()=P]
.
Informally, a pattern consists of either a single path or a sequence of paths separated by vertical bars. An element matches the match-pattern if it matches any one of the paths.
A path consists of a sequence of path-parts separated by either /
or
//
. There is an optional separator (/
or
//
) at the start; a //
has no effect and can be
ignored. The last path-part may be an element-match, a text-match, an
attribute-match, a pi-match, or a node-match; in practice, a path-part other than
the last should be an element-match.
The axis syntax child::
and attribute::
may also be used in
patterns, as described in the XSLT specification.