Table of Contents
Customised Catalog Resolver
1 Introduction
Those DeltaXML product's that provide catalog support use a customised variant of the Apache Commons OASIS resolver; specifically, we customise version 1.2 of the Apache resolver. These customisations are broadly classified into three groups:
Fixes to bug's 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.
Enhancments, mainly to support the use of 'in-built' catalog's when in application server environments.
2 Customisations
2.1 Fixes to known Bugs
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
FileURLclass in theorg.apache.xml.resolver.helperspackage has been updated appropriately.
2.2 Fixes to minor featurs
Ensure verbosity setting is used: The
xml.verbositysystem property is not used when constructing a catalog via a default instantication of theCatalogResolverin theorg.apache.xml.resolver.toolspackage. 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 theinitializeCatalogs(boolean privateCatalog)method of theCatalogResolverin theorg.apache.xml.resolver.toolspackage.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
Catalogclass's instantciation of the XML parser.
2.3 Enhancements
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
CatalogFixSlashesclass to theorg.apache.xml.resolverpackage. 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.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, wheremy_catalog_entry_idis 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
UrlResourceHandlerinterface to theorg.apache.xml.resolver.helperspackage, which has a single method for opening a URL as anInputStream; i.e. theopenStream(URL url)method. In addition, we needed to update the:CatalogManagerandCatalogclasses in theorg.apache.xml.resolverpackage so that they can get, set and use the UrlResourceHandlers; andCatalogResolver,ResolvingXMLFilter, andResolvingParserin theorg.apache.xml.resolver.toolspackage, so that each call to open a URL stream was sent via the newUrlResourceHandler.
CatalogManagerandCatalogclasses in theorg.apache.xml.resolverpackage so that they can get, set and use the UrlResourceHandlers; andCatalogResolver,ResolvingXMLFilter, andResolvingParserin theorg.apache.xml.resolver.toolspackage, so that each call to open a URL stream was sent via the newUrlResourceHandler.
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:
org.apache.xml.resolver.Catalog.javaorg.apache.xml.resolver.CatalogFixSlashes.javaorg.apache.xml.resolver.CatalogManager.javaorg.apache.xml.resolver.helpers.FileURL.javaorg.apache.xml.resolver.helpers.UrlResourceHandler.javaorg.apache.xml.resolver.tools.CatalogResolver.javaorg.apache.xml.resolver.tools.ResolvingParser.javaorg.apache.xml.resolver.tools.ResolvingXMLFilter.java
The complete source code to our customised version of the Apache commons resolver is available on request.
