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

Using Choose, When And Otherwise To Replace - And +

12.20.2006
| 226 views |
  • submit to reddit
        This uses choose, when and otherwise to replace - and + when $day_change would return '+0.1p'. The result would be 'Up 0.1p'

<xsl:choose>
 <xsl:when test="$day_change > 0">
    Up <xsl:value-of select="$day_change" />
 </xsl:when>
 <xsl:when test="$day_change < 0">
    Down <xsl:value-of select="$day_change" />
 </xsl:when>
 <xsl:otherwise>
    No change
 </xsl:otherwise>
</xsl:choose>