DZone Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world

Snippets has posted 5883 posts at DZone. View Full User Profile

Simple XSL When Statement

12.13.2006
| 2197 views |
  • submit to reddit
        Checks to see if 'Stuff' has returned any data. If not then displays 'No data available'. If 'Stuff' has returned data then moves onto otherwise. Use  <xsl:when test="stuff = !'' "> to swap the when around.

<xsl:choose>
 <xsl:when test="stuff = '' ">
  <div>No data available</div>
 </xsl:when>
 <xsl:otherwise>
  <div><xsl:value-of select="stuff_alternative"/></div>
 </xsl:otherwise>
</xsl:choose>