Why use a resolver?

I chose the preceding DTD example with care. Even though DTDs are no longer fashionable in many circles, it’s a popular, effectively immutable resource served up by the W3C. The W3C web server gets so many requests for the XHTML DTD that it sometimes goes out of its way to make retrieving it painful.

You may have noticed that downloading resources (schemas, DTDs, etc., not the specifications, generally) from the W3C is sometimes very slow. This is a kind of rate limiting effect to save bandwidth. It discourages developers from pounding on their servers. If you don’t take the hint, they’ll even lock you out for a period of time.

Even if the servers you frequently access don’t discourage you from repeatedly downloading the same resources, you (or your customers!) may sometimes have limited connectivity.

Point being: there are lots of URIs which you can usefully cache locally.

There are basically two approaches to local caching: you can setup a proxy server and have it cache things for you, or you can use XML Catalogs. Oh, I don’t dispute there might be other approaches, but those are the two common, obvious ones.

The advantage of the local caching proxy is that it’s automatic. It caches the resources you request according to whatever criteria you establish, it works transparently in the background. No muss, no fuss. Well, except for the fact that you have to install and setup a local caching proxy. You have to use it everywhere. You might have to chain it together with your corporate caching proxy. You also have to configure the criteria for local caching. I find its advantages are a lot more theoretical than practical.

The XML Resolver project is about doing it with catalogs, but it will also cache resources for you!

XML Catalogs are straightforward; you provide an XML document that has mappings from identifiers that might appear in documents to local resources that should be returned for those identifiers.

Here’s an example:

<catalog xmlns="urn:oasis:names:tc:entity:xmlns:xml:catalog">
  <system systemId="http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"
          uri="/share/dtds/xhtml1-strict.dtd"/>
</catalog>

If you load that catalog, attempts to obtain the XHTML DTD from the W3C will be satisfied by a local copy of the DTD obtained from the /share/dtds/xhtml1-strict.dtd.

You can write catalogs that suit your resources, and they can be chained together to work with and across multiple projects.