XSLT TutorialLesson 59Free preview
XSLT <if>
This lesson is part of XML · All levels
Summary
<xsl:if> executes the block content only if the expression on the test attribute is worth true. This element has no else branch; for other branches use <xsl:choose>/<xsl:when>/<xsl:otherwise>. The test expression is written with the XPath syntax, for example price > 10 or @discount.
Key points
- The test attribute must be filled with the boolean expression XPath
- It has no else, only one branch of the condition
- The number comparison is written directly: test="price > 10"
- Testing the existence of attributes can be done by testing="@sale"
- For many branches use <xsl:choose>
Full lesson
Code examples and quizzes
Full lessons, code examples, and quizzes are available to subscribers. 5 questions.