Tallan's Technology Blog

Tallan's Top Technologists Share Their Thoughts on Today's Technology Challenges

Posts Tagged "data view web part"

Convert XSLT Variables to Upper or Lower Case

Craig Condon

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)]”/>