ArticleDirectory
- Attribute
- Example 1
- Example 2
- Example 3
Definition and usage
<XSL: Apply-templates> the template can be applied to the current element or the child element of the current element.
If we add select to the <XSL: Apply-templates> element
Attribute, it only processes child elements that match the value of this attribute. We can use the select attribute to define the sequence of processing submediates.
Syntax
<XSL: Apply-templates select = "expression" mode = "name">
<! -- Content :( XSL: Sort | XSL: With-Param) * -->
</XSL: Apply-templates>
Attribute
Attribute |
Value |
Description |
Select |
Expression |
Optional. Specifies the node to be processed. Select the entire node set. If this attribute is omitted, all child nodes of the current node are selected. |
Mode |
Name |
Optional. If multiple processing methods are defined for the same element, use mode to differentiate them. |
Example 1
Enclose each title element in the document with the H1 element:
<? XML version = "1.0" encoding = "ISO-8859-1"?>
<XSL: stylesheetversion = "1.0"
Xmlns: XSL = "http://www.w3.org/1999/XSL/Transform">
<XSL: template match = "title">
<H1><XSL: Apply-templates/>
</H1>
</XSL: Template>
</XSL: stylesheet>
Example 2
Use the H1 element to enclose the title elements of all subelements of the message in the document:
<? XML version = "1.0" encoding = "ISO-8859-1"?>
<XSL: stylesheetversion = "1.0"
Xmlns: XSL = "http://www.w3.org/1999/XSL/Transform">
<XSL: template match = "message">
<H1><XSL: Apply-templates select = "title"/>
</H1>
</XSL: Template>
</XSL: stylesheet>
Example 3
Use the H1 element to enclose all the subnodes of the message whose mode attribute is set to "big" in the document:
xmlns: XSL = "http://www.w3.org/1999/XSL/Transform">