Package net.sf.saxon.lib
Class StandardModuleURIResolver
- java.lang.Object
-
- net.sf.saxon.lib.StandardModuleURIResolver
-
- All Implemented Interfaces:
ModuleURIResolver
public class StandardModuleURIResolver extends java.lang.Object implements ModuleURIResolver
This class is the standard ModuleURIResolver used to implement the "import module" declaration in a Query Prolog. It is used when no user-defined ModuleURIResolver has been specified, or when the user-defined ModuleURIResolver decides to delegate to the standard ModuleURIResolver. It relies on location hints being supplied in the "import module" declaration, and attempts to locate a module by dereferencing the URI given as the location hint. It accepts standard URIs recognized by the Java URL class, including thejarURI scheme; it also acceptsclasspathURIs as defined in the Spring framework.
-
-
Constructor Summary
Constructors Constructor Description StandardModuleURIResolver()Create a StandardModuleURIResolver.StandardModuleURIResolver(Configuration config)Create a StandardModuleURIResolver, with a supplied configuration
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description javax.xml.transform.stream.StreamSource[]resolve(java.lang.String moduleURI, java.lang.String baseURI, java.lang.String[] locations)Resolve a module URI and associated location hints.protected javax.xml.transform.stream.StreamSourceresolveLocationHint(java.lang.String baseURI, java.lang.String locationHint)Resolve a location hint appearing in an "import module" declarationprotected javax.xml.transform.stream.StreamSourceresolveModuleURI(java.lang.String moduleURI, java.lang.String baseURI)Attempt to resolve the module namespace URI without the help of location hints.voidsetConfiguration(Configuration config)Set the Configuration that this resolver uses.
-
-
-
Constructor Detail
-
StandardModuleURIResolver
public StandardModuleURIResolver()
Create a StandardModuleURIResolver. If this constructor is used, a configuration must be supplied in a subsequent call. The constructor is provided to allow instantiation from a Configuration file.
-
StandardModuleURIResolver
public StandardModuleURIResolver(Configuration config)
Create a StandardModuleURIResolver, with a supplied configuration- Parameters:
config- the Saxon Configuration object
-
-
Method Detail
-
setConfiguration
public void setConfiguration(Configuration config)
Set the Configuration that this resolver uses. Has no effect if the configuration has already been supplied by the constructor.- Parameters:
config- the Saxon Configuration object
-
resolve
public javax.xml.transform.stream.StreamSource[] resolve(java.lang.String moduleURI, java.lang.String baseURI, java.lang.String[] locations) throws XPathExceptionResolve a module URI and associated location hints.The logic of this is as follows:
- First, call the configuration-level ResourceResolver to resolve the module URI as a namespace (via the method resolveModuleURI, which can be overridden in a subclass).
- If this returns null and there are no location hints, throw XQST0059.
- Otherwise attempt to resolve each of the supplied location hints in turn, using first the configuration-level ResourceResolver and then the fallback DirectResourceResolver, via the method resolveLocationHint, which can be overridden in a subclass. Return an array containing any non-null results; if there are none, throw XQST0059.
- Specified by:
resolvein interfaceModuleURIResolver- Parameters:
moduleURI- The module namespace 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 knownlocations- The set of URIs specified in the "at" clause of "import module", which serve as location hints for the module- Returns:
- an array of StreamSource objects each identifying the contents of a 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 InputSource or a Reader representing the text of the module.
- Throws:
XPathException- (error XQST0059) if the module cannot be located
-
resolveModuleURI
protected javax.xml.transform.stream.StreamSource resolveModuleURI(java.lang.String moduleURI, java.lang.String baseURI)Attempt to resolve the module namespace URI without the help of location hints.- Parameters:
moduleURI- the namespace URI of the module being importedbaseURI- the base URI of the module containing the "import module" declaration- Returns:
- a StreamSource delivering the contents of the module.
-
resolveLocationHint
protected javax.xml.transform.stream.StreamSource resolveLocationHint(java.lang.String baseURI, java.lang.String locationHint) throws XPathExceptionResolve a location hint appearing in an "import module" declaration- Parameters:
baseURI- the base URI of the "import module" declarationlocationHint- the location hint, as written- Returns:
- either a StreamSource representing the content of the module, or null
- Throws:
XPathException- if the URI is invalid or can't be resolved (but not if the module simply doesn't exist at that location)
-
-