On Tue, 2017-08-08 at 09:24 +0800, donaldjohn wrote: > is there a way that I can cache the sub query result and > reuse it somewhere else? I think it will run faster in that way.
You may find it runs at the same speed - BaseX may have noticed hte common query. But you can try using, let $statuslist := for $result in doc("50PatentDividedCreatingClause.xml")/results/result return db:open($result/dbName)/business:PatentDocumentAndRelated/@status return ( . . . do stuff with $statuslist . . . do more stuff with $statuslist ) > Liam -- Liam Quin, W3C, http://www.w3.org/People/Quin/ Staff contact for Verifiable Claims WG, XQuery WG Web slave for http://www.fromoldbooks.org/