XSLT <xsl:otherwise> အရာသည်
အသုံးချက် နှင့် အသုံးပြုခြင်း
<xsl:otherwise> အရာသည် <xsl:choose> အရာသည် အခြေခံအခြေအား ဖော်ပြတာပါ။ အခြား <xsl:when> အခြေခံအခြေအား မရှိဘဲ အခြား <xsl:when> အခြေခံအခြေအား ပြောင်းလဲတင်သွင်းတာပါ။
ပေါ့ပိုင်း
<xsl:otherwise> <!-- Content:template --> </xsl:otherwise>
အချက်အလက်
အခြေခံ
အကျိုးသတ္တု
အကြောင်းအရာ ၁
အော်ဒိပ်သုံးချိန်ကုန်အား ၃၀ ထက် မြင်းကျန်းတဲ့အခါ အော်ဒိပ်သုံးချိန်ကုန်အား အော်ဒိပ်သုံးချိန်ကုန်အားအပေါ် ပန်းများကို ပြောင်းလဲတင်သွင်းတာပါ။ အခြားအခါ အော်ဒိပ်သုံးချိန်ကုန်အားအပေါ် အော်ဒိပ်သုံးချိန်ကုန်အားအပေါ် အော်ဒိပ်သုံးချိန်ကုန်အားအပေါ် ပြောင်းလဲတင်သွင်းတာပါ။
<?xml version="1.0" encoding="ISO-8859-1"?> <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 ဖိုင် ကြည့်ပါ,ရလဒ် ကြည့်ပါ.
အမှတ် 2
အမည် "color" အကွက် တစ်ခု ကို ပြောဆိုပါ။ အကွက် အရာ သတ်မှတ်ထားသော color အကွက် သတ်မှတ်ထားသည်။ အကွက် အရာ မရှိဘဲ လျှင် "color" အကွက် အရာ "green" ဖြစ်လိမ့်မည်။
<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>