📄 catalog.html
字号:
orchis:~/XML -> </pre><p>For debugging what is going on, adding one -v flags increase the verbositylevel to indicate the processing done (adding a second flag also indicatewhat 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 contentFound public match -//OASIS//DTD DocBook XML V4.1.2//ENhttp://www.oasis-open.org/docbook/xml/4.1.2/docbookx.dtdCatalogs cleanuporchis:~/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 \ "-//OASIS//DTD DocBook XML V4.1.2//EN"> help Commands available:public PublicID: make a PUBLIC identifier lookupsystem SystemID: make a SYSTEM identifier lookupresolve PublicID SystemID: do a full resolver lookupadd 'type' 'orig' 'replace' : add an entrydel 'values' : remove valuesdump: print the current catalog statedebug: increase the verbosity levelquiet: decrease the verbosity levelexit: quit the shell> public "-//OASIS//DTD DocBook XML V4.1.2//EN"http://www.oasis-open.org/docbook/xml/4.1.2/docbookx.dtd> quitorchis:~/XML -> </pre><p>This should be sufficient for most debugging purpose, this was actuallyused 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 tomanage them or use <strong>xmlcatalog</strong> for this. The basic step isto 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 theresult on the standard output, this can be overridden using the -nooutoption. The <code>-add</code> command allows to add entries in thecatalog:</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.xmlorchis:~/XML -> cat 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"><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 ofthe XML Catalog constructs (like nextCatalog) will have only a singleargument, just pass a third empty string, it will be ignored.</p><p>Similarly the <code>-del</code> option remove matching entries from thecatalog:</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> isexact and would have worked in a similar fashion with the Public IDstring.</p><p>This is rudimentary but should be sufficient to manage a not too complexcatalog tree of resources.</p><h3><a name="implemento" id="implemento">The implementor corner quick review of theAPI:</a></h3><p>First, and like for every other module of libxml, there is anautomatically generated <a href="html/libxml-catalog.html">API page forcatalog 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 thatapplications really need access to it since it is the default behaviour oflibxml2 (Note: it is possible to completely override libxml2 default catalogby using <a href="html/libxml-parser.html">xmlSetExternalEntityLoader</a> toplug 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 beused at startup to initialize the catalog, if the catalog should beinitialized with specific values xmlLoadCatalog() or xmlLoadCatalogs()should be called before xmlInitializeCatalog() which would otherwise do adefault initialization first.</p><p>The xmlCatalogAddLocal() call is used by the parser to grow the documentown catalog list if needed.</p><h4>Preferences setup:</h4><p>The XML Catalog spec requires the possibility to select defaultpreferences between public and system delegation,xmlCatalogSetDefaultPrefer() allows this, xmlCatalogSetDefaults() andxmlCatalogGetDefaults() allow to control if XML Catalogs resolution shouldbe forbidden, allowed for global catalog, for document catalog or both, thedefault 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 XMLCatalog specification they correspond to section 7 algorithms, they shouldalso work if you have loaded an SGML catalog with a simplified semantic.</p><p>xmlCatalogLocalResolve() and xmlCatalogLocalResolveURI() are the same butoperate 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 modify thefirst catalog in the global list, and xmlCatalogDump() allows to dump acatalog state, those routines are primarily designed for xmlcatalog, I'm notsure that exposing more complex interfaces (like navigation ones) would bereally 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'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 taken totry to avoid troubles in multithreaded environments. The code is now threadsafe assuming that the libxml2 library has been compiled with threadssupport.</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 muchliterature 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: <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> </li> <li>I have uploaded <a href="ftp://xmlsoft.org/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 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>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -