Read XSLT 2.0 and XPath 2.0 Programmer's Reference, 4th Edition Online
Authors: Michael Kay
This production rule is the way the syntax is defined in the XSLT specification. However, the following equivalent production rule may be easier to understand, and it corresponds more closely with the description in the
Usage
section discussed later.
Expression | Syntax |
PathPattern | / | RelativePathPattern | / RelativePathPattern | // RelativePathPattern | IdKeyPattern| IdKeyPattern / RelativePathPattern| IdKeyPattern // RelativePathPattern |
The syntax of a
RelativePathPattern
(page 693) and that of an
IdKeyPattern
(page 704) are described later.
Effect
The syntax rule reproduced earlier from the XSLT specification can be better understood by listing the seven different kinds of
PathPatter
n
, as follows:
Construct | Meaning |
/ | Matches a document node. |
RelativePathPattern | Matches a node that can appear anywhere in the document. Example: book/chapter/title matches any |
/ RelativePathPattern | Matches a node via a defined path from a document node. Example: /book/title matches a |
// RelativePathPattern | Matches a node that can appear anywhere in the document. The inclusion of the leading // rules out nodes in trees that don't have a document node at their root. It also affects the default priority of a template rule that uses this pattern. The default priority of a pattern comes into play when two template rules match the same node: for details, see the description of //title matches any |