XML Catalog API Interfaces

Access the XML Catalog API through its interfaces.

XML Catalog API Interfaces

The XML Catalog API defines the following interfaces:

  • The Catalog interface represents an entity catalog as defined by XML Catalogs, OASIS Standard V1.1, 7 October 2005. A Catalog object is immutable. After it’s created, the Catalog object can be used to find matches in a system, public, or uri entry. A custom resolver implementation may find it useful to locate local resources through a catalog.

  • The CatalogFeatures class provides the features and properties the Catalog API supports, including javax.xml.catalog.files, javax.xml.catalog.defer, javax.xml.catalog.prefer, and javax.xml.catalog.resolve.

  • The CatalogManager class manages the creation of XML catalogs and catalog resolvers.

  • The CatalogResolver interface is a catalog resolver that implements SAX EntityResolver, StAX XMLResolver, DOM LS LSResourceResolver used by schema validation, and transform URIResolver. This interface resolves external references using catalogs.

Details on the CatalogFeatures Class

The catalog features are collectively defined in the CatalogFeatures class. The features are defined at the API and system levels, which means that they can be set through the API, system properties, and JAXP properties. To set a feature through the API, use the CatalogFeatures class.

The following code sets javax.xml.catalog.resolve to continue so that the process continues even if no match is found by the CatalogResolver:

CatalogFeatures f = CatalogFeatures.builder().with(Feature.RESOLVE, "continue").build();

To set this continue functionality system-wide, use the Java command line or System.setProperty method:

System.setProperty(Feature.RESOLVE.getPropertyName(), "continue");

To set this continue functionality for the whole JVM instance, enter a line in the jaxp.properties file:

javax.xml.catalog.resolve = "continue"

The jaxp.properties file is typically in the $JAVA_HOME/conf directory.

The resolve property, as well as the prefer and defer properties, can be set as an attribute of the catalog or group entry in a catalog file. For example, in the following catalog, the resolve attribute is set with the value continue. The attribute can also be set on the group entry as follows:

<?xml version="1.0" encoding="UTF-8"?> 
<catalog
  xmlns="urn:oasis:names:tc:entity:xmlns:xml:catalog"
  resolve="continue"
  xml:base="http://local/base/dtd/">
  <group resolve="continue">
    <system
      systemId="http://remote/dtd/alice/docAlice.dtd"
      uri="http://local/dtd/docAliceSys.dtd"/>     
  </group> 
</catalog>

Properties set in a narrower scope override those that are set in a wider one. Therefore, a property set through the API always takes preference.