OK thanks Markus, I was probably thinking more about this functionality for the library modules that get installed in the repo. I was not explicitly thinking about restxq modules/functions but being able to install these would also be useful.
I think effectively what I am trying to achieve is to have some method for a remote application to create isolated databases and install some associated basex modules through a single existing server. Maybe the general idea is that you would do this by having multiple basex instances (and multiple servers). So perhaps I could raise a couple of feature requests: * Ability to install webapp modules through the server as per REPO INSTALL * This would give us the ability to create a new database and install and manage associated modules from a client without needing to understand the basex files structure * Ability to install repo and webapp modules for a specific database (eg DBREPO INSTALL) * This would give us the ability to install modules for a new database on an existing server, without needing to understand what else is already on the server for other databases. * Ability to install main modules through the server as per REPO INSTALL (for consistency) Is there a preferred method to raise these requests and potentially maintain reference to this discussion for context? In the meantime, we can look at managing these by * Explicitly copying files to a predefined web app directory (or use an admin account to get the web app directory) when installing rexq modules when a database is created. * Isolating the database specific modules in the webapp and repo directory through naming conventions or by creating completely separate basex instances and servers Cheers, Chris From: Markus Wittenberg <wittenb...@axxepta.de> Sent: Friday, 21 February 2020 5:11 PM To: DYER Chris <chris.d...@sydac.com>; basex-talk@mailman.uni-konstanz.de Subject: Re: [basex-talk] Database specific xquery modules If you want to use RESTXQ you would have to put the modules, or least the functions defining the endpoints, in the webapp directory and not in the repo directory. And far as I know, BaseX doesn't support installation for modules in webapp as for in repo. So you have to explicitly change/add files in webapp directory. You could write a module for each database, defining its own endpoints, and maybe still reuse some code by importing a module with common functions in every specific module. Am 21.02.2020 um 07:11 schrieb DYER Chris: Hi Markus, Not quite what I am aiming for. We do want a single BaseX Instance to provide access to multiple databases. Further to this though, a set of client applications will only connect to one database. We have multiple sets of client applications, with each set each connecting to one database. We do want to modularise the functions, however as an example we want to be able to have 2 versions of the same function, where 1 version works with the schema of the data in database 1, and the second version with a different schema in database 2. If I could explicitly link the function modules with a database, I could call the same function from both application sets, and use the context of the open database to call the correct version of the function. An example situation may help Say we have Database for "Black Books", which has book data in xml structures which conform to some version (1.1) of a schema. We want a query stored on the server that returns books on art Get-Books-About-Art We have a client application specifically for this database that calls this function. It will only need to query the data in this database. Now we add a second Database for "Goliath Books" The book data in this database uses a modified xml structure (version 2 of a schema) We have a client application for this database that also wants to get books about art. The query for this database is slightly different because the xml schema has changed. I would like to store both versions of Get-Books-About-Art in the database. Then for each client to connect to their associated database, and be able to execute the correct version of the xquery function. The idea is that each time I add a new database that has data in some format, I can install associated query modules that are restricted to the context of that database to avoid conflicts with existing databases. Maybe what I am looking for is effectively a database specific repo to install modules to, rather than a basex install repo. From: Markus Wittenberg <wittenb...@axxepta.de><mailto:wittenb...@axxepta.de> Sent: Friday, 21 February 2020 2:15 PM To: DYER Chris <chris.d...@sydac.com><mailto:chris.d...@sydac.com>; basex-talk@mailman.uni-konstanz.de<mailto:basex-talk@mailman.uni-konstanz.de> Subject: Re: [basex-talk] Database specific xquery modules A RESTXQ definition could look something like this: declare %rest:path("/a/{$client}/{$path}") function yourmodule:test($client as xs:string, $path as xs:string) { let $db := switch ($client) case "clientA" return db:open("dbA") case "clientA" return db:open("dbA") default return db:open("dbX") return yourmodule:do-something-with($db, $path) }; And the called function do-something-with could also depend on the client Am 21.02.2020 um 03:48 schrieb DYER Chris: Hi Markus, Our intent is to use REST and RESTXQ interfaces to interact with data on a single database using some server side XQueries. However, we may have 2 (or more) databases provided by some server, and associated xqueries are specific to the contents of each database (as the contents of each of these databases may be structured differently). We would like for a client to be able to open a single database and be able to run associated XQueries, without requiring client side knowledge of which server side xqueries are associated with the database it has opened. Does this help describe what we are trying to achieve? Cheers, Chris From: BaseX-Talk <basex-talk-boun...@mailman.uni-konstanz.de><mailto:basex-talk-boun...@mailman.uni-konstanz.de> On Behalf Of Markus Wittenberg Sent: Friday, 21 February 2020 12:08 PM To: basex-talk@mailman.uni-konstanz.de<mailto:basex-talk@mailman.uni-konstanz.de> Subject: Re: [basex-talk] Database specific xquery modules Hi Chris, as you might already know, BaseX has built-in REST support [1] which you can use to query and update data via HTTP. You can also use the RESTXQ [2] functionality to define arbitrary server side XQueries which can also be requested by HTTP and are also suitable for web applications. Both methods are not restricted to a single database. Best regards, Markus [1] http://docs.basex.org/wiki/REST [2] http://docs.basex.org/wiki/RESTXQ Am 21.02.2020 um 02:05 schrieb DYER Chris: I am looking for some ideas on some architecture surrounding xquery modules. Our situation is that we have multiple client applications in various languages that will connect to a database. We will have some reasonably complex xqueries to extract data in certain structures that will be used by each of these clients. So to avoid having to duplicate the query logic we would like the xqueries to reside "in" the database. Additionally, we would like to use the same BaseX installation for multiple databases, corresponding to multiple projects. The data in each of these databases may be against a different schema and our xqueries are essentially tied to the schema of the data. Thus, each database may need slightly different xqueries. The xquery library modules looks to be global for the BaseX instance, as does the loading of main modules off of disk. Is there any way to tie the query module or file to a specific database? We are trying to avoid being limited to 1 database per BaseX instance. An alternative would be to embed the xqueries within our client applications, but that involves duplication. Also, we are not sure if there are any performance difference with having the queries stored in the repo vs client side? For background, we are looking at migrating from oracle to BaseX. So, we are effectively looking for an equivalent of multiple clients connecting to a userspace and using stored procedures which are specific to that userspace. Any ideas on how to achieve this currently? Or is this something that BaseX could support? Cheers, Chris -- Markus Wittenberg Tel +49 (0)341 248 475 36 Mail wittenb...@axxepta.de<mailto:wittenb...@axxepta.de> ---- axxepta solutions GmbH Lehmgrubenweg 17, 88131 Lindau Amtsgericht Berlin HRB 97544B Geschäftsführer: Karsten Becke, Maximilian Gärber -- Markus Wittenberg Tel +49 (0)341 248 475 36 Mail wittenb...@axxepta.de<mailto:wittenb...@axxepta.de> ---- axxepta solutions GmbH Lehmgrubenweg 17, 88131 Lindau Amtsgericht Berlin HRB 97544B Geschäftsführer: Karsten Becke, Maximilian Gärber -- Markus Wittenberg Tel +49 (0)341 248 475 36 Mail wittenb...@axxepta.de<mailto:wittenb...@axxepta.de> ---- axxepta solutions GmbH Lehmgrubenweg 17, 88131 Lindau Amtsgericht Berlin HRB 97544B Geschäftsführer: Karsten Becke, Maximilian Gärber