Logo

Choose

Goal: colour code the different types of CD

    <tbody>
      <xsl:for-each select="cdlist/cd">
       <tr>
         <xsl:attribute name="style">color:
           <xsl:choose>
             <xsl:when test="filed[. = 'C05 World']">lime</xsl:when>
             <xsl:when test="filed[. = 'C06 Country']">yellow</xsl:when> 
             <xsl:when test="filed[. = 'C11 Jazz Trad']">orange</xsl:when>
             <xsl:when test="filed[. = 'C01 Pop']">red</xsl:when>
             <xsl:otherwise>white</xsl:otherwise>
           </xsl:choose>
         </xsl:attribute>
         <td><xsl:value-of select="artist"/></td>
         <td><xsl:value-of select="title"/></td>
         <td><xsl:value-of select="filed"/></td>
       </tr>
      </xsl:for-each>
    </tbody>

It tests the content of the element "filed" to set the style

Ivan Herman, W3C Head of Offices16 July, 200219 (32)