Interface ModuleURIResolver

All Superinterfaces:
All Known Implementing Classes:

public interface ModuleURIResolver
extends Serializable

A ModuleURIResolver is used when resolving references to query modules. It takes as input a URI that identifies the module to be loaded, and a set of location hints, and returns one or more StreamSource obects containing the queries to be imported.

Michael H. Kay

Method Summary
 StreamSource[] resolve(String moduleURI, String baseURI, String[] locations)
          Locate a query module, or a set of query modules, given the identifying URI and a set of associated location hints.

Method Detail


StreamSource[] resolve(String moduleURI,
                       String baseURI,
                       String[] locations)
                       throws XPathException
Locate a query module, or a set of query modules, given the identifying URI and a set of associated location hints.

The module URI resolver is always invoked when locating library modules. It is also invoked when loading the main query module in cases where this is provided in the form of a URI: specifically, when running a query from the command line specifying the -u option, or with a supplied query file name that starts with "http:" or "file:". When locating the main query module, the moduleURI and baseURI parameters will be null, and the resolver must either return null (which delegates to the standard ModuleURIResolver), or must return a singleton StreamSource, that is, an array of length 1.

moduleURI - the module URI of the module to be imported; or null when loading a non-library module.
baseURI - The base URI of the module containing the "import module" declaration; null if no base URI is known
locations - The set of URIs specified in the "at" clause of "import module", which serve as location hints for the module
an array of StreamSource objects each identifying the contents of a query module to be imported. Each StreamSource must contain a non-null absolute System ID which will be used as the base URI of the imported module, and either an InputStream or an Reader representing the text of the module.

The contained InputStream or Reader must be positioned at the start of the content to be read; it will be consumed by the system and will be closed after use.

The method may alternatively return null, in which case the system attempts to resolve the URI using the standard module URI resolver.

XPathException - if the module cannot be located, and if delegation to the default module resolver is not required.

Copyright (c) 2004-2010 Saxonica Limited. All rights reserved.