On 22/02/2012 13:33, Jakub Malý wrote:


in my case, as a workaround, I can  replace the XSLT variable declaration with let expression, which works.

Just for my calm – the way I use free variables in inline functions – expect them to be bound to variables defined in the context where the function item is created – that is supposed to work, right?


Yes, correct, that's the way it is supposed to work (the inline function declaration creates a closure, which contains both the code of the function and the values of any variables referenced whose declarations are outside the function. Saxon implements this by turning these variables into parameters and then doing a partial function application, so

let $x := 3
return function($y) {$x + $y}

first creates a function

function($y, $x) {$x + $y}

and then does a partial function application to bind the argument $x.

Michael Kay