Skip to Content
Special Edition Using XSLT
book

Special Edition Using XSLT

by Michael Floyd
January 2002
Intermediate to advanced
480 pages
11h 5m
English
Que
Content preview from Special Edition Using XSLT

Conditional Processing

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 ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Special Edition Using XML, Second Edition

Special Edition Using XML, Second Edition

- et al. David Gulbransen
XML for Publishers

XML for Publishers

Keith Fahlgren

Publisher Resources

ISBN: 0789725053Purchase book