PatternsĀ
A pattern is a type of expression that returns a set of nodes based on a set of conditions for a node. Nodes that satisfy the conditions match the pattern. The syntax for patterns is a subset of the syntax for expressions. In particular, location paths that meet certain restrictions can be used as patterns. An expression that is also a pattern always evaluates to an object of type node-set. A node matches a pattern if the node is a member of the result of evaluating the pattern as an expression with respect to some possible context; the possible contexts are those whose context node is the node being matched or one of its ancestors.
The following table lists examples of patterns.
Pattern | Matches |
---|---|
|
any |
|
any element |
|
any |
|
any |
|
any |
|
the root node |
|
any text node |
|
any processing instruction |
|
any node other than an attribute node and the root node |
|
the element with unique ID |
|
any |
|
any |
|
any |
|
any |
|
any |
|
any |
|
any |
|
any attribute |