January 2002
Intermediate to advanced
480 pages
11h 5m
English
XSLT provides two methods for processing based on a set of conditions. Those methods involve the following two elements:
<xsl:if>
<xsl:choose>
The <xsl:if> element operates like the if ... then construct typically found in programming and scripting languages. You specify the condition for the if statement using the test attribute. The condition results in a Boolean expression that returns either True or False. If the condition is True, the processing is carried out. For example:
<xsl:template match=”product/price”>
<xsl:if test=”number()”>
$
</xsl:if>
<xsl:value-of />
</xsl:template> To see how this might work in a database application, consider the XML document in Listing 4.8, which represents the results of a database ...