Patterns
A version of this page is also available for
4/8/2010
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 identifier |
|
Any |
|
Any |
|
Any |
|
Any |
|
Any |
|
Any |
|
Any |
|
Any attribute |