Apostrophe character in Data View Web Parts

0 minute read

Here’s another case where looking at my blog stats gave me an idea for a post.  There were several searches about the apostrophe character which led people to my blog today:

  • sharepoint data view apostrophe
  • dataview apostrophe problem sharepoint

The apostrophe character (‘ or ' or ASCII character 39) is a bit of a trickster in Data View Web Parts (DVWPs).  When you create a new DVWP, you’ll generally see that SharePoint Designer creates a parameter for the apostrophe for you:

<xsl:param name="dvt_apos">'</xsl:param>

This lets you use the $dvt_apos value where you might need an apostrophe, such as in concat(), contains(), etc. functions.  In many cases, you will be able to use encoding for the apostrophe: &apos;, but if that doesn’t seem to be working, try the $dvt_apos value instead.  Once you get the hang of it, the apostrophe isn’t much of a problem (I usually delete the parameter just to keep my XSL clean), but it can be infuriating until you do catch on.

Have a thought or opinion?