Hi everyone, I have a couple of questions about BaseX's REST API and how it executes stored XQuery. I'm evaluating how much effort would be involved in porting an existing XQuery code base to BaseX. The existing code is a directory of XQuery scripts and modules that are called over a REST interface. They aren't RESTXQ aware, although with some work they could be converted if needed. (I'd prefer to do as little modification as possible initially, however.)
I've installed BaseX 9.6.4 on Mac OS in a directory I'll call BASEX_HOME. In $BASEX_HOME/.basex, I have WEBPATH set to $BASEX_HOME/webapp (the default) and RESTPATH = "" (the default). I also set an appropriate user and password. I've placed the following two scripts in $BASEX_HOME/webapp:
-------- t1.xq --------
import module namespace t2="t2" at "t2.xq";
t2:response()
-------- t2.xq --------
module namespace t2="t2";
declare function t2:response() as xs:string { "Hello World!" };
--------
When I run the first script using curl, I get an error back that the second cannot be located in the $BASEX_HOME directory not $BASEX_HOME/webapp as I expected:
$ curl http://localhost:8984/rest?run=t1.xq Stopped at ., 3/1: [XQST0059] Could not retrieve module: $BASEX_HOME/t2.xq.
Is this the expected behavior, or is BaseX resolving the path to module t2 incorrectly? In any case given this behavior, if I want to point RESTPATH outside the BaseX installation to a much larger library of XQuery, how can I share modules within the library without having to use absolute paths for everything?
My second question is simply, is it possible to set a cookie in response to a REST (not RESTXQ) response?
Thanks!
-- Paul