Musing on the the usefulness of actions that update the database and return something, specifically in a web server with Xforms context, and the absence of XQuery scripting. I have been playing around with things like the following:
let $s:=util:eval(' let $x:=copy $c:=db:open("listman","1.xml") modify (replace value of node $c/updated with current-dateTime()) return $c return db:replace("listman","1.xml",$x) ') return db:open("listman","1.xml")
This works, but is it likely to stop working in the future? Is there a better way?
/Andy
Dear Andy,
sorry for the frightening delay! We haven't been inactive, however: you have warmed up a frequently discussed limitation of XQuery Update, and after a longer discussion, we found a solution that complies to the semantics of the XQuery Update spec., but still gives you a solution to return results from an updating query.
The solution is a new function db:output() [1], which caches its argument at runtime and returns the result after all update operations have been processed. If a node is passed on as argument, it is copied in main memory to avoid that it will be modified or deleted in a pending update operation. The db:output() function itself is marked "updating", which means that it can only be used in combination with other updating operations.
Beside that, we have now defined all functions that return no value as "vacuous", which means they can now be used along with other updating operations. This way, you can e.g. perform update operations and call file:append(...) to write information to a log file in a single query.
I have just updated our snapshots; feedback is welcome. Christian
[1] http://docs.basex.org/wiki/Database_Module#db:output [2] http://docs.basex.org/wiki/Releases#Stable_Snapshots ___________________________
On Fri, Apr 13, 2012 at 2:54 PM, Andy Bunce bunce.andy@gmail.com wrote:
Musing on the the usefulness of actions that update the database and return something, specifically in a web server with Xforms context, and the absence of XQuery scripting. I have been playing around with things like the following:
let $s:=util:eval(' let $x:=copy $c:=db:open("listman","1.xml") modify (replace value of node $c/updated with current-dateTime()) return $c return db:replace("listman","1.xml",$x) ') return db:open("listman","1.xml")
This works, but is it likely to stop working in the future? Is there a better way?
/Andy
BaseX-Talk mailing list BaseX-Talk@mailman.uni-konstanz.de https://mailman.uni-konstanz.de/mailman/listinfo/basex-talk
Hi Christian,
This looks like a clean and sufficient solution to the problem. I will try it out and let you know how it goes. Thanks. /Andy
On Thu, Apr 19, 2012 at 4:37 PM, Christian Grün christian.gruen@gmail.comwrote:
Dear Andy,
sorry for the frightening delay! We haven't been inactive, however: you have warmed up a frequently discussed limitation of XQuery Update, and after a longer discussion, we found a solution that complies to the semantics of the XQuery Update spec., but still gives you a solution to return results from an updating query.
The solution is a new function db:output() [1], which caches its argument at runtime and returns the result after all update operations have been processed. If a node is passed on as argument, it is copied in main memory to avoid that it will be modified or deleted in a pending update operation. The db:output() function itself is marked "updating", which means that it can only be used in combination with other updating operations.
Beside that, we have now defined all functions that return no value as "vacuous", which means they can now be used along with other updating operations. This way, you can e.g. perform update operations and call file:append(...) to write information to a log file in a single query.
I have just updated our snapshots; feedback is welcome. Christian
[1] http://docs.basex.org/wiki/Database_Module#db:output [2] http://docs.basex.org/wiki/Releases#Stable_Snapshots ___________________________
On Fri, Apr 13, 2012 at 2:54 PM, Andy Bunce bunce.andy@gmail.com wrote:
Musing on the the usefulness of actions that update the database and
return
something, specifically in a web server with Xforms context, and the
absence
of XQuery scripting. I have been playing around with things like the following:
let $s:=util:eval(' let $x:=copy $c:=db:open("listman","1.xml") modify (replace value of node $c/updated with current-dateTime()) return $c return db:replace("listman","1.xml",$x) ') return db:open("listman","1.xml")
This works, but is it likely to stop working in the future? Is there a better way?
/Andy
BaseX-Talk mailing list BaseX-Talk@mailman.uni-konstanz.de https://mailman.uni-konstanz.de/mailman/listinfo/basex-talk
Hi Christian,
db:output() is working for me. I have put together a little blog piece about it http://cubeb.blogspot.co.uk/2012/04/listman.html
/Andy
On Mon, Apr 23, 2012 at 5:56 PM, Andy Bunce bunce.andy@gmail.com wrote:
Hi Christian,
This looks like a clean and sufficient solution to the problem. I will try it out and let you know how it goes. Thanks. /Andy
On Thu, Apr 19, 2012 at 4:37 PM, Christian Grün <christian.gruen@gmail.com
wrote:
Dear Andy,
sorry for the frightening delay! We haven't been inactive, however: you have warmed up a frequently discussed limitation of XQuery Update, and after a longer discussion, we found a solution that complies to the semantics of the XQuery Update spec., but still gives you a solution to return results from an updating query.
The solution is a new function db:output() [1], which caches its argument at runtime and returns the result after all update operations have been processed. If a node is passed on as argument, it is copied in main memory to avoid that it will be modified or deleted in a pending update operation. The db:output() function itself is marked "updating", which means that it can only be used in combination with other updating operations.
Beside that, we have now defined all functions that return no value as "vacuous", which means they can now be used along with other updating operations. This way, you can e.g. perform update operations and call file:append(...) to write information to a log file in a single query.
I have just updated our snapshots; feedback is welcome. Christian
[1] http://docs.basex.org/wiki/Database_Module#db:output [2] http://docs.basex.org/wiki/Releases#Stable_Snapshots ___________________________
On Fri, Apr 13, 2012 at 2:54 PM, Andy Bunce bunce.andy@gmail.com wrote:
Musing on the the usefulness of actions that update the database and
return
something, specifically in a web server with Xforms context, and the
absence
of XQuery scripting. I have been playing around with things like the following:
let $s:=util:eval(' let $x:=copy $c:=db:open("listman","1.xml") modify (replace value of node $c/updated with current-dateTime()) return $c return db:replace("listman","1.xml",$x) ') return db:open("listman","1.xml")
This works, but is it likely to stop working in the future? Is there a better way?
/Andy
BaseX-Talk mailing list BaseX-Talk@mailman.uni-konstanz.de https://mailman.uni-konstanz.de/mailman/listinfo/basex-talk
Andy,
thanks for the blog entry; nice to a have a first feedback on this new feature, which we are already using excessively on our own..
Christian ___________________________
On Sun, Apr 29, 2012 at 12:51 PM, Andy Bunce bunce.andy@gmail.com wrote:
Hi Christian,
db:output() is working for me. I have put together a little blog piece about it http://cubeb.blogspot.co.uk/2012/04/listman.html
/Andy
On Mon, Apr 23, 2012 at 5:56 PM, Andy Bunce bunce.andy@gmail.com wrote:
Hi Christian,
This looks like a clean and sufficient solution to the problem. I will try it out and let you know how it goes. Thanks. /Andy
On Thu, Apr 19, 2012 at 4:37 PM, Christian Grün christian.gruen@gmail.com wrote:
Dear Andy,
sorry for the frightening delay! We haven't been inactive, however: you have warmed up a frequently discussed limitation of XQuery Update, and after a longer discussion, we found a solution that complies to the semantics of the XQuery Update spec., but still gives you a solution to return results from an updating query.
The solution is a new function db:output() [1], which caches its argument at runtime and returns the result after all update operations have been processed. If a node is passed on as argument, it is copied in main memory to avoid that it will be modified or deleted in a pending update operation. The db:output() function itself is marked "updating", which means that it can only be used in combination with other updating operations.
Beside that, we have now defined all functions that return no value as "vacuous", which means they can now be used along with other updating operations. This way, you can e.g. perform update operations and call file:append(...) to write information to a log file in a single query.
I have just updated our snapshots; feedback is welcome. Christian
[1] http://docs.basex.org/wiki/Database_Module#db:output [2] http://docs.basex.org/wiki/Releases#Stable_Snapshots ___________________________
On Fri, Apr 13, 2012 at 2:54 PM, Andy Bunce bunce.andy@gmail.com wrote:
Musing on the the usefulness of actions that update the database and return something, specifically in a web server with Xforms context, and the absence of XQuery scripting. I have been playing around with things like the following:
let $s:=util:eval(' let $x:=copy $c:=db:open("listman","1.xml") modify (replace value of node $c/updated with current-dateTime()) return $c return db:replace("listman","1.xml",$x) ') return db:open("listman","1.xml")
This works, but is it likely to stop working in the future? Is there a better way?
/Andy
BaseX-Talk mailing list BaseX-Talk@mailman.uni-konstanz.de https://mailman.uni-konstanz.de/mailman/listinfo/basex-talk
basex-talk@mailman.uni-konstanz.de