Element <xsl:choose> na XSLT

Tirar da kuma amfani

<xsl:choose> cece da <xsl:when> da <xsl:otherwise> doniya, za a gudan shirin da kowa.

Kwannan bai <xsl:when> ce ne, ya a gudan <xsl:otherwise> anfani.

Ruge mei you <xsl:when> shi true, qie bu cun zai <xsl:otherwise> yuan su, zenme bu chuang jian ren he neirong.

Tishi:Dui yu jian dan de tiao jian ce shi, qing shi yong <xsl:if> yuan su qu er dai.

Yufa


<!-- Content:(xsl:when+,xsl:otherwise?) -->

Shuxing

None

Shi li

Dizi 1

Dizi code a kan CD de jia gé gao yu 10 shi, xiang artist lie tian fengsen de beijing se:

<?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>

Can quan XML wénjiàn, can quan XSL wénjiàn, can quan jiéguo.

Dizi 2

A yin bayan kanama "color". Ba zai bayan anfa "color" zai current yunxing yuansu de color shuxing. Ruge current yunxing yuansu mei you color shuxing, zenme color de zhi shi "green":

<xsl:variable name="color">
  
    
      
      
    green