XSLT <xsl:apply-templates>
❮ XSLT ဒြပ်စင် အကိုးအကားကို အပြီးသတ်ပါ။
အဓိပ္ပါယ်နှင့် အသုံးပြုမှု
<xsl:apply-templates> ဒြပ်စင်သည် လက်ရှိဒြပ်စင် သို့မဟုတ် လက်ရှိဒြပ်စင်၏ ကလေး node များအတွက် နမူနာပုံစံကို အသုံးပြုသည်။
<xsl:apply-templates> ဒြပ်စင်တွင် ရွေးချယ်ထားသော အရည်အချင်းကို ပေါင်းထည့်ပါက ၎င်းသည် attribute ၏တန်ဖိုးနှင့် ကိုက်ညီသော ကလေးဒြပ်စင်ကိုသာ လုပ်ဆောင်ပေးမည်ဖြစ်သည်။ ကလေး node များကို လုပ်ဆောင်ရမည့် အစီအစဥ်ကို သတ်မှတ်ရန် ရွေးချယ်ထားသော attribute ကို အသုံးပြုနိုင်ပါသည်။
အထားအသို
<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 |
ဥပမာ ၁
စာရွက်စာတမ်းရှိ ခေါင်းစဉ်ဒြပ်စင်တစ်ခုစီတွင် 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>
ဥပမာ ၂
မက်ဆေ့ချ်၏ သားသမီးများဖြစ်သည့် ခေါင်းစဉ်ဒြပ်စင်အားလုံးတွင် 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>
ဥပမာ ၃
မုဒ် ရည်ညွှန်းချက် "ကြီး" ဟု သတ်မှတ်ထားသည့် မက်ဆေ့ခ်ျ၏ ကလေးဆုံမှတ်များအားလုံးတွင် 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>
❮ XSLT ဒြပ်စင် အကိုးအကားကို အပြီးသတ်ပါ။