Templates and Template Rules

Templates are the individual statements you’ll use to create a transformation. A collection of templates are grouped together into what’s called a template rule. Listing 2.2 contains just one template rule. This begins with

<xsl:template match="/"> 

and ends with the closing tag

</xsl:template> 

This template rule is called the root template rule, because it processes the root element of the source document (see Listing 2.1). All style sheets must contain a root template rule. Later, you’ll learn how you can add other template rules to process additional elements from the source document.

Template rules contain a match attribute that specifies which element or elements you are processing. The root template rule’s ...

Get Special Edition Using XSLT now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.