How to declare xsl:choose element in XSLT

In this article,we are describing xsl:choose element.
  • 1883
The <xsl:choose> element is tests multiple condition in conjunction with the <xsl:otherwise> and <xsl:when> elements.For simple conditional testing, use the <xsl:if> element.It behaves like a switch statement.It is support to IE 5.0 and FF 1.0.

Syntax of xsl:choose element


  <xsl:when test="First Statement"></xsl:when>

  <xsl:when test="Second Statement"></xsl:when>

  <xsl:otherwise></xsl:otherwise> [optional]


  • It have no any attribute.

Example of xsl:chhose element

<?xml version="1.0" encoding="ISO-9000-1"?>

<xsl:stylesheet version="1.0"


  <xsl:template match="/">



        <h2>Shrit Price</h2>

        <table border="1">

          <tr bgcolor="red">




          <xsl:for-each select="catalog/shrit">



                <xsl:value-of select="title"/>



                <xsl:when test="price &gt; 20">

                  <td bgcolor="blue">

                    <xsl:value-of select="title1"/>





                    <xsl:value-of select="title"/>











Further Readings

You may also want to read these related articles :

Ask Your Question 

Ask Your Question Got a programming related question? You may want to post your question here

Programming Answers here

© 2020 DotNetHeaven. All rights reserved.