title: How to get the current working directory in Xquery?
body: <p>Im writing xquery script that need passing absolute path as an argument, this script will work perfectly if i put the project on the port root, but if i shift it to a sub-directory v2,v3 ... it will not work. </p>
  
  <p>relative path will work perfect if the called function within the project root, but my called function is one of the Marklogic library like search:search. So i have to pass the absolute path to it.</p>
  
  <p>This status make my code less dynamic, while the solution is to find a function that give me the current working directory so i can build the absolute path dynamically.</p>
  
  <p>I found a module library called "file module" in the following link:</p>
  
  <p><a href="http://expath.org/spec/file#pr.current-dir" rel="nofollow">http://expath.org/spec/file#pr.current-dir</a></p>
  
  <p>is there any function in Marklogic help me in this issue, or does they support this library?. If none of those options is available can anyone give me work around solution other than define global variable to handle the changes in the absolute path?  </p>
  
  <p>example:</p>
  
  <pre><code>&lt;constraint name="Title"&gt;
              &lt;custom facet="true"&gt;
                  &lt;parse apply="parse-facet-thesourous"
                         ns="......"
                         at="/utilites/custom-constrains.xqy"/&gt;
                      .....
              &lt;/custom&gt;
  &lt;/constraint&gt; 
  </code></pre>
  
  <p>this is a snap shot of my options. this part passing the absolute path of custom-constrains file to search:search. now if i put the project on the weberver port root www.test.com:8050 every thing will work fine, but if i move the project inside sub directory www.test.com:8050/v1 the link in the option should be /v1/utilites/custom-constrains.xqy</p>
  
  <p>on the other hand making the path relative is useless since this path will passed to an external marklogic module. </p>
  
  <p>but if i can get in some way the current working directory absolute path or the uri of the current running script, then i can build the absolute path dynamically  </p>