Learn how easy it is to sync an existing GitHub or Google Code repo to a SourceForge project! See Demo

Close

#315 Incorrect optimization for "except"

v8.3
closed
Michael Kay
5
2012-10-08
2005-02-22
Michael Kay
No

Given an expression such as

A/B/C op A/B/D

where "op" is union, intersect, or except, and A,B,C,D
are arbitrary steps, Saxon rewrites the expression as

A/B/(C op D)

There are cases where this optimization is incorrect.
For example

//B except //A//B

translates to

desc-or-self::node()/child::B except
desc-or-self::node()/child::A/desc-or-self::node()/child::B

which is not the same as

desc-or-self::node() /
(child::B except child::A/desc-or-self::node()/child::B)

The problem applies to 8.3 and previous releases for
some way back.

I believe that the optimization is correct for union; I
have not yet established whether it is correct for
intersection. The following change suppresses the
optimization for both intersection and except:

At line 189 of net.sf.saxon.expr.VennExpression, change

    if (operand0 instanceof PathExpression &&

operand1 instanceof PathExpression) {

to

    if (operator==Token.UNION && operand0

instanceof PathExpression && operand1 instanceof
PathExpression) {

Michael Kay

Discussion