एक्सएसएलटी <xsl:apply-templates>
❮ पूर्ण एक्सएसएलटी तत्व संदर्भ
परिभाषा और उपयोग
<xsl:apply-templates> तत्व वर्तमान तत्व या वर्तमान तत्व के चाइल्ड नोड्स के लिए एक टेम्पलेट लागू करता है।
यदि हम <xsl:apply-templates> तत्व में एक चुनिंदा विशेषता जोड़ते हैं तो यह केवल उस बच्चे के तत्व को संसाधित करेगा जो विशेषता के मूल्य से मेल खाता है। हम यह निर्दिष्ट करने के लिए चयन विशेषता का उपयोग कर सकते हैं कि बच्चे के नोड्स को किस क्रम में संसाधित किया जाना है।
वाक्य - विन्यास
<xsl:apply-templates select="expression" mode="name">
<!-- Content:(xsl:sort|xsl:with-param)* -->
</xsl:apply-templates>
गुण
Attribute | Value | Description |
---|---|---|
select | expression | Optional. Specifies the nodes to be processed. An asterisk selects the entire node-set. If this attribute is omitted, all child nodes of the current node will be selected |
mode | name | Optional. If there are multiple ways of processing defined for the same element, distinguishes among them |
उदाहरण 1
दस्तावेज़ में प्रत्येक शीर्षक तत्व के चारों ओर एक एकल h1 तत्व लपेटें:
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="title">
<h1><xsl:apply-templates/></h1>
</xsl:template>
</xsl:stylesheet>
उदाहरण 2
संदेश के बच्चे हैं जो सभी शीर्षक तत्वों के चारों ओर एक एकल h1 तत्व लपेटें:
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="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>
उदाहरण 3
संदेश के सभी चाइल्ड नोड्स के चारों ओर एक एकल h1 तत्व लपेटें जिसमें मोड विशेषता "बड़ा" पर सेट हो:
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="message">
<h1><xsl:apply-templates select="*" mode="big"/></h1>
</xsl:template>
</xsl:stylesheet>
❮ पूर्ण एक्सएसएलटी तत्व संदर्भ