Bug #758
closedNullPointerException with optimized filter expression
0%
Description
SourceForge user: mhkay
The following query:
declare function local:foo(){
((, , <e1
id="3" att1="3"/>, )[fn:position()
< 3])[./@id = 5]
};
local:foo()
generates the spurious error message
java.lang.NullPointerException: Unbound function call
local:foo
There are a number of problems interacting here.
Firstly, it's a bad error message. The cause of the
NullPointerException has nothing to do with the
function call being unbound.
The NullPointerException occurs because a rewrite of
the function body has left a subexpression with no
pointer to its parent expression. (a) this shouldn't
occur, and (b) if it does occur, Saxon should recover
from the situation.
The initial cause in this case is that a rewrite of a
filter expression with a positional range [position() >
3] isn't fixing up the tree correctly. This is solved
by the attached replacement module for
net.sf.saxon.expr.FilterExpression.
The NullPointerException is caused by the code at line
711 of net.sf.saxon.expr.ComputedExpression. This can
be fixed by changing the method getHostLanguage to read:
public int getHostLanguage() {
if (parentExpression == null) {
// this shouldn't happen, but it's been known
return Configuration.XSLT;
}
return parentExpression.getHostLanguage();
}
(I've chosen to default the host language to XSLT here.
Since this is used on exception paths only, and it's
rare for the choice of host language to make a
difference, this is entirely arbitrary).
Files
Please register to edit this issue