Project

Profile

Help

Bug #1616

Query wrongly reported to make no use of context item

Added by Michael Kay over 4 years ago. Updated about 4 years ago.

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

100%

Legacy ID:
Applies to branch:
Fix Committed on Branch:
Fixed in Maintenance Release:
Found in version:
9.4
Fixed in version:
9.4.0.6

Description

When the following query is run:

let $elemInfos := //*:elemInfo return
<msgs>{for $elemInfo in $elemInfos return $elemInfo/@name/string()}</msgs>

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

History

#1 Updated by Michael Kay over 4 years ago

  • Status changed from New to Resolved
  • % Done changed from 0 to 100

A patch is now committed.

#2 Updated by O'Neil Delpratt about 4 years ago

  • Status changed from Resolved to Closed
  • Fixed in version set to 9.4.0.6

Also available in: Atom PDF