Dear Ludovic,
thanks for the in-depth investigation. It's true, we have removed the feature to evaluate queries inside databases. I've finally updated our documentation. There were two reasons why we removed this feature:
-- other modules, which were referenced from query files in database, could not be correctly imported -- we want to keep our REST API as RESTful as possible, and reduce side effects (due to the power of XQuery processing in BaseX, an XQuery expression within a database directory could also be used to modify other databases).
You already went for the best alternative: files can also be evaluated if they are located in the designated http directory. In the future, we'll add our "basex-web" service to the HTTP portfolio, which will further simplify evaluation of XQuery code via BaseX and web servers.
Hope this helps, Christian ___________________________
On Sun, Apr 22, 2012 at 8:47 PM, Ludovic Kuty mailing@kuty.be wrote:
Hi,
I used an old version of BaseX (7.0 I think) and made HTTP GET requests to application/xquery ressources in the database which evaluated them before returning the result of the evaluation. That way I could used predefined XQuery queries stored in the database. The following sentence is written in the documentation at http://docs.basex.org/wiki/REST#Operations%C2%A0: "If a resource with content type application/xquery is addressed, it will be evaluated first, and the result will be returned." But it no more the case in 7.2 and instead I get the query verbatim, not the result of the evaluation.
Indeed, Googling around I even found a bug correction made by Christian Grün ( https://github.com/BaseXdb/basex-api/blob/146d594931abe0143766203a329d8f6823...) to an old version of the code. We can see at lines 76 to 82 that an application/xquery ressource is evaluated first:
if(type.equals(MimeTypes.APP_XQUERY)) { // execute raw file as query final ArrayOutput ao = new ArrayOutput(); session.setOutputStream(ao); session.execute(new Retrieve(ctx.dbpath())); query(ao.toString(), ctx); }
Thus, I tried to find the same sort of code in the actual 7.2 version but could not. So I am wondering if this is a wanted omission, and thus the documentation is out of sync, or if it is an unwanted omission and needs to be corrected. The code I checked is at https://github.com/BaseXdb/basex-api/blob/master/src/main/java/org/basex/htt...
The workaround I used is to put my queries as files in the HTTPPATH directory found in the .basex file.
TIA for any clarification on that matter,
Ludovic Kuty
BaseX-Talk mailing list BaseX-Talk@mailman.uni-konstanz.de https://mailman.uni-konstanz.de/mailman/listinfo/basex-talk