RE: [xml] attach a local catalog
- From: Peter Ring <pri magnus dk>
- To: xml gnome org
- Subject: RE: [xml] attach a local catalog
- Date: Mon, 2 Sep 2002 20:36:26 +0200
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
customized.
The following 'works for me'(TM) and can probably be done in a more elegant
fashion.
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
later).
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
catalog.
4) An example of a local XML catalog:
---
<?xml version="1.0"?>
<!DOCTYPE catalog PUBLIC
"-//OASIS//DTD Entity Resolution XML Catalog V1.0//EN"
"http://www.oasis-open.org/committees/entity/release/1.0/catalog.dtd">
<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 -->
<delegatePublic
publicIdStartString="-//OASIS//"
catalog="file:///etc/xml/catalog" />
<delegateSystem
systemIdStartString="http://www.oasis-open.org/"
catalog="file:///etc/xml/catalog" />
<delegateURI
uriStartString="http://www.oasis-open.org/"
catalog="file:///etc/xml/catalog" />
<!-- some local customization of DocBook etc.
goes to another local catalog -->
<delegatePublic
publicIdStartString="-//MAGNUS//"
catalog="magnus.xml"/>
<!-- canonical URL references to DocBook stylesheets -->
<delegateSystem
systemIdStartString="http://docbook.sourceforge.net/release/xsl/"
catalog="file:///etc/xml/catalog" />
<delegateURI
uriStartString="http://docbook.sourceforge.net/release/xsl/"
catalog="file:///etc/xml/catalog" />
<!-- in case I didn't use canonical URLs for xsl:import'ed
stylesheet modules -->
<system
systemId="docbook.xsl"
uri="http://docbook.sourceforge.net/release/xsl/1.50.0/html/docbook.xsl"
/>
<system
systemId="chunk-common.xsl"
uri="http://docbook.sourceforge.net/release/xsl/1.50.0/html/chunk-common.xsl
" />
</catalog>
---
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:
$ export XML_DEBUG_CATALOG=
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?
Thanks,
Michael
_______________________________________________
xml mailing list, project page http://xmlsoft.org/
xml gnome org
http://mail.gnome.org/mailman/listinfo/xml
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]