June 28, 2010

how to use more than one condition in xsl:if | Multiple Conditions in xsl:if and xsl:for-each

QUESTION:

how to use more than one condition in xsl:if
Multiple Conditions in xsl:if and xsl:for-each
Is it possible to place multiple conditions in an xsl:if statement?
having more than one conditions inside/in xsl:if
placing / checking more than one condition in xsl:if
switch case in xsl
switch case in xslt


ANSWER:
In xslt IF THEN ELSE / IF ELSE structure doesn’t exist.
Using xsl:if a condition can be tested. If it goes true the true-statements will be executed
Else, Noting happens.
If you like to use then else use tag

<xsl:choose>
Here the list of conditions are given inside <xsl:when>
If all goes false <xsl:otherwise> is executed.
This concept looks like switch case.
Code:
<xsl:choose>
<xsl:when test="if-condition1"> statement(s) </xsl:when>
<xsl:when test="if-condition2"> statement(s) </xsl:when>
.
.
<xsl:otherwise> else block statement(s)</xsl:otherwise>
</xsl:choose>


No comments :

Post a Comment