[xquery-talk] XQuery web APIs

Per Bothner per at bothner.com
Tue May 16 14:38:47 PDT 2006


Martin Probst wrote:
> This looks like what eXist an MarkLogic do - does response-header(..., 
> ...) actually return a value in XQuery or does it have a side effect?

It returns a value.

> And if it returns a value, how does that look? Do you use XML or rather 
> have a "magic" value?

It actually is a "bare" attribute node, though it could be a magic
value.

When the response-header value is serialized it effects how the
following item(s) in the response get serialized.  No immediate
nodes need to be created: The response-header function is applied
and serialized, which means we can then immediately set the
response mode, before evaluating and serializing the body.

> In my local changes I currently use external variables to pass in 
> parameters from the web request, I get the list of declared external 
> variables from the query, and bind each one to a request parameter if 
> the namespace URI is a certain X-Hive URI and the local name matches the 
> HTTP request parameter name. Writing
> declare variable $web:req external;
> seemed somewhat more natural to me than
> web:get-request-param("req")
> though the default values have some appeal.

I wish one could supply default values to 'declare variable'.
Perhaps that might be a worthwhile extension.

Another idea: $web:req(default-value-expression)
-- 
	--Per Bothner
per at bothner.com   http://per.bothner.com/


More information about the talk mailing list