Hi Jakob,
I have this helper function for that purpose. It uses the
xdmp:modules-root that Mike suggests as basis, and don't some other little
trick to complete it:
declare function tw:get-modules-path($path) {
fn:resolve-uri($path,
fn:resolve-uri(fn:substring-after(fn:replace(xdmp:get-request-path(),
'qconsole/endpoints/', ''), "/"), xdmp:modules-root()))
};
I resolve against the request-path so that the relative paths are resolved
against the path of the current xqy. Note: this only works when the xqy is
executed through http. Spawned and run through xdbc won't work,
get-request-path returns empty in those cases.
The replace for 'qconsole/endpoints/' is a little trick to make the code
work as-is from within Query Console too..
Kind regards,
Geert
> -----Oorspronkelijk bericht-----
> Van: [email protected] [mailto:general-
> [email protected]] Namens Michael Blakeley
> Verzonden: zaterdag 12 mei 2012 0:17
> Aan: MarkLogic Developer Discussion
> CC: General Mark Logic Developer Discussion
> Onderwerp: Re: [MarkLogic Dev General] xdmp:document-get and file
location
>
> You can call xdmp:modules-root to help build absolute paths. There are
some
> examples of this in cq/lib-io.xqy
>
> -- Mike
>
> On May 11, 2012, at 14:18, Jakob Fix <[email protected]> wrote:
>
> > Hi,
> >
> > I noticed that if I am using xdmp:document-get to retrieve a file from
> > the file system (not http), I need to either supply an absolute path,
> > or a relative path. What bothers me is that a relative path will be
> > resolved relative to the MarkLogic installation directory. Usually,
> > my projects are in a directory far far away from this directory,
> > something like /Users/jakob/Projects/aProject. How can I load an XML
> > file that's located inside such a directory using relative paths.
> > Also, if I wanted to make the code available to other people, the
> > absolute paths won't work, obviously.
> >
> > So, is there are recommendation for how to do this properly? My
> > apologies, if I've overlooked the obvious solution.
> >
> > cheers,
> > Jakob.
> > _______________________________________________
> > General mailing list
> > [email protected]
> > http://developer.marklogic.com/mailman/listinfo/general
> >
> _______________________________________________
> General mailing list
> [email protected]
> http://developer.marklogic.com/mailman/listinfo/general
_______________________________________________
General mailing list
[email protected]
http://developer.marklogic.com/mailman/listinfo/general