XSLT <xsl:apply-templates>
Element
Definition and Usage
The <xsl:apply-templates>
element applies templates to the current element or its child nodes.
If we add the select attribute to the <xsl:apply-templates>
element, it will only process child elements that match the value of this attribute. We can use the select attribute to specify the order of the child nodes to be processed.
Syntax
Attributes
Attribute | Value | Description |
---|---|---|
select | expression | Optional. Specifies the nodes to be processed. An asterisk selects the entire node set. If omitted, all child nodes of the current node will be selected. |
mode | name | Optional. Used to differentiate between multiple processing methods defined for the same element. |
Example 1
Enclose each title element in the document with an h1 element:
Example 2
Enclose all title elements that are child elements of message in the document with an h1 element:
Example 3
Enclose all child nodes of message with the mode attribute set to "big" in the document with an h1 element: