The xsl:choose Element

The xsl:choose element enables you to make multiple choices about how nodes should be processed. For each specified test, you use an xsl:when element with a test attribute. If you want to create a default type of processing when none of the tests on xsl:when elements is satisfied, you can use an xsl:otherwise element.

Listing 12.4 shows a modified stylesheet. When the value of the version attribute has the value final, you will output the full document as in the earlier example. This time, you will create different outputs when the value of the version attribute is draft or outdated.

Listing 12.4. Documents2.xsl: A Modified XSLT Stylesheet Using xsl:choose
					<?xml version='1.0'?> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" ...

Get Sams Teach Yourself XML in 10 Minutes 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.