The problem
I have a query that gets executed by eXist through the REST API, and it gets POSTed to the collection it needs to run on, e.g. /db/foo or /db/bar. In the query, I’d like to get the child collections of the current collection. That is: if posted on /db/foo, I’d like the query return what xmldb:get-child-collections('/db/foo') would return; if posted on /db/bar, I’d like the query return what xmldb:get-child-collections('/db/bar') would return. But of course, I don’t want the path of the current collection to be hard-coded in the query.
What I tried
xmldb:get-child-collections('.'), no luck,.is not understood by eXist as “the current collection”.- Looking for a function that returns the path to the current collection, like
pwdwould in a shell, but I couldn’t find one.
With the REST API, you can use
request:get-path-info()to get the path to the “current collection”. For instance:http://www.my-site.com/exist/rest/db/my-collection.request:get-path-info()will return/db/my-collection, which is precisely the part of the path you’re interested in.