> 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
[email protected]
https://mailman.uni-konstanz.de/mailman/listinfo/basex-talk

Reply via email to