module import / base URI declaration

Saturday, 17 January 2015 · 4 messages · last reply 18 Jan 2015
HR
Hans-Juergen Rennau17 Jan 2015 00:20 #
Dear BaseX team, I think that the resolving of module import hints does not work properly if the importing module has a relative base URI declaration. In the example below, module1 and module2 both are located in a directory "tt". As module 1 has a base URI declaration setting the base URI to "..", its import of module2 should require the following import hint: "tt/module2.xq", rather than "module2.xq". However, this produces an error; the error is not thrown when the import hint is erroneously set to "module" - which is, of course, also wrong behaviour. Compare: http://www.w3.org/TR/xquery-30/#id-base-uri-decl Cheers, Hans-Jürgen PS call: basex -b uri=dummy.xml main.xq => [XQST0059] Could not retrieve module 'C:/projects/infospace/pcol/tmp/tt/module2.xq'. main.xq:
=======
import module namespace m="http://www.ttools.org/xquery-functions" at "tmp/module1.xq";
declare variable $uri external;
m:foo($uri)
module1.xq:
=========
module namespace m="http://www.ttools.org/xquery-functions";
import module namespace i="http://www.ttools.org/xquery-functions" at "tt/module2.xq";
declare base-uri "..";
declare function m:foo($uri as xs:string) {i:bar($uri)};
module2.xq:
==========
module namespace m="http://www.ttools.org/xquery-functions";
declare base-uri "..";
declare function m:bar($uri as xs:string) {doc($uri)};
CG
Christian Grün17 Jan 2015 17:09 #
Hi Hans-Jürgen, Your query will work if you move the base-uri declaration before the module imports. I agree this is not compliant with the spec. The reason is that we import a module as soon as the "import module" statement is found. We'll probably need to parse the full query prolog before starting the import. As I cannot foresee what other consequences this will have, I have added a new GitHub issue [1]. All the best, Christian [1] https://github.com/BaseXdb/basex/issues/1058
Quoted text · Hans-Juergen Rennau · 47 lines
On Sat, Jan 17, 2015 at 12:20 AM, Hans-Juergen Rennau <hrennau at yahoo.de> wrote: > Dear BaseX team, > > I think that the resolving of module import hints does not work properly if > the importing module has a relative base URI declaration. > > In the example below, module1 and module2 both are located in a directory > "tt". As module 1 has a base URI declaration setting the base URI to "..", > its import of module2 should require the following import hint: > "tt/module2.xq", rather than "module2.xq". However, this produces an error; > the error is not thrown when the import hint is erroneously set to "module" > - which is, of course, also wrong behaviour. > > Compare: http://www.w3.org/TR/xquery-30/#id-base-uri-decl > > Cheers, > Hans-Jürgen > > PS > call: basex -b uri=dummy.xml main.xq > => > [XQST0059] Could not retrieve module > 'C:/projects/infospace/pcol/tmp/tt/module2.xq'. > > main.xq: > ======= > import module namespace m="http://www.ttools.org/xquery-functions" at > "tmp/module1.xq"; > declare variable $uri external; > m:foo($uri) > > module1.xq: > ========= > module namespace m="http://www.ttools.org/xquery-functions"; > import module namespace i="http://www.ttools.org/xquery-functions" at > "tt/module2.xq"; > declare base-uri ".."; > declare function m:foo($uri as xs:string) {i:bar($uri)}; > > module2.xq: > ========== > module namespace m="http://www.ttools.org/xquery-functions"; > declare base-uri ".."; > declare function m:bar($uri as xs:string) {doc($uri)}; > > >
CG
Christian Grün18 Jan 2015 14:13 #
Hi Hans-Jürgen, the parsing problem has been fixed. Christian
Quoted text · Christian Grün · 64 lines
On Sat, Jan 17, 2015 at 5:09 PM, Christian Grün <christian.gruen at gmail.com> wrote: > Hi Hans-Jürgen, > > Your query will work if you move the base-uri declaration before the > module imports. I agree this is not compliant with the spec. The > reason is that we import a module as soon as the "import module" > statement is found. We'll probably need to parse the full query prolog > before starting the import. As I cannot foresee what other > consequences this will have, I have added a new GitHub issue [1]. > > All the best, > Christian > > [1] https://github.com/BaseXdb/basex/issues/1058 > > > On Sat, Jan 17, 2015 at 12:20 AM, Hans-Juergen Rennau <hrennau at yahoo.de> wrote: >> Dear BaseX team, >> >> I think that the resolving of module import hints does not work properly if >> the importing module has a relative base URI declaration. >> >> In the example below, module1 and module2 both are located in a directory >> "tt". As module 1 has a base URI declaration setting the base URI to "..", >> its import of module2 should require the following import hint: >> "tt/module2.xq", rather than "module2.xq". However, this produces an error; >> the error is not thrown when the import hint is erroneously set to "module" >> - which is, of course, also wrong behaviour. >> >> Compare: http://www.w3.org/TR/xquery-30/#id-base-uri-decl >> >> Cheers, >> Hans-Jürgen >> >> PS >> call: basex -b uri=dummy.xml main.xq >> => >> [XQST0059] Could not retrieve module >> 'C:/projects/infospace/pcol/tmp/tt/module2.xq'. >> >> main.xq: >> ======= >> import module namespace m="http://www.ttools.org/xquery-functions" at >> "tmp/module1.xq"; >> declare variable $uri external; >> m:foo($uri) >> >> module1.xq: >> ========= >> module namespace m="http://www.ttools.org/xquery-functions"; >> import module namespace i="http://www.ttools.org/xquery-functions" at >> "tt/module2.xq"; >> declare base-uri ".."; >> declare function m:foo($uri as xs:string) {i:bar($uri)}; >> >> module2.xq: >> ========== >> module namespace m="http://www.ttools.org/xquery-functions"; >> declare base-uri ".."; >> declare function m:bar($uri as xs:string) {doc($uri)}; >> >> >>
HR
Hans-Juergen Rennau18 Jan 2015 15:13 #
Cordial thanks,Christian! Hans-Jürgen
Quoted text · Christian Grün · 1 line
Christian Grün <christian.gruen at gmail.com> schrieb am 14:13 Sonntag, 18.Januar 2015:
Hi Hans-Jürgen, the parsing problem has been fixed. Christian
Quoted text · Christian Grün · 64 lines
On Sat, Jan 17, 2015 at 5:09 PM, Christian Grün <christian.gruen at gmail.com> wrote: > Hi Hans-Jürgen, > > Your query will work if you move the base-uri declaration before the > module imports. I agree this is not compliant with the spec. The > reason is that we import a module as soon as the "import module" > statement is found. We'll probably need to parse the full query prolog > before starting the import. As I cannot foresee what other > consequences this will have, I have added a new GitHub issue [1]. > > All the best, > Christian > > [1] https://github.com/BaseXdb/basex/issues/1058 > > > On Sat, Jan 17, 2015 at 12:20 AM, Hans-Juergen Rennau <hrennau at yahoo.de> wrote: >> Dear BaseX team, >> >> I think that the resolving of module import hints does not work properly if >> the importing module has a relative base URI declaration. >> >> In the example below, module1 and module2 both are located in a directory >> "tt". As module 1 has a base URI declaration setting the base URI to "..", >> its import of module2 should require the following import hint: >> "tt/module2.xq", rather than "module2.xq". However, this produces an error; >> the error is not thrown when the import hint is erroneously set to "module" >> - which is, of course, also wrong behaviour. >> >> Compare: http://www.w3.org/TR/xquery-30/#id-base-uri-decl >> >> Cheers, >> Hans-Jürgen >> >> PS >> call: basex -b uri=dummy.xml main.xq >> => >> [XQST0059] Could not retrieve module >> 'C:/projects/infospace/pcol/tmp/tt/module2.xq'. >> >> main.xq: >> ======= >> import module namespace m="http://www.ttools.org/xquery-functions" at >> "tmp/module1.xq"; >> declare variable $uri external; >> m:foo($uri) >> >> module1.xq: >> ========= >> module namespace m="http://www.ttools.org/xquery-functions"; >> import module namespace i="http://www.ttools.org/xquery-functions" at >> "tt/module2.xq"; >> declare base-uri ".."; >> declare function m:foo($uri as xs:string) {i:bar($uri)}; >> >> module2.xq: >> ========== >> module namespace m="http://www.ttools.org/xquery-functions"; >> declare base-uri ".."; >> declare function m:bar($uri as xs:string) {doc($uri)}; >> >> >>

⚡Generated with XQuery