Well, it's not easy !

In my case, we use the same prefix/uri mapping in all files, and modules only declares function. Humm... I hope !

 

I'm going to look at QueryProcessor, and see what I can do. Maybe, I won't cover the whole XQuery syntax, but just a part, and with limitations. If my maven plugin can warn and/or thro errors, it will be good enough.

 

Thanks again,

Christophe

Le 2015-08-17 12:07, Christian Grün a écrit :

I suppose, you have such a code that reads .xq file, analyses imports, read
and process imports, to build the full query with all functions attached.

But as finding a piece of code in a project you've never code on is a very
long process, I thought you could help me to point out the main class in
basex-core that does the job...

I see. You could start with the QueryProcessor class [1]. However, I
believe it's a fairly complex job you are tackling. Even if you did it
manually, it would not always be clear how the merged representation
should look like. See the following modules:

______ query.xq ______

import module namespace mod1 = 'uri1' at 'mod1.xqm';
declare namespace mod2 = 'c';
declare variable $mod2:v := 'VAR1';
($mod1:v, $mod2:v)

______ mod1.xqm ______

module namespace ns = 'uri1';
import module namespace mod2 = 'uri2' at 'mod2.xqm';
declare variable $ns:v := $mod2:v;

______ mod2.xqm ______

module namespace ns = 'uri2';
declare variable $ns:v := 'VAR2';

How do you think should the merged query look like?

Christian

[1] https://github.com/BaseXdb/basex/blob/master/basex-core/src/main/java/org/basex/query/QueryProcessor.java





Best regards,

Christophe



Le 2015-08-17 11:43, Christian Grün a écrit :

Hi Christophe,

I want to produce a .XQ file that includes all the code contained in
imported modules (via import module clause). My purpose is to produce a
maven plugin to do this.

I think such a code already exists in basex, and I would like to reuse it.


I don't know anything about such a module. Where did you hear about it?

Cheers,
Christian