XML Catalogs

from Wikipedia, the free encyclopedia

XML Catalogs is a technique for replacing external references in XML documents. Here is the parsing of XML checks if there is a replacement rule for the referenced external file in the catalog. If an applicable rule is found here, the reference in the file is replaced by the reference from the catalog. The catalog itself is an XML file that must be made known to the parser. XML Catalogs is an OASIS standard.

XML Catalogs has two primary uses:

  1. Replacing remote files with local files: Many files include additional external files. If a network connection has to be established each time, execution is slowed down and, in the event of a connection error, may be disrupted. In addition, servers that provide frequently used files (for example the servers of the W3C for the DTD of XHTML below http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd) can be overloaded.
  2. Replacing references with others: For example, old URLs or outdated schemes can be replaced with new ones without having to make changes to the respective document or application. This is a common technique for XML interfaces (where the data format of external sources often cannot be influenced).

Examples

The following example shows a catalog (usually saved in a file with the name catalog.xml) that provides a local DTD for the external reference with the system identifier . The same procedure is used for the other two DTDs. http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtddtd/xhtml1/xhtml1-strict.dtd

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

    <system systemId="http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"
            uri="dtd/xhtml1/xhtml1-strict.dtd"/>

    <system systemId="http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"
            uri="dtd/xhtml1/xhtml1-transitional.dtd"/>

    <system systemId="http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd"
            uri="dtd/xhtml11/xhtml11-flat.dtd"/>

  </catalog>

The problem can also be solved for several documents by replacing entire parts of the URI :

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

    <rewriteURI uriStartString="http://www.w3.org/TR/xhtml1/DTD/" rewritePrefix="dtd/"/>

  </catalog>

The following catalog assigns the same local DTD to different system identifiers (e.g. different spellings):

<?xml version="1.0"?>
<!DOCTYPE catalog PUBLIC "-//OASIS//DTD Entity Resolution XML Catalog V1.1//EN" "http://www.oasis-open.org/committees/entity/release/1.1/catalog.dtd">

<catalog xmlns="urn:oasis:names:tc:entity:xmlns:xml:catalog">
	<systemSuffix systemIdSuffix="xhtml1-strict.dtd" uri="dtd/xhtml1/xhtml1-strict.dtd"/>
	<systemSuffix systemIdSuffix="XHTML1-STRICT.dtd" uri="dtd/xhtml1/xhtml1-strict.dtd"/>
</catalog>

This functionality was only included in the catalog standard with version 1.1.

Web links