From http://www.w3schools.com (Copyright Refsnes Data)
XSLT Element Reference
The <xsl:choose> element is used in conjunction with <xsl:when> and <xsl:otherwise> to express multiple conditional tests.
If no <xsl:when> is true, the content of <xsl:otherwise> is processed.
If no <xsl:when> is true, and no <xsl:otherwise> element is present, nothing is created.
Tip: For simple conditional testing, use the <xsl:if> element instead.
|
<xsl:choose> <!-- Content:(xsl:when+,xsl:otherwise?) --> </xsl:choose> |
None
The code below will add a pink background-color to the artist column WHEN the price of the CD is higher than 10.
Example
Try it yourself » |
Declare a variable named "color". Set its value to the color attribute of the current element. If the current element has no color attribute, the value of "color" will be "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> |
XSLT Element Reference
From http://www.w3schools.com (Copyright Refsnes Data)