<xsl: choose> <xsl: when test ="Boolean expression"> <xsl: when test ="Boolean expression"> <xsl:otherwise> </xsl: choose>
Each <xsl: when> element has a test condition. The test condition is a Boolean expression, which is an XPath expression that is converted to a Boolean value. The contents of the first <xsl: when> element whose test condition is true is output to a result tree.
As well, the <xsl: choose> element can have an optional <xsl:otherwise> element whose contents are output only if no test conditions of any <xsl: when> element are true. If no <xsl:otherwise> element exists and none of the test conditions in any of the <xsl: when> child elements are true, then the <xsl: choose> element does not produce any output.
The following is an example of an <xsl: choose> element:
<xsl: choose> <xsl: when test = "number [ . > 2000]">A big number</xsl:when> <xsl:otherwise>A small number</xsl:otherwise> </xsl:choose>
If the number element in the target XML file contains a number value greater than 2,000, then the string "A big number" is inserted into the result tree. In any other case, "A small number" will be inserted.
The following instructions were written for the Resource perspective, but they will also work in many other perspectives.
To create an <xsl: choose> element, follow these steps: