Bug #4329
closedGetting warning "Source document ignored - query does not access the context item" although XQuery accesses /*/* (in right hand side of let expression)
0%
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.
Files
Updated by Michael Kay about 5 years 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.
Updated by Michael Kay about 5 years 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
Updated by O'Neil Delpratt almost 5 years 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