title: In XQuery, with eXist, how to get the child collections of the current collection?
body: <h2>The problem</h2>
  
  <p>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. <code>/db/foo</code> or <code>/db/bar</code>. In the query, I'd like to get the child collections of the current collection. That is: if posted on <code>/db/foo</code>, I'd like the query return what <code>xmldb:get-child-collections('/db/foo')</code> would return; if posted on <code>/db/bar</code>, I'd like the query return what <code>xmldb:get-child-collections('/db/bar')</code> would return. But of course, I don't want the path of the current collection to be hard-coded in the query.</p>
  
  <h2>What I tried</h2>
  
  <ul>
  <li><code>xmldb:get-child-collections('.')</code>, no luck, <code>.</code> is not understood by eXist as "the current collection".</li>
  <li>Looking for a <a href="http://demo.exist-db.org/exist/apps/xqfdocs/index.html" rel="nofollow">function</a> that returns the path to the current collection, like <code>pwd</code> would in a shell, but I couldn't find one.</li>
  </ul>