What happens with the lexical value space and the closure of dynamic functions?

Consider:

<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="3.0">
   <xsl:variable name="fun" select="system-property#1" />
   <other:variable name="test" select="$fun('xsl:version')" 
        xmlns:xsl="http://other"
        xmlns:other="http://www.w3.org/1999/XSL/Transform" />
</xsl:stylesheet>

What would the value of $test be? When I wrote it (and didn't think about it), I assumed somewhat naïve that the dynamic function call would return the empty string, because the "xsl" prefix does not resolve to the correct namespace in scope.

However, after testing this, we return "3.0", because at the moment of binding the variable, the namespace for "xsl" is in scope and becomes part of its closure of $fun. Then, when the dynamic call is resolved, it uses whatever namespace bindings were in scope at the binding of $fun and ignores the namespace redefinition. 

Likewise, using $fun('other:version') fails here (returns empty string) for the same reasons.

I am not sure this is correct. Or wrong. Or either. Or neither.

The example here is with system-property, but applies to any dynamic function call that takes a string that takes the lexical namepace into account. The problem does not arise for functions with the argument as a QName.

Cheers,
Abel

Received on Thursday, 1 October 2015 04:44:17 UTC