How Catalogs Work
Catalogs can be used to redirect both DTDs and XML Schemas. While the concept behind the mechanisms of both cases is the same, the details are different and are explained below.
Catalogs are commonly used to redirect a call to a DTD to a local URI. This is achieved by mapping, in the catalog file, public or system identifiers to the required local URI. So when the DOCTYPE declaration in an XML file is read, its public or system identifier locates the required local resource via the catalog file mapping.
For popular schemas, the PUBLIC identifier is usually pre-defined, thus requiring only that the URI in the catalog file map the PUBLIC identifier to the correct local copy. When the XML document is parsed, the PUBLIC identifier in it is read. If this identifier is found in a catalog file, then the corresponding URL in the catalog file will be looked up and the schema will be read from this location. So, for example, if the following SVG file is opened in RaptorXML+XBRL Server:
<?xml version="1.0" standalone="no"?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN"
<svg width="20" height="20" xml:space="preserve">
<g style="fill:red; stroke:#000000">
<rect x="0" y="0" width="15" height="15"/>
<rect x="5" y="5" width="15" height="15"/>
The catalog is searched for the PUBLIC identifier of this SVG file. Let's say the catalog file contains the following entry:
<public publicId="-//W3C//DTD SVG 1.1//EN" uri="schemas/svg/svg11.dtd"/>
In this case, there is a match for the PUBLIC identifier. As a result, the lookup for the SVG DTD is redirected to the URL schemas/svg/svg11.dtd (which is relative to the catalog file). This is a local file that will be used as the DTD for the SVG file. If there is no mapping for the Public ID in the catalog, then the URL in the XML document will be used (in the SVG fie example above, this is the Internet URL: http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd).
In RaptorXML+XBRL Server, you can also use catalogs with XML Schemas. In the XML instance file, the reference to the schema will occur in the xsi:schemaLocation attribute of the XML document's top-level element. For example,
The value of the xsi:schemaLocation attribute has two parts: a namespace part (green above) and a URI part (highlighted). The namespace part is used in the catalog to map to the alternative resource. For example, the following catalog entry redirects the schema reference above to a schema at an alternative location.
<uri name="http://www.xmlspy.com/schemas/orgchart" uri="C:\MySchemas\OrgChart.xsd"/>
Normally, the URI part of the xsi:schemaLocation attribute's value 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 must 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 attribute's value to be valid.