I've noted several points which I would like to mention here:
1) First of all, the internal XSLT processor of XML Spy 5 is not Xalan, whereas the code you used is intended for Xalan. Therefore, try to run the transformation using Xalan 2.5, for instance.
2) Try to replace the respective code-snippet with this one(you'll find what parts I mean). Note the namespace declaration for "lxslt": your declaration was wrong.
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
<xalan:script lang="javaclass" src="xalan://Test"/>
3) It will be safer to surround extension function calls by xsl:if like this:
4) And finally put the class Test on the classpath
I hope these will be sufficient to perform the transformation successfully.
If not, let me know, and we'll discuss untill the final solution.