4.4 What Is a Pattern?

An XSLT pattern is a subset of an XPath expression. It is part of a template rule that allows the template to test whether a node matches certain criteria. This subset of expressions called a pattern is defined by XSLT, not by XPath.

A pattern can only evaluate a node-set, meaning a group of zero or more nodes. A node-set type is the only thing a pattern can evaluate or return. A pattern can match elements and attributes and use node tests (see Section 4.7, later in this chapter) and predicates (see the next section, Section 4.5). It can also use the id( ) function (demonstrated in Chapter 5) and the key( ) function (described in Chapter 11), but that's about the sum of it.

There are four places in XSLT where you can identify a pattern, each time as a value of an attribute. The places that specify a pattern are in the match attribute of template and key elements, and in the count and from attributes of the number element. You can read more about patterns in Section 5.2 of the XSLT specification.

A pattern is one of two parts of a template rule, which, according to XSLT 2.0, consists of a pattern described in an attribute value and a sequence constructor, which tells the processor what to do what items to produce when it encounters the pattern and therefore is instantiated (see Section 2.4.1 of the XSLT 2.0 spec available at http://www.w3.org/TR/xslt20/).



Learning XSLT
Learning XSLT
ISBN: 0596003277
EAN: 2147483647
Year: 2003
Pages: 164

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net