No, you haven't done anything wrong: just hit a limitation in the implementation.

You might be able to work around it by setting -opt:0 to disable this optimization.

Alternatively, do the optimization which Saxon is attempting by hand, by rewriting the query as


for $file in doc('files.xml')//file


I'll look into fixing it.

Michael Kay

On 07/06/2012 18:23, Nicolas LABROT wrote:

I'm currently evaluating saxon (SaxonEE9-4-0-3J) streaming features with XQuery.

I have create the following query:


let $res := for $file in doc('files.xml')//file

return $res


Where files.xml contains files to be parsed and the purpose of "saxon:stream(doc($file)//dmCode)[1]" is to return the first dmCode and stop the streaming.

But Saxon throws me the following Exception [1]

Do I something wrong ?

Thanks for your help!


java.lang.UnsupportedOperationException: StreamingCopy.copy()
        at net.sf.saxon.expr.FirstItemExpression.copy(
        at net.sf.saxon.expr.ForExpression.copy(
        at net.sf.saxon.expr.flwor.FLWORExpression.optimize(
        at net.sf.saxon.expr.parser.ExpressionVisitor.optimize(
        at net.sf.saxon.expr.instruct.ParentNodeConstructor.optimize(
        at net.sf.saxon.expr.instruct.FixedElement.optimize(
        at net.sf.saxon.query.XQueryExpression.<init>(
        at net.sf.saxon.query.QueryParser.makeXQueryExpression(
        at net.sf.saxon.query.StaticQueryContext.compileQuery(
        at net.sf.saxon.query.StaticQueryContext.compileQuery(
        at net.sf.saxon.Query.compileQuery(
        at net.sf.saxon.Query.doQuery(
        at net.sf.saxon.Query.main(
Fatal error during query: java.lang.UnsupportedOperationException: StreamingCopy.copy()

Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and 
threat landscape has changed and how IT managers can respond. Discussions 
will include endpoint security, mobile security and the latest in malware 

saxon-help mailing list archived at