Conditional Processing

One of the more powerful features of XSL is the ability to do conditional processing. If you are familiar with any programming or scripting languages, then you are probably already familiar with conditional processing.

The idea is that you establish a condition, a test, and if that test is met, you continue with the remainder of the processing. The most common structure for conditional processing is an “if…then” structure.

XSLT does have some structures for conditional processing: if, choose, when, and otherwise.

xsl:if

The xsl:if element allows you to perform a test, and if that test turns out to be true, you can then perform some transformation. The element accepts one attribute:

  • test

The test attribute must be a boolean ...

Get Special Edition Using XML, Second Edition 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.