Hi Omar,
Right, we had some discussion on this. If I remember correctly, you had been dynamically addressing databases in BaseX, whereas in eXist-db (as far as I remember), all queries and rewritten path expressions will refer to one static and globally opened database instance, right?
I guess your setup doesn’t allow this, but in use cases where the names of the databases are statically known, a popular approach is to reference the databases in global variables and address them inside the query. Here is a simple example for a nested query that will take advantage of the index:
declare variable $DB := db:open('factbook'); declare function local:city($city) { local:countries()//city[name = $city] }; declare function local:countries() { $DB//country }; local:city('Rome')
You can also open a global database (e.g. via basexhttp and the -c option [1]) and enable DEFAULTDB [2], but in this case, you’ll always need to use collection() or doc() before each path expression:
declare function local:city($city) { collection()//city[name = $city] }; declare function local:countries() { collection()//country }; local:city('Rome')
Hope this helps, Christian
[1] http://docs.basex.org/wiki/Command-Line_Options#HTTP_Server [2] http://docs.basex.org/wiki/Options#DEFAULTDB