Catalogs are useful for redirecting calls to remote resources to a local URL. This is achieved by mapping, in the catalog file, public or system identifiers, URIs, or parts of identifiers or URIs to the required local URL.
When the DOCTYPE declaration of a DTD in an XML file is read, the declaration's public or system identifier locates the required resource. If the identifier selects a remote resource or if the identifier is not a locator, it can still be mapped via a catalog entry to a local resource.
For example, consider the following SVG file:
<?xml version="1.0" standalone="no"?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN"
Its public identifier is: -//W3C//DTD SVG 1.1//EN
Its system identifier is: http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd
A catalog entry could map the public identifier to a local URL, like this:
<public publicId="-//W3C//DTD SVG 1.1//EN" uri="schemas/svg/svg11.dtd"/>
Or, a catalog entry could map the system identifier to a local URL, like this:
<system systemId="http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd" uri="schemas/svg/svg11.dtd"/>
If there is a match for the public or system identifier in the catalog, the URL to which it is mapped is used. (Relative paths are resolved with reference to an xml:base attribute in the redirecting catalog element; the fallback base URL is the URL of the catalog file.) If there is no match for the public or system identifier in the catalog, then the URL in the XML document will be used (in the example above: http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd).
The uri element can be used to map a relative or absolute filepath or a Web URL, or just any name, to a local URL, like this:
•<uri name="doc.xslt" uri="C:\Docs\doc.xslt"/>
•<uri name="U:\Docs\2013\doc.xslt" uri="C:\Docs\doc.xslt"/>
•<uri name="http://www.altova.com/schemas/doc.xslt" uri="C:\Docs\doc.xslt"/>
•<uri name="foo" uri="C:\Docs\doc.xslt"/>
When the name value is encountered, it is mapped to the resource specified in the uri attribute. With a different catalog, the same name can be mapped to a different resource. For example, if you have:
Normally, the URI part of the attribute's value (bold in the example above) is a path to the actual schema location. However, if the schema is referenced via a catalog, the URI part need not point to an actual XML Schema, but it does need to exist so that the lexical validity of the xsi:schemaLocation attribute is maintained. A value of foo, for example, would be sufficient for the URI part of the xsi:schemaLocation attribute's value (instead of Orgchart.xsd). The schema is located in the catalog by means of the namespace part of the xsi:schemaLocation attribute's value. In the example above, the namespace part is http://www.altova.com/schemas/orgchart.
In the catalog, the following entry would locate the schema on the basis of that namespace part.
<uri name="http://www.altova.com/schemas/orgchart" uri="C:\MySchemas\OrgChart.xsd"/>
For more information on these elements, see the XML Catalogs specification.