Bug #1616
closedQuery wrongly reported to make no use of context item
100%
Description
When the following query is run:
let $elemInfos := //*:elemInfo return
{for $elemInfo in $elemInfos return $elemInfo/@name/string()}
with a source document supplied using the -s option on the command line, Saxon incorrectly reports a warning
Source document ignored - query does not access the context item
followed by an error:
XPDY0002: Finding root of tree: the context item is undefined
Reported by Hans-Juergen Rennau on the saxon-help list at SourceForge.
The problem arises because of the sequence of events:
(a) the dependencies of the "for" expression are calculated; it has no dependency on the focus
(b) the variable $elemInfos is inlined, because the variable is only used once
(c) during inlining of the variable, the dependencies of the "for" expression are not recaculated
(d) this results in the warning message saying the source document is not used
(e) as well as issuing the warning message, Saxon actually does ignore the source document
(f) therefore no source document is available to the query, resulting in the XPDY0002 error.
A patch (to ExpressionTool.replaceVariableReferences()) is being committed on the 9.4 branch
Updated by Michael Kay over 11 years ago
- Status changed from New to Resolved
- % Done changed from 0 to 100
A patch is now committed.
Updated by O'Neil Delpratt over 11 years ago
- Status changed from Resolved to Closed
- Fixed in version set to 9.4.0.6
Please register to edit this issue