Daniel Veillard | 43d3f61 | 2001-11-10 11:57:23 +0000 | [diff] [blame] | 1 | <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/1999/REC-html401-19991224/loose.dtd"> |
Daniel Veillard | e7ead2d | 2001-08-22 23:44:09 +0000 | [diff] [blame] | 2 | <html> |
| 3 | <head> |
Daniel Veillard | b8cfbd1 | 2001-10-25 10:53:28 +0000 | [diff] [blame] | 4 | <meta content="text/html; charset=ISO-8859-1" http-equiv="Content-Type"> |
Daniel Veillard | c332dab | 2002-03-29 14:08:27 +0000 | [diff] [blame] | 5 | <link rel="SHORTCUT ICON" href="/favicon.ico"> |
Daniel Veillard | b8cfbd1 | 2001-10-25 10:53:28 +0000 | [diff] [blame] | 6 | <style type="text/css"><!-- |
Daniel Veillard | 373a475 | 2002-02-21 14:46:29 +0000 | [diff] [blame] | 7 | TD {font-family: Verdana,Arial,Helvetica} |
| 8 | BODY {font-family: Verdana,Arial,Helvetica; margin-top: 2em; margin-left: 0em; margin-right: 0em} |
| 9 | H1 {font-family: Verdana,Arial,Helvetica} |
| 10 | H2 {font-family: Verdana,Arial,Helvetica} |
| 11 | H3 {font-family: Verdana,Arial,Helvetica} |
Daniel Veillard | b8cfbd1 | 2001-10-25 10:53:28 +0000 | [diff] [blame] | 12 | A:link, A:visited, A:active { text-decoration: underline } |
| 13 | --></style> |
| 14 | <title>Catalog support</title> |
Daniel Veillard | e7ead2d | 2001-08-22 23:44:09 +0000 | [diff] [blame] | 15 | </head> |
Daniel Veillard | b8cfbd1 | 2001-10-25 10:53:28 +0000 | [diff] [blame] | 16 | <body bgcolor="#8b7765" text="#000000" link="#000000" vlink="#000000"> |
| 17 | <table border="0" width="100%" cellpadding="5" cellspacing="0" align="center"><tr> |
| 18 | <td width="180"> |
| 19 | <a href="http://www.gnome.org/"><img src="smallfootonly.gif" alt="Gnome Logo"></a><a href="http://www.w3.org/Status"><img src="w3c.png" alt="W3C Logo"></a><a href="http://www.redhat.com/"><img src="redhat.gif" alt="Red Hat Logo"></a> |
| 20 | </td> |
| 21 | <td><table border="0" width="90%" cellpadding="2" cellspacing="0" align="center" bgcolor="#000000"><tr><td><table width="100%" border="0" cellspacing="1" cellpadding="3" bgcolor="#fffacd"><tr><td align="center"> |
| 22 | <h1>The XML C library for Gnome</h1> |
| 23 | <h2>Catalog support</h2> |
| 24 | </td></tr></table></td></tr></table></td> |
| 25 | </tr></table> |
| 26 | <table border="0" cellpadding="4" cellspacing="0" width="100%" align="center"><tr><td bgcolor="#8b7765"><table border="0" cellspacing="0" cellpadding="2" width="100%"><tr> |
| 27 | <td valign="top" width="200" bgcolor="#8b7765"><table border="0" cellspacing="0" cellpadding="1" width="100%" bgcolor="#000000"><tr><td> |
| 28 | <table width="100%" border="0" cellspacing="1" cellpadding="3"> |
| 29 | <tr><td colspan="1" bgcolor="#eecfa1" align="center"><center><b>Main Menu</b></center></td></tr> |
Daniel Veillard | 8acca11 | 2002-01-21 09:52:27 +0000 | [diff] [blame] | 30 | <tr><td bgcolor="#fffacd"><ul> |
Daniel Veillard | b8cfbd1 | 2001-10-25 10:53:28 +0000 | [diff] [blame] | 31 | <li><a href="index.html">Home</a></li> |
| 32 | <li><a href="intro.html">Introduction</a></li> |
| 33 | <li><a href="FAQ.html">FAQ</a></li> |
| 34 | <li><a href="docs.html">Documentation</a></li> |
| 35 | <li><a href="bugs.html">Reporting bugs and getting help</a></li> |
| 36 | <li><a href="help.html">How to help</a></li> |
| 37 | <li><a href="downloads.html">Downloads</a></li> |
| 38 | <li><a href="news.html">News</a></li> |
Daniel Veillard | 7b602b4 | 2002-01-08 13:26:00 +0000 | [diff] [blame] | 39 | <li><a href="XMLinfo.html">XML</a></li> |
Daniel Veillard | b8cfbd1 | 2001-10-25 10:53:28 +0000 | [diff] [blame] | 40 | <li><a href="XSLT.html">XSLT</a></li> |
Daniel Veillard | 6dbcaf8 | 2002-02-20 14:37:47 +0000 | [diff] [blame] | 41 | <li><a href="python.html">Python and bindings</a></li> |
Daniel Veillard | b8cfbd1 | 2001-10-25 10:53:28 +0000 | [diff] [blame] | 42 | <li><a href="architecture.html">libxml architecture</a></li> |
| 43 | <li><a href="tree.html">The tree output</a></li> |
| 44 | <li><a href="interface.html">The SAX interface</a></li> |
| 45 | <li><a href="xmldtd.html">Validation & DTDs</a></li> |
| 46 | <li><a href="xmlmem.html">Memory Management</a></li> |
| 47 | <li><a href="encoding.html">Encodings support</a></li> |
| 48 | <li><a href="xmlio.html">I/O Interfaces</a></li> |
| 49 | <li><a href="catalog.html">Catalog support</a></li> |
| 50 | <li><a href="library.html">The parser interfaces</a></li> |
| 51 | <li><a href="entities.html">Entities or no entities</a></li> |
| 52 | <li><a href="namespaces.html">Namespaces</a></li> |
| 53 | <li><a href="upgrade.html">Upgrading 1.x code</a></li> |
Daniel Veillard | 52dcab3 | 2001-10-30 12:51:17 +0000 | [diff] [blame] | 54 | <li><a href="threads.html">Thread safety</a></li> |
Daniel Veillard | b8cfbd1 | 2001-10-25 10:53:28 +0000 | [diff] [blame] | 55 | <li><a href="DOM.html">DOM Principles</a></li> |
| 56 | <li><a href="example.html">A real example</a></li> |
| 57 | <li><a href="contribs.html">Contributions</a></li> |
| 58 | <li> |
| 59 | <a href="xml.html">flat page</a>, <a href="site.xsl">stylesheet</a> |
| 60 | </li> |
| 61 | </ul></td></tr> |
| 62 | </table> |
| 63 | <table width="100%" border="0" cellspacing="1" cellpadding="3"> |
Daniel Veillard | 3bf65be | 2002-01-23 12:36:34 +0000 | [diff] [blame] | 64 | <tr><td colspan="1" bgcolor="#eecfa1" align="center"><center><b>API Indexes</b></center></td></tr> |
| 65 | <tr><td bgcolor="#fffacd"><ul> |
Daniel Veillard | f859256 | 2002-01-23 17:58:17 +0000 | [diff] [blame] | 66 | <li><a href="APIchunk0.html">Alphabetic</a></li> |
Daniel Veillard | 3bf65be | 2002-01-23 12:36:34 +0000 | [diff] [blame] | 67 | <li><a href="APIconstructors.html">Constructors</a></li> |
| 68 | <li><a href="APIfunctions.html">Functions/Types</a></li> |
| 69 | <li><a href="APIfiles.html">Modules</a></li> |
| 70 | <li><a href="APIsymbols.html">Symbols</a></li> |
| 71 | </ul></td></tr> |
| 72 | </table> |
| 73 | <table width="100%" border="0" cellspacing="1" cellpadding="3"> |
Daniel Veillard | b8cfbd1 | 2001-10-25 10:53:28 +0000 | [diff] [blame] | 74 | <tr><td colspan="1" bgcolor="#eecfa1" align="center"><center><b>Related links</b></center></td></tr> |
Daniel Veillard | 8acca11 | 2002-01-21 09:52:27 +0000 | [diff] [blame] | 75 | <tr><td bgcolor="#fffacd"><ul> |
Daniel Veillard | b8cfbd1 | 2001-10-25 10:53:28 +0000 | [diff] [blame] | 76 | <li><a href="http://mail.gnome.org/archives/xml/">Mail archive</a></li> |
| 77 | <li><a href="http://xmlsoft.org/XSLT/">XSLT libxslt</a></li> |
Daniel Veillard | 4a85920 | 2002-01-08 11:49:22 +0000 | [diff] [blame] | 78 | <li><a href="http://phd.cs.unibo.it/gdome2/">DOM gdome2</a></li> |
Daniel Veillard | 2d347fa | 2002-03-17 10:34:11 +0000 | [diff] [blame] | 79 | <li><a href="http://www.aleksey.com/xmlsec/">XML-DSig xmlsec</a></li> |
Daniel Veillard | b8cfbd1 | 2001-10-25 10:53:28 +0000 | [diff] [blame] | 80 | <li><a href="ftp://xmlsoft.org/">FTP</a></li> |
| 81 | <li><a href="http://www.fh-frankfurt.de/~igor/projects/libxml/">Windows binaries</a></li> |
Daniel Veillard | db9dfd9 | 2001-11-26 17:25:02 +0000 | [diff] [blame] | 82 | <li><a href="http://garypennington.net/libxml2/">Solaris binaries</a></li> |
Daniel Veillard | e6d8e20 | 2002-05-02 06:11:10 +0000 | [diff] [blame] | 83 | <li><a href="http://sourceforge.net/projects/libxml2-pas/">Pascal bindings</a></li> |
Daniel Veillard | 2d347fa | 2002-03-17 10:34:11 +0000 | [diff] [blame] | 84 | <li><a href="http://bugzilla.gnome.org/buglist.cgi?product=libxml&product=libxml2">Bug Tracker</a></li> |
Daniel Veillard | b8cfbd1 | 2001-10-25 10:53:28 +0000 | [diff] [blame] | 85 | </ul></td></tr> |
| 86 | </table> |
| 87 | </td></tr></table></td> |
| 88 | <td valign="top" bgcolor="#8b7765"><table border="0" cellspacing="0" cellpadding="1" width="100%"><tr><td><table border="0" cellspacing="0" cellpadding="1" width="100%" bgcolor="#000000"><tr><td><table border="0" cellpadding="3" cellspacing="1" width="100%"><tr><td bgcolor="#fffacd"> |
Daniel Veillard | e7ead2d | 2001-08-22 23:44:09 +0000 | [diff] [blame] | 89 | <p>Table of Content:</p> |
| 90 | <ol> |
Daniel Veillard | b8cfbd1 | 2001-10-25 10:53:28 +0000 | [diff] [blame] | 91 | <li><a href="General2">General overview</a></li> |
| 92 | <li><a href="#definition">The definition</a></li> |
| 93 | <li><a href="#Simple">Using catalogs</a></li> |
| 94 | <li><a href="#Some">Some examples</a></li> |
| 95 | <li><a href="#reference">How to tune catalog usage</a></li> |
| 96 | <li><a href="#validate">How to debug catalog processing</a></li> |
| 97 | <li><a href="#Declaring">How to create and maintain catalogs</a></li> |
| 98 | <li><a href="#implemento">The implementor corner quick review of the |
Daniel Veillard | e7ead2d | 2001-08-22 23:44:09 +0000 | [diff] [blame] | 99 | API</a></li> |
Daniel Veillard | b8cfbd1 | 2001-10-25 10:53:28 +0000 | [diff] [blame] | 100 | <li><a href="#Other">Other resources</a></li> |
Daniel Veillard | e7ead2d | 2001-08-22 23:44:09 +0000 | [diff] [blame] | 101 | </ol> |
Daniel Veillard | b8cfbd1 | 2001-10-25 10:53:28 +0000 | [diff] [blame] | 102 | <h3><a name="General2">General overview</a></h3> |
| 103 | <p>What is a catalog? Basically it's a lookup mechanism used when an entity |
| 104 | (a file or a remote resource) references another entity. The catalog lookup |
| 105 | is inserted between the moment the reference is recognized by the software |
| 106 | (XML parser, stylesheet processing, or even images referenced for inclusion |
| 107 | in a rendering) and the time where loading that resource is actually |
| 108 | started.</p> |
Daniel Veillard | e7ead2d | 2001-08-22 23:44:09 +0000 | [diff] [blame] | 109 | <p>It is basically used for 3 things:</p> |
| 110 | <ul> |
Daniel Veillard | b8cfbd1 | 2001-10-25 10:53:28 +0000 | [diff] [blame] | 111 | <li>mapping from "logical" names, the public identifiers and a more |
Daniel Veillard | e7ead2d | 2001-08-22 23:44:09 +0000 | [diff] [blame] | 112 | concrete name usable for download (and URI). For example it can associate |
Daniel Veillard | ffb120d | 2001-08-23 00:52:23 +0000 | [diff] [blame] | 113 | the logical name |
Daniel Veillard | b8cfbd1 | 2001-10-25 10:53:28 +0000 | [diff] [blame] | 114 | <p>"-//OASIS//DTD DocBook XML V4.1.2//EN"</p> |
| 115 | <p>of the DocBook 4.1.2 XML DTD with the actual URL where it can be |
Daniel Veillard | e7ead2d | 2001-08-22 23:44:09 +0000 | [diff] [blame] | 116 | downloaded</p> |
Daniel Veillard | b8cfbd1 | 2001-10-25 10:53:28 +0000 | [diff] [blame] | 117 | <p>http://www.oasis-open.org/docbook/xml/4.1.2/docbookx.dtd</p> |
| 118 | </li> |
| 119 | <li>remapping from a given URL to another one, like an HTTP indirection |
Daniel Veillard | e7ead2d | 2001-08-22 23:44:09 +0000 | [diff] [blame] | 120 | saying that |
Daniel Veillard | b8cfbd1 | 2001-10-25 10:53:28 +0000 | [diff] [blame] | 121 | <p>"http://www.oasis-open.org/committes/tr.xsl"</p> |
| 122 | <p>should really be looked at</p> |
| 123 | <p>"http://www.oasis-open.org/committes/entity/stylesheets/base/tr.xsl"</p> |
| 124 | </li> |
| 125 | <li>providing a local cache mechanism allowing to load the entities |
Daniel Veillard | e7ead2d | 2001-08-22 23:44:09 +0000 | [diff] [blame] | 126 | associated to public identifiers or remote resources, this is a really |
| 127 | important feature for any significant deployment of XML or SGML since it |
MDT 2001 John Fleck | 0468500 | 2001-09-03 16:11:47 +0000 | [diff] [blame] | 128 | allows to avoid the aleas and delays associated to fetching remote |
Daniel Veillard | e7ead2d | 2001-08-22 23:44:09 +0000 | [diff] [blame] | 129 | resources.</li> |
| 130 | </ul> |
Daniel Veillard | b8cfbd1 | 2001-10-25 10:53:28 +0000 | [diff] [blame] | 131 | <h3><a name="definition">The definitions</a></h3> |
Daniel Veillard | e7ead2d | 2001-08-22 23:44:09 +0000 | [diff] [blame] | 132 | <p>Libxml, as of 2.4.3 implements 2 kind of catalogs:</p> |
| 133 | <ul> |
Daniel Veillard | b8cfbd1 | 2001-10-25 10:53:28 +0000 | [diff] [blame] | 134 | <li>the older SGML catalogs, the official spec is SGML Open Technical |
| 135 | Resolution TR9401:1997, but is better understood by reading <a href="http://www.jclark.com/sp/catalog.htm">the SP Catalog page</a> from |
Daniel Veillard | e7ead2d | 2001-08-22 23:44:09 +0000 | [diff] [blame] | 136 | James Clark. This is relatively old and not the preferred mode of |
| 137 | operation of libxml.</li> |
Daniel Veillard | b8cfbd1 | 2001-10-25 10:53:28 +0000 | [diff] [blame] | 138 | <li> |
| 139 | <a href="http://www.oasis-open.org/committees/entity/spec.html">XML |
Daniel Veillard | af43f63 | 2002-03-08 15:05:20 +0000 | [diff] [blame] | 140 | Catalogs</a> is far more flexible, more recent, uses an XML syntax and |
| 141 | should scale quite better. This is the default option of libxml.</li> |
Daniel Veillard | e7ead2d | 2001-08-22 23:44:09 +0000 | [diff] [blame] | 142 | </ul> |
Daniel Veillard | b8cfbd1 | 2001-10-25 10:53:28 +0000 | [diff] [blame] | 143 | <p> |
| 144 | <h3><a name="Simple">Using catalog</a></h3> |
Daniel Veillard | e7ead2d | 2001-08-22 23:44:09 +0000 | [diff] [blame] | 145 | <p>In a normal environment libxml will by default check the presence of a |
| 146 | catalog in /etc/xml/catalog, and assuming it has been correctly populated, |
| 147 | the processing is completely transparent to the document user. To take a |
| 148 | concrete example, suppose you are authoring a DocBook document, this one |
| 149 | starts with the following DOCTYPE definition:</p> |
| 150 | <pre><?xml version='1.0'?> |
Daniel Veillard | b8cfbd1 | 2001-10-25 10:53:28 +0000 | [diff] [blame] | 151 | <!DOCTYPE book PUBLIC "-//Norman Walsh//DTD DocBk XML V3.1.4//EN" |
| 152 | "http://nwalsh.com/docbook/xml/3.1.4/db3xml.dtd"></pre> |
Daniel Veillard | e7ead2d | 2001-08-22 23:44:09 +0000 | [diff] [blame] | 153 | <p>When validating the document with libxml, the catalog will be |
Daniel Veillard | b8cfbd1 | 2001-10-25 10:53:28 +0000 | [diff] [blame] | 154 | automatically consulted to lookup the public identifier "-//Norman Walsh//DTD |
| 155 | DocBk XML V3.1.4//EN" and the system identifier |
| 156 | "http://nwalsh.com/docbook/xml/3.1.4/db3xml.dtd", and if these entities have |
Daniel Veillard | e7ead2d | 2001-08-22 23:44:09 +0000 | [diff] [blame] | 157 | been installed on your system and the catalogs actually point to them, libxml |
| 158 | will fetch them from the local disk.</p> |
Daniel Veillard | b8cfbd1 | 2001-10-25 10:53:28 +0000 | [diff] [blame] | 159 | <p style="font-size: 10pt"> |
| 160 | <strong>Note</strong>: Really don't use this |
Daniel Veillard | e7ead2d | 2001-08-22 23:44:09 +0000 | [diff] [blame] | 161 | DOCTYPE example it's a really old version, but is fine as an example.</p> |
Daniel Veillard | e7ead2d | 2001-08-22 23:44:09 +0000 | [diff] [blame] | 162 | <p>Libxml will check the catalog each time that it is requested to load an |
MDT 2001 John Fleck | 0468500 | 2001-09-03 16:11:47 +0000 | [diff] [blame] | 163 | entity, this includes DTD, external parsed entities, stylesheets, etc ... If |
Daniel Veillard | e7ead2d | 2001-08-22 23:44:09 +0000 | [diff] [blame] | 164 | your system is correctly configured all the authoring phase and processing |
MDT 2001 John Fleck | 0468500 | 2001-09-03 16:11:47 +0000 | [diff] [blame] | 165 | should use only local files, even if your document stays portable because it |
Daniel Veillard | e7ead2d | 2001-08-22 23:44:09 +0000 | [diff] [blame] | 166 | uses the canonical public and system ID, referencing the remote document.</p> |
Daniel Veillard | b8cfbd1 | 2001-10-25 10:53:28 +0000 | [diff] [blame] | 167 | <h3><a name="Some">Some examples:</a></h3> |
Daniel Veillard | e7ead2d | 2001-08-22 23:44:09 +0000 | [diff] [blame] | 168 | <p>Here is a couple of fragments from XML Catalogs used in libxml early |
| 169 | regression tests in <code>test/catalogs</code> :</p> |
Daniel Veillard | b8cfbd1 | 2001-10-25 10:53:28 +0000 | [diff] [blame] | 170 | <pre><?xml version="1.0"?> |
| 171 | <!DOCTYPE catalog PUBLIC |
| 172 | "-//OASIS//DTD Entity Resolution XML Catalog V1.0//EN" |
| 173 | "http://www.oasis-open.org/committees/entity/release/1.0/catalog.dtd"> |
| 174 | <catalog xmlns="urn:oasis:names:tc:entity:xmlns:xml:catalog"> |
| 175 | <public publicId="-//OASIS//DTD DocBook XML V4.1.2//EN" |
| 176 | uri="http://www.oasis-open.org/docbook/xml/4.1.2/docbookx.dtd"/> |
Daniel Veillard | e7ead2d | 2001-08-22 23:44:09 +0000 | [diff] [blame] | 177 | ...</pre> |
Daniel Veillard | e7ead2d | 2001-08-22 23:44:09 +0000 | [diff] [blame] | 178 | <p>This is the beginning of a catalog for DocBook 4.1.2, XML Catalogs are |
| 179 | written in XML, there is a specific namespace for catalog elements |
Daniel Veillard | b8cfbd1 | 2001-10-25 10:53:28 +0000 | [diff] [blame] | 180 | "urn:oasis:names:tc:entity:xmlns:xml:catalog". The first entry in this |
Daniel Veillard | e7ead2d | 2001-08-22 23:44:09 +0000 | [diff] [blame] | 181 | catalog is a <code>public</code> mapping it allows to associate a Public |
Daniel Veillard | ffb120d | 2001-08-23 00:52:23 +0000 | [diff] [blame] | 182 | Identifier with an URI.</p> |
Daniel Veillard | e7ead2d | 2001-08-22 23:44:09 +0000 | [diff] [blame] | 183 | <pre>... |
Daniel Veillard | b8cfbd1 | 2001-10-25 10:53:28 +0000 | [diff] [blame] | 184 | <rewriteSystem systemIdStartString="http://www.oasis-open.org/docbook/" |
| 185 | rewritePrefix="file:///usr/share/xml/docbook/"/> |
Daniel Veillard | e7ead2d | 2001-08-22 23:44:09 +0000 | [diff] [blame] | 186 | ...</pre> |
Daniel Veillard | e7ead2d | 2001-08-22 23:44:09 +0000 | [diff] [blame] | 187 | <p>A <code>rewriteSystem</code> is a very powerful instruction, it says that |
| 188 | any URI starting with a given prefix should be looked at another URI |
| 189 | constructed by replacing the prefix with an new one. In effect this acts like |
| 190 | a cache system for a full area of the Web. In practice it is extremely useful |
| 191 | with a file prefix if you have installed a copy of those resources on your |
Daniel Veillard | ffb120d | 2001-08-23 00:52:23 +0000 | [diff] [blame] | 192 | local system.</p> |
Daniel Veillard | e7ead2d | 2001-08-22 23:44:09 +0000 | [diff] [blame] | 193 | <pre>... |
Daniel Veillard | b8cfbd1 | 2001-10-25 10:53:28 +0000 | [diff] [blame] | 194 | <delegatePublic publicIdStartString="-//OASIS//DTD XML Catalog //" |
| 195 | catalog="file:///usr/share/xml/docbook.xml"/> |
| 196 | <delegatePublic publicIdStartString="-//OASIS//ENTITIES DocBook XML" |
| 197 | catalog="file:///usr/share/xml/docbook.xml"/> |
| 198 | <delegatePublic publicIdStartString="-//OASIS//DTD DocBook XML" |
| 199 | catalog="file:///usr/share/xml/docbook.xml"/> |
| 200 | <delegateSystem systemIdStartString="http://www.oasis-open.org/docbook/" |
| 201 | catalog="file:///usr/share/xml/docbook.xml"/> |
| 202 | <delegateURI uriStartString="http://www.oasis-open.org/docbook/" |
| 203 | catalog="file:///usr/share/xml/docbook.xml"/> |
Daniel Veillard | e7ead2d | 2001-08-22 23:44:09 +0000 | [diff] [blame] | 204 | ...</pre> |
Daniel Veillard | e7ead2d | 2001-08-22 23:44:09 +0000 | [diff] [blame] | 205 | <p>Delegation is the core features which allows to build a tree of catalogs, |
| 206 | easier to maintain than a single catalog, based on Public Identifier, System |
Daniel Veillard | b8cfbd1 | 2001-10-25 10:53:28 +0000 | [diff] [blame] | 207 | Identifier or URI prefixes it instructs the catalog software to look up |
| 208 | entries in another resource. This feature allow to build hierarchies of |
| 209 | catalogs, the set of entries presented should be sufficient to redirect the |
| 210 | resolution of all DocBook references to the specific catalog in |
Daniel Veillard | e7ead2d | 2001-08-22 23:44:09 +0000 | [diff] [blame] | 211 | <code>/usr/share/xml/docbook.xml</code> this one in turn could delegate all |
| 212 | references for DocBook 4.2.1 to a specific catalog installed at the same time |
| 213 | as the DocBook resources on the local machine.</p> |
Daniel Veillard | b8cfbd1 | 2001-10-25 10:53:28 +0000 | [diff] [blame] | 214 | <h3><a name="reference">How to tune catalog usage:</a></h3> |
Daniel Veillard | e7ead2d | 2001-08-22 23:44:09 +0000 | [diff] [blame] | 215 | <p>The user can change the default catalog behaviour by redirecting queries |
| 216 | to its own set of catalogs, this can be done by setting the |
| 217 | <code>XML_CATALOG_FILES</code> environment variable to a list of catalogs, an |
Daniel Veillard | b8cfbd1 | 2001-10-25 10:53:28 +0000 | [diff] [blame] | 218 | empty one should deactivate loading the default <code>/etc/xml/catalog</code> |
| 219 | default catalog</p> |
| 220 | <h3><a name="validate">How to debug catalog processing:</a></h3> |
Daniel Veillard | e7ead2d | 2001-08-22 23:44:09 +0000 | [diff] [blame] | 221 | <p>Setting up the <code>XML_DEBUG_CATALOG</code> environment variable will |
| 222 | make libxml output debugging informations for each catalog operations, for |
| 223 | example:</p> |
| 224 | <pre>orchis:~/XML -> xmllint --memory --noout test/ent2 |
Daniel Veillard | b8cfbd1 | 2001-10-25 10:53:28 +0000 | [diff] [blame] | 225 | warning: failed to load external entity "title.xml" |
Daniel Veillard | e7ead2d | 2001-08-22 23:44:09 +0000 | [diff] [blame] | 226 | orchis:~/XML -> export XML_DEBUG_CATALOG= |
| 227 | orchis:~/XML -> xmllint --memory --noout test/ent2 |
| 228 | Failed to parse catalog /etc/xml/catalog |
| 229 | Failed to parse catalog /etc/xml/catalog |
Daniel Veillard | b8cfbd1 | 2001-10-25 10:53:28 +0000 | [diff] [blame] | 230 | warning: failed to load external entity "title.xml" |
Daniel Veillard | e7ead2d | 2001-08-22 23:44:09 +0000 | [diff] [blame] | 231 | Catalogs cleanup |
| 232 | orchis:~/XML -> </pre> |
Daniel Veillard | e7ead2d | 2001-08-22 23:44:09 +0000 | [diff] [blame] | 233 | <p>The test/ent2 references an entity, running the parser from memory makes |
Daniel Veillard | b8cfbd1 | 2001-10-25 10:53:28 +0000 | [diff] [blame] | 234 | the base URI unavailable and the the "title.xml" entity cannot be loaded. |
Daniel Veillard | e7ead2d | 2001-08-22 23:44:09 +0000 | [diff] [blame] | 235 | Setting up the debug environment variable allows to detect that an attempt is |
| 236 | made to load the <code>/etc/xml/catalog</code> but since it's not present the |
Daniel Veillard | ffb120d | 2001-08-23 00:52:23 +0000 | [diff] [blame] | 237 | resolution fails.</p> |
Daniel Veillard | e7ead2d | 2001-08-22 23:44:09 +0000 | [diff] [blame] | 238 | <p>But the most advanced way to debug XML catalog processing is to use the |
| 239 | <strong>xmlcatalog</strong> command shipped with libxml2, it allows to load |
| 240 | catalogs and make resolution queries to see what is going on. This is also |
| 241 | used for the regression tests:</p> |
Daniel Veillard | b8cfbd1 | 2001-10-25 10:53:28 +0000 | [diff] [blame] | 242 | <pre>orchis:~/XML -> ./xmlcatalog test/catalogs/docbook.xml \ |
| 243 | "-//OASIS//DTD DocBook XML V4.1.2//EN" |
Daniel Veillard | e7ead2d | 2001-08-22 23:44:09 +0000 | [diff] [blame] | 244 | http://www.oasis-open.org/docbook/xml/4.1.2/docbookx.dtd |
| 245 | orchis:~/XML -> </pre> |
Daniel Veillard | e7ead2d | 2001-08-22 23:44:09 +0000 | [diff] [blame] | 246 | <p>For debugging what is going on, adding one -v flags increase the verbosity |
| 247 | level to indicate the processing done (adding a second flag also indicate |
| 248 | what elements are recognized at parsing):</p> |
Daniel Veillard | b8cfbd1 | 2001-10-25 10:53:28 +0000 | [diff] [blame] | 249 | <pre>orchis:~/XML -> ./xmlcatalog -v test/catalogs/docbook.xml \ |
| 250 | "-//OASIS//DTD DocBook XML V4.1.2//EN" |
Daniel Veillard | e7ead2d | 2001-08-22 23:44:09 +0000 | [diff] [blame] | 251 | Parsing catalog test/catalogs/docbook.xml's content |
| 252 | Found public match -//OASIS//DTD DocBook XML V4.1.2//EN |
| 253 | http://www.oasis-open.org/docbook/xml/4.1.2/docbookx.dtd |
| 254 | Catalogs cleanup |
| 255 | orchis:~/XML -> </pre> |
Daniel Veillard | e7ead2d | 2001-08-22 23:44:09 +0000 | [diff] [blame] | 256 | <p>A shell interface is also available to debug and process multiple queries |
| 257 | (and for regression tests):</p> |
Daniel Veillard | b8cfbd1 | 2001-10-25 10:53:28 +0000 | [diff] [blame] | 258 | <pre>orchis:~/XML -> ./xmlcatalog -shell test/catalogs/docbook.xml \ |
| 259 | "-//OASIS//DTD DocBook XML V4.1.2//EN" |
Daniel Veillard | e7ead2d | 2001-08-22 23:44:09 +0000 | [diff] [blame] | 260 | > help |
| 261 | Commands available: |
| 262 | public PublicID: make a PUBLIC identifier lookup |
| 263 | system SystemID: make a SYSTEM identifier lookup |
| 264 | resolve PublicID SystemID: do a full resolver lookup |
| 265 | add 'type' 'orig' 'replace' : add an entry |
| 266 | del 'values' : remove values |
| 267 | dump: print the current catalog state |
| 268 | debug: increase the verbosity level |
| 269 | quiet: decrease the verbosity level |
| 270 | exit: quit the shell |
Daniel Veillard | b8cfbd1 | 2001-10-25 10:53:28 +0000 | [diff] [blame] | 271 | > public "-//OASIS//DTD DocBook XML V4.1.2//EN" |
Daniel Veillard | e7ead2d | 2001-08-22 23:44:09 +0000 | [diff] [blame] | 272 | http://www.oasis-open.org/docbook/xml/4.1.2/docbookx.dtd |
| 273 | > quit |
| 274 | orchis:~/XML -> </pre> |
Daniel Veillard | e7ead2d | 2001-08-22 23:44:09 +0000 | [diff] [blame] | 275 | <p>This should be sufficient for most debugging purpose, this was actually |
MDT 2001 John Fleck | 0468500 | 2001-09-03 16:11:47 +0000 | [diff] [blame] | 276 | used heavily to debug the XML Catalog implementation itself.</p> |
Daniel Veillard | b8cfbd1 | 2001-10-25 10:53:28 +0000 | [diff] [blame] | 277 | <h3> |
| 278 | <a name="Declaring">How to create and maintain</a> catalogs:</h3> |
Daniel Veillard | e7ead2d | 2001-08-22 23:44:09 +0000 | [diff] [blame] | 279 | <p>Basically XML Catalogs are XML files, you can either use XML tools to |
| 280 | manage them or use <strong>xmlcatalog</strong> for this. The basic step is |
| 281 | to create a catalog the -create option provide this facility:</p> |
| 282 | <pre>orchis:~/XML -> ./xmlcatalog --create tst.xml |
Daniel Veillard | b8cfbd1 | 2001-10-25 10:53:28 +0000 | [diff] [blame] | 283 | <?xml version="1.0"?> |
| 284 | <!DOCTYPE catalog PUBLIC "-//OASIS//DTD Entity Resolution XML Catalog V1.0//EN" |
| 285 | "http://www.oasis-open.org/committees/entity/release/1.0/catalog.dtd"> |
| 286 | <catalog xmlns="urn:oasis:names:tc:entity:xmlns:xml:catalog"/> |
Daniel Veillard | e7ead2d | 2001-08-22 23:44:09 +0000 | [diff] [blame] | 287 | orchis:~/XML -> </pre> |
Daniel Veillard | e7ead2d | 2001-08-22 23:44:09 +0000 | [diff] [blame] | 288 | <p>By default xmlcatalog does not overwrite the original catalog and save the |
MDT 2001 John Fleck | 0468500 | 2001-09-03 16:11:47 +0000 | [diff] [blame] | 289 | result on the standard output, this can be overridden using the -noout |
Daniel Veillard | e7ead2d | 2001-08-22 23:44:09 +0000 | [diff] [blame] | 290 | option. The <code>-add</code> command allows to add entries in the |
| 291 | catalog:</p> |
Daniel Veillard | b8cfbd1 | 2001-10-25 10:53:28 +0000 | [diff] [blame] | 292 | <pre>orchis:~/XML -> ./xmlcatalog --noout --create --add "public" \ |
| 293 | "-//OASIS//DTD DocBook XML V4.1.2//EN" \ |
| 294 | http://www.oasis-open.org/docbook/xml/4.1.2/docbookx.dtd tst.xml |
Daniel Veillard | e7ead2d | 2001-08-22 23:44:09 +0000 | [diff] [blame] | 295 | orchis:~/XML -> cat tst.xml |
Daniel Veillard | b8cfbd1 | 2001-10-25 10:53:28 +0000 | [diff] [blame] | 296 | <?xml version="1.0"?> |
| 297 | <!DOCTYPE catalog PUBLIC "-//OASIS//DTD Entity Resolution XML Catalog V1.0//EN" \ |
| 298 | "http://www.oasis-open.org/committees/entity/release/1.0/catalog.dtd"> |
| 299 | <catalog xmlns="urn:oasis:names:tc:entity:xmlns:xml:catalog"> |
| 300 | <public publicId="-//OASIS//DTD DocBook XML V4.1.2//EN" |
| 301 | uri="http://www.oasis-open.org/docbook/xml/4.1.2/docbookx.dtd"/> |
Daniel Veillard | e7ead2d | 2001-08-22 23:44:09 +0000 | [diff] [blame] | 302 | </catalog> |
| 303 | orchis:~/XML -> </pre> |
Daniel Veillard | e7ead2d | 2001-08-22 23:44:09 +0000 | [diff] [blame] | 304 | <p>The <code>-add</code> option will always take 3 parameters even if some of |
| 305 | the XML Catalog constructs (like nextCatalog) will have only a single |
| 306 | argument, just pass a third empty string, it will be ignored.</p> |
MDT 2001 John Fleck | 0468500 | 2001-09-03 16:11:47 +0000 | [diff] [blame] | 307 | <p>Similarly the <code>-del</code> option remove matching entries from the |
Daniel Veillard | e7ead2d | 2001-08-22 23:44:09 +0000 | [diff] [blame] | 308 | catalog:</p> |
Daniel Veillard | b8cfbd1 | 2001-10-25 10:53:28 +0000 | [diff] [blame] | 309 | <pre>orchis:~/XML -> ./xmlcatalog --del \ |
| 310 | "http://www.oasis-open.org/docbook/xml/4.1.2/docbookx.dtd" tst.xml |
| 311 | <?xml version="1.0"?> |
| 312 | <!DOCTYPE catalog PUBLIC "-//OASIS//DTD Entity Resolution XML Catalog V1.0//EN" |
| 313 | "http://www.oasis-open.org/committees/entity/release/1.0/catalog.dtd"> |
| 314 | <catalog xmlns="urn:oasis:names:tc:entity:xmlns:xml:catalog"/> |
Daniel Veillard | e7ead2d | 2001-08-22 23:44:09 +0000 | [diff] [blame] | 315 | orchis:~/XML -> </pre> |
MDT 2001 John Fleck | 0468500 | 2001-09-03 16:11:47 +0000 | [diff] [blame] | 316 | <p>The catalog is now empty. Note that the matching of <code>-del</code> is |
Daniel Veillard | e7ead2d | 2001-08-22 23:44:09 +0000 | [diff] [blame] | 317 | exact and would have worked in a similar fashion with the Public ID |
| 318 | string.</p> |
Daniel Veillard | ffb120d | 2001-08-23 00:52:23 +0000 | [diff] [blame] | 319 | <p>This is rudimentary but should be sufficient to manage a not too complex |
| 320 | catalog tree of resources.</p> |
Daniel Veillard | b8cfbd1 | 2001-10-25 10:53:28 +0000 | [diff] [blame] | 321 | <h3><a name="implemento">The implementor corner quick review of the |
| 322 | API:</a></h3> |
| 323 | <p>First, and like for every other module of libxml, there is an |
| 324 | automatically generated <a href="html/libxml-catalog.html">API page for |
| 325 | catalog support</a>.</p> |
Daniel Veillard | ffb120d | 2001-08-23 00:52:23 +0000 | [diff] [blame] | 326 | <p>The header for the catalog interfaces should be included as:</p> |
| 327 | <pre>#include <libxml/catalog.h></pre> |
Daniel Veillard | ffb120d | 2001-08-23 00:52:23 +0000 | [diff] [blame] | 328 | <p>The API is voluntarily kept very simple. First it is not obvious that |
| 329 | applications really need access to it since it is the default behaviour of |
| 330 | libxml (Note: it is possible to completely override libxml default catalog by |
| 331 | using <a href="html/libxml-parser.html">xmlSetExternalEntityLoader</a> to |
| 332 | plug an application specific resolver).</p> |
Daniel Veillard | ffb120d | 2001-08-23 00:52:23 +0000 | [diff] [blame] | 333 | <p>Basically libxml support 2 catalog lists:</p> |
| 334 | <ul> |
Daniel Veillard | b8cfbd1 | 2001-10-25 10:53:28 +0000 | [diff] [blame] | 335 | <li>the default one, global shared by all the application</li> |
| 336 | <li>a per-document catalog, this one is built if the document uses the |
Daniel Veillard | ffb120d | 2001-08-23 00:52:23 +0000 | [diff] [blame] | 337 | <code>oasis-xml-catalog</code> PIs to specify its own catalog list, it is |
| 338 | associated to the parser context and destroyed when the parsing context |
| 339 | is destroyed.</li> |
| 340 | </ul> |
Daniel Veillard | ffb120d | 2001-08-23 00:52:23 +0000 | [diff] [blame] | 341 | <p>the document one will be used first if it exists.</p> |
Daniel Veillard | b8cfbd1 | 2001-10-25 10:53:28 +0000 | [diff] [blame] | 342 | <h4>Initialization routines:</h4> |
Daniel Veillard | ffb120d | 2001-08-23 00:52:23 +0000 | [diff] [blame] | 343 | <p>xmlInitializeCatalog(), xmlLoadCatalog() and xmlLoadCatalogs() should be |
| 344 | used at startup to initialize the catalog, if the catalog should be |
| 345 | initialized with specific values xmlLoadCatalog() or xmlLoadCatalogs() |
| 346 | should be called before xmlInitializeCatalog() which would otherwise do a |
| 347 | default initialization first.</p> |
Daniel Veillard | ffb120d | 2001-08-23 00:52:23 +0000 | [diff] [blame] | 348 | <p>The xmlCatalogAddLocal() call is used by the parser to grow the document |
| 349 | own catalog list if needed.</p> |
Daniel Veillard | b8cfbd1 | 2001-10-25 10:53:28 +0000 | [diff] [blame] | 350 | <h4>Preferences setup:</h4> |
Daniel Veillard | ffb120d | 2001-08-23 00:52:23 +0000 | [diff] [blame] | 351 | <p>The XML Catalog spec requires the possibility to select default |
| 352 | preferences between public and system delegation, |
| 353 | xmlCatalogSetDefaultPrefer() allows this, xmlCatalogSetDefaults() and |
| 354 | xmlCatalogGetDefaults() allow to control if XML Catalogs resolution should |
| 355 | be forbidden, allowed for global catalog, for document catalog or both, the |
| 356 | default is to allow both.</p> |
Daniel Veillard | ffb120d | 2001-08-23 00:52:23 +0000 | [diff] [blame] | 357 | <p>And of course xmlCatalogSetDebug() allows to generate debug messages |
| 358 | (through the xmlGenericError() mechanism).</p> |
Daniel Veillard | b8cfbd1 | 2001-10-25 10:53:28 +0000 | [diff] [blame] | 359 | <h4>Querying routines:</h4> |
Daniel Veillard | ffb120d | 2001-08-23 00:52:23 +0000 | [diff] [blame] | 360 | <p>xmlCatalogResolve(), xmlCatalogResolveSystem(), xmlCatalogResolvePublic() |
| 361 | and xmlCatalogResolveURI() are relatively explicit if you read the XML |
| 362 | Catalog specification they correspond to section 7 algorithms, they should |
| 363 | also work if you have loaded an SGML catalog with a simplified semantic.</p> |
Daniel Veillard | ffb120d | 2001-08-23 00:52:23 +0000 | [diff] [blame] | 364 | <p>xmlCatalogLocalResolve() and xmlCatalogLocalResolveURI() are the same but |
| 365 | operate on the document catalog list</p> |
Daniel Veillard | b8cfbd1 | 2001-10-25 10:53:28 +0000 | [diff] [blame] | 366 | <h4>Cleanup and Miscellaneous:</h4> |
Daniel Veillard | ffb120d | 2001-08-23 00:52:23 +0000 | [diff] [blame] | 367 | <p>xmlCatalogCleanup() free-up the global catalog, xmlCatalogFreeLocal() is |
| 368 | the per-document equivalent.</p> |
Daniel Veillard | ffb120d | 2001-08-23 00:52:23 +0000 | [diff] [blame] | 369 | <p>xmlCatalogAdd() and xmlCatalogRemove() are used to dynamically modify the |
| 370 | first catalog in the global list, and xmlCatalogDump() allows to dump a |
| 371 | catalog state, those routines are primarily designed for xmlcatalog, I'm not |
| 372 | sure that exposing more complex interfaces (like navigation ones) would be |
| 373 | really useful.</p> |
Daniel Veillard | 9f7b84b | 2001-08-23 15:31:19 +0000 | [diff] [blame] | 374 | <p>The xmlParseCatalogFile() is a function used to load XML Catalog files, |
| 375 | it's similar as xmlParseFile() except it bypass all catalog lookups, it's |
| 376 | provided because this functionality may be useful for client tools.</p> |
Daniel Veillard | b8cfbd1 | 2001-10-25 10:53:28 +0000 | [diff] [blame] | 377 | <h4>threaded environments:</h4> |
Daniel Veillard | ffb120d | 2001-08-23 00:52:23 +0000 | [diff] [blame] | 378 | <p>Since the catalog tree is built progressively, some care has been taken to |
Daniel Veillard | b8cfbd1 | 2001-10-25 10:53:28 +0000 | [diff] [blame] | 379 | try to avoid troubles in multithreaded environments. The code is now thread |
| 380 | safe assuming that the libxml library has been compiled with threads |
| 381 | support.</p> |
| 382 | <p> |
| 383 | <h3><a name="Other">Other resources</a></h3> |
Daniel Veillard | e7ead2d | 2001-08-22 23:44:09 +0000 | [diff] [blame] | 384 | <p>The XML Catalog specification is relatively recent so there isn't much |
MDT 2001 John Fleck | 0468500 | 2001-09-03 16:11:47 +0000 | [diff] [blame] | 385 | literature to point at:</p> |
Daniel Veillard | e7ead2d | 2001-08-22 23:44:09 +0000 | [diff] [blame] | 386 | <ul> |
Daniel Veillard | 63d8314 | 2002-05-20 06:51:05 +0000 | [diff] [blame^] | 387 | <li>You can find a good rant from Norm Walsh about <a href="http://www.arbortext.com/Think_Tank/XML_Resources/Issue_Three/issue_three.html">the |
Daniel Veillard | e7ead2d | 2001-08-22 23:44:09 +0000 | [diff] [blame] | 388 | need for catalogs</a>, it provides a lot of context informations even if |
Daniel Veillard | 93d3a47 | 2002-04-26 14:04:55 +0000 | [diff] [blame] | 389 | I don't agree with everything presented. Norm also wrote a more recent |
| 390 | article <a href="http://wwws.sun.com/software/xml/developers/resolver/article/">XML |
| 391 | entities and URI resolvers</a> describing them.</li> |
Daniel Veillard | b8cfbd1 | 2001-10-25 10:53:28 +0000 | [diff] [blame] | 392 | <li>An <a href="http://home.ccil.org/~cowan/XML/XCatalog.html">old XML |
Daniel Veillard | e7ead2d | 2001-08-22 23:44:09 +0000 | [diff] [blame] | 393 | catalog proposal</a> from John Cowan</li> |
Daniel Veillard | b8cfbd1 | 2001-10-25 10:53:28 +0000 | [diff] [blame] | 394 | <li>The <a href="http://www.rddl.org/">Resource Directory Description |
Daniel Veillard | e7ead2d | 2001-08-22 23:44:09 +0000 | [diff] [blame] | 395 | Language</a> (RDDL) another catalog system but more oriented toward |
| 396 | providing metadata for XML namespaces.</li> |
Daniel Veillard | b8cfbd1 | 2001-10-25 10:53:28 +0000 | [diff] [blame] | 397 | <li>the page from the OASIS Technical <a href="http://www.oasis-open.org/committees/entity/">Committee on Entity |
Daniel Veillard | e7ead2d | 2001-08-22 23:44:09 +0000 | [diff] [blame] | 398 | Resolution</a> who maintains XML Catalog, you will find pointers to the |
| 399 | specification update, some background and pointers to others tools |
| 400 | providing XML Catalog support</li> |
Daniel Veillard | 35e937a | 2002-01-19 22:21:54 +0000 | [diff] [blame] | 401 | <li>Here is a <a href="buildDocBookCatalog">shell script</a> to generate |
| 402 | XML Catalogs for DocBook 4.1.2 . If it can write to the /etc/xml/ |
| 403 | directory, it will set-up /etc/xml/catalog and /etc/xml/docbook based on |
| 404 | the resources found on the system. Otherwise it will just create |
| 405 | ~/xmlcatalog and ~/dbkxmlcatalog and doing: |
Daniel Veillard | c575b99 | 2002-02-08 13:28:40 +0000 | [diff] [blame] | 406 | <p><code>export XMLCATALOG=$HOME/xmlcatalog</code></p> |
Daniel Veillard | 35e937a | 2002-01-19 22:21:54 +0000 | [diff] [blame] | 407 | <p>should allow to process DocBook documentations without requiring |
Daniel Veillard | 63d8314 | 2002-05-20 06:51:05 +0000 | [diff] [blame^] | 408 | network accesses for the DTD or stylesheets</p> |
Daniel Veillard | 35e937a | 2002-01-19 22:21:54 +0000 | [diff] [blame] | 409 | </li> |
Daniel Veillard | b8cfbd1 | 2001-10-25 10:53:28 +0000 | [diff] [blame] | 410 | <li>I have uploaded <a href="ftp://xmlsoft.org/test/dbk412catalog.tar.gz">a |
Daniel Veillard | 35e937a | 2002-01-19 22:21:54 +0000 | [diff] [blame] | 411 | small tarball</a> containing XML Catalogs for DocBook 4.1.2 which seems |
| 412 | to work fine for me too</li> |
Daniel Veillard | b8cfbd1 | 2001-10-25 10:53:28 +0000 | [diff] [blame] | 413 | <li>The <a href="http://www.xmlsoft.org/xmlcatalog_man.html">xmlcatalog |
| 414 | manual page</a> |
| 415 | </li> |
Daniel Veillard | e7ead2d | 2001-08-22 23:44:09 +0000 | [diff] [blame] | 416 | </ul> |
Daniel Veillard | e7ead2d | 2001-08-22 23:44:09 +0000 | [diff] [blame] | 417 | <p>If you have suggestions for corrections or additions, simply contact |
| 418 | me:</p> |
Daniel Veillard | 3f4c40f | 2002-02-13 09:19:28 +0000 | [diff] [blame] | 419 | <p><a href="bugs.html">Daniel Veillard</a></p> |
Daniel Veillard | b8cfbd1 | 2001-10-25 10:53:28 +0000 | [diff] [blame] | 420 | </td></tr></table></td></tr></table></td></tr></table></td> |
| 421 | </tr></table></td></tr></table> |
Daniel Veillard | e7ead2d | 2001-08-22 23:44:09 +0000 | [diff] [blame] | 422 | </body> |
| 423 | </html> |