XML technologies / DocBook / XML catalogs / XML catalogs verification

(Excerpt from "DocBook-XML: Media-neutral and platform-independent publishing" by Thomas Schraitle)

If a DTD cannot be found, a missing or incorrect catalog entry is often the cause. There are two ways to trace resolution:

  1. using the program xmlcatalog

  2. using the variable XML_DEBUG_CATALOG and the program xmllint

The command xmlcatalog can add or remove catalog entries and also perform lookups. This example uses the catalog from "testCatalog.xml". Entering

xmlcatalog testCatalog.xml "-//OASIS//DTD DocBook XML V4.5//EN"

produces

file:///usr/share/xml/docbook/schema/dtd/4.5/docbookx.dtd

The option -v makes the command more verbose:

Resolve pubID -//OASIS//DTD DocBook XML V4.5//EN
0 Parsing catalog testCatalog.xml
testCatalog.xml added to file hash
Found public match -//OASIS//DTD DocBook XML V4.5//EN
file:///usr/share/xml/docbook/schema/dtd/4.5/docbookx.dtd
Catalogs cleanup
Free catalog entry -//OASIS//DTD DocBook XML V4.5//EN
Free catalog entry http://www.beispiel.de/dtd/v2.3.4/bsp.dtd
Free catalog entry file:///usr/local/doc/xsldbg/catalog.xml
Free catalog entry testCatalog.xml
Free catalog entry

Run this test before investigating other causes. It helps locate typos in your catalog file more quickly.

The other method uses the environment variable XML_DEBUG_CATALOG. To use the preceding catalog (file testCatalog.xml) with the XML parser xmllint, also set the environment variable XML_CATALOG_FILES to the relevant catalogs. A command using an XML file looks like this:

XML_DEBUG_CATALOG=1 XML_CATALOG_FILES=./testCatalog.xml \
xmllint --valid --noout test.xml

set XML_DEBUG_CATALOG=1
set XML_CATALOG_FILES=./testCatalog.xml 
xmllint --valid --noout test.xml

This command produces the same output as the preceding command using xmlcatalog.

  

back to top