270 11 The XML Transformation Language
<xsl:choose>
<xsl:when test="@bmi<25">
Normal
</xsl:when>
<xsl:when test="@bmi<30">
Overweight
</xsl:when>
<xsl:otherwise>
Obese
</xsl:otherwise>
</xsl:choose>
By using sorting and conditionals one can compute the maximum and
minimum. Here is the computation of a maximum:
<xsl:for-each select="interaction/BindingStrength">
<xsl:sort data-type="number" select="."/>
<xsl:if test="position()=last()">
<xsl:value-of select="."/>
</xsl:if>
</xsl:for-each>
This computation sorts all the binding strengths in increasing numerical or-
der. It then selects just the last (largest) one. Note the use of the “.” to denote
the current element. Alternatively, one could have sorted in descending or-
der and selected the first one as follows:
<xsl:for-each select="interaction/BindingStrength">
<xsl:sort data-type="number"
order="descending" select="."/>
<xsl:if test="position()=1">
<xsl:value-of select="."/>
</xsl:if>
</xsl:for-each>
Conditionals can appear either as elements usingxsl:chooseorxsl:if
as above or within match and select attributes. For example,
<xsl:value-of select="BindingStrength[position()=1]"/>
will select just the firstBindingStrengthelement. One can abbreviate the
test above as