<xsl:choose>

We already described the <xsl:if> which can be compared to an if(..){...} statement in many programming languages. The <xsl:choose> element can be compared to multiple else conditions including an optional final else block being reached if all boolean tests fail:

if (condition a){
...//block 1
} else if (condition b){
... //block b
} ...
...
else {
  ... //code being reached whan all conditions evaluate to false
}

We want to generate a list of memo recipient names with roman type numeration up to 10. Higher numbers shall be displayed in ordinary decimal notation:

I:Adam Hacker
II:Eve intruder
III: ...
IV: ...
...

Though XSL offers a better way we may generate these number literals by:

<xsl:template match="/memo">
  <xsl:apply-templates select="to"/>
</xsl:template>

<xsl:template match="to">
  <xsl:choose>
    <xsl:when test="1 = position()">I</xsl:when>
    <xsl:when test="2 = position()">II</xsl:when>
    <xsl:when test="3 = position()">III</xsl:when>
    <xsl:when test="4 = position()">IV</xsl:when>
    <xsl:when test="5 = position()">V</xsl:when>
    <xsl:when test="6 = position()">VI</xsl:when>
    <xsl:when test="7 = position()">VII</xsl:when>
    <xsl:when test="8 = position()">VIII</xsl:when>
    <xsl:when test="9 = position()">IX</xsl:when>
    <xsl:when test="10 = position()">X</xsl:when>
    <xsl:otherwise>
      <xsl:value-of select="position()"/>
    </xsl:otherwise>
  </xsl:choose>

  <xsl:text>:</xsl:text>
  <xsl:value-of select="."/>
  <xsl:value-of select="$newline"/>
</xsl:template>

Note that this conversion is incomplete: If the number in question is larger than 10 it will be formatted in ordinary decimal style according to the <xsl:otherwise> clause.