By the way, your code is full of constructs that are ridiculously inefficient, for example you wrote:
<xsl:with-param name="text">
<xsl:for-each select="@name">
<xsl:value-of select="."/>
</xsl:for-each>
</xsl:with-param>
where you could have written
<xsl:with-param name="text" select="@name"/>
Michael Kay
http://www.saxonica.com/
Author, XSLT Programmer's Reference and XPath 2.0 Programmer's Reference