XSLT လက်ရှိ() လုပ်ဆောင်ချက်
❮ XSLT လုပ်ဆောင်ချက် အကိုးအကားအဓိပ္ပါယ်နှင့် အသုံးပြုမှု
current() function သည် လက်ရှိ node များသာပါရှိသော node-set တစ်ခုကို ပြန်ပေးသည်။ အများအားဖြင့် လက်ရှိ node နှင့် context node သည် တူညီသည်။
<xsl:value-of select="current()"/>
ညီမျှသည်။
<xsl:value-of select=""/>
သို့သော် ခြားနားချက်တစ်ခုရှိသည်။ အောက်ပါ XPath expression ကိုကြည့်ပါ- "catalog/cd" ကိုကြည့်ပါ။ ဤအသုံးအနှုန်းသည် လက်ရှိ node ၏ <catalog> ကလေး node များကို ရွေးချယ်ပြီး၊ ထို့နောက် <cd> ကလေး nodes များကို ရွေးချယ်သည်။ ဆိုလိုသည်မှာ အကဲဖြတ်ခြင်း၏ အဆင့်တိုင်းတွင် "" ဖြစ်သည်။ အဓိပ္ပါယ်အမျိုးမျိုးရှိသည်။
အောက်ပါစာကြောင်း
<xsl:apply-templates select="//cd[@title=current()/@ref]"/>
လက်ရှိ node ၏ ref attribute ၏တန်ဖိုးနှင့် ညီမျှသောတန်ဖိုးနှင့် ခေါင်းစဉ် attribute ပါရှိသော cd အစိတ်အပိုင်းအားလုံးကို စီမံဆောင်ရွက်ပါမည်။
ဒါက မတူဘူး။
<xsl:apply-templates select="//cd[@title=./@ref]"/>
၎င်းသည် title attribute နှင့် ref attribute တစ်ခုပါရှိသော cd အစိတ်အပိုင်းအားလုံးကို တူညီသောတန်ဖိုးဖြင့် လုပ်ဆောင်မည်ဖြစ်သည်။
အထားအသို
node-set current()
ဥပမာ ၁
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="/">
<html>
<body>
<xsl:for-each select="catalog/cd/artist">
Current node: <xsl:value-of select="current()"/>
<br />
</xsl:for-each>
</body>
</html>
</xsl:template>
</xsl:stylesheet>
XML ဖိုင်ကို ကြည့်ပါ ၊ XSL ဖိုင်ကို ကြည့်ပါ ၊ ရလဒ်ကိုကြည့်ရှုပါ ။
❮ XSLT လုပ်ဆောင်ချက် အကိုးအကား