Partager via


Patterns (Windows Embedded CE 6.0)

1/6/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
Para

Any para element

*

Any element

chapter|appendix

Any chapter element and any appendix element

olist/item

Any item element with an olist parent

appendix//para

Any para element with an appendix ancestor element

/

The root node

text()

Any text node

processing-instruction()

Any processing instruction

node()

Any node other than an attribute node and the root node

id("W11")

The element with unique identifier W11

para[1]

Any para element that is the first para child element of its parent

*[position()=1 and self::para]

Any para element that is the first child element of its parent

para[last()=1]

Any para element that is the only para child element of its parent

items/item[position()>1]

Any item element that has an items parent and that is not the first item child of its parent

item[position() mod 2 = 1]

Any item element that is an odd-numbered item child of its parent

div[@class="appendix"]//p

Any p element with a div ancestor element that has a class attribute with value appendix

@class

Any class attribute (not any element that has a class attribute)

@*

Any attribute

See Also

Concepts

Location Paths

Other Resources

XQL Application Development