Class XMLResolver


  • public class XMLResolver
    extends java.lang.Object
    The XML Resolver.

    This class is the main entry point for the XML Resolver APIs. It provides methods to construct resolver APIs for many parsers as well as methods to lookup catalog entries or resolve resources through the catalog directly.

    Use the XMLResolverConfiguration to control the configuration of the resolver.

    • Constructor Detail

      • XMLResolver

        public XMLResolver()
        Construct a new resolver with a default configuration.
      • XMLResolver

        public XMLResolver​(ResolverConfiguration config)
        Construct a new resolver with the specified configuration.
        Parameters:
        config - the configuration
    • Method Detail

      • getConfiguration

        public ResolverConfiguration getConfiguration()
        Get the configuration associated with this resolver.
        Returns:
        the configuration
      • getRequest

        public ResourceRequest getRequest​(java.lang.String uri)
        Construct a resource request for the given URI.

        This request will use the specified URI without a base URI and with a RDDL nature of "any" and a RDDL purpose of "any".

        Parameters:
        uri - The URI.
        Returns:
        The request.
      • getRequest

        public ResourceRequest getRequest​(java.lang.String uri,
                                          java.lang.String baseUri)
        Construct a resource request for the given URI and base URI.

        This request will use the specified URIs with a RDDL nature of "any" and a RDDL purpose of "any".

        Parameters:
        uri - The URI.
        baseUri - The base URI.
        Returns:
        The request.
      • getRequest

        public ResourceRequest getRequest​(java.lang.String uri,
                                          java.lang.String nature,
                                          java.lang.String purpose)
        Construct a resource request for the given URI, nature, and purpose.

        This request will use the specified URI without a base URI using the RDDL nature and purpose specified. See ResolverConstants for a list of natures and purposes.

        Parameters:
        uri - The URI.
        nature - The RDDL nature.
        purpose - The RDDL purpose.
        Returns:
        The request.
      • getRequest

        public ResourceRequest getRequest​(java.lang.String uri,
                                          java.lang.String baseUri,
                                          java.lang.String nature,
                                          java.lang.String purpose)
        Construct a resource request for the given URI, base URI, nature, and purpose.

        This request will use the specified URIs and the RDDL nature and purpose specified. See ResolverConstants for a list of natures and purposes.

        Parameters:
        uri - The URI.
        baseUri - The base URI.
        nature - The RDDL nature.
        purpose - The RDDL purpose.
        Returns:
        The request.
      • lookupEntity

        public ResourceResponse lookupEntity​(java.lang.String publicId,
                                             java.lang.String systemId)
        Lookup an entity in the catalog.

        This method searches for the specified entity in the catalog.

        This method does not attempt to resolve the resource beyond finding it in the catalog.

        Either the system or public identifier may be null, but at least one of them should have a value.

        Parameters:
        publicId - The system identifier.
        systemId - The public identifier.
        Returns:
        The response.
      • lookupEntity

        public ResourceResponse lookupEntity​(java.lang.String publicId,
                                             java.lang.String systemId,
                                             java.lang.String baseUri)
        Lookup an entity in the catalog.

        This method searches for the specified entity in the catalog.

        This method does not attempt to resolve the resource beyond finding it in the catalog.

        Either the system or public identifier may be null, but at least one of them should have a value.

        If lookup fails for the system identifier, it will be made absolute with respect to the base URI (if possible) and the search will be repeated for the new URI.

        Parameters:
        publicId - The system identifier.
        systemId - The public identifier.
        baseUri - The base URI.
        Returns:
        The response.
      • lookupDoctype

        public ResourceResponse lookupDoctype​(java.lang.String name)
        Lookup a document type in the catalog.

        This method searches for the specified doctype in the catalog.

        This method does not attempt to resolve the resource beyond finding it in the catalog.

        Parameters:
        name - The doctype name.
        Returns:
        The response.
      • lookupDoctype

        public ResourceResponse lookupDoctype​(java.lang.String name,
                                              java.lang.String publicId,
                                              java.lang.String systemId)
        Lookup a document type in the catalog.

        This method searches for the specified doctype in the catalog.

        This method does not attempt to resolve the resource beyond finding it in the catalog.

        Parameters:
        name - The doctype name.
        publicId - The public identifier.
        systemId - The system identifier.
        Returns:
        The response.
      • lookupDoctype

        public ResourceResponse lookupDoctype​(java.lang.String name,
                                              java.lang.String publicId,
                                              java.lang.String systemId,
                                              java.lang.String baseUri)
        Lookup a document type in the catalog.

        This method searches for the specified doctype in the catalog.

        This method does not attempt to resolve the resource beyond finding it in the catalog.

        Either the system or public identifier may be null, but at least one of them should have a value.

        If lookup fails for the system identifier, it will be made absolute with respect to the base URI (if possible) and the search will be repeated for the new URI.

        Parameters:
        name - The doctype name.
        publicId - The public identifier.
        systemId - The system identifier.
        baseUri - the base URI.
        Returns:
        The response.
      • lookupUri

        public ResourceResponse lookupUri​(java.lang.String href)
        Lookup a uri in the catalog.

        This method searches for the specified URI in the catalog using any RDDL nature or purpose.

        This method does not attempt to resolve the resource beyond finding it in the catalog.

        Parameters:
        href - The URI.
        Returns:
        The response.
      • lookupUri

        public ResourceResponse lookupUri​(java.lang.String href,
                                          java.lang.String baseUri)
        Lookup a URI in the catalog.

        This method searches for the specified URI in the catalog using any RDDL nature or purpose.

        This method does not attempt to resolve the resource beyond finding it in the catalog.

        If lookup fails for the href, it will be made absolute with respect to the base URI (if possible) and the search will be repeated for the new URI.

        Parameters:
        href - The URI.
        baseUri - the base URI.
        Returns:
        The response.
      • lookupNamespace

        public ResourceResponse lookupNamespace​(java.lang.String href,
                                                java.lang.String nature,
                                                java.lang.String purpose)
        Lookup a URI in the catalog.

        This method searches for the specified URI in the catalog using the specified RDDL nature and purpose.

        This method does not attempt to resolve the resource beyond finding it in the catalog.

        Parameters:
        href - The URI.
        nature - the RDDL nature.
        purpose - the RDDL purpose.
        Returns:
        The response.
      • lookup

        public ResourceResponse lookup​(ResourceRequest request)
        Lookup a resource request in the catalog.

        This method searches for the resource identified by the request.

        This method does not attempt to resolve the resource beyond finding it in the catalog.

        Parameters:
        request - The request.
        Returns:
        The response.
      • resolve

        public ResourceResponse resolve​(ResourceRequest request)
        Attempts to resolve a request.

        This method searches for the resource identified by the request in the catalog.

        If a matching catalog entry is found, the URI provided by that entry is taken as the URI to use for resolution. The resolver will then attempt to access that resource and return a stream that can be used to read it. Any additional details provided by the response (content type, headers, etc.) are also made available.

        If a matching entry is not found, the behavior depends on the ResolverFeature.ALWAYS_RESOLVE feature setting. If it's true, the resolver will attempt to access the original URI. Otherwise, it returns a response that indicates that resolution was unsuccessful.

        Parameters:
        request - The request.
        Returns:
        The response.
      • getURIResolver

        public javax.xml.transform.URIResolver getURIResolver()
        Get a URIResolver.
        Returns:
        A URI resolver.
      • getEntityResolver

        public SAXAdapter getEntityResolver()
        Get a SAXAdapter.
        Returns:
        An entity resolver.
      • getEntityResolver2

        public SAXAdapter getEntityResolver2()
        Get a SAXAdapter.
        Returns:
        An entity resolver.
      • getXMLResolver

        public javax.xml.stream.XMLResolver getXMLResolver()
        Returns:
        an XML resolver.