XML Catalog

This is an introduction of XML catalog.

An XML catalog, which can be physically composed of several catalog entry files, is a logical structure that describes mapping information for various resources. A catalog entry file is an xml file that includes a group of catalog entries.

A catalog entry can be used to locate a unified resource identifier (URI) reference for a certain resource such as a DTD or Schema module. An external entity's public identifier is used for mapping to the URI reference.

When the Public ID and System ID are both specified in a document, and the Public ID is used to locate a resource, the URI of the System identifier can be ignored.

Why use XML Catalog

XML Catalogs are used to make the XML setup more flexible and portable. Using XML Catalogs, you can:
  • Map from the logical names such as the public identifiers. The public identifier is safer and more stable to use to locate a specific file than the system identifier. Even if the physical location of the resource changes, you only need to make revision accordingly on the public identifier within the catalog.
  • Move documents without changing references. If a document uses another resource, and the location of the document changes, the Public ID remains valid and the content is still valid.
  • Establish a local cache mechanism to locate the files associated with public identifiers or remote resources. With this mechanism the delay that occurs when locating remote resources can be avoided.

An XML Catalog Example

Here is an example of a XML Catalog file.

Example 1. An XML Catalog File: catalog-dita.xml.

 <?xml version="1.0" ?> 
<catalog xmlns="urn:oasis:names:tc:entity:xmlns:xml:catalog" prefer="public"> 
  <!-- Catalog for DITA -->
  <!-- DITA DTDs -->
  <group xml:base="dtd">
    <public publicId="-//IBM//DTD DITA Concept//EN" uri="concept.dtd"/>
    <public publicId="-//IBM//ELEMENTS DITA Concept//EN" uri="concept.mod"/>
  </group>
</catalog>
Note:
  1. The catalog element contains all other entries, and also includes a catalog namespace identifier. The attribute of prefer is set to public, which means that the public identifiers are used to resolve the catalog before using the system identifiers.
  2. The group element is simply a wrapper element where the attributes such as xml:base are set. These attributes apply to all entries that are within the group content. The xml:base attribute sets the main pathname prefix that all URIs are located relative to; so, in the example above, concept.dtd will be found in the dtd/ directory (relative to the location of the catalog).