#338 Path expression dependency on local variables

v8.3
closed
5
2012-10-08
2005-03-23
Michael Kay
No

The compile-time expression analysis fails to register
that a path expression or filter expression is
dependent on a local variable if the variable appears
inside a predicate.

This could have a wide range of adverse effects (the
surprising thing is that these don't happen all the
time). It could cause the path expression to be
incorrectly moved out of a loop, for example. In the
reported incident, it meant that the values of local
variables were not saved when the path expression was
lazily evaluated, with the result that it was
subsequently evaluated with the wrong values for the
variables.

The source fix below saves dependencies on user-defined
functions as well as local variables: this is dependent
on the patch in

https://sourceforge.net/tracker/index.php?func=detail&aid=1167638&group_id=29872&atid=397617

(a) in net.sf.saxon.expr.FilterExpression, line 474,
change method computeDependencies() to:

public int computeDependencies() {
    // not all dependencies in the filter

expression matter, because the context node,
// position, and size are not dependent on the
outer context.
return (start.getDependencies() |
(filterDependencies &
(StaticProperty.DEPENDS_ON_XSLT_CONTEXT |

StaticProperty.DEPENDS_ON_LOCAL_VARIABLES |

StaticProperty.DEPENDS_ON_USER_FUNCTIONS)));
}

(b) in net.sf.saxon.expr.PathExpression, line 448,
change method computeDependencies() to:

public int computeDependencies() {
    return start.getDependencies() |
            // not all dependencies in the step

matter, because the context node, etc,
// are not those of the outer expression
(step.getDependencies() &
(StaticProperty.DEPENDS_ON_XSLT_CONTEXT |

StaticProperty.DEPENDS_ON_LOCAL_VARIABLES |

StaticProperty.DEPENDS_ON_USER_FUNCTIONS));
}

Michael Kay

Discussion

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:





No, thanks