You can simplify this:
<xsl:if test="current()[not(@firstname = preceding-sibling::row/@firstname)]">
as this:
<xsl:if test="not(@firstname = preceding-sibling::row/@firstname)">
Michael Kay
http://www.saxonica.com/
Author, XSLT Programmer's Reference and XPath 2.0 Programmer's Reference