Customized Catalog Resolver

1. Introduction

Those DeltaXML products that provide catalog support use a customized variant of the Apache Commons OASIS resolver; specifically, we customize version 1.2 of the Apache resolver. These customizations are broadly classified into three groups:

  • Fixes to bugs identified on the Apache Commons bug-tracker site (specifically those bugs that have been encountered by DeltaXML's usage of the Appache Common's API)
  • Fixes to minor 'features' identified during the Apache Commons integration.
  • Enhancements, mainly to support the use of 'in-built' catalogs when in application server environments.

2. Customizations

2.1. Fixes to known Bugs

  1. Bug 28719 - Resolver generates an incorrect base URL when user.dir is "/": This bug is resolved in accordance with Drew Wills's contribution.

    Implementation Details: The FileURL class in the org.apache.xml.resolver.helpers package has been updated appropriately.

2.2. Fixes to minor featurs

  1. Ensure verbosity setting is used: The xml.verbosity system property is not used when constructing a catalog via a default instantication of the CatalogResolver in the org.apache.xml.resolver.tools package. When denugging this feature, we discovered that explicitly getting the visibility setting before the catalog is fetched fixes the problem in this case. This hack has been applied.

    Implementation details: Add the statement catalogManager.getVerbosity(); as the first statement in the initializeCatalogs(boolean privateCatalog) method of the CatalogResolver in the org.apache.xml.resolver.tools package.

  2. Explicit instantciation of Xerces parser: We have a requirement to enable staticly determinable linking for some versions of our products, as this enables the IKVM technology to be used to cross-compile a product to .NET framework. A side-effect of this change is that it introduces a circular dependancy between the Catalog resolver and the Xerces SAX parser.

    Implementation details: A straightforward change to the Catalog class's instantciation of the XML parser.

2.3. Enhancements

  1. Slash tolerant catalogs: We have provided an alternative catalog resolver that handles both Unix style and DOS/Windows style paths in a catalog.

    Implementation Details: We have added a CatalogFixSlashes class to the org.apache.xml.resolver package. It is a simple extension of the Apache's Catalog, which by default is configured to handle both Unix style and DOS/Windows style paths in a catalog.

  2. Resource loading catalog support: We have provided a mechanism for catalogs to load entries using Java's resource loading mechanism. The provided default implementation looks for a catalog identifier of the form jar:file:_internal-jar_._rsc_!/my_catalog_entry_id, where my_catalog_entry_id is the identity of the entry to resolve using Java's resource loading mechanism. It attempts to load the resource using the context class loader's getResourceAsStream(name) method, from the current thread of execution.

    Implementation Details: We have added a UrlResourceHandler interface to the org.apache.xml.resolver.helpers package, which has a single method for opening a URL as an InputStream; i.e. the openStream(URL url) method. In addition, we needed to update the:

    • CatalogManager and Catalog classes in the  org.apache.xml.resolver package so that they can get, set and use the UrlResourceHandlers; and
    • CatalogResolver, ResolvingXMLFilter, and ResolvingParser in the org.apache.xml.resolver.tools package, so that each call to open a URL stream was sent via the new UrlResourceHandler.
    • CatalogManager and Catalog classes in the  org.apache.xml.resolver package so that they can get, set and use the UrlResourceHandlers; and
    • CatalogResolver, ResolvingXMLFilter, and ResolvingParser in the org.apache.xml.resolver.tools package, so that each call to open a URL stream was sent via the new UrlResourceHandler.

3. Source Code

Both the original Apache commons resolver and our modifications use version 2 of the Apache License.

All files that we have changed (other than by reformatting in an IDE) and added are made available for download:

The complete source code to our customized version of the Apache commons resolver is available on request.