I am not sure if this tells more of the problem (xquery:invoke does not open the collection), but: if the query does something with the collection plus predicates retrieved, the query is evaluated. So, in my example
collection('suuryritys_com/suuryritys.com/data/ou')//*[@cat='production']
if I add some extra content that forces the evaluation, like
<a>{collection('suuryritys_com/suuryritys.com/data/ou')//*[@cat='production']}</a>/*
I.e. add the result to a -element and retrieve it, the xquery:invoke("file-name.xq") evaluates the query, even if the database (suuryritys_com) is closed!
-- Arto Viitanen Microteam Oy Finland