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

<result>
{

for $file in doc('files.xml')//file
return
    saxon:stream(doc($file)//dmCode)[1]

}
</result>

I'll look into fixing it.

Michael Kay
Saxonica

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

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

I have create the following query:

********************************************
<result>
{

let $res := for $file in doc('files.xml')//file
return
    saxon:stream(doc($file)//dmCode)[1]

return $res
}
</result>

********************************************

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!

Nicolas



[1]
java.lang.UnsupportedOperationException: StreamingCopy.copy()
        at com.saxonica.stream.StreamingCopy.copy(StreamingCopy.java:130)
        at net.sf.saxon.expr.FirstItemExpression.copy(FirstItemExpression.java:47)
        at net.sf.saxon.expr.ForExpression.copy(ForExpression.java:575)
        at net.sf.saxon.expr.flwor.FLWORExpression.optimize(FLWORExpression.java:534)
        at net.sf.saxon.expr.parser.ExpressionVisitor.optimize(ExpressionVisitor.java:251)
        at net.sf.saxon.expr.instruct.ParentNodeConstructor.optimize(ParentNodeConstructor.java:224)
        at net.sf.saxon.expr.instruct.FixedElement.optimize(FixedElement.java:92)
        at net.sf.saxon.query.XQueryExpression.<init>(XQueryExpression.java:82)
        at net.sf.saxon.query.QueryParser.makeXQueryExpression(QueryParser.java:155)
        at net.sf.saxon.query.StaticQueryContext.compileQuery(StaticQueryContext.java:536)
        at net.sf.saxon.query.StaticQueryContext.compileQuery(StaticQueryContext.java:598)
        at net.sf.saxon.Query.compileQuery(Query.java:719)
        at net.sf.saxon.Query.doQuery(Query.java:313)
        at net.sf.saxon.Query.main(Query.java:97)
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 
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/


_______________________________________________
saxon-help mailing list archived at http://saxon.markmail.org/
saxon-help@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/saxon-help