Hello,
my name is Neven Jovanovic, and I have beginner's problems with BaseX RESTXQ interface. We'd like to have a textarea form where users would compose their own XQueries to be executed over our database (just querying it, no updating etc). I have already written a cgi Perl script which does this through BaseX REST interface. Now I'd like to do the same with RESTXQ, but I'm missing something.
For testing purposes, we use the .zip version of 7.7.2 release, on Linux Mint Debian (locally), started with .basexhttp. Everything works OK, the db is there etc.
Here is the form added to the existing restxq.xqm:
<h3>Write an XQuery</h3> <p>Compose your own XQuery.</p> <form method="post" action="compoxq"> <p>XQuery:<br /> <textarea name="query" rows="5" cols="80"></textarea><br/> <input type="submit" /></p> </form>
Here is the function added to the restxq.xqm:
(:~ : A free-form XQuery. :) declare %rest:path("/compoxq") %rest:POST %rest:form-param("query","{$query}", "(no query)") function page:cpxq-postman( $query as xs:string*) { let $q := $query return element q { collection("crobib")//$q } };
Submitting the following form string: //*:person
I get these results at http://localhost:8984/compoxq: <q> //*:person //*:person //*:person //*:person //*:person (lots more...) </q>
Some query obviously is being performed, but instead of results, I get the query string.
Appreciating your help,
Neven
Neven Jovanovic University of Zagreb Hrvatska / Croatia