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)]“/>
3 Comments
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.
Vlad,
First, you need to create a ParameterBinding, like this:
<ParameterBindings>
<ParameterBinding Name="myVar" Location="QueryString(myQSVar)" />
</ParameterBindings>
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.
abcdefghijklmnopqrstuvwxyz
ABCDEFGHIJKLMNOPQRSTUVWXYZ
@ID=#@FileRef=#@_ModerationStatus=
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
One Trackback
[...] Convert XSLT Variables to Upper or Lower Case [...]