Another observation on this code, if I might: I really would recommend declaring the types of your function parameters and the return type of the function, using the "as" attribute on xsl:function and xsl:param. It gives far better error checking, and when binding extension functions it means the compiler has much better information to go on. 
 
Michael Kay
http://www.saxonica.com/
 
The xslt I am modifying has to following:

 

  <xsl:function name="symyx:format-number">

    <xsl:param name='num'/>

    <xsl:param name='pattern'/>

  <xsl:sequence select='$num'/>

  </xsl:function>