Wednesday 20 July 2016

XSL - If Else condition Choose When Otherwise

In XSL, there is no If - Else construct. Only If is present.

If your requirement is stricly If - Else, instead use the Choose When Otherwise construct as below:

<xsl:choose>
 <xsl:when test="$a > $b">
  <h2> A is greater than B </h2>
 </xsl:when>
 <xsl:otherwise>
  <h2> B is greater than A </h2>
 </xsl:otherwise>
</xsl:choose>

In the above example, a ($a) and b ($b), are variables.

No comments:

Post a Comment