Home > Articles > Programming > Java

  • Print
  • + Share This
This chapter is from the book

This chapter is from the book

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


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 match attribute uses the slash character (/) to indicate the root element. This character, called a pattern, is one of a handful of operators you'll need to know in order to navigate around the source tree.

  • + Share This
  • 🔖 Save To Your Account