Resolving includes

Monday, 17 August 2015 · 5 messages
C
cmarchand17 Aug 2015 11:42 #
Hi, back to my questions on resolving modules includes. 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. Any entry-point will be much appreciated. Thanks in advance, Christophe
CG
Christian Grün17 Aug 2015 11:43 #
Hi Christophe,
Quoted text · cmarchand · 5 lines
> 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
C
cmarchand17 Aug 2015 11:52 #
Well... 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... Best regards, Christophe
Quoted text · Christian Grün · 13 lines
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
CG
Christian Grün17 Aug 2015 12:07 #
Quoted text · cmarchand · 6 lines
> 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';
Quoted text · cmarchand · 24 lines
> > > > 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
C
cmarchand17 Aug 2015 13:03 #
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
Quoted text · Christian Grün · 55 lines
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 [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 [1] > >> 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

⚡Generated with XQuery