Saxon-EE attempts to extract subexpressions from a template or function and turn them into global variables if there are no dependencies on the parameters of the template or function, or on the context (plus some other preconditions). This should not happen to an expression (as may appear in an XSLT template) that contains an xsl:param instruction. However, the check to prevent this happening is not catching all cases. In particular it is not catching the case where the template is declared to return an atomic type, and the body of the template is therefore wrapped in code to perform atomization.
A patch is being placed in Subversion.