<xsl:apply-templates> Element
Directs the XSLT processor to find the appropriate template to apply, based on the type and context of each selected node.
<xsl:apply-templates
select = Expression
mode = QName
</xsl:apply-templates>
Attributes
- select
Can be used to process nodes selected by an expression, instead of processing all children. The value of theselect
attribute is an Expressions, which must evaluate to a node-set. The selected node-set is processed in document order, unless a different sort order has been specified.
- mode
Themode
attribute allows an element as specified by its Qualified Names to be processed multiple times, each time producing a different result. If<xsl:template>
does not have amatch
attribute, it cannot have amode
attribute. If an<xsl:apply-templates>
element has amode
attribute, it applies only to template rules from<xsl:template>
elements that have amode
attribute with the same value. If an<xsl:apply-templates>
element does not have amode
attribute, it applies only to template rules from<xsl:template>
elements that do not have amode
attribute.
Element Information
Number of occurrences |
Unlimited |
Parent elements |
xsl:attribute, xsl:comment, xsl:copy, xsl:element, xsl:fallback, xsl:for-each, xsl:if, xsl:message, xsl:otherwise, xsl:param, xsl:processing-instruction, xsl:template, xsl:variable, xsl:when, xsl:with-param, outputelements |
Child elements |
Remarks
The <xsl:apply-templates>
element first selects a set of nodes using the expression specified in the select
attribute. If this attribute is left unspecified, all children of the current node are selected. For each of the selected nodes, <xsl:apply-templates>
directs the XSLT processor to find an appropriate <xsl:template>
to apply. Templates are tested for applicability by comparing the node to the XPath expression specified in the template's match
attribute. If more than one template satisfies the match pattern, the one appearing with the highest priority is chosen. If several templates have the same priority, the last in the style sheet is chosen.
The following topic provides an example of the <xsl:apply-templates>
element.