HowTo/XmlCommonsResolver

This page describes how to use the XML Commons Resolver with Apache FOP. It shows you how you can use abstract URIs to specify resources such as images and how you can translate these abstract URIs to actual URLs pointing to the real file. This is ideal to do a mapping for resources for which the final location at deployment time is not known. The catalog file is where you specify how the URIs are supposed to be mapped to the concrete URLs.

Please note that this currently doesn't work, yet! And it will only work with the new FOP!

Get XML Commons Resolver

You can download it at: [WWW] http://xml.apache.org/mirrors.cgi

The main website is at: [WWW] http://xml.apache.org/commons/components/resolver/

The Example

You can download the source for the example from the web using the following links:

Setup instructions

     -Dxml.catalog.files="C:/Dev/Java/workspace/FOP Main Sandbox/src/xml/fop-demo-catalog.xml"

(Obviously, you will need to adjust the path. You simply need to make sure that the path is right and the catalog file is found.

Notes

You will recognize that the FO file is specified through a "URN", too, not just the image referenced in the FO file. This is simply to make it easier for you to set up the demo. The FO file itself will be loaded directly from the Web.

TODO

At the moment, this example doesn't work, since the resolution mechanism requires StreamSource instance to be returned by the resolver, readily set up with an InputStream. The XML Commons Resolver doesn't do that. It actually returns a SAXSource on which the SystemID is set. The ImageFactory there has to be able to convert the SystemID into a URL and get the InputStream through that URL. Care needs to be taken that the InputStream is properly closed after usage.

last edited 2007-03-27 08:11:13 by VincentHennebert