In order to use XML Catalogs with Xerces, the
Apache XML Commons Resolver:
resolver.jar needs to be on your classpath (or accessible
in some other way to the ClassLoader). The resolver provides an implementation
of OASIS XML Catalogs v1.1
as well as some other catalog formats. The XML Commons Resolver 1.2 is included with
the binary distribution of Xerces. For information about interacting directly with
the Resolver's API visit the XML Commons
As a convenience for users the parser provides a utility class:
org.apache.xerces.util.XMLCatalogResolver which encapsulates
the XML Commons Resolver exposing methods relevant to resolving XML entities.
It implements the (
XNI entity resolver, the (
org.xml.sax.EntityResolver) SAX entity resolver
and the (
org.w3c.dom.ls.LSResourceResolver) DOM resource resolver
XMLCatalogResolver the resolveEntity methods only query the
catalog for a mapping of the given identifier. These methods may be overridden if
other behaviour is required.
XMLCatalogResolver as an XNI EntityResolver you need
to do something like this:
String  catalogs =
// Create catalog resolver and set a catalog list.
XMLCatalogResolver resolver = new XMLCatalogResolver();
// Set the resolver on the parser.
Note that setting an XNI entity resolver on a SAX or DOM parser will
replace any type of entity resolver which was previously registered. If
some other type of resolver is registered on the parser it will replace
any XNI entity resolver previously registered.
In addition to being used as an entity resolver, it is intended that
XMLCatalogResolver may be used standalone to perform
catalog resolution outside of a parsing context. It may also be shared
between several parsers and the application. See the API
documentation for details.
The XMLCatalogResolver class requires the XML Commons Resolver 1.1
or a version compatible with 1.1.