TemplatesThe bulk of a style sheet is a list of templates ( xsl:template ). The templates describe the various steps in the transformation. Most templates match an XPath (see the section XPath later in this chapter). The template content describes the corresponding output: <xsl:template match="Title"> <H1><xsl:apply-templates/></H1> </xsl:template> Priority and ModeThe priority and mode attributes control which template is used when two or more templates match the same name . priority boosts or lowers a template's priority: <xsl:template match="Title" priority="-1"> <H1><xsl:apply-templates/></H1> </xsl:template> mode allows an element to be processed several times by various templates: <xsl:template match="Title" mode="toc"> <H1><xsl:apply-templates mode="toc"/></H1> </xsl:template> Named TemplatesNamed templates are similar to functions: They can be invoked by their names (a name attribute) and accept parameters: <xsl:template name="label-it"> <xsl:param name="label"/> <xsl:value-of select="$label">: <xsl:apply-templates/> </xsl:template> Named templates are called through an xsl:call-template element. xsl:call-template applies the template to the current node: <xsl:call-template name="label-it"> <xsl:with-param name="">Title</xsl:with-param> </xsl:call-template> |