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. 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 file. An external entity's public identifier is used for mapping to the URI reference.

The URI of any 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 file changes, you only need to make revision accordingly on the public identifier within the catalog.
  • Establish a local cache mechanism to locate the files associated to 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"/> ... <!-- Demo/Experimental --> 
      <public publicId="-//IBM//DTD DITA Element Reference//EN" 
      uri="demo/elementref/elementref_shell.dtd"/> <public 
      publicId="-//IBM//ELEMENTS DITA Element Reference//EN" 
      uri="demo/elementref/elementref.mod"/> <public 
      publicId="-//IBM//DTD DITA FAQ//EN" uri="demo/faq/faq_shell.dtd"/> 
      <public publicId="-//IBM//ELEMENTS DITA FAQ//EN" 
      uri="demo/faq/faq.mod"/> </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 tried 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 set the main pathname prefix that all URIs are located relative to.

Demo/Experimental section

The Demo/Experimental section in the catalog-dita.xml file is the section to place demo or experimental dtd descriptions. New DITA specialization features can be added in these descriptions. For example, if you want to use the public identifier, -//IBM//DTD SAMPLE//EN, to refer to the file with the pathname dtd/sample/mysample.dtd, put the following catalog entry within the Demo/Experimental section.

<public publicId="-//IBM//DTD SAMPLE//EN" 
        uri="sample/mysample.dtd"/>