So, would the convention of using the database name as the function namespace for queries to that database be sufficient ? Or is convention not a sufficient encapsulation ? ( i.e. do you need stronger enforcement, so that db1 users can’t possibly call db2:func() ? )
A stronger enforcement on the encapsulation would be ideal. I would suggest a built in concept of database specific modules should give you this.
Using Convention and the database name in the function namespace could potentially be sufficient in terms of referencing. It would likely be more convenient if this was not through namespacing though. The database our applications connect to is configurable at application start up time, so we would need to take some care in making sure the function namespaces are generated as well. We would also need to avoid conflicts in their installation location on disk.
if you DO go the route of storing procedures in the database, you might consider whether you could express those procedures as XSLT stylesheets that you could call from XQuery using xslt:transform() function.
For sure, something to consider here. We would likely start with raw/text to see how we go and potentially look to formalise using xslt at a later stage.
Chris