Hi Andy,
I thought you say something like this :-) One thing I don't understand is how the existing facilities handle the current looseness of sequentiality.
For example I can mix Xquery updates and document db:replace or document db:add or I could use the http module to do a REST interface create request in the middle of a larger Xquery script
I have update our documentation on XQuery Update; it now lists all update primitives in the order they will be executed [1]. Similar to util:eval/evil(), http:send-request() will be evaluated in place, which means you can easily create deadlock situations. Just one more reason why those functions should be handled with care, or completely avoided. But I know we still need a nice alternative to make things handier.
Christian
[1] http://docs.basex.org/wiki/XQuery_Update#Pending_Update_List
On Wed, May 23, 2012 at 1:59 PM, Andreas Weiler andreas.weiler@uni-konstanz.de wrote:
You still could use the Java Bindings.
-- Andreas
Am 23.05.2012 um 14:23 schrieb Christian Grün:
I sometimes find myself, in code, wanting to create a database, or more specifically test if a database exists and create it if does not. The database module appears not have functions to create (or delete databases). Is this a deliberate design decision?
Indeed it is; but we are still looking for a good solution to fill this obvious gap. Even if databases are pretty light-weight entities in BaseX, the creation of a new database within an XQuery expression may trigger numerous side effects related to other database operations. The main reason for that is the functional nature of XQuery and the "pending update list" of XQuery Update: all updating commands will become effective after the query itself has been evaluated. However, commands like db:add() or db:delete() commands will (currently) only end up on the list if the addressed database already exists. Another example: db:create() could overwrite a database that already existed, and some commands would possibly refer to the old instance, while other updating commands would access the new one.
One general solution to this challenge would be the XQuery Scripting Extension [1], which allows you to execute commands sequentially (i.e., in an imperative manner). XQSE is definitely on our list, but which will require considerable time to realize -- mainly because a straightforward implementation would sabotage many of the existing functional optimizations in the code (some of the functional and imperative optimizations are even diametrical).
In summary, I cannot give a satifsying answer yet except for the advice to use the BaseX commands, REST or XQJ (via XQExpression.executeCommand()), but I'm very open to ideas and proposals how to tackle this challenge.
Christian
[1] http://www.w3.org/TR/xquery-sx-10/ _______________________________________________ BaseX-Talk mailing list BaseX-Talk@mailman.uni-konstanz.de https://mailman.uni-konstanz.de/mailman/listinfo/basex-talk