Regression? Unknown parameter: 'wrap' in 8.0.x

Wednesday, 18 February 2015 · 4 messages
GB
Gioele Barabucci18 Feb 2015 10:41 #

Hello,

I am toying around with BaseX 8.0.1 (beta 161c4fd) and it looks like there is a regression from BaseX 7.9.

In BaseX 7.9 I could issue the following POST query via the REST interface.

     <query xmlns="http://basex.org/rest">
             <text>...</text>
             <parameter name='wrap' value='yes'/>
     </query>

Now, the same query raises an exception in the server:

     org.basex.http.HTTPException: Unknown parameter: 'wrap'.
         at org.basex.http.HTTPCode.get(HTTPCode.java:55)
         at org.basex.http.rest.RESTPost.get(RESTPost.java:65)
         at org.basex.http.rest.RESTServlet.code(RESTServlet.java:43)

Has something been changed in the way REST requests are processed? What is the proper way in 8.0.x to wrap results?

Regards,

-- Gioele Barabucci <gioele at svario.it>
GB
Gioele Barabucci18 Feb 2015 11:14 #
Quoted text · Gioele Barabucci · 10 lines
Am 18.02.2015 um 10:41 schrieb Gioele Barabucci: > Hello, > > I am toying around with BaseX 8.0.1 (beta 161c4fd) and it looks like > there is a regression from BaseX 7.9. > > [...] > > Has something been changed in the way REST requests are processed? What > is the proper way in 8.0.x to wrap results?

It looks like support for wrapping results has been removed recently in this commit in favour of a new "adaptive" serialization method.

https://github.com/BaseXdb/basex/commit/7619d16cc611f4f0ccd2e77e3f12322a263c4782

Given that in my use-case (uncontrolled user queries [1]) I need each result to be wrapped, could someone suggest a reliable workaround?

[1] https://github.com/gioele/xpathquery/blob/master/lib/xpathquery/basex.rb#L42

-- Gioele Barabucci <gioele at svario.it>
CG
Christian Grün18 Feb 2015 11:41 #

Hi Gioele,

Good to hear that the query is evaluated faster now.

Quoted text · Gioele Barabucci · 1 line
> It looks like support for wrapping results has been removed recently [...]

Exactly, the wrap parameter was removed. The reason was that our wrapping mechanism never really fit well together with the existing serialization parameters (unless the default parameters were used).

Quoted text · Gioele Barabucci · 2 lines
> Given that in my use-case (uncontrolled user queries [1]) I need each result > to be wrapped, could someone suggest a reliable workaround?

The easiest way out is to wrap your results via XQuery. If your query string is "/a/b/c", you could e.g. rewrite it to:

( /a/b/c ) ! element wrap { . }

Cheers, Christian

[1] http://docs.basex.org/wiki/Serialization

GB
Gioele Barabucci18 Feb 2015 13:42 #
Quoted text · Christian Grün · 5 lines
Am 18.02.2015 um 11:41 schrieb Christian Grün: > The easiest way out is to wrap your results via XQuery. If your query > string is "/a/b/c", you could e.g. rewrite it to: > > ( /a/b/c ) ! element wrap { . }

Thank you for the suggestion.

My current solution looks like this:

     declare namespace basex='http://basex.org/rest';

     let $results := ( QUERY ) ! element basex:result { . }
     return <basex:results>{$results}</basex:results>

This simulates well enough the wrapped results as returned by BaseX 7.9.

Regards,

-- Gioele Barabucci <gioele at svario.it>

⚡Generated with XQuery