Class Resolver

  • All Implemented Interfaces:
    javax.xml.transform.URIResolver, org.w3c.dom.ls.LSResourceResolver, org.xml.sax.EntityResolver, org.xml.sax.ext.EntityResolver2, NamespaceResolver
    Direct Known Subclasses:
    XercesResolver

    public class Resolver
    extends java.lang.Object
    implements javax.xml.transform.URIResolver, org.xml.sax.EntityResolver, org.xml.sax.ext.EntityResolver2, NamespaceResolver, org.w3c.dom.ls.LSResourceResolver
    An implementation of many resolver interfaces.

    This class is probably the most common entry point to the XML Catalog resolver. It has a zero argument constructor so it can be instantiated directly from its class name (for example, passed to an application as a commend line argument or stored in a configuration file). When instantiated this way, it will automatically be configured by system properties and an xmlresolver.properties configuration file, if one exists.

    This class implements the EntityResolver, EntityResolver2, LSResourceResolver and NamespaceResolver, and URIResolver interfaces.

    The StAX XMLResolver interface is implemented by the StAXResolver class because the resolveEntity method of the XMLResolver interface isn't compatible with the EntityResolver2 method of the same name.

    See Also:
    StAXResolver
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      CatalogResolver getCatalogResolver()
      Get the underlying CatalogResolver used by this resolver.
      XMLResolverConfiguration getConfiguration()
      Get the Catalog used by this resolver.
      org.xml.sax.InputSource getExternalSubset​(java.lang.String name, java.lang.String baseURI)
      Implements the EntityResolver2 interface.
      javax.xml.transform.Source resolve​(java.lang.String href, java.lang.String base)
      Implements the URIResolver interface.
      org.xml.sax.InputSource resolveEntity​(java.lang.String publicId, java.lang.String systemId)
      Implements the EntityResolver interface.
      org.xml.sax.InputSource resolveEntity​(java.lang.String name, java.lang.String publicId, java.lang.String baseURI, java.lang.String systemId)
      Implements the EntityResolver2 interface.
      javax.xml.transform.Source resolveNamespace​(java.lang.String uri, java.lang.String nature, java.lang.String purpose)
      Implements the NamespaceResolver interface.
      org.w3c.dom.ls.LSInput resolveResource​(java.lang.String type, java.lang.String namespaceURI, java.lang.String publicId, java.lang.String systemId, java.lang.String baseURI)
      Implements the LSResourceResolver interface.
      static java.lang.String version()
      What version is this? Returns the version number of this resolver instance.
      • Methods inherited from class java.lang.Object

        equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • PURPOSE_SCHEMA_VALIDATION

        public static final java.lang.String PURPOSE_SCHEMA_VALIDATION
        See Also:
        Constant Field Values
      • NATURE_XML_SCHEMA

        public static final java.lang.String NATURE_XML_SCHEMA
        See Also:
        Constant Field Values
      • NATURE_XML_SCHEMA_1_1

        public static final java.lang.String NATURE_XML_SCHEMA_1_1
        See Also:
        Constant Field Values
    • Constructor Detail

      • Resolver

        public Resolver()
        Creates a new instance of Resolver. The default resolver is a new ResourceResolver that uses a static catalog shared by all threads.
      • Resolver

        public Resolver​(XMLResolverConfiguration config)
        Creates a new instance of a Resolver. Creates a resolver using a specific Catalog.
        Parameters:
        config - The configuration to use.
      • Resolver

        public Resolver​(CatalogResolver resolver)
        Creates a new instance of a Resolver. Creates a resolver using a specific underlying ResourceResolver.
        Parameters:
        resolver - The resource resolver to use.
    • Method Detail

      • version

        public static java.lang.String version()
        What version is this? Returns the version number of this resolver instance.
        Returns:
        The version number
      • getConfiguration

        public XMLResolverConfiguration getConfiguration()
        Get the Catalog used by this resolver.
        Returns:
        The underlying catalog.
      • getCatalogResolver

        public CatalogResolver getCatalogResolver()
        Get the underlying CatalogResolver used by this resolver.
        Returns:
        The catalog resolver.
      • resolve

        public javax.xml.transform.Source resolve​(java.lang.String href,
                                                  java.lang.String base)
                                           throws javax.xml.transform.TransformerException
        Implements the URIResolver interface.
        Specified by:
        resolve in interface javax.xml.transform.URIResolver
        Throws:
        javax.xml.transform.TransformerException
      • resolveResource

        public org.w3c.dom.ls.LSInput resolveResource​(java.lang.String type,
                                                      java.lang.String namespaceURI,
                                                      java.lang.String publicId,
                                                      java.lang.String systemId,
                                                      java.lang.String baseURI)
        Implements the LSResourceResolver interface.
        Specified by:
        resolveResource in interface org.w3c.dom.ls.LSResourceResolver
      • getExternalSubset

        public org.xml.sax.InputSource getExternalSubset​(java.lang.String name,
                                                         java.lang.String baseURI)
                                                  throws org.xml.sax.SAXException,
                                                         java.io.IOException
        Implements the EntityResolver2 interface.
        Specified by:
        getExternalSubset in interface org.xml.sax.ext.EntityResolver2
        Throws:
        org.xml.sax.SAXException
        java.io.IOException
      • resolveEntity

        public org.xml.sax.InputSource resolveEntity​(java.lang.String name,
                                                     java.lang.String publicId,
                                                     java.lang.String baseURI,
                                                     java.lang.String systemId)
                                              throws org.xml.sax.SAXException,
                                                     java.io.IOException
        Implements the EntityResolver2 interface.
        Specified by:
        resolveEntity in interface org.xml.sax.ext.EntityResolver2
        Throws:
        org.xml.sax.SAXException
        java.io.IOException
      • resolveEntity

        public org.xml.sax.InputSource resolveEntity​(java.lang.String publicId,
                                                     java.lang.String systemId)
                                              throws org.xml.sax.SAXException,
                                                     java.io.IOException
        Implements the EntityResolver interface.
        Specified by:
        resolveEntity in interface org.xml.sax.EntityResolver
        Throws:
        org.xml.sax.SAXException
        java.io.IOException
      • resolveNamespace

        public javax.xml.transform.Source resolveNamespace​(java.lang.String uri,
                                                           java.lang.String nature,
                                                           java.lang.String purpose)
                                                    throws javax.xml.transform.TransformerException
        Implements the NamespaceResolver interface.
        Specified by:
        resolveNamespace in interface NamespaceResolver
        Parameters:
        uri - The namespace URI.
        nature - The RDDL nature of the resource.
        purpose - The RDDL purpose of the resource.
        Returns:
        A Source object, or null if the href cannot be resolved, and the processor should try to resolve the URI itself.
        Throws:
        javax.xml.transform.TransformerException - If an error occurs