[xquery-talk] flowrrr - how to structure a function?

Martin Probst martin at x-hive.com
Wed Oct 18 11:47:24 PDT 2006


>> What kind of a result is the "response-header (name?) value" pair?  
>> Does it fit into the XQuery data model?
>
> I guess you missed the last sentence you quoted ...

Ouch, no responses before 9 AM in the future ;-)

> PIs would also work.  But attributes work just as well, I think,
> and it makes sense: an attribute is a property with a name and a
> string value - and a response header is the same thing.

> Using PIs would actually be more ambiguous, just because it can
> be part of a well-former XML document:  When should be PI be
> transmitted as part of the result "body", and when should be
> it extracted as a result header?

Yes, it's kind of a pity that PIs don't carry namespaces. However in  
your case you might swallow programming errors (returning attributes  
toplevel). I think you won't get around that unless you use special  
"magic" values (that are not part of the XQDM), which I rather  
wouldn't. If it's  possible to construct the expected result within  
XQuery, you always might accidentally swallow a value that was not  
supposed to go that way. However if you e.g. only swallow PIs with a  
certain local name of (for example) "xquery-web" it's pretty unlikely  
you run into errors.

Using well-formed XML documents as responses might make caching  
easier. Apart from these minor and probably quite hypothetical issues  
it's probably totally irrelevant whether it's attributes or PIs.

I think Wolfgang's function library in eXist (http://demo.exist- 
db.org/xquery/functions.xq) also includes functions to create user  
sessions, this might be more difficult to make side-effect free. I.e.  
if session:create(), session:set-current-user() and session:invalidate 
() return values if called in the right order, but give errors if  
called in the wrong order, it's much more difficult because you need  
to provide access to those values. I'm not picking on you Wolfgang, I  
rather think your library is a good example of what one does need in  
webapps.

On the other hand, RESTafarians might argue that all kinds of storing  
stuff in sessions (or sessions in general?) are evil anyways ;-)

Regards,
Martin

-- 
Martin Probst
X-Hive Corporation
martin at x-hive.com




More information about the talk mailing list