Using XML Catalogs

According the XML Schema specification, the schemaLocation attributes of include, import and redefine tags are optional and only hints to schema processors for locating files defining other namespaces. With XML catalogs, the actual locations of the schema files can be plugged in into a schema processor like xnsdoc.

xnsdoc accepts OASIS XML catalogs v1.1.

Example 1

Suppose you have a schema file containing the following import tag:

<xsd:import namespace="http://www.buldocs.com/sample/import"
   schemaLocation="http://www.buldocs.com/sample/import.xsd"/>

The schema location is only a hint and might not by available, e.g if working offline. The schema location even might not point to any valid resource!

With the following XML catalog, a location of the schema can be provided independent of the schema files: the schema location is taken as a system-id and mapped to a real location in form of a relative path. The base for the relative path is the location path of the importing schema.

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE catalog PUBLIC "-//OASIS//DTD Entity Resolution XML Catalog V1.0//EN"
    "http://www.oasis-open.org/committees/entity/release/1.0/catalog.dtd">
<catalog xmlns="urn:oasis:names:tc:entity:xmlns:xml:catalog" prefer="public">
  <uri name="http://www.buldocs.com/sample/import.xsd" uri="import.xsd"/>
</catalog>

Example 2

Instead of mapping system-identifiers to actiual locations, you also can map namespace URIs to their actual locations. In this case, relative paths are relative to the base path of the application that executes the XML processor. This is the prefered way, since the schemaLocation attribute is optional.

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE catalog PUBLIC "-//OASIS//DTD Entity Resolution XML Catalog V1.0//EN"
    "http://www.oasis-open.org/committees/entity/release/1.0/catalog.dtd">
<catalog xmlns="urn:oasis:names:tc:entity:xmlns:xml:catalog" prefer="public">
  <uri name="http://www.buldocs.com/sample/import" uri="samples/catalog/import.xsd"/>
</catalog>

Safe Online Shopping

Payment options

Billing currencies

  • 1

Site Conformance

Valid XHTML 1.0 Transitional

Valid CSS!