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.

Tip

 

You can create an xsl:choose element automatically using the XSLT mapper.

DataDirect XML Converters Video Demonstration

DataDirect XML Converters are Java and .NET components that enable access to any data (flat files, EDI) from your application code. Learn how to deploy XML applications today.

XQuery Profiler

Stylus Studio's XQuery Profiler allows you to benchmark any XQuery expression, and it helps you locate and eliminate performance bottlenecks for maximum XQuery performance.

Banks That Bank on Stylus Studio for Enhanced XML Productivity

Guess what! You can pass go and collect 200 dollars because with Stylus Studio 2006 you can save your banking company time and labor in every day work activities. Come see which banking companies are already taking advantage of Stylus Studio today!

Web Service Standards

Stylus Studio supports Web service standards including WSDL, UDDI and SOAP. The Web Service Tester lets you easily develop and leverage Web services in your XML applications.

Stylus Most Wanted

 
Free Stylus Studio XML Training:
W3C Member