XSLT <xsl:otherwise> အရာ

အသုံးပြုနည်း

<xsl:otherwise> အရာတွင် <xsl:choose> အရာ၏ လျှပ်ပျက်သည့် အပြုအမူကို အသုံးပြုသည်။ <xsl:when> အခြေအနေမရှိဘဲဖြစ်လျှင် အမှုးကို လုပ်ဆောင်သည်။

ပြောင်းလဲ

<xsl:otherwise>
<!-- Content:template -->
</xsl:otherwise>

အချက်

None

အကြောင်းကြား

အမှတ် 1

ယခုအော်တွင်း အရာတို့၏ ဈေးနှုန်း 30 ထက် မြင့်သော အခါတွင် အကြောင်းအရာ artist အရွိုင်းတွင် ပဲရ်ကို အမှတ် 30 အစိတ်ဖြင့် အပြည့်အဝင် ပြုလုပ်သည်။ အခြားအရာတို့၏ ဈေးနှုန်း 30 ထက် ပိုသော အခါတွင် အကြောင်းအရာ artist ကို သာလျှင် ထုတ်ပြန်ကြေညာသည်:

<?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:when test="price>'10'">
            <td bgcolor="#ff00ff">
            <xsl:value-of select="artist"/></td>
          
          <xsl:otherwise>
            <td><xsl:value-of select="artist"/></td>
          </xsl:otherwise>
        
      </tr>
      </xsl:for-each>
    </table>
  </body>
  </html>
</xsl:template>
</xsl:stylesheet>

XML ဖိုင်ကြည့်XSL ဖိုင်ကြည့်ရလဒ်ကြည့်

အမှတ် 2

ကြောင်းချက်တစ်ခု ဖြစ်သည်။ "color" အမည်ရှိ သတင်းအကိုးအကား ကို သုံးပြီး အခြားအရာတို့၏ color အကိုးအကား ကို သုံးပြီးသည်။ အခြားအရာတို့၏ color အကိုးအကား မရှိဘဲဖြစ်လျှင် "color" အမည်ရှိ သတင်းအကိုးအကား သည် "green" ဖြစ်လိမ့်မည်ဖြစ်သည့်:

<xsl:variable name="color">
  
    
      
      
    green