Fab 40 Employee Training Template and student names with apostrophes

One of my clients has been getting a lot of use from the SharePoint 2007 “Fab 40” template named “Employee Training Resources and Materials”.  As has been documented in numerous blogs, this template contains a few bugs that are pretty straight-forward to correct.  I ran into an issue the other day that was a little more obscure, so I thought I would write about it.

If you have a student with an apostrophe in his/her name (such as “O’Malley”), the student will be able to register multiple times for the same class (i.e.- it will not recognize that there is an existing registration record for the student).  The issue is in the “Register.aspx” page.  There is a line in the page that looks for an existing registration record, based on the current user and the selected Course ID.  There is a “contains” statement in that line that compares the @Author field to the $UserID variable.  The problem is that the @Author field spits out some XML in which the apostrophe has been converted to '.  So, the “contains” statement is trying to compare “O&#39Malley” to “O’Malley”, which obviously does not match.  To correct the issue replace this line…

<xsl:variable name="MyRegistration" select="$Rows[@Course_x0020_ID = $CourseID and contains(@Author, $UserID)]" />

with this line…

<xsl:variable name="MyRegistration" select="$Rows[@Course_x0020_ID = $CourseID and contains(translate(@Author, &quot;&amp;#39;&quot;, &quot;'&quot;), $UserID)]" />