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?



From: Michael Kay [mailto:mike@saxonica.com]
Sent: Wednesday, February 22, 2012 12:32 PM
To: saxon-help@lists.sourceforge.net
Subject: Re: [saxon] Saxon gives NullPointerException when parsing XPath expression


I'm afraid this is not so much a bug as a not-implemented-feature. The code for parsing inline functions in XPath simply isn't handling the case where there is a reference to a local variable declared as an XSLT local variable rather than being declared at an outer level in the same XPath expression.

I know why it isn't working; I now need to look at whether the solution can be implemented as a patch.

Michael Kay

On 21/02/2012 15:06, Jakub Malư wrote:

Saxon is giving NullPointerException in my stylesheet (attached with input
I hope the stylesheet is correct, though I am not 100% sure. The lines 19-50
are important and Saxon is failing to parse the following XPath expression: 
<xsl:variable name="self" as="item()" select="current()"/>
my:checked(function() { my:forAll($self/matches/day/match, function($m) {
$m/start eq $self/start} ) } )
It is the variable self, which makes trouble. I hope I did unterstand the
specification correctly regarding free variables in HOF. The variable self
is free both in the function passed to the first HOF (checked) and second
HOF (forAll). In the first function, self is bound correctly, but in the
second, the exception is thrown. When I change the line to this
my:checked(function() { my:forAll($self/matches/day/match, function($m) {
$m/start eq $m/start} ) } )
It works. 
Jakub Malư 
Ph. D. candidate
XML Research Group
Department of Software Engineering
Faculty of Mathematics and Physics
Charles University in Prague, Czech Republic

Keep Your Developer Skills Current with LearnDevNow!
The most comprehensive online learning library for Microsoft developers
is just $99.99! Visual Studio, SharePoint, SQL - plus HTML5, CSS3, MVC3,
Metro Style Apps, more. Free future releases when you subscribe now!

saxon-help mailing list archived at http://saxon.markmail.org/