Welcome to Bilal Haidar [MVP, MCT] Official Blog Sign in | Join | Help

ToLowerCase or ToUpperCase in XSLT

This is a simple sample to show you how to transform the content of an element in an XML file from lower/upper case to upper/lower case

First of all define a variable of the element as:

    <xsl:variable name="Title">
      <xsl:call-template name="ToLowerCase">
        <xsl:with-param name="Field" select="Title"/>
      </xsl:call-template>
    </xsl:variable>

Then define the Template that will do the transformation:

  <xsl:template name="ToLowerCase">
    <xsl:param name="Field" select="''"/>
    <xsl:value-of select='translate($Field,"ABCDEFGHIJKLMNOPQRSTUVWXYZ","abcdefghijklmnopqrstuvwxyz")'/>
  </xsl:template>

As you can see we are transforming all letters to lower case, the same can be done with a similar template to translate letters to upper case.

Hope this helps,

Regards

Published Sunday, June 18, 2006 10:35 AM by BilalHaidar [MVP]
Filed under:

Comment Notification

If you would like to receive an email when updates are made to this post, please register here

Subscribe to this post's comments using RSS

Comments

No Comments

Leave a Comment

(required) 
required 
(required)