In order to make our apps more portable (ie. deploying an app in the new xar format - which defaults to putting everything in /db/apps/) we need to be able to refer to collections and documents relatively.
So, instead of declaring an absolute path
let $coll := collection('/db/site/xml/texts')
we can create our working collection with relative paths like this:
let $pwd := substring-after(system:get-module-load-path(), 'xmldb:exist://embedded-eXist-server')
let $coll := collection(resolve-uri('xml/texts',$pwd))