REST documentation - bug?
Wednesday, 11 January 2023 · 3 messages
HR
Hans-Jürgen Rennau11 Jan 2023 08:56 #
Hello,
the documentation ( https://docs.basex.org/wiki/REST ) contains an example applying a query via REST to a complete database:
http://localhost:8080/rest/database?query=count(.)
(My understanding is that "database" should be replaced with the name of a database.)
However, the URL yields an error ("Document is empty"). At any rate, the documentation should be explicit about the evaluation context of REST calls with parameter "query" or "run". If the resource identified by the URL is a single document, the context item is fairly obvious. However, in case of a database or a database collection, the evaluation context is not obvious.
With kind regards
Hans-Jürgen
CG
Christian Grün11 Jan 2023 10:34 #
Hi Hans-Jürgen,
Quoted text · Hans-Jürgen Rennau · 1 line
> (My understanding is that "database" should be replaced with the name of a database.)
Right.
Quoted text · Hans-Jürgen Rennau · 1 line
> However, the URL yields an error ("Document is empty").
I guess this is how your browser interprets the result? If you use a command-line tool (curl, wget, etc.) or by looking at the source code in the browser, you should see the actual response.
Quoted text · Hans-Jürgen Rennau · 1 line
> At any rate, the documentation should be explicit about the evaluation context of REST calls with parameter "query" or "run". If the resource identified by the URL is a single document, the context item is fairly obvious. However, in case of a database or a database collection, the evaluation context is not obvious.
You mean that it’s not obvious that more than a single item can be bound to the context in BaseX, and that this behavior is not 100% compliant with the specification, right? This is something indeed that’s currently discussed in the qtspecs respository for upcoming XQuery 4 features [1].
All the best,
Christian
[1] https://github.com/qt4cg/qtspecs/issues/129
HR
Hans-Jürgen Rennau11 Jan 2023 11:09 #
Ah, you are right & thank you - appending "&method=text" I see the result.
Kind regards,
Hans-Jürgen
Am Mi., 11. Jan. 2023 um 10:34 Uhr schrieb Christian Grün <
christian.gruen at gmail.com>:
Quoted text · Christian Grün · 30 lines
> Hi Hans-Jürgen, > > > (My understanding is that "database" should be replaced with the name of > a database.) > > Right. > > > However, the URL yields an error ("Document is empty"). > > I guess this is how your browser interprets the result? If you use a > command-line tool (curl, wget, etc.) or by looking at the source code > in the browser, you should see the actual response. > > > At any rate, the documentation should be explicit about the evaluation > context of REST calls with parameter "query" or "run". If the resource > identified by the URL is a single document, the context item is fairly > obvious. However, in case of a database or a database collection, the > evaluation context is not obvious. > > You mean that it’s not obvious that more than a single item can be > bound to the context in BaseX, and that this behavior is not 100% > compliant with the specification, right? This is something indeed > that’s currently discussed in the qtspecs respository for upcoming > XQuery 4 features [1]. > > All the best, > Christian > > [1] https://github.com/qt4cg/qtspecs/issues/129 >
Written for BaseX 10.4. BaseX may have changed since: please check the current documentation.
⚡Generated with XQuery