Project

Profile

Help

Bug #4329

Getting warning "Source document ignored - query does not access the context item" although XQuery accesses /*/* (in right hand side of let expression)

Added by Martin Honnen 12 months ago. Updated 10 months ago.

Status:
Closed
Priority:
Normal
Assignee:
-
Category:
XQuery conformance
Sprint/Milestone:
-
Start date:
2019-10-02
Due date:
% Done:

0%

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

Description

Trying to write an XQuery based splitting of a large input into several ones using tumbling window I have run into two problems with Saxon 9 (tested with Saxon-HE 9.9.1.5J), this bug is about the first issue:

Although the query accesses the source document with /*/* Saxon emits a warning claiming

Source document ignored - query does not access the context item

Full command line output is:

PS C:\SomeDir> java -cp 'C:\Program Files\Saxonica\
Saxon9.9HE\saxon9he.jar' net.sf.saxon.Query -t -s:.\input-sample-2000-records.xml .\test-xquery-split-result-1.xq
Saxon-HE 9.9.1.5J from Saxonica
Java version 1.8.0_221
Analyzing query from .\test-xquery-split-result-1.xq
Analysis time: 243.5237 milliseconds
Processing file:/C:/SomeDir/./input-sample-2000-rec
ords.xml
Source document ignored - query does not access the context item
<?xml version="1.0" encoding="UTF-8"?>trueExecution time: 12.4667ms
Memory used: 36,983,024

Sample query is:

declare namespace output = "http://www.w3.org/2010/xslt-xquery-serialization";

declare option output:method 'xml';
declare option output:indent 'yes';

declare variable $chunk-size as xs:integer external := 500;


let $results := 
    for tumbling window $chunk in /*/*
    start at $sp when $sp mod $chunk-size = 1
    return
        document {
            element { node-name(head($chunk)/..) } {
                $chunk
            }
        }
return $results instance of document-node()*

I have attached the input sample.

I think the warning is wrong and indicates that Saxon somehow rewrites the query in the wrong way.

A variation of the query generates a java.lang.NullPointerException, I will fail that as a separate issue as I am not sure it is the same problem or a different code path.

input-sample-2000-records.xml (182 KB) input-sample-2000-records.xml Martin Honnen, 2019-10-02 14:08

History

#1 Updated by Michael Kay 12 months ago

I think Saxon is working out at compile time that $results can only be a sequence of zero or more document nodes, and that the result is therefore always true, regardless of the input. I agree the warning is a bit unhelpful in this case.

#2 Updated by Michael Kay 12 months ago

  • Status changed from New to Resolved
  • Applies to branch trunk added
  • Fix Committed on Branch 9.9, trunk added

I'm fixing this by changing the message to the slightly more precise:

Source document ignored - query can be evaluated without reference to the context item

#3 Updated by O'Neil Delpratt 10 months ago

  • Status changed from Resolved to Closed
  • Fixed in Maintenance Release 9.9.1.6 added

Patch committed to the Saxon 9.9.1.6 maintenance release.

Please register to edit this issue

Also available in: Atom PDF