Project

Profile

Help

Bug #1616

closed

Query wrongly reported to make no use of context item

Added by Michael Kay over 11 years ago. Updated over 11 years ago.

Status:
Closed
Priority:
Normal
Assignee:
Category:
XQuery conformance
Sprint/Milestone:
-
Start date:
2012-08-27
Due date:
% Done:

100%

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

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

Actions #1

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.

Actions #2

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

Also available in: Atom PDF