Introduction

This document gives an informal description of the syntax of XSLT patterns. For a formal specification, see the XSLT recommendation. Pattern syntax has not changed significantly in XSLT 2.0, except that any XPath 2.0 expression may now be used within a predicate.

Patterns define a condition that a node may or may not satisfy: a node either matches the pattern, or it does not. The syntax of patterns is a subset of that for XPath Expressions, and formally, a node matches a pattern if it is a member of the node set selected by the corresponding expression, with some ancestor of the node acting as the current node for evaluating the expression. For example a TITLE node matches the pattern "TITLE" because it is a member of the node set selected by the expression "TITLE" when evaluated at the immediate parent node.

XSLT patterns may be used either in an XSLT stylesheet, or as a parameter to various Java interfaces in the Saxon API. The syntax is the same in both cases. In the Java interface, patterns are encapsulated by the net.sf.saxon.pattern.Pattern class, and are created by calling the static method Pattern.make().

In style sheets, patterns are used primarily in the match attribute of the xsl:template element. They are also used in the count and from attributes of xsl:number, the match attribute of xsl:key, and the group-starting-at attribute of xsl:for-each-group.

Expand

Next