Thursday, 3 January 2008

How to Change String Case in XSLT

Here's a simple way to convert a string to lower case in XSLT. The snippet takes an input variable inputtext and saves the lower case version to a new variable called lowercasetext.

<xsl:variable name="lowercasetext" select="translate($inputtext, 'ABCDEFGHIJKLMNOPQRSTUVWXYZ', 'abcdefghijklmnopqrstuvwxyz')" />

To upper case a string, simply swap the position of the two alphabet literals shown.

No comments: