Tallan Blog

Tallan’s Experts Share Their Knowledge on Technology, Trends and Solutions to Business Challenges

Convert XSLT Variables to Upper or Lower Case

I had a situation where I needed to compare a query string parameter to a value in a list inside a data view web part in SharePoint Designer. If the two values matched in regards to the text, but did not match in regards to case (for example: SomeWord vs. someword), they would not match when compared in the XSLT. It appears that the version of XSLT used in a data view web parts doesn’t support the lower-case() and upper-case() functions.

Luckily, I discovered a workaround. Originally, I had the following code:

<xsl:variable name="Rows" select=/dsQueryResponse/MyList/Rows/Row[normalize-space(@MyField) = $myQueryStringVar]"/>

At first, I tried this:

<xsl:variable name="Rows" select=/dsQueryResponse/MyList/Rows/Row[normalize-space(lower-case(@MyField)) = lower-case($myQueryStringVar)]"/>

But I received an error that the function was not supported. The workaround is as follows:

<xsl:variable name="lower">abcdefghijklmnopqrstuvwxyz</xsl:variable>
<xsl:variable name="upper">ABCDEFGHIJKLMNOPQRSTUVWXYZ</xsl:variable>

<xsl:variable name="Rows" select="/dsQueryResponse/MyList/Rows/Row[normalize-space(translate(@MyField,$upper,$lower)) = translate($myQueryStringVar,$upper,$lower)]"/>


Learn more about Tallan or see us in person at one of our many Events!

Share this post:

5 Comments. Leave new

Links (10/23/2008) « Steve Pietrek - Everything SharePoint
October 23, 2008 8:41 pm

[…] Convert XSLT Variables to Upper or Lower Case […]

This is great! Thank you. I was wondering how did you compare a query string parameter to a value in a list inside a data view web part in SharePoint Designer? Do you have any XSLT code for it? Thank you.


First, you need to create a ParameterBinding, like this:

<ParameterBinding Name="myVar" Location="QueryString(myQSVar)" />

Then, you need to add this within your stylesheet (<xsl:stylesheet>):

<xsl:param name="myVar"></xsl:param>

And finally, add something like this within your template (<xsl:template>):

<xsl:variable name="Rows" select="/dsQueryResponse/Rows/Row[@ID = $myVar]"/>

Thx for the tip, worked great. Was manipulating strings from files uploaded to a Picture Library, everything I did yesterday worked fine, new uploads didn’t work. Drove me crazy till I realized the file extensions today were Uppercase. Your solution fixed me in 5 min.



Of course someone will now tell me this was a bad way to build the a string to the thumbnail, but I’m GREEN.

Thx again

Yes! Thanks a Ton! this helped me in fixing my matching login user with permissions.

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>