XSLT <xsl:preserve-space>
❮ XSLT ဒြပ်စင် အကိုးအကားကို အပြီးသတ်ပါ။
အဓိပ္ပါယ်နှင့် အသုံးပြုမှု
<xsl:preserve-space> ဒြပ်စင်အား အဖြူနေရာကို ထိန်းသိမ်းထားသင့်သည့် အစိတ်အပိုင်းများကို သတ်မှတ်ရန် အသုံးပြုသည်။
မှတ်ချက်- နေရာလွတ်များကို ထိန်းသိမ်းခြင်းသည် မူရင်းဆက်တင်ဖြစ်သောကြောင့် <xsl:preserve-space> ဒြပ်စင်ကို အသုံးပြုပါက <xsl:strip-space> ဒြပ်စင်ကို အသုံးပြုမှသာ လိုအပ်ပါသည်။
မှတ်ချက်- <xsl:preserve-space> ဒြပ်စင်နှင့် <xsl:strip-space> ဒြပ်စင်များသည် ထိပ်တန်းအဆင့်ဒြပ်စင်များဖြစ်သည်။
အထားအသို
<xsl:preserve-space elements="list-of-element-names"/>
<xsl:strip-space elements="list-of-element-names"/>
ဂုဏ်တော်
Attribute | Value | Description |
---|---|---|
elements | list-of-element-names | Required. A white space separated list of element names for which white space should be preserved/removed. Note: The list can also contain "*" and "prefix:*" so that all elements or all elements from a particular namespace can be joined |
ဥပမာ ၁
အောက်ဖော်ပြပါ ဥပမာတွင် ခေါင်းစဉ်နှင့် အနုပညာရှင်ဒြပ်စင်များအတွက် အဖြူရောင် space node များကို ထိန်းသိမ်းထားပြီး နိုင်ငံ၊ ကုမ္ပဏီ၊ ဈေးနှုန်းနှင့် နှစ်ဒြပ်စင်များအတွက် white space node များကို ဖယ်ရှားသည်-
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:strip-space elements="country company price year" />
<xsl:preserve-space elements="title artist" />
<xsl:template match="/">
<html>
<body>
<xsl:for-each select="catalog/cd">
<p>
<xsl:value-of select="title" /><br />
<xsl:value-of select="artist" /><br />
<xsl:value-of select="country" /><br />
<xsl:value-of select="company" /><br />
<xsl:value-of select="price" /><br />
<xsl:value-of select="year" />
</p>
</xsl:for-each>
</body>
</html>
</xsl:template>
</xsl:stylesheet>
❮ XSLT ဒြပ်စင် အကိုးအကားကို အပြီးသတ်ပါ။