XSLT <xsl:key>
❮ XSLT ဒြပ်စင် အကိုးအကားကို အပြီးသတ်ပါ။
အဓိပ္ပါယ်နှင့် အသုံးပြုမှု
<xsl:key> ဒြပ်စင်သည် key() လုပ်ဆောင်ချက်ဖြင့် ပုံစံစာရွက်တွင် အသုံးပြုနိုင်သည့် အမည်ရှိသောသော့ကို ကြေညာသည့် ထိပ်တန်းအဆင့်ဒြပ်စင်တစ်ခုဖြစ်သည်။
မှတ်ချက်- သော့သည် တစ်မူထူးခြားနေရန် မလိုပါ။
အထားအသို
<xsl:key
name="name"
match="pattern"
use="expression"/>
ဂုဏ်တော်
Attribute | Value | Description |
---|---|---|
name | name | Required. Specifies the name of the key |
match | pattern | Required. Defines the nodes to which the key will be applied |
use | expression | Required. The value of the key for each of the nodes |
ဥပမာ ၁
သင့်တွင် "persons.xml" ဟုခေါ်သော XML ဖိုင်တစ်ခုရှိသည်ဆိုပါစို့။
<persons>
<person name="Tarzan" id="050676"/>
<person name="Donald" id="070754"/>
<person name="Dolly" id="231256"/>
</persons>
ဤကဲ့သို့သော XSL ဖိုင်တွင် သော့တစ်ခုကို သင်သတ်မှတ်နိုင်သည်-
<xsl:key name="preg" match="person" use="@id"/>
id="050676" ရှိသည့်လူကို ရှာရန် (XSL ဖိုင်တွင် ရေးသားပါ)။
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:key name="preg" match="person" use="@id"/>
<xsl:template match="/">
<html>
<body>
<xsl:for-each select="key('preg','050676')">
<p>
Id: <xsl:value-of select="@id"/><br />
Name: <xsl:value-of select="@name"/>
</p>
</xsl:for-each>
</body>
</html>
</xsl:template>
</xsl:stylesheet>
❮ XSLT ဒြပ်စင် အကိုးအကားကို အပြီးသတ်ပါ။