XSLT <xsl:if> Element
Definition and Usage
The <xsl:if> element contains a template that is applied only if the specified condition is met.
Tip: Use <xsl:choose> with <xsl:when> and <xsl:otherwise> to express multiple conditional tests!
Syntax
Attributes
| Attribute | Value | Description |
|---|---|---|
| test | expression | Required. Specifies the condition to test. |
Examples
Select the title and artist values when the price of a CD is above 10:
Example 1
Display the title of each CD. If it is not the last or 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: