web:response-header()

Thursday, 10 January 2019 · 2 messages
JB
Johannes Bauer10 Jan 2019 07:42 #
Hello, I've a question to the response-header() function of the web module. In my RESTXQ function I try to return a response with HTTP Status 404: module namespace basex ='basex';
declare %rest:GET %rest:path("/db/{$db}/doc/{$doc}")
   %rest:produces("application/xml")
   %output:method("xml")
function basex:doc($dbas xs:string, $docas xs:string)as item()*
{
    web:response-header(map {},map {},map {"status" :404}),<notfound/> };
When I call this function I get the error: [basex:restxq] Unexpected node: status="404". If I call the function outside of the RESTXQ context the following response is generated:
<rest:response xmlns:rest="http://exquery.org/ns/restxq" *status="404"*>
   <http:response xmlns:http="http://expath.org/ns/http-client"/>
   <output:serialization-parameters
xmlns:output="http://www.w3.org/2010/xslt-xquery-serialization"/>
</rest:response>
<notfound/>
Shouldn't the status attribute be put on the http:response element instead? Best regards Johannes
CG
Christian Grün10 Jan 2019 07:56 #
Dear Johannes, Thanks for the observation. The third argument was added to the function just recently, and it was done wrong. I have just fixed this, a new stable snapshot is available [1]. The next patch release (BaseX 9.1.2) will be released in the near future. Best, Christian [1] http://files.basex.org/releases/latest/
Quoted text · Johannes Bauer · 38 lines
On Thu, Jan 10, 2019 at 7:42 AM Johannes Bauer <johannes.bauer at tanner.de> wrote: > > Hello, > > I've a question to the response-header() function of the web module. > > In my RESTXQ function I try to return a response with HTTP Status 404: > > module namespace basex = 'basex'; > > declare > %rest:GET > %rest:path("/db/{$db}/doc/{$doc}") > %rest:produces("application/xml") > %output:method("xml") > function basex:doc($db as xs:string, $doc as xs:string) as item()* > { > web:response-header(map {}, map {}, map {"status" : 404}), <notfound/> > }; > > > When I call this function I get the error: > > [basex:restxq] Unexpected node: status="404". > > > If I call the function outside of the RESTXQ context the following response is generated: > > <rest:response xmlns:rest="http://exquery.org/ns/restxq" status="404"> > <http:response xmlns:http="http://expath.org/ns/http-client"/> > <output:serialization-parameters xmlns:output="http://www.w3.org/2010/xslt-xquery-serialization"/> > </rest:response> > <notfound/> > > Shouldn't the status attribute be put on the http:response element instead? > > Best regards > Johannes

⚡Generated with XQuery