O'Reilly logo

Sams Teach Yourself XML in 10 Minutes by Andrew H. Watt

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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" ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required