Name

<xsl:apply-templates>

Instructs the XSLT processor to apply the appropriate templates to a node-set or sequence.

Category

Instruction.

Required Attributes

None.

Optional Attributes

select

Contains an XPath expression that selects the nodes to which templates should be applied. Valid values include * to select all the element children of the current node. Without this attribute, <xsl:apply-templates> selects all of the children of the current node, including text, processing instructions, and comments. The instructions <xsl:apply-templates /> and <xsl:apply-templates select="node()"/> are equivalent.

mode

Defines a processing mode, which is a convenient syntax that lets you write specific templates for specific purposes. For example, you could write an <xsl:template> with mode="toc" to process a node for the table of contents of a document, and write other <xsl:template>s with mode="print", mode="online", mode="index", etc. to process the same information for different purposes.

[2.0] In XSLT 2.0, there are two special values for the mode attribute when used with the <xsl:apply-templates> element:

#default

Matches the default mode

#current

Matches the current mode

Content

The <xsl:apply-templates> element can contain any number of <xsl:sort> and <xsl:with-param> elements. In many cases, <xsl:apply-templates> is an empty element.

Appears in

<xsl:apply-templates> appears inside a template.

Defined in

[1.0] XSLT section 5.4, “Applying Template Rules.”

[2.0] XSLT section 6.3, “Applying Template Rules.” ...

Get XSLT, 2nd Edition 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.