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

Conditional Processing

Controlling choices in XSLT as to how and whether a node is to be processed falls into two categories:

  • Choice of two processing alternatives, one of which is to do nothing

  • Choice of multiple (greater than two) options

The xsl:if Element

The xsl:if element in XSLT corresponds broadly to if...then... else type statements in other programming languages, but in XSLT there is no else option. If you want an else option, you must use xsl:choose, described later in this chapter.

An xsl:if element is always nested within an xsl:template element. XSLT elements that are nested within templates are termed instructions or instruction elements.

The general form is like this:

 <xsl:template> <!-- Other content can go here. --> <xsl:if ...

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