I want to query the eXist db via the XQJ API. Therefore I have an XQuery file which I want to apply to several different documents inside different collections of the database.
My question is, how can I set the path to the document/collection? I want to apply the XQuery only on specific documents/collections and can´t set the path directly in the XQuery document (with the doc(‘path/to/doc’) function ), because I want to apply the same XQuery to several files with different paths.
I could bind a Java variable to an Xquery expression but there has to be a more elegant way to achieve this task with the XQJ API. Hope you can help me out a little bit.
If you know the specific document URIs up-front, you could bind a bunch of URIs as a xs:string sequence, where you can then iterate through them in your XQuery expression, performing operations against each URI as necessary.
Or if you know the collection uri,
In a future version of eXist XQJ API, you will be able to set a collection as the default context, which goes against both the XQJ standard AND the XQuery 1.0 / 3.0 standards but other users appear to be wanting this functionality quite badly.