[XQuery Talk Mailing List Archive Home] [By Date] [By Thread] [By Subject] [By Author] [Recent Entries] [Reply To This Message]

How do different XQuery products implement modules?

Per Bothner per at bothner.com
Wed Oct 15 19:53:53 PDT 2008


  How do different XQuery products implement modules?
Answers for Qexo:

[I wrote the code a number of years ago, so in some cases my
memory might be off, so I am looking at teh code to refresh
my memory.]

Michael Kay wrote:

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

It can be be arbitrary string, but it is "mangled" to the name of a
"package" in the Java class hierarchy, similar to the JAXB mangling.

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

No.

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

Yes.

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

Possibly, but it isn't supported or recommended.

> 3. Can users import a module without specifying a location URI?

Yes, but the module has to either have been previously compiled
to a Java class (in the current class path), or the imported
module must have been "registered" with the module manager - which
happens when compiling multiple modules on the same "compilation line".

 > If so, how is the module located?

It mangles the namespace to a package name.  It then looks for a class
named $ModuleMap$ in that packages.  This class contains a list of all
modules whose namespace mangle to this package name.  The compiler
loads the $ModuleMap$ class, and selects the modules whose namespace
URIs match.

When a module is compiled, the compiler creates a class in the package
corresponding to the module's URI.  The name of the class is a mangling
of the last component of the source file name, within the package
created by mangling the namespace URI.  The compiler then updates the
$ModuleMap$ to include the compiled module(s).  If $ModuleMap$ already
exists, then the class is first is loaded so the old contents can be
merged into the $ModuleMap$ that gets written out.

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

A source file is looked for.  It also mangles the source file name
and the namespace URI to yield a class name, and looks for that as well. 
  It will work if it finds either.  If both are found, it will compre
time-stamps.

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

Each location URI must map to a module; all are loaded.

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

Hm.  That should be an error, but I don't think I test that,

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

Same module.

>    6b. specifying different location URIs

Not sure - it should be an error.

>    6c. without specifying a location URI

Same module, found using mangled class - see 3,

> 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?

The latter.  By default a module variables are compiled to static fields
of the module class, so they're inherently shared.  There is a compiler
option to compile to instance variables.  In that case a single "module
instance" will be allocated, global to the current "module context".
-- 
	--Per Bothner
http://x-query.com/mailman/listinfo/talk   http://per.bothner.com/


PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2007 All Rights Reserved.