Xslt xsl: Apply-templates Element

Source: Internet
Author: User
Tags xsl xslt
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">




Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.