Class 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 the jar URI scheme; it also accepts classpath URIs as defined in the Spring framework.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      protected javax.xml.transform.stream.StreamSource getQuerySource​(java.net.URI absoluteURI)
      Get a StreamSource object representing the source of a query, given its URI.
      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.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • StandardModuleURIResolver

        public StandardModuleURIResolver()
        Create a StandardModuleURIResolver. Although the class is generally used as a singleton, a public constructor is provided so that the class can be named in configuration files and instantiated in the same way as user-written module URI resolvers.
      • StandardModuleURIResolver

        public StandardModuleURIResolver​(Configuration config)
        Create a StandardModuleURIResolver. Although the class is generally used as a singleton, a public constructor is provided so that the class can be named in configuration files and instantiated in the same way as user-written module URI resolvers.
    • Method Detail

      • resolve

        public javax.xml.transform.stream.StreamSource[] resolve​(java.lang.String moduleURI,
                                                                 java.lang.String baseURI,
                                                                 java.lang.String[] locations)
                                                          throws XPathException
        Resolve a module URI and associated location hints.
        Specified by:
        resolve in interface ModuleURIResolver
        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 known
        locations - 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
      • getQuerySource

        protected javax.xml.transform.stream.StreamSource getQuerySource​(java.net.URI absoluteURI)
                                                                  throws XPathException
        Get a StreamSource object representing the source of a query, given its URI. This method attempts to discover the encoding by reading any HTTP headers. If the encoding can be determined, it returns a StreamSource containing a Reader that performs the required decoding. Otherwise, it returns a StreamSource containing an InputSource, leaving the caller to sort out encoding problems.
        Parameters:
        absoluteURI - the absolute URI of the source query
        Returns:
        a StreamSource containing a Reader or InputSource, as well as a systemID representing the base URI of the query.
        Throws:
        XPathException - if the URIs are invalid or cannot be resolved or dereferenced, or if any I/O error occurs