Private archive copy · Unofficial site · Content copyright belongs to Runoob Tutorial and the original authors · View Original

XSLT Element

XSLT xsl:if Element


XSLT Element Reference Manual XSLT Element Reference Manual


Definition and Usage

xsl:if element contains a template that is applied only when a specified condition is true.

**Tip:** Please place the xsl:choose The difference between xsl:when and xsl:otherwise used together to express multiple conditional tests!


Syntax

test="expression">

property

property Value Description
test expression Required. Specifies the condition to test.

Example

Select the values of title and artist when the price of a CD is higher than 10:

Example 1

xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

My CD Collection

Title Artist

Try it »

Display the title of each CD. If it is neither the last nor the second-to-last CD, insert ", " between each CD-title. If it is the last CD, add "!" after the title. If it is the second-to-last CD, add ", and " after the title:

Example 2

xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

My CD Collection

Titles:

xsl:text,

xsl:text and

xsl:text!

Try it »


XSLT Element Reference Manual XSLT Element Reference Manual