WebReference.com - Excerpt from Inside XSLT, Chapter 2, Part 3 (1/5)
XSL templates enable you to specify how you want your transformation to work.
<sxl:template> element is set up to match one node (which may
contain other nodes) or a number of nodes in the source document, and to specify exactly
how that node should be transformed.
The following list describes the attributes of
match(optional). Specifies a pattern that matches nodes to be processed. Set to a valid pattern.
name(optional). Holds the name of the template, which enables it to be called. If you do not use this attribute, you must use the
matchattribute. Set to a
priority(optional). A positive or negative integer or real number that sets the priority of this template. Used when more than one template matches the same node. Set to a number.
mode(optional). If you use
<xsl:apply-templates>on a set of nodes, the only templates used have a matching mode. Set to a
<xsl:template> element is called a rule. In general,
<xsl:template> element can contain zero or more
elements (which you'll see in Chapter 9), followed by the template body, which specifies how
you want the transformation to take place.
Templates have very specific rules. They can contain
elements, followed by a template body, which can contain
PCDATA, XSLT instructions,
extension elements, and literal result elements.
A number of XSLT elements, called instructions, may appear in a template body:
No other XSLT element may appear directly in a template body. As you'll see in
Chapter 9, the
<xsl:param> element may appear in a template before the template body,
but it is not called an XSLT instruction. In addition, other XSLT elements, such as
can appear in templates, but only at specific locations, so W3C doesn't call them instructions.
You'll see how to use each of these instructions throughout this book.
Extension elements are covered in Chapter 5; these elements are defined by the user or the XSLT processor, and extend XSLT. Many XSLT processors have defined their own extensions, and that's one of the reasons W3C has introduced the XSLT 1.1 working draft, where the extension mechanism is more regulated. Presumably, this functionality will be incorporated into XSLT 2.0.
Created: September 26, 2001
Revised: September 26, 2001