Hi All,

I am trying to figure out how to load an XQuery module into a static context programmatically.
I am successfully currently using the following Java code to load and compile main modules:
String myQuery = "...";
StaticQueryContext myStaticQueryContext = new StaticQueryContext(theConfiguration);
XQueryExpression myXQueryExpression = myStaticQueryContext.compileQuery(myQuery);

However, attempting to do this with a library module, I get the following error:
  XQuery syntax error on line 2 in `...sion "1.0"; module namespace c`:
    Module declaration should not be used in a main module

The library module I'm trying to load looks like this:
xquery version "1.0";
module namespace lib = "http://acme.net/lib/effective";

declare function lib:effectiveDuring($elements as element()*, $start as xs:date, $end as xs:date) as element()*
  if(not(empty($elements))) then
  ( for $n in $elements where $n/*:Effective/*:From <= $end and $n/*:Effective/*:To >= $start return $n)

So, I conclude from this that you can't load library modules the same way. However, the
method on StaticQueryContext for loading modules, StaticQueryContext.loadQueryModule(..),
takes a locationURI are presumably loads the query text internally. However, I already
have the query text and would like to just pass it in exactly the same was compileQuery(..).

In a related problem, it isn't clear how this method should be used, e.g.:
- what should be passed in as the Executable instance?
- and the StaticQueryContext "importer"?

Doesn't anyone have example Java code of how to load a library module and a main module that uses
the library module?

(I am using Saxon 8.3 under Windows XP and JDK 1.4.2_04)

Thanks for any help,