RE: [xml] attach a local catalog

There is a typical use-case for XSLT processing of documents in which a
local XML catalog comes handy. The following example refers to the DocBook
stylesheets; they are designed in a modular fashion and are intended to be

The following 'works for me'(TM) and can probably be done in a more elegant

The purposes are 

 - to make it easy to have local control of entity 
   resolution, since it might be a PITA to affect 
   entity resolution globally,

 - to make it easy to have local customization 
   stylesheets with overrides and parameter 
   settings for the DocBook stylesheets,

 - to make it easy to have more than one version of 
   the DocBook stylesheets available.

The last two purposes can often be fulfilled without a local XML catalog if
you take care to always use canonical URLs in xsl:include and xsl:import
references in the customization stylesheet. But OTOH, you just might want to
make it easy e.g. to change which version of the 'base' stylesheet to use,
without touching the customization stylesheet.

1) The customization stylesheet is located in the same directory as the
(root) document(s). Any xsl:include and xsl:import references to the 'base'
parts of the DocBook stylesheet should either be written as canonical URLs,
or can be resolved as system identifiers in the local XML catalog (se

2) Point to a local XML catalog:

$ export XML_CATALOG_FILES=./catalog.xml

Unfortunately, XML_CATALOG_FILES seems to be a list of zero or one XML
catalog files. So we must explicitly delegate to the root XML catalog from
the local XML catalog.

3) The root XML catalog, /etc/xml/catalog, should of course have sensible
entries for what gets delegated to it/is not resolved by the local XML

4) An example of a local XML catalog:
<?xml version="1.0"?>
  "-//OASIS//DTD Entity Resolution XML Catalog V1.0//EN" 
<catalog xmlns="urn:oasis:names:tc:entity:xmlns:xml:catalog">

  <!-- delegate to /etc/xml/catalog explicitly; XML_CATALOG_FILES 
       is a list of zero or one XML Catalog files -->

    catalog="file:///etc/xml/catalog" />
    catalog="file:///etc/xml/catalog" />
    catalog="file:///etc/xml/catalog" />

  <!-- some local customization of DocBook etc. 
       goes to another local catalog -->

  <!-- canonical URL references to DocBook stylesheets -->
    catalog="file:///etc/xml/catalog" />
    catalog="file:///etc/xml/catalog" />

  <!-- in case I didn't use canonical URLs for xsl:import'ed 
       stylesheet modules -->
" />


5) Run xsltproc and watch the show:

$ xsltproc --xinclude --nonet chunk.xsl somedocbook.xml 
Writing ch01s02.html for section
Writing ch01s03.html for section
Writing ch01s04.html for section
Writing ch01s05.html for section
Writing ch01s06.html for section
Writing ch01s07.html for section
Writing ch01s08.html for section
Writing ch01s09.html for section
Writing ch01s10.html for section
Writing ch01s11.html for section
Writing index.html for chapter

For greater fun, set XML_DEBUG_CATALOG first:


Kind regards
Peter Ring

-----Original Message-----
From: Michael Rothwell [mailto:rothwell holly-springs nc us]
Sent: 2. september 2002 06:12
To: xml gnome org
Subject: [xml] attach a local catalog

Hi there --

What's the best way to attach a local catalog to a stylesheet document, 
so as to affect the resolution of hrefs for  xsl:include and xsl:import?



xml mailing list, project page
xml gnome org

[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]