The <xsl:choose>, <xsl:when>, and <xsl:otherwise> Elements

The <xsl:choose> element is something like the Java switchstatement, which enables you to compare a test value against several possible matches.

The <xsl:choose> element has no attributes. It contains one or more <xsl:when> elements, and, optionally, one <xsl:otherwise> element, which must come last if you use it.

Here’s how it works; you enclose <xsl:when> elements, each of which has a true/false test, in an <xsl:choose> element. The template body in the first <xsl:when> element whose test evaluates as true is used, and all the others are not. The last element inside the <xsl:choose> element may be an <xsl:otherwise> element, and the template body inside this element is used if none ...

Get Inside XSLT now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.