Project

Profile

Help

Bug #758

closed

NullPointerException with optimized filter expression

Added by Anonymous over 18 years ago. Updated over 12 years ago.

Status:
Closed
Priority:
Normal
Assignee:
-
Category:
XPath conformance
Sprint/Milestone:
-
Start date:
Due date:
% Done:

0%

Estimated time:
Legacy ID:
sf-1443046
Applies to branch:
Fix Committed on Branch:
Fixed in Maintenance Release:
Platforms:

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

FilterExpression.java (9.56 KB) FilterExpression.java Anonymous, 2006-03-04 13:18

Please register to edit this issue

Also available in: Atom PDF