Convert string to lowercase-uppercase in xslt


In my previous article I have explained about  How to maintain scroll position on postback. In this article I am going to explain about how to convert the text to uppercase and lowercase in xslt.

Declare the three xslt variables one for lowercase characters and one for uppercase characters. And the third one is to assign the input value. Below is the sample code.

<xsl:variable name="lcletters">abcdefghijklmnopqrstuvwxyz</xsl:variable>
<xsl:variable name="ucletters">ABCDEFGHIJKLMNOPQRSTUVWXYZ</xsl:variable>
<xsl:variable name="toconvert">SamPLE TeXt</xsl:variable>

Now to convert the “SamPLE TeXt” to lowercase below code is used

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

To convert the “SamPLE TeXt” to uppercase below code is used

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

Do you like this article? Help us to improve. Please post your comments below.


Post a Comment

Online Casino