The xsl:if Element

All programming languages contain a construct to test for an item that can be only either true or false. If the value is true, a section of code is executed. If it's false, the first section is skipped, and another section may or may not be executed. In JavaScript, the construct is an if-else statement. The else part is optional. If your goal is to execute a segment of code when the value is true and do nothing otherwise, the else is not included.

In XSL, you can use the xsl:if command to construct an expression that will control the conditional execution of a block of XSL code. The delimiters of the block of code are the opening and closing <xsl:if> tags. There's no companion xsl:else command, although it can be mimicked ...

Get Sams Teach Yourself XML in 24 Hours 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.