XSLT <xsl:otherwise>
❮ XSLT ဒြပ်စင် အကိုးအကားကို အပြီးသတ်ပါ။
အဓိပ္ပါယ်နှင့် အသုံးပြုမှု
<xsl:otherwise> ဒြပ်စင်သည် <xsl:choose> ဒြပ်စင်အတွက် ပုံသေလုပ်ဆောင်ချက်ကို သတ်မှတ်သည်။ <xsl:when> အခြေအနေများ တစ်ခုမှ မကျင့်သုံးသောအခါတွင် ဤလုပ်ဆောင်ချက်ကို လုပ်ဆောင်ပါမည်။
အထားအသို
<xsl:otherwise>
<!-- Content:template -->
</xsl:otherwise>
ဂုဏ်တော်
တစ်ခုမှ
ဥပမာ ၁
စီဒီ၏စျေးနှုန်းသည် 10 ထက်များသောအခါတွင် အောက်ဖော်ပြပါကုဒ်သည် ပန်းရောင်နောက်ခံ-အရောင်ကို အနုပညာရှင်ကော်လံတွင် ပေါင်းထည့်မည်ဖြစ်ပြီး၊ မဟုတ်ပါက ၎င်းသည် အနုပညာရှင်၏အမည်ကို ပရင့်ထုတ်လိမ့်မည်-
<?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>
<h2>My CD Collection</h2>
<table border="1">
<tr bgcolor="#9acd32">
<th>Title</th>
<th>Artist</th>
</tr>
<xsl:for-each select="catalog/cd">
<tr>
<td><xsl:value-of select="title"/></td>
<xsl:choose>
<xsl:when test="price>'10'">
<td bgcolor="#ff00ff">
<xsl:value-of select="artist"/></td>
</xsl:when>
<xsl:otherwise>
<td><xsl:value-of select="artist"/></td>
</xsl:otherwise>
</xsl:choose>
</tr>
</xsl:for-each>
</table>
</body>
</html>
</xsl:template>
</xsl:stylesheet>
XML ဖိုင်ကို ကြည့်ပါ ၊ XSL ဖိုင်ကို ကြည့်ပါ ၊ ရလဒ်ကိုကြည့်ရှုပါ။
ဥပမာ ၂
"အရောင်" အမည်ရှိ ကိန်းရှင်တစ်ခုကို ကြေညာပါ။ ၎င်း၏တန်ဖိုးကို လက်ရှိဒြပ်စင်၏ အရောင်အရည်အသွေးအဖြစ် သတ်မှတ်ပါ။ လက်ရှိဒြပ်စင်တွင် အရောင်ရည်ညွှန်းချက်မရှိပါက၊ "အရောင်" ၏တန်ဖိုးသည် "အစိမ်းရောင်" ဖြစ်လိမ့်မည်-
<xsl:variable name="color">
<xsl:choose>
<xsl:when test="@color">
<xsl:value-of select="@color"/>
</xsl:when>
<xsl:otherwise>green</xsl:otherwise>
</xsl:choose>
</xsl:variable>
❮ XSLT ဒြပ်စင် အကိုးအကားကို အပြီးသတ်ပါ။