<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE zprava SYSTEM "techrep.dtd">

<zprava cislo="7/2004" jazyk="en">
	<nazev>XML catalogs in the Netopeer tools</nazev>
	<autor>Petr Novák</autor>
	<datum>19. 11. 2004</datum>

	<h1>Motivation</h1>
	<p>
		The XML catalogs are used to resolve the version of the Netopeer
		schema to URI of this schema. This allows to frontends and libraries to
		be independent on emplacement of the Netopeer schemas. The version is
		the namespace for the XML configuration in the Netopeer system.
	</p>
	<p>
		For example: if we have the XML configuration, which begins:
	</p>
	<p>
		<vstup>&lt;configuration xmlns="http://www.liberouter.org/ns/netopeer/1.1.10"&gt;</vstup>
	</p>
	<p>
		The <tt>http://www.liberouter.org/ns/netopeer/1.1.10</tt> is the version
		of the XML configuration (and its namespace too). It can be
		resolved by catalog to the local path (e.g.,
		<tt>/usr/local/etc/netopeer/1.1.10/netopeer.rng</tt>)
	</p>
	<p>
		All operations with XML catalog are fully transparent for users.
	</p>

	<h1>Local catalog in Netopeer</h1>
	<p>
		There is a local catalog used in the Netopeer.
		This catalog is used for resolving the
		version to the name of the file in the local filesystem. E.g., the
		version <tt>http://www.liberouter.org/ns/netopeer/1.1.10</tt> corresponds
		<tt>/usr/local/etc/netopeer/1.1.10/netopeer.rng</tt>. The content of
		this catalog depends on schemas which user has installed.
		It is possible to have more than one Netopeer catalog.
	</p>

	<h1>Working with catalogs in the netopeer_xml library</h1>
	<p>
		Here is described how the netopeer_xml library (which is used by all
		rontends) works with catalogs.
	</p>

	<h2>Importing catalogs</h2>
	<p>
		It is important to import some catalog before the resolving the
		version of the Netopeer schema. It may be done by several ways:
	</p>
	<ul>
		<li>using preprocessing instruction in the XML configuration
			to import specified catalog:
			<tt>&lt;?oasis-xml-catalog catalog="someURI"?&gt;</tt></li>
		<li>using the default system catalog - this is the local catalog
			placed at <tt>/etc/xml/catalog</tt></li>
		<li>using Netopeer default catalog - it is created link to this catalog from
			the system catalog during Netopeer installation (root privileg is
			needed)</li>
		<li>using Netopeer configuration file to set the catalog for the netopeer_xml library
			(the configuration files are <tt>/etc/netopeer</tt>, <tt>/usr/local/etc/netopeer</tt>,
			<tt>&vlnka;/.netopeer</tt> etc., you can set the location during Netopeer install)</li>
		<li>using the <tt>XML_CATALOG_FILES</tt> variable - it contains all catalogs
			processed by XML parser; you can set your own catalogs list</li>
	</ul>
	<p>
		<i>Note:</i> If there is some error during importing the catalog,
		the exception is thrown - see documentation of the netopeer_xml
		library for more.
	</p>

	<h2>Resolving the version to the URI</h2>
	<p>
		The version of the XML configuration is resolved to the URI by
		the follow way:
	</p>
	<p>
		First the version is resolved by the local catalog to the local URI,
		if possible. It means that if the user has installed the proper version of the
		Netopeer schema on his system, this schema is used.
	</p>
	<p>
		If the resolution by the local catalog fails (e.g., the version of the
		XML configuration is newer than schemas which the user has installed), the
		schema from the Netopeer Web is used. The URL of this schema is the
		namespace of the XML configuration. There are all Netopeer schemas
		on the Web (these schemas are managed by Netopeer developers).
		If this step fails (e.g., the user has not connection to
		the Netopeer Web or the version of the XML configuration is "wired"),
		the exception
		is thrown (see documentation of the netopeer_xml library for more).
	</p>
	<p>
		<i>Note:</i> The local catalog is ever imported, because it is imported
		to the system catalog and the system catalog is ever imported automatically
		by the XML parser.
	</p>


	<h1>Managing the local catalog in the Netopeer distribution</h1>
	<p>
		There are some scripts for managing the catalogs in the Netopeer
		(most of these scripts are for other Netopeer tools or for testing, not
		for common users):
	</p>
	<ul>
		<li><tt>mkcatalog</tt> - creates the catalog (see 
			<tt>mkcatalog --help</tt> for more)</li>
		<li><tt>catalogs</tt> - for editing the catalog
			(see <tt>catalogs --help</tt> for more)</li>
		<li><tt>installschema</tt> - installs the new Netopeer
			schema and updates the local catalog</li>
	</ul>
	<p>
		The local catalog for Netopeer is implicitly located at
		<tt>/usr/local/etc/netopeer/</tt>. It is imported to the system catalog
		at <tt>/etc/xml/catalog</tt> (the link to the system catalog is added
		during install of the Netopeer distribution; if you install Netopeer
		as a non-root, it is created the <tt>system_catalog_path</tt> script which
		root must execute to patch the system catalog).
	</p>
	<p>
		There is added the line like this to the system catalog:
	</p>
	<p>
		<vstup>&lt;nextCatalog catalog="/usr/local/etc/netopeer/catalog"/&gt;</vstup>
	</p>
	<p>
		Other catalogs can be used too, see section Importing catalogs for more.
	</p>

	<h2>Installing the new Netopeer schema</h2>
	<p>
		User can install the new Netopeer schema during the <tt>installschema</tt>
		script. It installs the schema implicitly to the
		<tt>/usr/local/etc/netopeer/&lt;version&gt;/netopeer.rng</tt> and then
		updates the local catalog (the <tt>&lt;version&gt;</tt> is only the number
		here, e.g., <tt>1.1.10</tt>).
	</p>
	<p>
		So, installation is fully transparent for the user and he/she cannot
		know that there is some catalog in the Netopeer.
	</p>
</zprava>
