[xquery-talk] Re: How do different XQuery products implement modules?

Dan Muresan danmbox at gmail.com
Fri Oct 17 18:38:09 PDT 2008


Hi, here are the answers for Zorba (http://www.zorba-xquery.com/):

>> 1. Is the module URI just an arbitrary character string, or does it
>> have any semantics?

It is an arbitrary character string.

>>   1a. In particular, is it the location of a resource on the web?

This is not required; however, users can supply module URI resolvers
that may choose to attach arbitrary meaning to the module URI (this is
work in progress).

>> 2. Do you allow several different modules in the same query to have
>> the same module URI?

Yes, but all modules sharing the same module URI must be imported from a
single "import module" declaration (by specifying multiple location hints).

>>   2a. if so, can different "import module" declarations import different
>> subsets of these?

No.

>> 3. Can users import a module without specifying a location URI? If so, how
>> is the module located?

Not by default. However, a user-supplied module URI resolver can process
the module namespace and location hints arbitrarily to generate one (or
more) final locations.

>> 4. If import module specifies a location URI, is it used, and if so how?

It is used to locate a local file or a web location.

>> 5. If import module specifies more than one location URI, how are they
>> used?

By default, each location hint URI is processed separately to yield a
separate LibraryModule. Custom module URI resolvers can do whatever the
user wants (possibly yielding fewer or more LibraryModule's than the
supplied hints).

>>   5b. If multiple location URIs are allowed, what happens if
>>   import module specifies the same location URI more than once?

By default, redundant hints are ignored.

>> 6. What happens when two modules A and B both import module URI M
>>
>>   6a. specifying the same location URI

A single instance of the module M is created.

>>   6b. specifying different location URIs

If the two location URIs are equivalent up to relative URI resolution,
same as above. If not, then two distinct modules are imported.

>>   6c. without specifying a location URI

This can only happened with a user-supplied module URI resolver, and the
result then depends on the user's code.

>> 7. Is it possible (by means of multiple imports) to create two different
>> "instances" of the same module in a query, with distinct values of global
>> variables, or do all imports get the same instance with a common set of
>> variables?

A single instance of a module is ever created. If a module is
addressable by two distinct URI's (e.g. in Unix, if file mod2.xq is a
symlink to mod1.xq), then these behave as two separate modules with
identical source code.


-- Dan Muresan


More information about the talk mailing list