diff options
Diffstat (limited to 'doc/catalog.html')
-rw-r--r-- | doc/catalog.html | 324 |
1 files changed, 161 insertions, 163 deletions
diff --git a/doc/catalog.html b/doc/catalog.html index 4100fed..34f9902 100644 --- a/doc/catalog.html +++ b/doc/catalog.html @@ -14,77 +14,78 @@ A:link, A:visited, A:active { text-decoration: underline } <li><a href="#reference">How to tune catalog usage</a></li> <li><a href="#validate">How to debug catalog processing</a></li> <li><a href="#Declaring">How to create and maintain catalogs</a></li> - <li><a href="#implemento">The implementor corner quick review of the - API</a></li> + <li><a href="#implemento">The implementor corner quick review + oftheAPI</a></li> <li><a href="#Other">Other resources</a></li> -</ol><h3><a name="General2" id="General2">General overview</a></h3><p>What is a catalog? Basically it's a lookup mechanism used when an entity -(a file or a remote resource) references another entity. The catalog lookup -is inserted between the moment the reference is recognized by the software -(XML parser, stylesheet processing, or even images referenced for inclusion -in a rendering) and the time where loading that resource is actually -started.</p><p>It is basically used for 3 things:</p><ul><li>mapping from "logical" names, the public identifiers and a more - concrete name usable for download (and URI). For example it can associate - the logical name +</ol><h3><a name="General2" id="General2">General overview</a></h3><p>What is a catalog? Basically it's a lookup mechanism used when an +entity(afile or a remote resource) references another entity. The catalog +lookupisinserted between the moment the reference is recognized by the +software(XMLparser, stylesheet processing, or even images referenced for +inclusionin arendering) and the time where loading that resource is +actuallystarted.</p><p>It is basically used for 3 things:</p><ul><li>mapping from "logical" names, the public identifiers and a + moreconcretename usable for download (and URI). For example it can + associatethelogical name <p>"-//OASIS//DTD DocBook XML V4.1.2//EN"</p> - <p>of the DocBook 4.1.2 XML DTD with the actual URL where it can be - downloaded</p> + <p>of the DocBook 4.1.2 XML DTD with the actual URL where it + canbedownloaded</p> <p>http://www.oasis-open.org/docbook/xml/4.1.2/docbookx.dtd</p> </li> - <li>remapping from a given URL to another one, like an HTTP indirection - saying that + <li>remapping from a given URL to another one, like an + HTTPindirectionsaying that <p>"http://www.oasis-open.org/committes/tr.xsl"</p> <p>should really be looked at</p> <p>"http://www.oasis-open.org/committes/entity/stylesheets/base/tr.xsl"</p> </li> - <li>providing a local cache mechanism allowing to load the entities - associated to public identifiers or remote resources, this is a really - important feature for any significant deployment of XML or SGML since it - allows to avoid the aleas and delays associated to fetching remote - resources.</li> -</ul><h3><a name="definition" id="definition">The definitions</a></h3><p>Libxml, as of 2.4.3 implements 2 kind of catalogs:</p><ul><li>the older SGML catalogs, the official spec is SGML Open Technical - Resolution TR9401:1997, but is better understood by reading <a href="http://www.jclark.com/sp/catalog.htm">the SP Catalog page</a> from - James Clark. This is relatively old and not the preferred mode of - operation of libxml.</li> - <li><a href="http://www.oasis-open.org/committees/entity/spec.html">XML - Catalogs</a> is far more flexible, more recent, uses an XML syntax and - should scale quite better. This is the default option of libxml.</li> -</ul><p></p><h3><a name="Simple" id="Simple">Using catalog</a></h3><p>In a normal environment libxml2 will by default check the presence of a -catalog in /etc/xml/catalog, and assuming it has been correctly populated, -the processing is completely transparent to the document user. To take a -concrete example, suppose you are authoring a DocBook document, this one -starts with the following DOCTYPE definition:</p><pre><?xml version='1.0'?> + <li>providing a local cache mechanism allowing to load + theentitiesassociated to public identifiers or remote resources, this is + areallyimportant feature for any significant deployment of XML or + SGMLsince itallows to avoid the aleas and delays associated to + fetchingremoteresources.</li> +</ul><h3><a name="definition" id="definition">The definitions</a></h3><p>Libxml, as of 2.4.3 implements 2 kind of catalogs:</p><ul><li>the older SGML catalogs, the official spec is SGML + OpenTechnicalResolution TR9401:1997, but is better understood by reading + <a href="http://www.jclark.com/sp/catalog.htm">the SP + Catalogpage</a>fromJames Clark. This is relatively old and not the + preferredmode ofoperation of libxml.</li> + <li><a href="http://www.oasis-open.org/committees/entity/spec.html">XMLCatalogs</a>isfar + more flexible, more recent, uses an XML syntax andshould scale + quitebetter. This is the default option of libxml.</li> +</ul><p></p><h3><a name="Simple" id="Simple">Using catalog</a></h3><p>In a normal environment libxml2 will by default check the presence +ofacatalog in /etc/xml/catalog, and assuming it has been +correctlypopulated,the processing is completely transparent to the document +user. Totake aconcrete example, suppose you are authoring a DocBook document, +thisonestarts with the following DOCTYPE definition:</p><pre><?xml version='1.0'?> <!DOCTYPE book PUBLIC "-//Norman Walsh//DTD DocBk XML V3.1.4//EN" - "http://nwalsh.com/docbook/xml/3.1.4/db3xml.dtd"></pre><p>When validating the document with libxml, the catalog will be -automatically consulted to lookup the public identifier "-//Norman Walsh//DTD -DocBk XML V3.1.4//EN" and the system identifier -"http://nwalsh.com/docbook/xml/3.1.4/db3xml.dtd", and if these entities have -been installed on your system and the catalogs actually point to them, libxml -will fetch them from the local disk.</p><p style="font-size: 10pt"><strong>Note</strong>: Really don't use this -DOCTYPE example it's a really old version, but is fine as an example.</p><p>Libxml2 will check the catalog each time that it is requested to load an -entity, this includes DTD, external parsed entities, stylesheets, etc ... If -your system is correctly configured all the authoring phase and processing -should use only local files, even if your document stays portable because it -uses the canonical public and system ID, referencing the remote document.</p><h3><a name="Some" id="Some">Some examples:</a></h3><p>Here is a couple of fragments from XML Catalogs used in libxml2 early -regression tests in <code>test/catalogs</code> :</p><pre><?xml version="1.0"?> + "http://nwalsh.com/docbook/xml/3.1.4/db3xml.dtd"></pre><p>When validating the document with libxml, the catalog will +beautomaticallyconsulted to lookup the public identifier "-//Norman +Walsh//DTDDocBk XMLV3.1.4//EN" and the +systemidentifier"http://nwalsh.com/docbook/xml/3.1.4/db3xml.dtd", and if +theseentities havebeen installed on your system and the catalogs actually +point tothem, libxmlwill fetch them from the local disk.</p><p style="font-size: 10pt"><strong>Note</strong>: Really don't usethisDOCTYPE +example it's a really old version, but is fine as an example.</p><p>Libxml2 will check the catalog each time that it is requested to +loadanentity, this includes DTD, external parsed entities, stylesheets, etc +...Ifyour system is correctly configured all the authoring phase +andprocessingshould use only local files, even if your document stays +portablebecause ituses the canonical public and system ID, referencing the +remotedocument.</p><h3><a name="Some" id="Some">Some examples:</a></h3><p>Here is a couple of fragments from XML Catalogs used in +libxml2earlyregression tests in <code>test/catalogs</code>:</p><pre><?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"> <public publicId="-//OASIS//DTD DocBook XML V4.1.2//EN" uri="http://www.oasis-open.org/docbook/xml/4.1.2/docbookx.dtd"/> -...</pre><p>This is the beginning of a catalog for DocBook 4.1.2, XML Catalogs are -written in XML, there is a specific namespace for catalog elements -"urn:oasis:names:tc:entity:xmlns:xml:catalog". The first entry in this -catalog is a <code>public</code> mapping it allows to associate a Public -Identifier with an URI.</p><pre>... +...</pre><p>This is the beginning of a catalog for DocBook 4.1.2, XML +Catalogsarewritten in XML, there is a specific namespace for +catalogelements"urn:oasis:names:tc:entity:xmlns:xml:catalog". The first entry +inthiscatalog is a <code>public</code>mapping it allows to associate +aPublicIdentifier with an URI.</p><pre>... <rewriteSystem systemIdStartString="http://www.oasis-open.org/docbook/" rewritePrefix="file:///usr/share/xml/docbook/"/> -...</pre><p>A <code>rewriteSystem</code> is a very powerful instruction, it says that -any URI starting with a given prefix should be looked at another URI -constructed by replacing the prefix with an new one. In effect this acts like -a cache system for a full area of the Web. In practice it is extremely useful -with a file prefix if you have installed a copy of those resources on your -local system.</p><pre>... +...</pre><p>A <code>rewriteSystem</code>is a very powerful instruction, it saysthatany +URI starting with a given prefix should be looked at anotherURIconstructed by +replacing the prefix with an new one. In effect this actslikea cache system +for a full area of the Web. In practice it is extremelyusefulwith a file +prefix if you have installed a copy of those resources onyourlocal system.</p><pre>... <delegatePublic publicIdStartString="-//OASIS//DTD XML Catalog //" catalog="file:///usr/share/xml/docbook.xml"/> <delegatePublic publicIdStartString="-//OASIS//ENTITIES DocBook XML" @@ -95,21 +96,21 @@ local system.</p><pre>... catalog="file:///usr/share/xml/docbook.xml"/> <delegateURI uriStartString="http://www.oasis-open.org/docbook/" catalog="file:///usr/share/xml/docbook.xml"/> -...</pre><p>Delegation is the core features which allows to build a tree of catalogs, -easier to maintain than a single catalog, based on Public Identifier, System -Identifier or URI prefixes it instructs the catalog software to look up -entries in another resource. This feature allow to build hierarchies of -catalogs, the set of entries presented should be sufficient to redirect the -resolution of all DocBook references to the specific catalog in -<code>/usr/share/xml/docbook.xml</code> this one in turn could delegate all -references for DocBook 4.2.1 to a specific catalog installed at the same time -as the DocBook resources on the local machine.</p><h3><a name="reference" id="reference">How to tune catalog usage:</a></h3><p>The user can change the default catalog behaviour by redirecting queries -to its own set of catalogs, this can be done by setting the -<code>XML_CATALOG_FILES</code> environment variable to a list of catalogs, an -empty one should deactivate loading the default <code>/etc/xml/catalog</code> -default catalog</p><h3><a name="validate" id="validate">How to debug catalog processing:</a></h3><p>Setting up the <code>XML_DEBUG_CATALOG</code> environment variable will -make libxml2 output debugging informations for each catalog operations, for -example:</p><pre>orchis:~/XML -> xmllint --memory --noout test/ent2 +...</pre><p>Delegation is the core features which allows to build a tree +ofcatalogs,easier to maintain than a single catalog, based on +PublicIdentifier, SystemIdentifier or URI prefixes it instructs the +catalogsoftware to look upentries in another resource. This feature allow to +buildhierarchies ofcatalogs, the set of entries presented should be +sufficient toredirect theresolution of all DocBook references to the specific +catalogin<code>/usr/share/xml/docbook.xml</code>this one in turn could +delegateallreferences for DocBook 4.2.1 to a specific catalog installed at +the sametimeas the DocBook resources on the local machine.</p><h3><a name="reference" id="reference">How to tune catalog usage:</a></h3><p>The user can change the default catalog behaviour by redirecting +queriestoits own set of catalogs, this can be done by +settingthe<code>XML_CATALOG_FILES</code>environment variable to a list of +catalogs,anempty one should deactivate loading the +default<code>/etc/xml/catalog</code>default catalog</p><h3><a name="validate" id="validate">How to debug catalog processing:</a></h3><p>Setting up the <code>XML_DEBUG_CATALOG</code>environment variable +willmakelibxml2 output debugging informations for each catalog +operations,forexample:</p><pre>orchis:~/XML -> xmllint --memory --noout test/ent2 warning: failed to load external entity "title.xml" orchis:~/XML -> export XML_DEBUG_CATALOG= orchis:~/XML -> xmllint --memory --noout test/ent2 @@ -117,26 +118,26 @@ Failed to parse catalog /etc/xml/catalog Failed to parse catalog /etc/xml/catalog warning: failed to load external entity "title.xml" Catalogs cleanup -orchis:~/XML -> </pre><p>The test/ent2 references an entity, running the parser from memory makes -the base URI unavailable and the the "title.xml" entity cannot be loaded. -Setting up the debug environment variable allows to detect that an attempt is -made to load the <code>/etc/xml/catalog</code> but since it's not present the -resolution fails.</p><p>But the most advanced way to debug XML catalog processing is to use the -<strong>xmlcatalog</strong> command shipped with libxml2, it allows to load -catalogs and make resolution queries to see what is going on. This is also -used for the regression tests:</p><pre>orchis:~/XML -> ./xmlcatalog test/catalogs/docbook.xml \ +orchis:~/XML -> </pre><p>The test/ent2 references an entity, running the parser from memorymakesthe +base URI unavailable and the the "title.xml" entity cannot beloaded.Setting +up the debug environment variable allows to detect that anattempt ismade to +load the <code>/etc/xml/catalog</code>but since it's notpresent theresolution +fails.</p><p>But the most advanced way to debug XML catalog processing is to +usethe<strong>xmlcatalog</strong>command shipped with libxml2, it allows +toloadcatalogs and make resolution queries to see what is going on. This +isalsoused for the regression tests:</p><pre>orchis:~/XML -> ./xmlcatalog test/catalogs/docbook.xml \ "-//OASIS//DTD DocBook XML V4.1.2//EN" http://www.oasis-open.org/docbook/xml/4.1.2/docbookx.dtd -orchis:~/XML -> </pre><p>For debugging what is going on, adding one -v flags increase the verbosity -level to indicate the processing done (adding a second flag also indicate -what elements are recognized at parsing):</p><pre>orchis:~/XML -> ./xmlcatalog -v test/catalogs/docbook.xml \ +orchis:~/XML -> </pre><p>For debugging what is going on, adding one -v flags increase +theverbositylevel to indicate the processing done (adding a second flag +alsoindicatewhat elements are recognized at parsing):</p><pre>orchis:~/XML -> ./xmlcatalog -v test/catalogs/docbook.xml \ "-//OASIS//DTD DocBook XML V4.1.2//EN" Parsing catalog test/catalogs/docbook.xml's content Found public match -//OASIS//DTD DocBook XML V4.1.2//EN http://www.oasis-open.org/docbook/xml/4.1.2/docbookx.dtd Catalogs cleanup -orchis:~/XML -> </pre><p>A shell interface is also available to debug and process multiple queries -(and for regression tests):</p><pre>orchis:~/XML -> ./xmlcatalog -shell test/catalogs/docbook.xml \ +orchis:~/XML -> </pre><p>A shell interface is also available to debug and process +multiplequeries(and for regression tests):</p><pre>orchis:~/XML -> ./xmlcatalog -shell test/catalogs/docbook.xml \ "-//OASIS//DTD DocBook XML V4.1.2//EN" > help Commands available: @@ -152,18 +153,18 @@ exit: quit the shell > public "-//OASIS//DTD DocBook XML V4.1.2//EN" http://www.oasis-open.org/docbook/xml/4.1.2/docbookx.dtd > quit -orchis:~/XML -> </pre><p>This should be sufficient for most debugging purpose, this was actually -used heavily to debug the XML Catalog implementation itself.</p><h3><a name="Declaring" id="Declaring">How to create and maintain</a> catalogs:</h3><p>Basically XML Catalogs are XML files, you can either use XML tools to -manage them or use <strong>xmlcatalog</strong> for this. The basic step is -to create a catalog the -create option provide this facility:</p><pre>orchis:~/XML -> ./xmlcatalog --create tst.xml +orchis:~/XML -> </pre><p>This should be sufficient for most debugging purpose, this wasactuallyused +heavily to debug the XML Catalog implementation itself.</p><h3><a name="Declaring" id="Declaring">How to create and maintain</a>catalogs:</h3><p>Basically XML Catalogs are XML files, you can either use XML toolstomanage +them or use <strong>xmlcatalog</strong>for this. The basic stepisto create a +catalog the -create option provide this facility:</p><pre>orchis:~/XML -> ./xmlcatalog --create tst.xml <?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"/> -orchis:~/XML -> </pre><p>By default xmlcatalog does not overwrite the original catalog and save the -result on the standard output, this can be overridden using the -noout -option. The <code>-add</code> command allows to add entries in the -catalog:</p><pre>orchis:~/XML -> ./xmlcatalog --noout --create --add "public" \ +orchis:~/XML -> </pre><p>By default xmlcatalog does not overwrite the original catalog and +savetheresult on the standard output, this can be overridden using +the-nooutoption. The <code>-add</code>command allows to add entries +inthecatalog:</p><pre>orchis:~/XML -> ./xmlcatalog --noout --create --add "public" \ "-//OASIS//DTD DocBook XML V4.1.2//EN" \ http://www.oasis-open.org/docbook/xml/4.1.2/docbookx.dtd tst.xml orchis:~/XML -> cat tst.xml @@ -174,83 +175,80 @@ orchis:~/XML -> cat tst.xml <public publicId="-//OASIS//DTD DocBook XML V4.1.2//EN" uri="http://www.oasis-open.org/docbook/xml/4.1.2/docbookx.dtd"/> </catalog> -orchis:~/XML -> </pre><p>The <code>-add</code> option will always take 3 parameters even if some of -the XML Catalog constructs (like nextCatalog) will have only a single -argument, just pass a third empty string, it will be ignored.</p><p>Similarly the <code>-del</code> option remove matching entries from the -catalog:</p><pre>orchis:~/XML -> ./xmlcatalog --del \ +orchis:~/XML -> </pre><p>The <code>-add</code>option will always take 3 parameters even if +someofthe XML Catalog constructs (like nextCatalog) will have only +asingleargument, just pass a third empty string, it will be ignored.</p><p>Similarly the <code>-del</code>option remove matching entries +fromthecatalog:</p><pre>orchis:~/XML -> ./xmlcatalog --del \ "http://www.oasis-open.org/docbook/xml/4.1.2/docbookx.dtd" tst.xml <?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"/> -orchis:~/XML -> </pre><p>The catalog is now empty. Note that the matching of <code>-del</code> is -exact and would have worked in a similar fashion with the Public ID -string.</p><p>This is rudimentary but should be sufficient to manage a not too complex -catalog tree of resources.</p><h3><a name="implemento" id="implemento">The implementor corner quick review of the -API:</a></h3><p>First, and like for every other module of libxml, there is an -automatically generated <a href="html/libxml-catalog.html">API page for -catalog support</a>.</p><p>The header for the catalog interfaces should be included as:</p><pre>#include <libxml/catalog.h></pre><p>The API is voluntarily kept very simple. First it is not obvious that -applications really need access to it since it is the default behaviour of -libxml2 (Note: it is possible to completely override libxml2 default catalog -by using <a href="html/libxml-parser.html">xmlSetExternalEntityLoader</a> to -plug an application specific resolver).</p><p>Basically libxml2 support 2 catalog lists:</p><ul><li>the default one, global shared by all the application</li> - <li>a per-document catalog, this one is built if the document uses the - <code>oasis-xml-catalog</code> PIs to specify its own catalog list, it is - associated to the parser context and destroyed when the parsing context - is destroyed.</li> -</ul><p>the document one will be used first if it exists.</p><h4>Initialization routines:</h4><p>xmlInitializeCatalog(), xmlLoadCatalog() and xmlLoadCatalogs() should be -used at startup to initialize the catalog, if the catalog should be -initialized with specific values xmlLoadCatalog() or xmlLoadCatalogs() -should be called before xmlInitializeCatalog() which would otherwise do a -default initialization first.</p><p>The xmlCatalogAddLocal() call is used by the parser to grow the document -own catalog list if needed.</p><h4>Preferences setup:</h4><p>The XML Catalog spec requires the possibility to select default -preferences between public and system delegation, -xmlCatalogSetDefaultPrefer() allows this, xmlCatalogSetDefaults() and -xmlCatalogGetDefaults() allow to control if XML Catalogs resolution should -be forbidden, allowed for global catalog, for document catalog or both, the -default is to allow both.</p><p>And of course xmlCatalogSetDebug() allows to generate debug messages -(through the xmlGenericError() mechanism).</p><h4>Querying routines:</h4><p>xmlCatalogResolve(), xmlCatalogResolveSystem(), xmlCatalogResolvePublic() -and xmlCatalogResolveURI() are relatively explicit if you read the XML -Catalog specification they correspond to section 7 algorithms, they should -also work if you have loaded an SGML catalog with a simplified semantic.</p><p>xmlCatalogLocalResolve() and xmlCatalogLocalResolveURI() are the same but -operate on the document catalog list</p><h4>Cleanup and Miscellaneous:</h4><p>xmlCatalogCleanup() free-up the global catalog, xmlCatalogFreeLocal() is -the per-document equivalent.</p><p>xmlCatalogAdd() and xmlCatalogRemove() are used to dynamically modify the -first catalog in the global list, and xmlCatalogDump() allows to dump a -catalog state, those routines are primarily designed for xmlcatalog, I'm not -sure that exposing more complex interfaces (like navigation ones) would be -really useful.</p><p>The xmlParseCatalogFile() is a function used to load XML Catalog files, -it's similar as xmlParseFile() except it bypass all catalog lookups, it's -provided because this functionality may be useful for client tools.</p><h4>threaded environments:</h4><p>Since the catalog tree is built progressively, some care has been taken to -try to avoid troubles in multithreaded environments. The code is now thread -safe assuming that the libxml2 library has been compiled with threads -support.</p><p></p><h3><a name="Other" id="Other">Other resources</a></h3><p>The XML Catalog specification is relatively recent so there isn't much -literature to point at:</p><ul><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 - need for catalogs</a>, it provides a lot of context informations even if - I don't agree with everything presented. Norm also wrote a more recent - article <a href="http://wwws.sun.com/software/xml/developers/resolver/article/">XML - entities and URI resolvers</a> describing them.</li> - <li>An <a href="http://home.ccil.org/~cowan/XML/XCatalog.html">old XML - catalog proposal</a> from John Cowan</li> - <li>The <a href="http://www.rddl.org/">Resource Directory Description - Language</a> (RDDL) another catalog system but more oriented toward - providing metadata for XML namespaces.</li> - <li>the page from the OASIS Technical <a href="http://www.oasis-open.org/committees/entity/">Committee on Entity - Resolution</a> who maintains XML Catalog, you will find pointers to the - specification update, some background and pointers to others tools - providing XML Catalog support</li> - <li>There is a <a href="buildDocBookCatalog">shell script</a> to generate - XML Catalogs for DocBook 4.1.2 . If it can write to the /etc/xml/ - directory, it will set-up /etc/xml/catalog and /etc/xml/docbook based on - the resources found on the system. Otherwise it will just create - ~/xmlcatalog and ~/dbkxmlcatalog and doing: +orchis:~/XML -> </pre><p>The catalog is now empty. Note that the matching +of<code>-del</code>isexact and would have worked in a similar fashion with +thePublic IDstring.</p><p>This is rudimentary but should be sufficient to manage a not +toocomplexcatalog tree of resources.</p><h3><a name="implemento" id="implemento">The implementor corner quick review +oftheAPI:</a></h3><p>First, and like for every other module of libxml, there is +anautomaticallygenerated <a href="html/libxml-catalog.html">API page +forcatalogsupport</a>.</p><p>The header for the catalog interfaces should be included as:</p><pre>#include <libxml/catalog.h></pre><p>The API is voluntarily kept very simple. First it is not +obviousthatapplications really need access to it since it is the default +behaviouroflibxml2 (Note: it is possible to completely override libxml2 +defaultcatalogby using <a href="html/libxml-parser.html">xmlSetExternalEntityLoader</a>toplug +anapplication specific resolver).</p><p>Basically libxml2 support 2 catalog lists:</p><ul><li>the default one, global shared by all the application</li> + <li>a per-document catalog, this one is built if the document + usesthe<code>oasis-xml-catalog</code>PIs to specify its own catalog list, + itisassociated to the parser context and destroyed when the + parsingcontextis destroyed.</li> +</ul><p>the document one will be used first if it exists.</p><h4>Initialization routines:</h4><p>xmlInitializeCatalog(), xmlLoadCatalog() and xmlLoadCatalogs() +shouldbeused at startup to initialize the catalog, if the catalog +shouldbeinitialized with specific values xmlLoadCatalog() +orxmlLoadCatalogs()should be called before xmlInitializeCatalog() which +wouldotherwise do adefault initialization first.</p><p>The xmlCatalogAddLocal() call is used by the parser to grow thedocumentown +catalog list if needed.</p><h4>Preferences setup:</h4><p>The XML Catalog spec requires the possibility to select +defaultpreferencesbetween public and system +delegation,xmlCatalogSetDefaultPrefer() allowsthis, xmlCatalogSetDefaults() +andxmlCatalogGetDefaults() allow to control ifXML Catalogs resolution +shouldbe forbidden, allowed for global catalog, fordocument catalog or both, +thedefault is to allow both.</p><p>And of course xmlCatalogSetDebug() allows to generate +debugmessages(through the xmlGenericError() mechanism).</p><h4>Querying routines:</h4><p>xmlCatalogResolve(), +xmlCatalogResolveSystem(),xmlCatalogResolvePublic()and xmlCatalogResolveURI() +are relatively explicitif you read the XMLCatalog specification they +correspond to section 7algorithms, they shouldalso work if you have loaded an +SGML catalog with asimplified semantic.</p><p>xmlCatalogLocalResolve() and xmlCatalogLocalResolveURI() are the +samebutoperate on the document catalog list</p><h4>Cleanup and Miscellaneous:</h4><p>xmlCatalogCleanup() free-up the global catalog, xmlCatalogFreeLocal()isthe +per-document equivalent.</p><p>xmlCatalogAdd() and xmlCatalogRemove() are used to dynamically +modifythefirst catalog in the global list, and xmlCatalogDump() allows to +dumpacatalog state, those routines are primarily designed for xmlcatalog, +I'mnotsure that exposing more complex interfaces (like navigation ones) +wouldbereally useful.</p><p>The xmlParseCatalogFile() is a function used to load XML Catalogfiles,it's +similar as xmlParseFile() except it bypass all catalog lookups,it'sprovided +because this functionality may be useful for client tools.</p><h4>threaded environments:</h4><p>Since the catalog tree is built progressively, some care has been +takentotry to avoid troubles in multithreaded environments. The code is +nowthreadsafe assuming that the libxml2 library has been compiled +withthreadssupport.</p><p></p><h3><a name="Other" id="Other">Other resources</a></h3><p>The XML Catalog specification is relatively recent so there +isn'tmuchliterature to point at:</p><ul><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">theneedfor + catalogs</a>, it provides a lot of context informations even ifIdon't + agree with everything presented. Norm also wrote a morerecentarticle <a href="http://wwws.sun.com/software/xml/developers/resolver/article/">XMLentitiesand + URI resolvers</a>describing them.</li> + <li>An <a href="http://home.ccil.org/~cowan/XML/XCatalog.html">oldXMLcatalog + proposal</a>from John Cowan</li> + <li>The <a href="http://www.rddl.org/">Resource + DirectoryDescriptionLanguage</a>(RDDL) another catalog system but more + orientedtowardproviding metadata for XML namespaces.</li> + <li>the page from the OASIS Technical <a href="http://www.oasis-open.org/committees/entity/">Committee + onEntityResolution</a>who maintains XML Catalog, you will find pointers + tothespecification update, some background and pointers to + otherstoolsproviding XML Catalog support</li> + <li>There is a <a href="buildDocBookCatalog">shell script</a>to + generateXMLCatalogs for DocBook 4.1.2 . If it can write to the + /etc/xml/directory,it will set-up /etc/xml/catalog and /etc/xml/docbook + based ontheresources found on the system. Otherwise it will just + create~/xmlcatalogand ~/dbkxmlcatalog and doing: <p><code>export XML_CATALOG_FILES=$HOME/xmlcatalog</code></p> - <p>should allow to process DocBook documentations without requiring - network accesses for the DTD or stylesheets</p> + <p>should allow to process DocBook documentations withoutrequiringnetwork + accesses for the DTD or stylesheets</p> </li> - <li>I have uploaded <a href="ftp://xmlsoft.org/libxml2/test/dbk412catalog.tar.gz">a - small tarball</a> containing XML Catalogs for DocBook 4.1.2 which seems - to work fine for me too</li> - <li>The <a href="http://www.xmlsoft.org/xmlcatalog_man.html">xmlcatalog - manual page</a></li> -</ul><p>If you have suggestions for corrections or additions, simply contact -me:</p><p><a href="bugs.html">Daniel Veillard</a></p></td></tr></table></td></tr></table></td></tr></table></td></tr></table></td></tr></table></body></html> + <li>I have uploaded <a href="ftp://xmlsoft.org/libxml2/test/dbk412catalog.tar.gz">asmalltarball</a>containing + XML Catalogs for DocBook 4.1.2 which seemsto workfine for me too</li> + <li>The <a href="http://www.xmlsoft.org/xmlcatalog_man.html">xmlcatalogmanualpage</a></li> +</ul><p>If you have suggestions for corrections or additions, simply contactme:</p><p><a href="bugs.html">Daniel Veillard</a></p></td></tr></table></td></tr></table></td></tr></table></td></tr></table></td></tr></table></body></html> |