xsl:template

Specifies a template rule.

Format

Description

The match attribute is required except when you specify the name attribute. The pattern you specify for the match attribute identifies the source node or set of source nodes to which the template rule applies.

The optional name attribute specifies a name for the template. You can use the name of a template to invoke it with the xsl:call-template instruction. The value you specify for name must be a qualified name. If you specify a name attribute, a match attribute is not required.

The optional mode attribute prevents the template from matching nodes selected by an xsl:apply-templates instruction that specifies a different mode. The value of mode must be a qualified name or an asterisk (*). If you specify an asterisk, it means match any node.

If an xsl:apply-templates instruction contains a mode attribute, the xsl:apply-templates instruction can apply to only those xsl:template instructions that specify a mode attribute with the same value. If an xsl:apply-templates instruction does not contain a mode attribute, the xsl:apply-templates instruction can apply to only those xsl:template instructions that do not specify a mode attribute.

If you specify the match and mode attributes, they have no effect if the template is instantiated by the xsl:call-template instruction. If you specify the name attribute, you can still instantiate the template as a result of an xsl:apply-templates instruction.

If two or more templates have the same name, Stylus Studio uses the template that appears last in the stylesheet.

The template body contains literal results and XSLT instructions. The XSLT processor instantiates the template body for each node identified by pattern. This means the XSLT processor copies literal results to the result document and executes the XSLT instructions.

If there is more than one matching template rule, the XSLT processor chooses the matching template rule with the higher priority. If both have the same priority, the XSLT processor chooses the one that occurs last in the stylesheet.

For examples and additional information about templates, see Working with Templates.

 
Free Stylus Studio XML Training: