Help us improve your experience.

Let us know what you think.

Do you have time for a two-minute survey?






Declare a template that contains rules to apply when a specified node is matched. The match attribute associates the template with an XML element. The match attribute can also be used to define a template for a whole branch of an XML document. For example, match="/" matches the root element of the document. Although the match and name attributes are optional, one of the two attributes must be included in the template definition.

When templates are applied to a node set using the <xsl:apply-templates> instruction, they might be applied in a particular mode; the mode attribute in the <xsl:template> instruction indicates the mode in which a template needs to be applied for the template to be used. If templates are applied in the specified mode, the match attribute is used to determine whether the template can be used with the particular node. If more than one template matches a node in the specified mode, the priority attribute determines which template is used. The highest priority wins. If no priority is specified explicitly, the priority of a template is determined by the match attribute.

You can pass template parameters using the <xsl:with-param> element. To receive a parameter, the template must contain an <xsl:param> element that declares a parameter of that name. These parameters are listed before the body of the template, which is used to process the node and create a result.


match(Optional) XPath expression specifying the nodes to which to apply the template. If this attribute is omitted, the name attribute must be included.
mode(Optional) Indicate the mode in which a template needs to be applied for the template to be used.
name(Optional) Specify a name for the template. Named templates can be explicitly called with the <xsl:call-template> element. If the name attribute is omitted, the match attribute must be included.
priority(Optional) Specify a numeric priority for the template.

Usage Examples