#110 ClassCast failure with positional filter

v7.3.1
closed
Michael Kay
6
2012-10-08
2002-12-18
Michael Kay
No

A Java ClassCastException may occur when executing an
XPath filter expression using a predicate of the form
[position() < x] (where "<" represents any relational
operator other than "=", and x may be any expression
whose value depends on the XSLT context but not the
XPath context - for example, a variable reference. (It
doesn't fail if x is a constant).

Applies to 7.3 and 7.3.1 only.

The stack trace shows that the error (for both 7.3 and
7.3.1) is:

java.lang.ClassCastException:
net.sf.saxon.expr.RelationalExpression
at
net.sf.saxon.expr.FilterExpression.iterate(FilterExpression.java:328)

Reported by Paul Biron.

Source fix: change line 328 of
net.sf.saxon.expr.FilterExpression from

PositionRange pr = (PositionRange)filter;

to

PositionRange pr = (PositionRange)newFilter;

As a workaround, change the XPath expression from
[position()<$x] to [position()+1<$x+1].

Test case added: pos66

Source code fixed.

Discussion

  • Michael Kay
    Michael Kay
    2003-02-17

    Logged In: YES
    user_id=251681

    Fixed in 7.4