Implementing IF-ELSE condition in ItemStyle.xsl file in SharePoint
In XSLT, there is no IF-ELS condition. However, you can use choose statement to perform IF-ELSE and NESTED IF in XSLT as the following:
<xsl:choose>
<xsl:when test="">
<!--do something-->
</xsl:when>
<xsl:otherwise>
<!-- Else do somthing -->
</xsl:otherwise>
</xsl:choose>
Implementing NESTED-IF-ELSE in SharePoint ItemStyle.xsl file
If you would like to implement multiple IF in ItemStyle.xsl
file, you have to repeat when clause as the following:
<xsl:choose>
<xsl:when test="">
<!--do something-->
</xsl:when>
<xsl:when test="">
<!--do something-->
</xsl:when>
<xsl:when test="">
<!--do something-->
</xsl:when>
<xsl:otherwise>
<!-- Else do somthing -->
</xsl:otherwise>
</xsl:choose>
Implementing NESTED CHOOSE in SharePoint ItemStyle.xsl file
Besides the above examples, you can also use NESTED CHOOSE in XSLT as the following:
<xsl:choose>
<xsl:when test="">
<xsl:choose>
<xsl:when test="">
<!--do something-->
</xsl:when>
<xsl:otherwise>
<!-- Else do somthing -->
</xsl:otherwise>
</xsl:choose>
</xsl:when>
<xsl:when test="">
<!--do something-->
</xsl:when>
<xsl:when test="">
<!--do something-->
</xsl:when>
<xsl:otherwise>
<!-- Else do somthing -->
</xsl:otherwise>
</xsl:choose>
NESTED-IF and Multiple CHOOSE in XSLT
Below is an example to perform Nested-IF
and Multiple CHOOSE
in XSLT ItemStyle file in SharePoint