Thursday, February 19, 2009

Convert a value to uppercase or lower case in XSLT

First lets place all the letters of the alphabet, lower case and upper case in two seperate variables.

<xsl:variable name="lcletters">abcdefghijklmnopqrstuvwxyz</xsl:variable>

<xsl:variable name="ucletters">ABCDEFGHIJKLMNOPQRSTUVWXYZ</xsl:variable>

The variable/data we have to covert is/in toconvert

For converting our data to upper case or lower case we can use the translate method


1.For converting to uppercase

<xsl:value-of select="translate($toconvert,$lcletters,$ucletters)"/>

2.For converting to lower case

<xsl:value-of select="translate($toconvert,$ucletters,$lcletters)"/>

No comments:

Post a Comment