Example DocBook catalog file

Here is a complete example of an XML catalog file that can resolve PUBLIC and SYSTEM identifiers for the DocBook DTD, and references to stylesheets. It assumes all the DocBook files are stored under /usr/share/xml so the group xml:base="/usr/share/xml/" element provides the main pathname prefix. You would need to replace that path with your own. If your system puts the stylesheet under a different location from the DTD, then you would need two group elements to specify the two xml:base values.

Example 5.4. Example XML catalog file

<?xml version="1.0"?>
<!DOCTYPE catalog
   PUBLIC "-//OASIS/DTD Entity Resolution XML Catalog V1.0//EN"

<catalog xmlns="urn:oasis:names:tc:entity:xmlns:xml:catalog">

  <!-- DTD and stylesheet files installed under /usr/share/xml -->
  <group  xml:base="file:///usr/share/xml/">

    <!-- Resolve DTD URL system ID to local file -->
        rewritePrefix="docbook45/" />
    <!-- Resolve stylesheet URL to local file -->
        rewritePrefix="docbook-xsl-1.73.1/" />

    <!-- Resolve DTD PUBLIC identifiers -->
    <nextCatalog  catalog="docbook45/catalog.xml" />

    <!-- To resolve simple DTD SYSTEM identifiers. -->
    <!-- Note: this does not work with Java resolver -->
    <!--   classes in Saxon or Xalan -->
         uri="docbook45/docbookx.dtd" />

    <!-- To resolve short stylesheet references -->
        uri="docbook-xsl-1.73.1/html/docbook.xsl" />
        uri="docbook-xsl-1.73.1/html/chunk.xsl" />
        uri="docbook-xsl-1.73.1/fo/docbook.xsl" />



It is sometimes useful to include DTD catalog entries for both the system and public identifiers. Oddly enough, that may negate the use of a prefer="public" attribute in the catalog for that DTD. The rules for catalog resolution say that the given DOCTYPE system identifier is first checked against the catalog system entries, regardless of the prefer setting. If the given system identifier is matched in the catalog, then that match is always used. If there is no match on the system identifier in the catalog, then the prefer="public" setting comes into play and means the catalog should first check for a match on the public identifier of the DTD. If that is not matched in the catalog, then the given system identifier is used. If prefer="system", then the public identifier is ignored entirely.