[Bug 2796] [Update] updating nodes, then returning values computed from them

http://www.w3.org/Bugs/Public/show_bug.cgi?id=2796





------- Comment #1 from holstege@mathling.com  2006-04-04 15:23 -------
This is related to 2794, I believe. The current rules are overly draconian.
They forbid so many use cases as to border on the unusable:
* create a function that, if some condition is met, performs an update and
returns true or false depending on whether the update was performed
* perform a series of insertions and return a count of how many were performed
* implement a simple queue: insert appends a child element, remove removes
  the first element and returns it
* delete an item in an invoice and return an XHTML rendering of the new
invoice... etc. etc.

In short, any real application that wants to communicate results to the user
is forbidden by the rule that update expressions must be pure update
expressions.  The only legitimate means of reporting an error is to crash
the entire application with fn:error. 

There is no reason for this restriction. Pending update lists are side effects;
so make the do expression have a value of empty sequence. The spec would
be much simplified as a result, and more usable besides.  All the special
rules for typeswitch, if-then-else, etc. go away.

Received on Tuesday, 4 April 2006 15:23:47 UTC