xsl:choose

Selects one template to instantiate from a group of templates.

Format

<xsl:choose> 
  <xsl:when test="expression1"> 
    template_body  
  </xsl:when> 
  [<xsl:when test="expression2"> 
    template_body  
  </xsl:when>] ... 
  [<xsl:otherwise> 
   template_body   
  </xsl:otherwise>] 
</xsl:choose> 

Description

An xsl:choose element contains one or more xsl:when elements followed by zero or one xsl:otherwise element. Each xsl:when element contains a required test attribute, whose value is an expression. Each xsl:when and xsl:otherwise element contains a template.

When the XSLT processor processes an xsl:choose element, it starts by evaluating the expression in the first xsl:when element. The XSLT processor converts the result to a Boolean value. If the result is true, the XSLT processor instantiates the template contained by that xsl:when element. If the result is false, the XSLT processor evaluates the expression in the next xsl:when element.

The XSLT processor instantiates the template of only the first xsl:when element whose test expression evaluates to true. If no expressions evaluate to true and there is an xsl:otherwise element, the XSLT processor instantiates the template in the xsl:otherwise element.

If no expressions in xsl:when elements are true and there is no xsl:otherwise element, the xsl:choose element has no effect.

SQL Server Tools

Integrated SQL Server Tools in Stylus Studio enable you to access relational data stored in SQL Server 2000 or SQL Server 2005 as XML using XQuery, SQL/XML or ADO - learn how to export relational data as XML today!

XHTML Tools

Powerful XHTML Tools for converting HTML to XHTML, validating XHTML, transforming XML to XHTML, editing JSP, creating XML driven Websites and more.

EDI to XML

Using the DataDirect XML Converters EDI repository, the EDI to XML Conversion module is able to support dozens of EDI standard dialects and message types like EDIFACT, HL7, and X12.

Accessing Relational Databases as XML with Stylus Studio's File Explorer

This demonstration is the first part of our series on working with relational and XML data, covering how to use Stylus Studio's File Explorer to connect to and query relational database tables as XML.

Stylus Most Wanted

 
Free Stylus Studio XML Training:
W3C Member