Import module with xquery:eval() function

Tuesday, 1 March 2016 · 3 messages · last reply 3 Mar 2016
IF
Ioan Fericel1 Mar 2016 18:27 #
Hi, I try to import a module dynamically, as in this example from a earlier discussion:
Quoted text · 3 lines
> let $s:='import module namespace p="xquery-30" at "../repotest/test.xqm"; > p:parse-XQuery("2+2")' > return xquery:eval($s)
It gives me the following error:
Quoted text · 1 line
> . . . [XQST0059] Could not retrieve module '/home/repotest/test.xqm'.
I run BaseX 8.3 as war in Tomcat container. If the module is imported in static way:
Quoted text · 1 line
> import module namespace p = "xquery-30 " at "../repotest/test.xqm";
everything works correctly. From where does the problem with malformed relative path, what solution could be found? Thanks, Ioan
CG
Christian Grün1 Mar 2016 18:31 #
Hi Ioan, you can try static-base-uri() in order to find out where your file will be located in the Tomcat environment. Besides that, it may be recommendable to move your library module to the repository. This way, there will be no need to specify a module location. Hope this helps Christian
Quoted text · Ioan Fericel · 31 lines
On Tue, Mar 1, 2016 at 6:27 PM, Ioan Fericel <mirabit at gmail.com> wrote: > Hi, > > I try to import a module dynamically, as in this example from a earlier > discussion: > > let $s:='import module namespace p="xquery-30" at "../repotest/test.xqm"; >> p:parse-XQuery("2+2")' >> return xquery:eval($s) >> > > It gives me the following error: > > . . . [XQST0059] Could not retrieve module '/home/repotest/test.xqm'. >> > > I run BaseX 8.3 as war in Tomcat container. > > If the module is imported in static way: > > import module namespace p = "xquery-30 " at "../repotest/test.xqm"; >> > > everything works correctly. > > From where does the problem with malformed relative path, what solution > could be found? > > Thanks, > Ioan >
IF
Ioan Fericel3 Mar 2016 14:11 #
Thanks Christian, The problem was solved for now processing the relative path before calling eval function. Placing modules in one single repo (RESTXQPATH), defined in the web.xml of BaseX, unfortunately is not an option in this case, because there will be more small separate applications and each has its module library included. Regards, Ioan

⚡Generated with XQuery