As most of you (should) know by know, eXist does support xquery modules. With this it is possible to efficiently re-use xquery code. A small xquery example:
and a not too complex module:
In this example the module is located in the same collection as the query; This rather simple query-module relation works perfectly and is used in many applications. Things get more difficult when a module itself has a relation with one ore more modules.
It turns out that modules are always resolved relative to the 'first executed' xquery. That means that if your module imports another module (e.g. module3.xqm in collection sub) special things happen:
In this example query.xq imports module2.xqm and module2.xqm imports module3.xqm ; One would expect that the following code would be sufficient for module2.xqm:
What actually happens is that the query engine tries to resolve module3.xqm from /db/sub/module3.xqm. The only solution to have the module loaded correctly, is to specify a full path in the database:
The bad thing about this construct is that it makes your application less portable/movable.
I think this limitation does not make sense. I'll investigate this issue and 'll (try to) make a fix for it (unless Perig disagrees with the solution :-) )