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
selectContains 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.modeDefines 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>withmode="toc"to process a node for the table of contents of a document, and write other<xsl:template>s withmode="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
modeattribute when used with the<xsl:apply-templates>element:#defaultMatches the default mode
#currentMatches 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.” ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access