BaseX 7.1.2 beta: relative paths within packages
Thursday, 23 February 2012 · 6 messages · last reply 26 Feb 2012
AB
Andy Bunce23 Feb 2012 00:47 #
I have a built an xar package with a xquery source that imports another module.
It has three files as follows:
---expath-pkg.xml-------
<package xmlns="http://expath.org/ns/pkg" name="apb.pacman" abbrev="lib"
version="0.1" spec="1.0">
<title>package tools</title>
<xquery>
<namespace>apb.pacman</namespace>
<file>pacman.xq</file>
</xquery>
</package>
----------lib/pacman.xq-------
xquery version "1.0" encoding "UTF-8";
module namespace q="apb.pacman";
import module namespace p="parser-basex" at "parser-basex.xq";
declare function q:info() {
"hello from pacman"
};
declare function q:parse($xq as xs:string) {
p:parse-XQuery($xq)
};----------lib/parser-basex.xq-------
xquery version "1.0"
... etc
--------------------------------
In the GUI I enter:
import module namespace q="apb.pacman";
q:info()
I get the error:
Error: [XQST0059] Module not found: '/home/andy/parser-basex.xq
I was expecting p="parser-basex" at "parser-basex.xq" to be resolved relative to pacman.xq in the repo.
Is this a bug, or am I misreading the spec?
/Andy
RS
Rositsa Shadura23 Feb 2012 01:30 #
Hi Andy,
as your module parser-basex.xq is part of the package, it must be registered in the package descriptor:
<xquery>
<namespace>parser-basex</namespace>
<file>parser-basex.xq</file>
</xquery>and thus the import statement in pacman.xq shall not specify its location:
import module namespace p="parser-basex";
Regards,
Rositsa
Quoted text · Andy Bunce · 43 lines
On Thu, 23 Feb 2012 00:47:06 +0100, Andy Bunce <bunce.andy at gmail.com> wrote: > I have a built an xar package with a xquery source that imports another > module. > It has three files as follows: > ---expath-pkg.xml------- > <package xmlns="http://expath.org/ns/pkg" name="apb.pacman" abbrev="lib" > version="0.1" spec="1.0"> > <title>package tools</title> > <xquery> > <namespace>apb.pacman</namespace> > <file>pacman.xq</file> > </xquery> > </package> > ----------lib/pacman.xq------- > xquery version "1.0" encoding "UTF-8"; > > module namespace q="apb.pacman"; > import module namespace p="parser-basex" at "parser-basex.xq"; > > declare function q:info() { > "hello from pacman" > }; > declare function q:parse($xq as xs:string) { > p:parse-XQuery($xq) > }; > > ----------lib/parser-basex.xq------- > xquery version "1.0" > ... etc > -------------------------------- > In the GUI I enter: > import module namespace q="apb.pacman"; > q:info() > > I get the error: > Error: [XQST0059] Module not found: '/home/andy/parser-basex.xq > > I was expecting p="parser-basex" at "parser-basex.xq" to be resolved > relative to pacman.xq in the repo. > Is this a bug, or am I misreading the spec? > > /Andy
--
Using Opera's revolutionary email client: http://www.opera.com/mail/
AB
Andy Bunce23 Feb 2012 23:46 #
Thanks Rosita, that works although I seem to have hit a namespace issue https://github.com/BaseXdb/basex/issues/397
/Andy
Quoted text · Rositsa Shadura · 72 lines
On Thu, Feb 23, 2012 at 12:30 AM, Rositsa Shadura < rositsa.shadura at uni-konstanz.de> wrote: > Hi Andy, > > as your module parser-basex.xq is part of the package, it must be > registered in the package descriptor: > > <xquery> > <namespace>parser-basex</**namespace> > <file>parser-basex.xq</file> > </xquery> > > and thus the import statement in pacman.xq shall not specify its location: > > import module namespace p="parser-basex"; > > Regards, > Rositsa > > > > On Thu, 23 Feb 2012 00:47:06 +0100, Andy Bunce <bunce.andy at gmail.com> > wrote: > > I have a built an xar package with a xquery source that imports another >> module. >> It has three files as follows: >> ---expath-pkg.xml------- >> <package xmlns="http://expath.org/ns/**pkg <http://expath.org/ns/pkg>" >> name="apb.pacman" abbrev="lib" >> version="0.1" spec="1.0"> >> <title>package tools</title> >> <xquery> >> <namespace>apb.pacman</**namespace> >> <file>pacman.xq</file> >> </xquery> >> </package> >> ----------lib/pacman.xq------- >> xquery version "1.0" encoding "UTF-8"; >> >> module namespace q="apb.pacman"; >> import module namespace p="parser-basex" at "parser-basex.xq"; >> >> declare function q:info() { >> "hello from pacman" >> }; >> declare function q:parse($xq as xs:string) { >> p:parse-XQuery($xq) >> }; >> >> ----------lib/parser-basex.xq-**------ >> xquery version "1.0" >> ... etc >> ------------------------------**-- >> In the GUI I enter: >> import module namespace q="apb.pacman"; >> q:info() >> >> I get the error: >> Error: [XQST0059] Module not found: '/home/andy/parser-basex.xq >> >> I was expecting p="parser-basex" at "parser-basex.xq" to be resolved >> relative to pacman.xq in the repo. >> Is this a bug, or am I misreading the spec? >> >> /Andy >> > > > -- > Using Opera's revolutionary email client: http://www.opera.com/mail/ >
FG
Quoted text · Rositsa Shadura · 1 line
Rositsa Shadura wrote:
Hi,
Quoted text · Rositsa Shadura · 9 lines
> as your module parser-basex.xq is part of the package, it must be > registered in the package descriptor: > <xquery> > <namespace>parser-basex</namespace> > <file>parser-basex.xq</file> > </xquery> > and thus the import statement in pacman.xq shall not specify its > location: > import module namespace p="parser-basex";
Actually, that's more complex than that. The components registered in the package descriptor can be accessed from the outside of the package, using their public URIs (for XQuery libraries, that is their target namespace). But inside the same package, components can import and reference each others by relative references. This is even the recommended way.
The idea is that some components are not intended at all to be used by the outside world, they are just private components (I don't know the details of this particular package, but it could be the case that the parser is completely private, so Andy's usage looks like completly legitimate).
I had a look at the pkg spec, but I couldn't find this explained explicitly. Maybe I should add it to the spec, at least as a note...
Regards,
--
Florent Georges
http://fgeorges.org/
http://h2oconsulting.be/
AB
Andy Bunce26 Feb 2012 11:54 #
My intent was that "parser-basex" be private. Although this
bug<https://github.com/BaseXdb/basex/issues/133>makes this area problematic at the moment.
Quoted text · Florent Georges · 1 line
> I had a look at the pkg spec, but I couldn't find this explained
explicitly.
I was sure I had seen a statement to this effect in the spec, then when I looked again I could find it.
/Andy
On Sat, Feb 25, 2012 at 11:52 PM, Florent Georges <lists at fgeorges.org>wrote:
Quoted text · Florent Georges · 40 lines
> Rositsa Shadura wrote: > > Hi, > > > as your module parser-basex.xq is part of the package, it must be > > registered in the package descriptor: > > > <xquery> > > <namespace>parser-basex</namespace> > > <file>parser-basex.xq</file> > > </xquery> > > > and thus the import statement in pacman.xq shall not specify its > > location: > > > import module namespace p="parser-basex"; > > Actually, that's more complex than that. The components registered > in the package descriptor can be accessed from the outside of the > package, using their public URIs (for XQuery libraries, that is their > target namespace). But inside the same package, components can import > and reference each others by relative references. This is even the > recommended way. > > The idea is that some components are not intended at all to be used > by the outside world, they are just private components (I don't know > the details of this particular package, but it could be the case that > the parser is completely private, so Andy's usage looks like completly > legitimate). > > I had a look at the pkg spec, but I couldn't find this explained > explicitly. Maybe I should add it to the spec, at least as a note... > > Regards, > > -- > Florent Georges > http://fgeorges.org/ > http://h2oconsulting.be/ >
AB
Andy Bunce26 Feb 2012 12:44 #
I meant NOT find it.
Section 3 has
Quoted text · Andy Bunce · 1 line
>All the relative URIs used to identify components are relative to the
package directory.
But this is referring to the package descriptor file expath-pkg.xml
/Andy
Quoted text · Andy Bunce · 55 lines
On Sun, Feb 26, 2012 at 10:54 AM, Andy Bunce <bunce.andy at gmail.com> wrote: > My intent was that "parser-basex" be private. Although this bug<https://github.com/BaseXdb/basex/issues/133>makes this area problematic at the moment. > > > > I had a look at the pkg spec, but I couldn't find this explained > explicitly. > I was sure I had seen a statement to this effect in the spec, then when I > looked again I could find it. > > /Andy > > On Sat, Feb 25, 2012 at 11:52 PM, Florent Georges <lists at fgeorges.org>wrote: > >> Rositsa Shadura wrote: >> >> Hi, >> >> > as your module parser-basex.xq is part of the package, it must be >> > registered in the package descriptor: >> >> > <xquery> >> > <namespace>parser-basex</namespace> >> > <file>parser-basex.xq</file> >> > </xquery> >> >> > and thus the import statement in pacman.xq shall not specify its >> > location: >> >> > import module namespace p="parser-basex"; >> >> Actually, that's more complex than that. The components registered >> in the package descriptor can be accessed from the outside of the >> package, using their public URIs (for XQuery libraries, that is their >> target namespace). But inside the same package, components can import >> and reference each others by relative references. This is even the >> recommended way. >> >> The idea is that some components are not intended at all to be used >> by the outside world, they are just private components (I don't know >> the details of this particular package, but it could be the case that >> the parser is completely private, so Andy's usage looks like completly >> legitimate). >> >> I had a look at the pkg spec, but I couldn't find this explained >> explicitly. Maybe I should add it to the spec, at least as a note... >> >> Regards, >> >> -- >> Florent Georges >> http://fgeorges.org/ >> http://h2oconsulting.be/ >> > >
Written for BaseX 7.1. BaseX may have changed since: please check the current documentation.
⚡Generated with XQuery