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
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@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
Thanks Rosita, that works although I seem to have hit a namespace issue https://github.com/BaseXdb/basex/issues/397
/Andy
On Thu, Feb 23, 2012 at 12:30 AM, Rositsa Shadura < rositsa.shadura@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@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/
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/
My intent was that "parser-basex" be private. Although this bughttps://github.com/BaseXdb/basex/issues/133makes 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@fgeorges.orgwrote:
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/
I meant NOT find it. Section 3 has
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
On Sun, Feb 26, 2012 at 10:54 AM, Andy Bunce bunce.andy@gmail.com wrote:
My intent was that "parser-basex" be private. Although this bughttps://github.com/BaseXdb/basex/issues/133makes 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@fgeorges.orgwrote:
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/
basex-talk@mailman.uni-konstanz.de