blob: ab68aa37fc212b505d425ae2b24c3184f3e69869 [file] [log] [blame]
Daniel Veillard09ab7e12001-07-10 15:49:44 +00001<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
2 "http://www.w3.org/TR/html4/loose.dtd">
Daniel Veillardccb09631998-10-27 06:21:04 +00003<html>
4<head>
Daniel Veillard598bec32003-07-06 10:02:03 +00005 <title>The XML C parser and toolkit of Gnome</title>
Daniel Veillard69839ba2006-06-06 13:27:03 +00006 <meta name="GENERATOR" content="amaya 8.8.5, see http://www.w3.org/Amaya/">
7 <meta http-equiv="content-type" content="text/html">
Daniel Veillardccb09631998-10-27 06:21:04 +00008</head>
Daniel Veillardccb09631998-10-27 06:21:04 +00009
Daniel Veillardb05deb71999-08-10 19:04:08 +000010<body bgcolor="#ffffff">
Daniel Veillard598bec32003-07-06 10:02:03 +000011<h1 align="center">The XML C parser and toolkit of Gnome</h1>
Daniel Veillardb05deb71999-08-10 19:04:08 +000012
Daniel Veillard69839ba2006-06-06 13:27:03 +000013<h1>Note: this is the flat content of the <a
14href="index.html">website</a></h1>
Daniel Veillard9c466822001-10-25 12:03:39 +000015
Daniel Veillardc9484202001-10-24 12:35:52 +000016<h1 style="text-align: center">libxml, a.k.a. gnome-xml</h1>
Daniel Veillardc8eab3a1999-09-04 18:27:23 +000017
18<p></p>
Daniel Veillard9c466822001-10-25 12:03:39 +000019
Daniel Veillard7ebac022004-02-25 22:36:35 +000020<p
Daniel Veillard69839ba2006-06-06 13:27:03 +000021style="text-align: right; font-style: italic; font-size: 10pt">"Programmingwith
22libxml2 is like the thrilling embrace of an exotic stranger." <a
23href="http://diveintomark.org/archives/2004/02/18/libxml2">MarkPilgrim</a></p>
Daniel Veillard7ebac022004-02-25 22:36:35 +000024
Daniel Veillard69839ba2006-06-06 13:27:03 +000025<p>Libxml2 is the XML C parser and toolkit developed for the Gnome
26project(but usable outside of the Gnome platform), it is free software
27availableunder the <a
28href="http://www.opensource.org/licenses/mit-license.html">MITLicense</a>.
29XML itself is a metalanguage to design markup languages, i.e.text language
30where semantic and structure are added to the content usingextra "markup"
31information enclosed between angle brackets. HTML is the mostwell-known
32markup language. Though the library is written in C <a href="python.html">a
33variety of language bindings</a>make it available inother environments.</p>
Daniel Veillard9c466822001-10-25 12:03:39 +000034
Daniel Veillard69839ba2006-06-06 13:27:03 +000035<p>Libxml2 is known to be very portable, the library should build and
36workwithout serious troubles on a variety of systems (Linux, Unix,
37Windows,CygWin, MacOS, MacOS X, RISC Os, OS/2, VMS, QNX, MVS, ...)</p>
Daniel Veillard710823b2003-03-04 10:05:52 +000038
Daniel Veillard69839ba2006-06-06 13:27:03 +000039<p>Libxml2 implements a number of existing standards related to
40markuplanguages:</p>
Daniel Veillard2f4dfc41999-09-24 14:03:48 +000041<ul>
Daniel Veillard9c466822001-10-25 12:03:39 +000042 <li>the XML standard: <a
43 href="http://www.w3.org/TR/REC-xml">http://www.w3.org/TR/REC-xml</a></li>
44 <li>Namespaces in XML: <a
45 href="http://www.w3.org/TR/REC-xml-names/">http://www.w3.org/TR/REC-xml-names/</a></li>
46 <li>XML Base: <a
47 href="http://www.w3.org/TR/xmlbase/">http://www.w3.org/TR/xmlbase/</a></li>
Daniel Veillard69839ba2006-06-06 13:27:03 +000048 <li><a href="http://www.cis.ohio-state.edu/rfc/rfc2396.txt">RFC
49 2396</a>:Uniform Resource Identifiers <a
Daniel Veillard9c466822001-10-25 12:03:39 +000050 href="http://www.ietf.org/rfc/rfc2396.txt">http://www.ietf.org/rfc/rfc2396.txt</a></li>
51 <li>XML Path Language (XPath) 1.0: <a
52 href="http://www.w3.org/TR/xpath">http://www.w3.org/TR/xpath</a></li>
53 <li>HTML4 parser: <a
54 href="http://www.w3.org/TR/html401/">http://www.w3.org/TR/html401/</a></li>
Daniel Veillard23a52c52003-08-18 10:01:18 +000055 <li>XML Pointer Language (XPointer) Version 1.0: <a
Daniel Veillard9c466822001-10-25 12:03:39 +000056 href="http://www.w3.org/TR/xptr">http://www.w3.org/TR/xptr</a></li>
57 <li>XML Inclusions (XInclude) Version 1.0: <a
58 href="http://www.w3.org/TR/xinclude/">http://www.w3.org/TR/xinclude/</a></li>
Daniel Veillard23a52c52003-08-18 10:01:18 +000059 <li>ISO-8859-x encodings, as well as <a
Daniel Veillard69839ba2006-06-06 13:27:03 +000060 href="http://www.cis.ohio-state.edu/rfc/rfc2044.txt">rfc2044</a>[UTF-8]and
61 <a
62 href="http://www.cis.ohio-state.edu/rfc/rfc2781.txt">rfc2781</a>[UTF-16]
63 Unicode encodings, and more if using iconv support</li>
Daniel Veillard9c466822001-10-25 12:03:39 +000064 <li>part of SGML Open Technical Resolution TR9401:1997</li>
65 <li>XML Catalogs Working Draft 06 August 2001: <a
66 href="http://www.oasis-open.org/committees/entity/spec-2001-08-06.html">http://www.oasis-open.org/committees/entity/spec-2001-08-06.html</a></li>
Daniel Veillard5c396542002-03-15 07:57:50 +000067 <li>Canonical XML Version 1.0: <a
Daniel Veillard69839ba2006-06-06 13:27:03 +000068 href="http://www.w3.org/TR/xml-c14n">http://www.w3.org/TR/xml-c14n</a>and
69 the Exclusive XML Canonicalization CR draft <a
Daniel Veillard2d347fa2002-03-17 10:34:11 +000070 href="http://www.w3.org/TR/xml-exc-c14n">http://www.w3.org/TR/xml-exc-c14n</a></li>
Daniel Veillard758c5312003-12-15 11:51:25 +000071 <li>Relax NG, ISO/IEC 19757-2:2003, <a
Daniel Veillard17bed982003-02-24 20:11:43 +000072 href="http://www.oasis-open.org/committees/relax-ng/spec-20011203.html">http://www.oasis-open.org/committees/relax-ng/spec-20011203.html</a></li>
Daniel Veillardf83a2c72003-04-08 13:48:40 +000073 <li>W3C XML Schemas Part 2: Datatypes <a
Daniel Veillard69839ba2006-06-06 13:27:03 +000074 href="http://www.w3.org/TR/2001/REC-xmlschema-2-20010502/">REC 02
75 May2001</a></li>
76 <li>W3C <a href="http://www.w3.org/TR/xml-id/">xml:id</a>Working Draft
77 7April 2004</li>
Daniel Veillard96984452000-08-31 13:50:12 +000078</ul>
79
Daniel Veillard69839ba2006-06-06 13:27:03 +000080<p>In most cases libxml2 tries to implement the specifications in arelatively
81strictly compliant way. As of release 2.4.16, libxml2 passed all1800+ tests
82from the <a
83href="http://www.oasis-open.org/committees/xml-conformance/">OASIS XML
84TestsSuite</a>.</p>
Daniel Veillard5b16f582002-02-20 11:38:46 +000085
Daniel Veillard69839ba2006-06-06 13:27:03 +000086<p>To some extent libxml2 provides support for the following
87additionalspecifications but doesn't claim to implement them completely:</p>
Daniel Veillard9c466822001-10-25 12:03:39 +000088<ul>
89 <li>Document Object Model (DOM) <a
Daniel Veillard69839ba2006-06-06 13:27:03 +000090 href="http://www.w3.org/TR/DOM-Level-2-Core/">http://www.w3.org/TR/DOM-Level-2-Core/</a>the
91 document model, but it doesn't implement the API itself, gdome2 doesthis
92 on top of libxml2</li>
93 <li><a href="http://www.cis.ohio-state.edu/rfc/rfc959.txt">RFC
94 959</a>:libxml2 implements a basic FTP client code</li>
95 <li><a href="http://www.cis.ohio-state.edu/rfc/rfc1945.txt">RFC
96 1945</a>:HTTP/1.0, again a basic HTTP client code</li>
97 <li>SAX: a SAX2 like interface and a minimal SAX1 implementation
98 compatiblewith early expat versions</li>
Daniel Veillard9c466822001-10-25 12:03:39 +000099</ul>
100
Daniel Veillardf83a2c72003-04-08 13:48:40 +0000101<p>A partial implementation of <a
Daniel Veillard69839ba2006-06-06 13:27:03 +0000102href="http://www.w3.org/TR/2001/REC-xmlschema-1-20010502/">XML Schemas Part1:
103Structure</a>is being worked on but it would be far too early to make
104anyconformance statement about it at the moment.</p>
Daniel Veillarde6d8e202002-05-02 06:11:10 +0000105
Daniel Veillard96984452000-08-31 13:50:12 +0000106<p>Separate documents:</p>
107<ul>
Daniel Veillard69839ba2006-06-06 13:27:03 +0000108 <li><a href="http://xmlsoft.org/XSLT/">the libxslt page</a>providing
109 animplementation of XSLT 1.0 and common extensions like EXSLT
110 forlibxml2</li>
111 <li><a href="http://www.cs.unibo.it/~casarini/gdome2/">the gdome2 page</a>:
112 a standard DOM2 implementation for libxml2</li>
113 <li><a href="http://www.aleksey.com/xmlsec/">the XMLSec page</a>:
114 animplementation of <a href="http://www.w3.org/TR/xmldsig-core/">W3C
115 XMLDigital Signature</a>for libxml2</li>
116 <li>also check the related links section below for more related and
117 activeprojects.</li>
Daniel Veillard2f4dfc41999-09-24 14:03:48 +0000118</ul>
Daniel Veillard252004d2004-03-23 12:32:32 +0000119<!----------------<p>Results of the <a
Daniel Veillard806cada2003-03-19 21:58:59 +0000120href="http://xmlbench.sourceforge.net/results/benchmark/index.html">xmlbench
Daniel Veillard31ae4622004-02-16 07:45:44 +0000121benchmark</a> on sourceforge February 2004 (smaller is better):</p>
Daniel Veillardd8da01c2003-03-24 15:58:23 +0000122
Daniel Veillard31ae4622004-02-16 07:45:44 +0000123<p align="center"><img src="benchmark.png"
Daniel Veillardd8da01c2003-03-24 15:58:23 +0000124alt="benchmark results for Expat Xerces libxml2 Oracle and Sun toolkits"></p>
Daniel Veillardcf80b782004-03-07 19:32:19 +0000125-------------->
Daniel Veillard806cada2003-03-19 21:58:59 +0000126
Daniel Veillarde1662542002-08-28 11:50:59 +0000127<p>Logo designed by <a href="mailto:liyanage@access.ch">Marc Liyanage</a>.</p>
128
Daniel Veillard2f4dfc41999-09-24 14:03:48 +0000129<h2><a name="Introducti">Introduction</a></h2>
Daniel Veillardc8eab3a1999-09-04 18:27:23 +0000130
Daniel Veillardf13e1ed2000-03-06 07:41:49 +0000131<p>This document describes libxml, the <a
Daniel Veillard69839ba2006-06-06 13:27:03 +0000132href="http://www.w3.org/XML/">XML</a>C parser and toolkit developed for the<a
133href="http://www.gnome.org/">Gnome</a>project. <a
134href="http://www.w3.org/XML/">XML is a standard</a>for building
135tag-basedstructured documents/data.</p>
Daniel Veillardb05deb71999-08-10 19:04:08 +0000136
Daniel Veillard0142b842000-01-14 14:45:24 +0000137<p>Here are some key points about libxml:</p>
138<ul>
Daniel Veillard69839ba2006-06-06 13:27:03 +0000139 <li>Libxml2 exports Push (progressive) and Pull (blocking) type
140 parserinterfaces for both XML and HTML.</li>
141 <li>Libxml2 can do DTD validation at parse time, using a parsed
142 documentinstance, or with an arbitrary DTD.</li>
Daniel Veillard8a469172003-06-12 16:05:07 +0000143 <li>Libxml2 includes complete <a
Daniel Veillard8c2ecaf2001-07-10 17:53:07 +0000144 href="http://www.w3.org/TR/xpath">XPath</a>, <a
Daniel Veillard69839ba2006-06-06 13:27:03 +0000145 href="http://www.w3.org/TR/xptr">XPointer</a>and <a
146 href="http://www.w3.org/TR/xinclude">XInclude</a>implementations.</li>
147 <li>It is written in plain C, making as few assumptions as possible,
148 andsticking closely to ANSI C/POSIX for easy embedding. Works
149 onLinux/Unix/Windows, ported to a number of other platforms.</li>
150 <li>Basic support for HTTP and FTP client allowing applications to
151 fetchremote resources.</li>
Daniel Veillard91e9d582001-02-26 07:31:12 +0000152 <li>The design is modular, most of the extensions can be compiled out.</li>
Daniel Veillard63d83142002-05-20 06:51:05 +0000153 <li>The internal document representation is as close as possible to the <a
Daniel Veillard69839ba2006-06-06 13:27:03 +0000154 href="http://www.w3.org/DOM/">DOM</a>interfaces.</li>
Daniel Veillard560c2a42003-07-06 21:13:49 +0000155 <li>Libxml2 also has a <a
Daniel Veillard69839ba2006-06-06 13:27:03 +0000156 href="http://www.megginson.com/SAX/index.html">SAX like interface</a>;the
157 interface is designed to be compatible with <a
Daniel Veillard402e8c82000-02-29 22:57:47 +0000158 href="http://www.jclark.com/xml/expat.html">Expat</a>.</li>
Daniel Veillardc575b992002-02-08 13:28:40 +0000159 <li>This library is released under the <a
Daniel Veillard69839ba2006-06-06 13:27:03 +0000160 href="http://www.opensource.org/licenses/mit-license.html">MITLicense</a>.
161 See the Copyright file in the distribution for the precisewording.</li>
Daniel Veillard0142b842000-01-14 14:45:24 +0000162</ul>
Daniel Veillardccb09631998-10-27 06:21:04 +0000163
Daniel Veillard69839ba2006-06-06 13:27:03 +0000164<p>Warning: unless you are forced to because your application links with
165aGnome-1.X library requiring it, <strong><span
166style="background-color: #FF0000">Do Not Use libxml1</span></strong>,
167uselibxml2</p>
Daniel Veillarde0c1d722001-03-21 10:28:36 +0000168
Daniel Veillardb8cfbd12001-10-25 10:53:28 +0000169<h2><a name="FAQ">FAQ</a></h2>
170
Daniel Veillard0b28e882002-07-24 23:47:05 +0000171<p>Table of Contents:</p>
Daniel Veillardb8cfbd12001-10-25 10:53:28 +0000172<ul>
Daniel Veillard63d83142002-05-20 06:51:05 +0000173 <li><a href="FAQ.html#License">License(s)</a></li>
Daniel Veillardb8cfbd12001-10-25 10:53:28 +0000174 <li><a href="FAQ.html#Installati">Installation</a></li>
175 <li><a href="FAQ.html#Compilatio">Compilation</a></li>
176 <li><a href="FAQ.html#Developer">Developer corner</a></li>
177</ul>
178
Daniel Veillard63d83142002-05-20 06:51:05 +0000179<h3><a name="License">License</a>(s)</h3>
Daniel Veillardb8cfbd12001-10-25 10:53:28 +0000180<ol>
181 <li><em>Licensing Terms for libxml</em>
Daniel Veillard8a469172003-06-12 16:05:07 +0000182 <p>libxml2 is released under the <a
Daniel Veillard69839ba2006-06-06 13:27:03 +0000183 href="http://www.opensource.org/licenses/mit-license.html">MITLicense</a>;
184 see the file Copyright in the distribution for the precisewording</p>
Daniel Veillardb8cfbd12001-10-25 10:53:28 +0000185 </li>
Daniel Veillard8a469172003-06-12 16:05:07 +0000186 <li><em>Can I embed libxml2 in a proprietary application ?</em>
Daniel Veillard69839ba2006-06-06 13:27:03 +0000187 <p>Yes. The MIT License allows you to keep proprietary the changes
188 youmade to libxml, but it would be graceful to send-back bug fixes
189 andimprovements as patches for possible incorporation in the
190 maindevelopment tree.</p>
Daniel Veillardb8cfbd12001-10-25 10:53:28 +0000191 </li>
192</ol>
193
194<h3><a name="Installati">Installation</a></h3>
195<ol>
Daniel Veillard69839ba2006-06-06 13:27:03 +0000196 <li><strong><span style="background-color: #FF0000">Do Not
197 Uselibxml1</span></strong>, use libxml2</li>
198 <li><em>Where can I get libxml</em>?
Daniel Veillardb8cfbd12001-10-25 10:53:28 +0000199 <p>The original distribution comes from <a
Daniel Veillard69839ba2006-06-06 13:27:03 +0000200 href="ftp://xmlsoft.org/libxml2/">xmlsoft.org</a>or <a
Daniel Veillard024f1992003-12-10 16:43:49 +0000201 href="ftp://ftp.gnome.org/pub/GNOME/sources/libxml2/2.6/">gnome.org</a></p>
Daniel Veillard69839ba2006-06-06 13:27:03 +0000202 <p>Most Linux and BSD distributions include libxml, this is probably
203 thesafer way for end-users to use libxml.</p>
Daniel Veillardb8cfbd12001-10-25 10:53:28 +0000204 <p>David Doolin provides precompiled Windows versions at <a
205 href="http://www.ce.berkeley.edu/~doolin/code/libxmlwin32/ ">http://www.ce.berkeley.edu/~doolin/code/libxmlwin32/</a></p>
206 </li>
207 <li><em>I see libxml and libxml2 releases, which one should I install ?</em>
208 <ul>
Daniel Veillard69839ba2006-06-06 13:27:03 +0000209 <li>If you are not constrained by backward compatibility issues
210 withexisting applications, install libxml2 only</li>
211 <li>If you are not doing development, you can safely install
212 both.Usually the packages <a
213 href="http://rpmfind.net/linux/RPM/libxml.html">libxml</a>and <a
214 href="http://rpmfind.net/linux/RPM/libxml2.html">libxml2</a>arecompatible
215 (this is not the case for development packages).</li>
216 <li>If you are a developer and your system provides separate
217 packagingfor shared libraries and the development components, it is
218 possibleto install libxml and libxml2, and also <a
219 href="http://rpmfind.net/linux/RPM/libxml-devel.html">libxml-devel</a>and
220 <a
221 href="http://rpmfind.net/linux/RPM/libxml2-devel.html">libxml2-devel</a>too
222 for libxml2 &gt;= 2.3.0</li>
223 <li>If you are developing a new application, please develop
224 againstlibxml2(-devel)</li>
Daniel Veillardb8cfbd12001-10-25 10:53:28 +0000225 </ul>
226 </li>
Daniel Veillard0b28e882002-07-24 23:47:05 +0000227 <li><em>I can't install the libxml package, it conflicts with libxml0</em>
Daniel Veillard69839ba2006-06-06 13:27:03 +0000228 <p>You probably have an old libxml0 package used to provide the
229 sharedlibrary for libxml.so.0, you can probably safely remove it. The
230 libxmlpackages provided on <a
231 href="ftp://xmlsoft.org/libxml2/">xmlsoft.org</a>providelibxml.so.0</p>
Daniel Veillardb8cfbd12001-10-25 10:53:28 +0000232 </li>
Daniel Veillard69839ba2006-06-06 13:27:03 +0000233 <li><em>I can't install the libxml(2) RPM package due to
234 faileddependencies</em>
235 <p>The most generic solution is to re-fetch the latest src.rpm ,
236 andrebuild it locally with</p>
Daniel Veillard0b28e882002-07-24 23:47:05 +0000237 <p><code>rpm --rebuild libxml(2)-xxx.src.rpm</code>.</p>
Daniel Veillard69839ba2006-06-06 13:27:03 +0000238 <p>If everything goes well it will generate two binary rpm packages
239 (oneproviding the shared libs and xmllint, and the other one, the
240 -develpackage, providing includes, static libraries and scripts needed to
241 buildapplications with libxml(2)) that you can install locally.</p>
Daniel Veillardb8cfbd12001-10-25 10:53:28 +0000242 </li>
243</ol>
244
245<h3><a name="Compilatio">Compilation</a></h3>
246<ol>
Daniel Veillard8a469172003-06-12 16:05:07 +0000247 <li><em>What is the process to compile libxml2 ?</em>
248 <p>As most UNIX libraries libxml2 follows the "standard":</p>
Daniel Veillardb8cfbd12001-10-25 10:53:28 +0000249 <p><code>gunzip -c xxx.tar.gz | tar xvf -</code></p>
250 <p><code>cd libxml-xxxx</code></p>
251 <p><code>./configure --help</code></p>
252 <p>to see the options, then the compilation/installation proper</p>
253 <p><code>./configure [possible options]</code></p>
254 <p><code>make</code></p>
255 <p><code>make install</code></p>
Daniel Veillard69839ba2006-06-06 13:27:03 +0000256 <p>At that point you may have to rerun ldconfig or a similar utility
257 toupdate your list of installed shared libs.</p>
Daniel Veillardb8cfbd12001-10-25 10:53:28 +0000258 </li>
Daniel Veillard8a469172003-06-12 16:05:07 +0000259 <li><em>What other libraries are needed to compile/install libxml2 ?</em>
Daniel Veillard69839ba2006-06-06 13:27:03 +0000260 <p>Libxml2 does not require any other library, the normal C ANSI
261 APIshould be sufficient (please report any violation to this rule you
262 mayfind).</p>
263 <p>However if found at configuration time libxml2 will detect and use
264 thefollowing libs:</p>
Daniel Veillardb8cfbd12001-10-25 10:53:28 +0000265 <ul>
Daniel Veillard69839ba2006-06-06 13:27:03 +0000266 <li><a href="http://www.info-zip.org/pub/infozip/zlib/">libz</a>:
267 ahighly portable and available widely compression library.</li>
268 <li>iconv: a powerful character encoding conversion library. It
269 isincluded by default in recent glibc libraries, so it doesn't need
270 tobe installed specifically on Linux. It now seems a <a
271 href="http://www.opennc.org/onlinepubs/7908799/xsh/iconv.html">partof
272 the official UNIX</a>specification. Here is one <a
273 href="http://www.gnu.org/software/libiconv/">implementation of
274 thelibrary</a>which source can be found <a
Daniel Veillardb8cfbd12001-10-25 10:53:28 +0000275 href="ftp://ftp.ilog.fr/pub/Users/haible/gnu/">here</a>.</li>
276 </ul>
277 </li>
Daniel Veillard0b28e882002-07-24 23:47:05 +0000278 <li><em>Make check fails on some platforms</em>
Daniel Veillard69839ba2006-06-06 13:27:03 +0000279 <p>Sometimes the regression tests' results don't completely match
280 thevalue produced by the parser, and the makefile uses diff to print
281 thedelta. On some platforms the diff return breaks the compilation
282 process;if the diff is small this is probably not a serious problem.</p>
283 <p>Sometimes (especially on Solaris) make checks fail due to
284 limitationsin make. Try using GNU-make instead.</p>
Daniel Veillardb8cfbd12001-10-25 10:53:28 +0000285 </li>
286 <li><em>I use the CVS version and there is no configure script</em>
Daniel Veillard69839ba2006-06-06 13:27:03 +0000287 <p>The configure script (and other Makefiles) are generated. Use
288 theautogen.sh script to regenerate the configure script and
289 Makefiles,like:</p>
Daniel Veillardb8cfbd12001-10-25 10:53:28 +0000290 <p><code>./autogen.sh --prefix=/usr --disable-shared</code></p>
291 </li>
292 <li><em>I have troubles when running make tests with gcc-3.0</em>
Daniel Veillard69839ba2006-06-06 13:27:03 +0000293 <p>It seems the initial release of gcc-3.0 has a problem with
294 theoptimizer which miscompiles the URI module. Please use
295 anothercompiler.</p>
Daniel Veillardb8cfbd12001-10-25 10:53:28 +0000296 </li>
297</ol>
298
Daniel Veillard69839ba2006-06-06 13:27:03 +0000299<h3><a name="Developer">Developer</a>corner</h3>
Daniel Veillardb8cfbd12001-10-25 10:53:28 +0000300<ol>
Daniel Veillard93d95252003-04-29 20:25:40 +0000301 <li><em>Troubles compiling or linking programs using libxml2</em>
Daniel Veillard69839ba2006-06-06 13:27:03 +0000302 <p>Usually the problem comes from the fact that the compiler doesn't
303 getthe right compilation or linking flags. There is a small shell
304 script<code>xml2-config</code>which is installed as part of libxml2
305 usualinstall process which provides those flags. Use</p>
Daniel Veillard93d95252003-04-29 20:25:40 +0000306 <p><code>xml2-config --cflags</code></p>
307 <p>to get the compilation flags and</p>
308 <p><code>xml2-config --libs</code></p>
Daniel Veillard69839ba2006-06-06 13:27:03 +0000309 <p>to get the linker flags. Usually this is done directly from
310 theMakefile as:</p>
Daniel Veillard93d95252003-04-29 20:25:40 +0000311 <p><code>CFLAGS=`xml2-config --cflags`</code></p>
312 <p><code>LIBS=`xml2-config --libs`</code></p>
313 </li>
Daniel Veillard69839ba2006-06-06 13:27:03 +0000314 <li><em>I want to install my own copy of libxml2 in my home directory
315 andlink my programs against it, but it doesn't work</em>
316 <p>There are many different ways to accomplish this. Here is one way
317 todo this under Linux. Suppose your home directory is
318 <code>/home/user.</code>Then:</p>
Daniel Veillard67952602006-01-05 15:29:44 +0000319 <ul>
320 <li>Create a subdirectory, let's call it <code>myxml</code></li>
William M. Brack99906ad2005-01-09 17:02:42 +0000321 <li>unpack the libxml2 distribution into that subdirectory</li>
Daniel Veillard69839ba2006-06-06 13:27:03 +0000322 <li>chdir into the unpacked distribution(<code>/home/user/myxml/libxml2
323 </code>)</li>
324 <li>configure the library using the "<code>--prefix</code>"
325 switch,specifying an installation subdirectory
326 in<code>/home/user/myxml</code>, e.g.
327 <p><code>./configure --prefix
328 /home/user/myxml/xmlinst</code>{otherconfiguration options}</p>
Daniel Veillard67952602006-01-05 15:29:44 +0000329 </li>
Daniel Veillard69839ba2006-06-06 13:27:03 +0000330 <li>now run <code>make</code>followed by <code>make install</code></li>
331 <li>At this point, the installation subdirectory contains the
332 complete"private" include files, library files and binary program
333 files (e.g.xmllint), located in
334 <p><code>/home/user/myxml/xmlinst/lib,/home/user/myxml/xmlinst/include
335 </code>and <code>/home/user/myxml/xmlinst/bin</code></p>
Daniel Veillard67952602006-01-05 15:29:44 +0000336 respectively.</li>
Daniel Veillard69839ba2006-06-06 13:27:03 +0000337 <li>In order to use this "private" library, you should first add it
338 tothe beginning of your default PATH (so that your own private
339 programfiles such as xmllint will be used instead of the normal
340 systemones). To do this, the Bash command would be
Daniel Veillard67952602006-01-05 15:29:44 +0000341 <p><code>export PATH=/home/user/myxml/xmlinst/bin:$PATH</code></p>
342 </li>
Daniel Veillard69839ba2006-06-06 13:27:03 +0000343 <li>Now suppose you have a program <code>test1.c</code>that you
344 wouldlike to compile with your "private" library. Simply compile it
345 usingthe command
Daniel Veillard67952602006-01-05 15:29:44 +0000346 <p><code>gcc `xml2-config --cflags --libs` -o test test.c</code></p>
Daniel Veillard69839ba2006-06-06 13:27:03 +0000347 Note that, because your PATH has been set with
348 <code>/home/user/myxml/xmlinst/bin</code>at the beginning, the
349 xml2-configprogram which you just installed will be used instead of
350 the systemdefault one, and this will <em>automatically</em>get the
351 correctlibraries linked with your program.</li>
Daniel Veillard67952602006-01-05 15:29:44 +0000352 </ul>
353 </li>
354
355 <p></p>
Daniel Veillard0b28e882002-07-24 23:47:05 +0000356 <li><em>xmlDocDump() generates output on one line.</em>
Daniel Veillard69839ba2006-06-06 13:27:03 +0000357 <p>Libxml2 will not <strong>invent</strong>spaces in the content of
358 adocument since <strong>all spaces in the content of a document
359 aresignificant</strong>. If you build a tree from the API and
360 wantindentation:</p>
Daniel Veillardb8cfbd12001-10-25 10:53:28 +0000361 <ol>
Daniel Veillard0b28e882002-07-24 23:47:05 +0000362 <li>the correct way is to generate those yourself too.</li>
Daniel Veillard69839ba2006-06-06 13:27:03 +0000363 <li>the dangerous way is to ask libxml2 to add those blanks to
364 yourcontent <strong>modifying the content of your document in
365 theprocess</strong>. The result may not be what you expect. There
366 is<strong>NO</strong>way to guarantee that such a modification
367 won'taffect other parts of the content of your document. See <a
368 href="http://xmlsoft.org/html/libxml-parser.html#xmlKeepBlanksDefault">xmlKeepBlanksDefault()</a>and
369 <a
370 href="http://xmlsoft.org/html/libxml-tree.html#xmlSaveFormatFile">xmlSaveFormatFile()</a></li>
Daniel Veillardb8cfbd12001-10-25 10:53:28 +0000371 </ol>
372 </li>
373 <li>Extra nodes in the document:
374 <p><em>For a XML file as below:</em></p>
375 <pre>&lt;?xml version="1.0"?&gt;
376&lt;PLAN xmlns="http://www.argus.ca/autotest/1.0/"&gt;
377&lt;NODE CommFlag="0"/&gt;
378&lt;NODE CommFlag="1"/&gt;
379&lt;/PLAN&gt;</pre>
Daniel Veillard69839ba2006-06-06 13:27:03 +0000380 <p><em>after parsing it with the
381 functionpxmlDoc=xmlParseFile(...);</em></p>
382 <p><em>I want to the get the content of the first node (node with
383 theCommFlag="0")</em></p>
Daniel Veillardb8cfbd12001-10-25 10:53:28 +0000384 <p><em>so I did it as following;</em></p>
Daniel Veillard63d83142002-05-20 06:51:05 +0000385 <pre>xmlNodePtr pnode;
Daniel Veillardb8cfbd12001-10-25 10:53:28 +0000386pnode=pxmlDoc-&gt;children-&gt;children;</pre>
387 <p><em>but it does not work. If I change it to</em></p>
388 <pre>pnode=pxmlDoc-&gt;children-&gt;children-&gt;next;</pre>
389 <p><em>then it works. Can someone explain it to me.</em></p>
390 <p></p>
Daniel Veillard69839ba2006-06-06 13:27:03 +0000391 <p>In XML all characters in the content of the document are
392 significant<strong>including blanks and formatting line
393 breaks</strong>.</p>
394 <p>The extra nodes you are wondering about are just that, text nodes
395 withthe formatting spaces which are part of the document but that people
396 tendto forget. There is a function <a
397 href="http://xmlsoft.org/html/libxml-parser.html">xmlKeepBlanksDefault()</a>to
398 remove those at parse time, but that's an heuristic, and itsuse should be
399 limited to cases where you are certain there is nomixed-content in the
400 document.</p>
Daniel Veillardb8cfbd12001-10-25 10:53:28 +0000401 </li>
Daniel Veillard69839ba2006-06-06 13:27:03 +0000402 <li><em>I get compilation errors of existing code like when
403 accessing<strong>root</strong>or <strong>child fields</strong>of
404 nodes.</em>
405 <p>You are compiling code developed for libxml version 1 and using
406 alibxml2 development environment. Either switch back to libxml v1 devel
407 oreven better fix the code to compile with libxml2 (or both) by <a
Daniel Veillardb8cfbd12001-10-25 10:53:28 +0000408 href="upgrade.html">following the instructions</a>.</p>
409 </li>
Daniel Veillard69839ba2006-06-06 13:27:03 +0000410 <li><em>I get compilation errors about non
411 existing<strong>xmlRootNode</strong>or
412 <strong>xmlChildrenNode</strong>fields.</em>
Daniel Veillardb8cfbd12001-10-25 10:53:28 +0000413 <p>The source code you are using has been <a
Daniel Veillard69839ba2006-06-06 13:27:03 +0000414 href="upgrade.html">upgraded</a>to be able to compile with both libxmland
415 libxml2, but you need to install a more recent version:libxml(-devel)
416 &gt;= 1.8.8 or libxml2(-devel) &gt;= 2.1.0</p>
Daniel Veillardb8cfbd12001-10-25 10:53:28 +0000417 </li>
418 <li><em>XPath implementation looks seriously broken</em>
Daniel Veillard69839ba2006-06-06 13:27:03 +0000419 <p>XPath implementation prior to 2.3.0 was really incomplete. Upgrade toa
420 recent version, there are no known bugs in the current version.</p>
Daniel Veillardb8cfbd12001-10-25 10:53:28 +0000421 </li>
Daniel Veillard0b28e882002-07-24 23:47:05 +0000422 <li><em>The example provided in the web page does not compile.</em>
Daniel Veillard69839ba2006-06-06 13:27:03 +0000423 <p>It's hard to maintain the documentation in sync with the
424 code&lt;grin/&gt; ...</p>
425 <p>Check the previous points 1/ and 2/ raised before, and please
426 sendpatches.</p>
Daniel Veillardb8cfbd12001-10-25 10:53:28 +0000427 </li>
Daniel Veillard69839ba2006-06-06 13:27:03 +0000428 <li><em>Where can I get more examples and information than provided on
429 theweb page?</em>
430 <p>Ideally a libxml2 book would be nice. I have no such plan ... But
431 youcan:</p>
Daniel Veillardb8cfbd12001-10-25 10:53:28 +0000432 <ul>
Daniel Veillard69839ba2006-06-06 13:27:03 +0000433 <li>check more deeply the <a
434 href="html/libxml-lib.html">existinggenerated doc</a></li>
435 <li>have a look at <a href="examples/index.html">the set
436 ofexamples</a>.</li>
437 <li>look for examples of use for libxml2 function using the Gnome
438 code.For example the following will query the full Gnome CVS base for
439 theuse of the <strong>xmlAddChild()</strong>function:
Daniel Veillardb8cfbd12001-10-25 10:53:28 +0000440 <p><a
441 href="http://cvs.gnome.org/lxr/search?string=xmlAddChild">http://cvs.gnome.org/lxr/search?string=xmlAddChild</a></p>
Daniel Veillard69839ba2006-06-06 13:27:03 +0000442 <p>This may be slow, a large hardware donation to the gnome
443 projectcould cure this :-)</p>
Daniel Veillardb8cfbd12001-10-25 10:53:28 +0000444 </li>
445 <li><a
Daniel Veillard69839ba2006-06-06 13:27:03 +0000446 href="http://cvs.gnome.org/bonsai/rview.cgi?cvsroot=/cvs/gnome&amp;dir=gnome-xml">Browsethe
447 libxml2 source</a>, I try to write code as clean and documentedas
448 possible, so looking at it may be helpful. In particular the codeof
449 xmllint.c and of the various testXXX.c test programs shouldprovide
450 good examples of how to do things with the library.</li>
Daniel Veillardb8cfbd12001-10-25 10:53:28 +0000451 </ul>
452 </li>
453 <li>What about C++ ?
Daniel Veillard69839ba2006-06-06 13:27:03 +0000454 <p>libxml2 is written in pure C in order to allow easy reuse on a
455 numberof platforms, including embedded systems. I don't intend to convert
456 toC++.</p>
Daniel Veillard91e69c52003-08-04 01:43:07 +0000457 <p>There is however a C++ wrapper which may fulfill your needs:</p>
Daniel Veillard9b6fd302002-05-13 12:06:47 +0000458 <ul>
459 <li>by Ari Johnson &lt;ari@btigate.com&gt;:
460 <p>Website: <a
Daniel Veillard91e69c52003-08-04 01:43:07 +0000461 href="http://libxmlplusplus.sourceforge.net/">http://libxmlplusplus.sourceforge.net/</a></p>
Daniel Veillard9b6fd302002-05-13 12:06:47 +0000462 <p>Download: <a
Daniel Veillard91e69c52003-08-04 01:43:07 +0000463 href="http://sourceforge.net/project/showfiles.php?group_id=12999">http://sourceforge.net/project/showfiles.php?group_id=12999</a></p>
Daniel Veillard9b6fd302002-05-13 12:06:47 +0000464 </li>
Daniel Veillard83ee40d2003-08-09 22:24:09 +0000465 <!-- Website is currently unavailable as of 2003-08-02
Daniel Veillard9b6fd302002-05-13 12:06:47 +0000466 <li>by Peter Jones &lt;pjones@pmade.org&gt;
Daniel Veillard83ee40d2003-08-09 22:24:09 +0000467 <p>Website: <a
468 href="http://pmade.org/pjones/software/xmlwrapp/">http://pmade.org/pjones/software/xmlwrapp/</a></p>
Daniel Veillard9b6fd302002-05-13 12:06:47 +0000469 </li>
Daniel Veillard83ee40d2003-08-09 22:24:09 +0000470 -->
Daniel Veillard9b6fd302002-05-13 12:06:47 +0000471 </ul>
Daniel Veillardb8cfbd12001-10-25 10:53:28 +0000472 </li>
473 <li>How to validate a document a posteriori ?
Daniel Veillard69839ba2006-06-06 13:27:03 +0000474 <p>It is possible to validate documents which had not been validated
475 atinitial parsing time or documents which have been built from
476 scratchusing the API. Use the <a
477 href="http://xmlsoft.org/html/libxml-valid.html#xmlValidateDtd">xmlValidateDtd()</a>function.
478 It is also possible to simply add a DTD to an existingdocument:</p>
Daniel Veillardb8cfbd12001-10-25 10:53:28 +0000479 <pre>xmlDocPtr doc; /* your existing document */
Daniel Veillard0b28e882002-07-24 23:47:05 +0000480xmlDtdPtr dtd = xmlParseDTD(NULL, filename_of_dtd); /* parse the DTD */
481
Daniel Veillardb8cfbd12001-10-25 10:53:28 +0000482 dtd-&gt;name = xmlStrDup((xmlChar*)"root_name"); /* use the given root */
483
484 doc-&gt;intSubset = dtd;
485 if (doc-&gt;children == NULL) xmlAddChild((xmlNodePtr)doc, (xmlNodePtr)dtd);
486 else xmlAddPrevSibling(doc-&gt;children, (xmlNodePtr)dtd);
487 </pre>
488 </li>
Daniel Veillarddad3f682002-11-17 16:47:27 +0000489 <li>So what is this funky "xmlChar" used all the time?
Daniel Veillard69839ba2006-06-06 13:27:03 +0000490 <p>It is a null terminated sequence of utf-8 characters. And only
491 utf-8!You need to convert strings encoded in different ways to utf-8
492 beforepassing them to the API. This can be accomplished with the iconv
493 libraryfor instance.</p>
John Fleck61f6fb62002-10-31 15:23:29 +0000494 </li>
Daniel Veillardb8cfbd12001-10-25 10:53:28 +0000495 <li>etc ...</li>
496</ol>
497
498<p></p>
499
Daniel Veillard66f68e72003-08-18 16:39:51 +0000500<h2><a name="Documentat">Developer Menu</a></h2>
Daniel Veillardb05deb71999-08-10 19:04:08 +0000501
Daniel Veillard0b28e882002-07-24 23:47:05 +0000502<p>There are several on-line resources related to using libxml:</p>
Daniel Veillard0142b842000-01-14 14:45:24 +0000503<ol>
Daniel Veillard69839ba2006-06-06 13:27:03 +0000504 <li>Use the <a href="search.php">search engine</a>to look
505 upinformation.</li>
Daniel Veillard0b28e882002-07-24 23:47:05 +0000506 <li>Check the <a href="FAQ.html">FAQ.</a></li>
Daniel Veillard69839ba2006-06-06 13:27:03 +0000507 <li>Check the <a
508 href="http://xmlsoft.org/html/libxml-lib.html">extensivedocumentation</a>automatically
509 extracted from code comments.</li>
510 <li>Look at the documentation about <a
511 href="encoding.html">libxmlinternationalization support</a>.</li>
512 <li>This page provides a global overview and <a
513 href="example.html">someexamples</a>on how to use libxml.</li>
Daniel Veillardc480c4e2003-12-10 13:24:38 +0000514 <li><a href="examples/index.html">Code examples</a></li>
Daniel Veillard69839ba2006-06-06 13:27:03 +0000515 <li>John Fleck's libxml2 tutorial: <a href="tutorial/index.html">html</a>or
516 <a href="tutorial/xmltutorial.pdf">pdf</a>.</li>
Daniel Veillard1177ca42003-04-26 22:29:54 +0000517 <li>If you need to parse large files, check the <a
Daniel Veillard69839ba2006-06-06 13:27:03 +0000518 href="xmlreader.html">xmlReader</a>API tutorial</li>
519 <li><a href="mailto:james@daa.com.au">James Henstridge</a>wrote <a
520 href="http://www.daa.com.au/~james/gnome/xml-sax/xml-sax.html">some
521 nicedocumentation</a>explaining how to use the libxml SAX interface.</li>
Daniel Veillardc480c4e2003-12-10 13:24:38 +0000522 <li>George Lebl wrote <a
Daniel Veillard69839ba2006-06-06 13:27:03 +0000523 href="http://www-106.ibm.com/developerworks/library/l-gnome3/">an
524 articlefor IBM developerWorks</a>about using libxml.</li>
525 <li>Check <a href="http://cvs.gnome.org/lxr/source/gnome-xml/TODO">the
526 TODOfile</a>.</li>
527 <li>Read the <a href="upgrade.html">1.x to 2.x upgrade path</a>description.
528 If you are starting a new project using libxml you shouldreally use the
529 2.x version.</li>
Daniel Veillard845cce42002-01-09 11:51:37 +0000530 <li>And don't forget to look at the <a
531 href="http://mail.gnome.org/archives/xml/">mailing-list archive</a>.</li>
Daniel Veillard0142b842000-01-14 14:45:24 +0000532</ol>
Daniel Veillardc8eab3a1999-09-04 18:27:23 +0000533
Daniel Veillardd5f97f82000-09-17 16:38:14 +0000534<h2><a name="Reporting">Reporting bugs and getting help</a></h2>
Daniel Veillard4c3a2031999-11-19 17:46:26 +0000535
Daniel Veillard69839ba2006-06-06 13:27:03 +0000536<p>Well, bugs or missing features are always possible, and I will make apoint
537of fixing them in a timely fashion. The best way to report a bug is touse the
538<a href="http://bugzilla.gnome.org/buglist.cgi?product=libxml2">Gnomebug
539tracking database</a>(make sure to use the "libxml2" module name). Ilook at
540reports there regularly and it's good to have a reminder when a bugis still
541open. Be sure to specify that the bug is for the package libxml2.</p>
Daniel Veillard4c3a2031999-11-19 17:46:26 +0000542
Daniel Veillard69839ba2006-06-06 13:27:03 +0000543<p>For small problems you can try to get help on IRC, the #xml channel
544onirc.gnome.org (port 6667) usually have a few person subscribed which may
545help(but there is no garantee and if a real issue is raised it should go on
546themailing-list for archival).</p>
Daniel Veillard9582d6c2003-09-16 11:40:04 +0000547
Daniel Veillard0142b842000-01-14 14:45:24 +0000548<p>There is also a mailing-list <a
Daniel Veillard69839ba2006-06-06 13:27:03 +0000549href="mailto:xml@gnome.org">xml@gnome.org</a>for libxml, with an <a
550href="http://mail.gnome.org/archives/xml/">on-line archive</a>(<a
551href="http://xmlsoft.org/messages">old</a>). To subscribe to this list,please
552visit the <a href="http://mail.gnome.org/mailman/listinfo/xml">associated
553Web</a>page andfollow the instructions. <strong>Do not send code, I won't
554debug it</strong>(but patches are really appreciated!).</p>
Daniel Veillardd99224d2004-04-06 10:04:16 +0000555
Daniel Veillard69839ba2006-06-06 13:27:03 +0000556<p>Please note that with the current amount of virus and SPAM, sending mailto
557the list without being subscribed won't work. There is *far too manybounces*
558(in the order of a thousand a day !) I cannot approve them manuallyanymore.
559If your mail to the list bounced waiting for administrator approval,it is
560LOST ! Repost it and fix the problem triggering the error. Also pleasenote
561that <span style="color: #FF0000; background-color: #FFFFFF">emails witha
562legal warning asking to not copy or redistribute freely the informationsthey
563contain</span>are <strong>NOT</strong>acceptable for the mailing-list,such
564mail will as much as possible be discarded automatically, and are lesslikely
565to be answered if they made it to the list, <strong>DO NOT</strong>post to
566the list from an email address where such legal requirements areautomatically
567added, get private paying support if you can't shareinformations.</p>
Daniel Veillard234547b2001-07-05 09:46:10 +0000568
Daniel Veillard69839ba2006-06-06 13:27:03 +0000569<p>Check the following <strong><span
570style="color: #FF0000">beforeposting</span></strong>:</p>
Daniel Veillard234547b2001-07-05 09:46:10 +0000571<ul>
Daniel Veillard69839ba2006-06-06 13:27:03 +0000572 <li>Read the <a href="FAQ.html">FAQ</a>and <a href="search.php">use
573 thesearch engine</a>to get information related to your problem.</li>
574 <li>Make sure you are <a href="ftp://xmlsoft.org/libxml2/">using a
575 recentversion</a>, and that the problem still shows up in a recent
576 version.</li>
577 <li>Check the <a
578 href="http://mail.gnome.org/archives/xml/">listarchives</a>to see if the
579 problem was reported already. In this casethere is probably a fix
580 available, similarly check the <a
581 href="http://bugzilla.gnome.org/buglist.cgi?product=libxml2">registeredopen
582 bugs</a>.</li>
583 <li>Make sure you can reproduce the bug with xmllint or one of the
584 testprograms found in source in the distribution.</li>
585 <li>Please send the command showing the error as well as the input (as
586 anattachment)</li>
Daniel Veillard234547b2001-07-05 09:46:10 +0000587</ul>
Daniel Veillard0142b842000-01-14 14:45:24 +0000588
Daniel Veillarda37aab82003-06-09 09:10:36 +0000589<p>Then send the bug with associated information to reproduce it to the <a
Daniel Veillard69839ba2006-06-06 13:27:03 +0000590href="mailto:xml@gnome.org">xml@gnome.org</a>list; if it's really
591libxmlrelated I will approve it. Please do not send mail to me directly, it
592makesthings really hard to track and in some cases I am not the best person
593toanswer a given question, ask on the list.</p>
Daniel Veillard98d071d2003-01-10 09:22:44 +0000594
595<p>To <span style="color: #E50000">be really clear about support</span>:</p>
596<ul>
Daniel Veillard69839ba2006-06-06 13:27:03 +0000597 <li>Support or help <span style="color: #E50000">requests MUST be sent
598 tothe list or on bugzilla</span>in case of problems, so that the
599 Questionand Answers can be shared publicly. Failing to do so carries the
600 implicitmessage "I want free support but I don't want to share the
601 benefits withothers" and is not welcome. I will automatically Carbon-Copy
602 thexml@gnome.org mailing list for any technical reply made about libxml2
603 orlibxslt.</li>
604 <li>There is <span style="color: #E50000">no garantee of support</span>,
605 ifyour question remains unanswered after a week, repost it, making sure
606 yougave all the detail needed and the information requested.</li>
607 <li>Failing to provide information as requested or double checking firstfor
608 prior feedback also carries the implicit message "the time of thelibrary
609 maintainers is less valuable than my time" and might not bewelcome.</li>
Daniel Veillard98d071d2003-01-10 09:22:44 +0000610</ul>
Daniel Veillard4c3a2031999-11-19 17:46:26 +0000611
Daniel Veillard69839ba2006-06-06 13:27:03 +0000612<p>Of course, bugs reported with a suggested patch for fixing them
613willprobably be processed faster than those without.</p>
Daniel Veillardec303412000-03-24 13:41:54 +0000614
615<p>If you're looking for help, a quick look at <a
Daniel Veillard69839ba2006-06-06 13:27:03 +0000616href="http://mail.gnome.org/archives/xml/">the list archive</a>may
617actuallyprovide the answer. I usually send source samples when answering
618libxml2usage questions. The <a
619href="http://xmlsoft.org/html/book1.html">auto-generated
620documentation</a>isnot as polished as I would like (i need to learn more
621about DocBook), butit's a good starting point.</p>
Daniel Veillardec303412000-03-24 13:41:54 +0000622
Daniel Veillardd5f97f82000-09-17 16:38:14 +0000623<h2><a name="help">How to help</a></h2>
624
Daniel Veillard69839ba2006-06-06 13:27:03 +0000625<p>You can help the project in various ways, the best thing to do first is
626tosubscribe to the mailing-list as explained before, check the <a
Daniel Veillardf7ed3362001-08-17 12:01:21 +0000627href="http://mail.gnome.org/archives/xml/">archives </a>and the <a
Daniel Veillard69839ba2006-06-06 13:27:03 +0000628href="http://bugzilla.gnome.org/buglist.cgi?product=libxml2">Gnome
629bugdatabase</a>:</p>
Daniel Veillardd5f97f82000-09-17 16:38:14 +0000630<ol>
Daniel Veillard0b28e882002-07-24 23:47:05 +0000631 <li>Provide patches when you find problems.</li>
Daniel Veillard69839ba2006-06-06 13:27:03 +0000632 <li>Provide the diffs when you port libxml2 to a new platform. They may
633 notbe integrated in all cases but help pinpointing portability
634 problemsand</li>
635 <li>Provide documentation fixes (either as patches to the code comments
636 oras HTML diffs).</li>
637 <li>Provide new documentations pieces (translations, examples, etc...).</li>
Daniel Veillard0b28e882002-07-24 23:47:05 +0000638 <li>Check the TODO file and try to close one of the items.</li>
Daniel Veillard69839ba2006-06-06 13:27:03 +0000639 <li>Take one of the points raised in the archive or the bug database
640 andprovide a fix. <a href="mailto:daniel@veillard.com">Get in touch with
641 me</a>before to avoid synchronization problems and check that the
642 suggestedfix will fit in nicely :-)</li>
Daniel Veillardd5f97f82000-09-17 16:38:14 +0000643</ol>
644
Daniel Veillard10a2c651999-12-12 13:03:50 +0000645<h2><a name="Downloads">Downloads</a></h2>
Daniel Veillard2f4dfc41999-09-24 14:03:48 +0000646
Daniel Veillard688f6692004-03-26 10:57:38 +0000647<p>The latest versions of libxml2 can be found on the <a
Daniel Veillard69839ba2006-06-06 13:27:03 +0000648href="ftp://xmlsoft.org/libxml2/">xmlsoft.org</a>server ( <a
Daniel Veillardeca726d2004-04-18 21:47:34 +0000649href="http://xmlsoft.org/sources/">HTTP</a>, <a
Daniel Veillard69839ba2006-06-06 13:27:03 +0000650href="ftp://xmlsoft.org/libxml2/">FTP</a>and rsync are available), there is
651alsomirrors (<a href="ftp://ftp.planetmirror.com/pub/xmlsoft/">Australia</a>(
652<a href="http://xmlsoft.planetmirror.com/">Web</a>), <a
Daniel Veillard20c8cf22001-06-26 22:47:36 +0000653href="ftp://fr.rpmfind.net/pub/libxml/">France</a>) or on the <a
Daniel Veillard69839ba2006-06-06 13:27:03 +0000654href="ftp://ftp.gnome.org/pub/GNOME/MIRRORS.html">Gnome FTP server</a>as <a
655href="ftp://ftp.gnome.org/pub/GNOME/sources/libxml2/2.6/">source archive</a>,
656Antonin Sprinzl also provide <a
657href="ftp://gd.tuwien.ac.at/pub/libxml/">amirror in Austria</a>. (NOTE that
658you need both the <a
659href="http://rpmfind.net/linux/RPM/libxml2.html">libxml(2)</a>and <a
660href="http://rpmfind.net/linux/RPM/libxml2-devel.html">libxml(2)-devel</a>packages
661installed to compile applications using libxml.)</p>
Daniel Veillardeca726d2004-04-18 21:47:34 +0000662
663<p>You can find all the history of libxml(2) and libxslt releases in the <a
Daniel Veillard69839ba2006-06-06 13:27:03 +0000664href="http://xmlsoft.org/sources/old/">old</a>directory. The
665precompiledWindows binaries made by Igor Zlatovic are available in the <a
666href="http://xmlsoft.org/sources/win32/">win32</a>directory.</p>
Daniel Veillardb46a5732003-04-08 13:35:48 +0000667
668<p>Binary ports:</p>
669<ul>
670 <li>Red Hat RPMs for i386 are available directly on <a
Daniel Veillard69839ba2006-06-06 13:27:03 +0000671 href="ftp://xmlsoft.org/libxml2/">xmlsoft.org</a>, the source RPM will
672 compile onany architecture supported by Red Hat.</li>
673 <li><a href="mailto:igor@zlatkovic.com">Igor Zlatkovic</a>is now
674 themaintainer of the Windows port, <a
675 href="http://www.zlatkovic.com/projects/libxml/index.html">he
676 providesbinaries</a>.</li>
Daniel Veillard67952602006-01-05 15:29:44 +0000677 <li>Blastwave provides <a
Daniel Veillard69839ba2006-06-06 13:27:03 +0000678 href="http://www.blastwave.org/packages.php/libxml2">Solarisbinaries</a>.</li>
679 <li><a href="mailto:Steve.Ball@explain.com.au">Steve Ball</a>provides <a
680 href="http://www.explain.com.au/oss/libxml2xslt.html">Mac Os
681 Xbinaries</a>.</li>
Daniel Veillardb46a5732003-04-08 13:35:48 +0000682 <li>The HP-UX porting center provides <a
683 href="http://hpux.connect.org.uk/hppd/hpux/Gnome/">HP-UX binaries</a></li>
Daniel Veillard67952602006-01-05 15:29:44 +0000684 <li>Bull provides precompiled <a
Daniel Veillard69839ba2006-06-06 13:27:03 +0000685 href="http://gnome.bullfreeware.com/new_index.html">RPMs for
686 AIX</a>aspatr of their GNOME packages</li>
Daniel Veillardb46a5732003-04-08 13:35:48 +0000687</ul>
688
689<p>If you know other supported binary ports, please <a
690href="http://veillard.com/">contact me</a>.</p>
Daniel Veillard2f4dfc41999-09-24 14:03:48 +0000691
Daniel Veillard6c8b1172000-03-01 00:40:41 +0000692<p><a name="Snapshot">Snapshot:</a></p>
693<ul>
Daniel Veillard3cef1192004-08-18 09:30:31 +0000694 <li>Code from the W3C cvs base libxml2 module, updated hourly <a
Daniel Veillard9110ed62006-04-03 15:21:57 +0000695 href="ftp://xmlsoft.org/libxml2/libxml2-cvs-snapshot.tar.gz">libxml2-cvs-snapshot.tar.gz</a>.</li>
Daniel Veillard6c8b1172000-03-01 00:40:41 +0000696 <li>Docs, content of the web site, the list archive included <a
Daniel Veillard9110ed62006-04-03 15:21:57 +0000697 href="ftp://xmlsoft.org/libxml2/libxml-docs.tar.gz">libxml-docs.tar.gz</a>.</li>
Daniel Veillard6c8b1172000-03-01 00:40:41 +0000698</ul>
699
Daniel Veillardc6271d22001-10-27 07:50:58 +0000700<p><a name="Contribs">Contributions:</a></p>
Daniel Veillard6c8b1172000-03-01 00:40:41 +0000701
Daniel Veillard69839ba2006-06-06 13:27:03 +0000702<p>I do accept external contributions, especially if compiling on
703anotherplatform, get in touch with the list to upload the package, wrappers
704forvarious languages have been provided, and can be found in the <a
Daniel Veillardd99224d2004-04-06 10:04:16 +0000705href="python.html">bindings section</a></p>
Daniel Veillard6c8b1172000-03-01 00:40:41 +0000706
Daniel Veillard8a469172003-06-12 16:05:07 +0000707<p>Libxml2 is also available from CVS:</p>
Daniel Veillard10a2c651999-12-12 13:03:50 +0000708<ul>
Daniel Veillard69839ba2006-06-06 13:27:03 +0000709 <li><p>The <a href="http://cvs.gnome.org/viewcvs/libxml2/">Gnome
710 CVSbase</a>. Check the <a
711 href="http://developer.gnome.org/tools/cvs.html">Gnome CVS Tools</a>page;
712 the CVS module is <b>libxml2</b>.</p>
Daniel Veillard10a2c651999-12-12 13:03:50 +0000713 </li>
Daniel Veillard69839ba2006-06-06 13:27:03 +0000714 <li>The <strong>libxslt</strong>module is also present there</li>
Daniel Veillard10a2c651999-12-12 13:03:50 +0000715</ul>
716
Daniel Veillard78fed532004-10-09 19:44:48 +0000717<h2><a name="News">Releases</a></h2>
Daniel Veillard10a2c651999-12-12 13:03:50 +0000718
Daniel Veillard69839ba2006-06-06 13:27:03 +0000719<p>Items not finished and worked on, get in touch with the list if you wantto
720help those</p>
Daniel Veillardab8500d2000-10-15 21:06:19 +0000721<ul>
Daniel Veillard72fef162003-02-05 14:31:19 +0000722 <li>More testing on RelaxNG</li>
Daniel Veillard69839ba2006-06-06 13:27:03 +0000723 <li>Finishing up <a
724 href="http://www.w3.org/TR/xmlschema-1/">XMLSchemas</a></li>
Daniel Veillard72fef162003-02-05 14:31:19 +0000725</ul>
726
Daniel Veillard69839ba2006-06-06 13:27:03 +0000727<p>The <a href="ChangeLog.html">change log</a>describes the recents commitsto
728the <a href="http://cvs.gnome.org/viewcvs/libxml2/">CVS</a>code base.</p>
Daniel Veillard2d908032004-08-10 10:16:36 +0000729
Daniel Veillardd99224d2004-04-06 10:04:16 +0000730<p>There is the list of public releases:</p>
731
Daniel Veillard69839ba2006-06-06 13:27:03 +0000732<h3>2.6.25: Jun 6 2006</h3>
733<ul>
734 <li>portability fixes: Python detection (Joseph Sacco), compilation error
735 (William Brack and Graham Bennett), LynxOS patch (Olli Savia)</li>
736 <li>bug fixes: encoding buffer problem, mix of code and data in xmlIO.c
737 (Kjartan Maraas), entities in XSD validation (Kasimier Buchcik), various
738 XSD validation fixes (Kasimier), memory leak in pattern (Rob Richards and
739 Kasimier), attribute with colon in name (Rob Richards), XPath leak in
740 error reporting (Aleksey Sanin), XInclude text include of self
741 document.</li>
742 <li>improvements: Xpath optimizations (Kasimier), XPath object cache
743 (Kasimier), </li>
744</ul>
745
Daniel Veillardb2f8f1d2006-04-28 16:30:48 +0000746<h3>2.6.24: Apr 28 2006</h3>
747<ul>
Daniel Veillard69839ba2006-06-06 13:27:03 +0000748 <li>Portability fixes: configure on Windows, testapi compile on
749 windows(Kasimier Buchcik, venkat naidu), Borland C++ 6 compile (Eric
750 Zurcher),HP-UX compiler workaround (Rick Jones), xml2-config bugfix,
751 gcc-4.1cleanups, Python detection scheme (Joseph Sacco), UTF-8 file paths
752 onWindows (Roland Schwingel).</li>
753 <li>Improvements: xmlDOMWrapReconcileNamespaces xmlDOMWrapCloneNode
754 (KasimierBuchcik), XML catalog debugging (Rick Jones), update to Unicode
755 4.01.</li>
756 <li>Bug fixes: xmlParseChunk() problem in 2.6.23, xmlParseInNodeContext()on
757 HTML docs, URI behaviour on Windows (Rob Richards), comment streamingbug,
758 xmlParseComment (with William Brack), regexp bug fixes (DV &amp;Youri
759 Golovanov), xmlGetNodePath on text/CDATA (Kasimier),one Relax-NG
760 interleave bug, xmllint --path and --valid,XSD bugfixes (Kasimier),
761 remove debugleft in Python bindings (Nic Ferrier), xmlCatalogAdd bug
762 (Martin Cole),xmlSetProp fixes (Rob Richards), HTML IDness (Rob
763 Richards), a largenumber of cleanups and small fixes based on Coverity
764 reports, bugin character ranges, Unicode tables const (Aivars Kalvans),
765 schemasfix (Stefan Kost), xmlRelaxNGParse error
766 deallocation,xmlSchemaAddSchemaDoc error deallocation, error handling on
767 unallowedcode point, ixmllint --nonet to never reach the net (Gary
768 Coady),line break in writer after end PI (Jason Viers).</li>
Daniel Veillardb2f8f1d2006-04-28 16:30:48 +0000769 <li>Documentation: man pages updates and cleanups (Daniel Leidert).</li>
770 <li>New features: Relax NG structure error handlers.</li>
771</ul>
772
Daniel Veillard67952602006-01-05 15:29:44 +0000773<h3>2.6.23: Jan 5 2006</h3>
774<ul>
Daniel Veillard69839ba2006-06-06 13:27:03 +0000775 <li>portability fixes: Windows (Rob Richards), getaddrinfo on Windows(Kolja
776 Nowak, Rob Richards), icc warnings (Kjartan Maraas),--with-minimum
777 compilation fixes (William Brack), error case handling fixon Solaris
778 (Albert Chin), don't use 'list' as parameter name reported bySamuel Diaz
779 Garcia, more old Unices portability fixes (Albert Chin),MinGW compilation
780 (Mark Junker), HP-UX compiler warnings (RickJones),</li>
781 <li>code cleanup: xmlReportError (Adrian Mouat), remove
782 xmlBufferClose(Geert Jansen), unreachable code (Oleksandr Kononenko),
783 refactoringparsing code (Bjorn Reese)</li>
784 <li>bug fixes: xmlBuildRelativeURI and empty path (William
785 Brack),combinatory explosion and performances in regexp code, leak
786 inxmlTextReaderReadString(), xmlStringLenDecodeEntities problem
787 (MassimoMorara), Identity Constraints bugs and a segfault (Kasimier
788 Buchcik),XPath pattern based evaluation bugs (DV &amp;
789 Kasimier),xmlSchemaContentModelDump() memory leak (Kasimier), potential
790 leak inxmlSchemaCheckCSelectorXPath(), xmlTextWriterVSprintf() misuse
791 ofvsnprintf (William Brack), XHTML serialization fix (Rob Richards),
792 CRLFsplit problem (William), issues with non-namespaced attributes
793 inxmlAddChild() xmlAddNextSibling() and xmlAddPrevSibling() (Rob
794 Richards),HTML parsing of script, Python must not output to stdout (Nic
795 Ferrier),exclusive C14N namespace visibility (Aleksey Sanin), XSD
796 dataypetotalDigits bug (Kasimier Buchcik), error handling when writing to
797 anxmlBuffer (Rob Richards), runtest schemas error not reported
798 (HisashiFujinaka), signed/unsigned problem in date/time code (Albert
799 Chin), fixXSI driven XSD validation (Kasimier), parsing of xs:decimal
800 (Kasimier),fix DTD writer output (Rob Richards), leak in
801 xmlTextReaderReadInnerXml(Gary Coady), regexp bug affecting schemas
802 (Kasimier), configuration ofruntime debugging (Kasimier),
803 xmlNodeBufGetContent bug on entity refs(Oleksandr Kononenko),
804 xmlRegExecPushString2 bug (Sreeni Nair),compilation and build fixes
805 (Michael Day), removed dependancies onxmlSchemaValidError (Kasimier), bug
806 with &lt;xml:foo/&gt;, more XPathpattern based evaluation fixes
807 (Kasimier)</li>
808 <li>improvements: XSD Schemas redefinitions/restrictions (KasimierBuchcik),
809 node copy checks and fix for attribute (Rob Richards), countedtransition
810 bug in regexps, ctxt-&gt;standalone = -2 to indicate nostandalone
811 attribute was found, add xmlSchemaSetParserStructuredErrors()(Kasimier
812 Buchcik), add xmlTextReaderSchemaValidateCtxt() to API(Kasimier), handle
813 gzipped HTTP resources (Gary Coady), addhtmlDocDumpMemoryFormat. (Rob
814 Richards),</li>
815 <li>documentation: typo (Michael Day), libxml man page (Albert Chin),
816 savefunction to XML buffer (Geert Jansen), small doc fix (Aron
817 Stansvik),</li>
Daniel Veillard67952602006-01-05 15:29:44 +0000818</ul>
819
Daniel Veillard33b20b72005-09-12 21:43:20 +0000820<h3>2.6.22: Sep 12 2005</h3>
821<ul>
822 <li>build fixes: compile without schematron (Stéphane Bidoul)</li>
Daniel Veillard69839ba2006-06-06 13:27:03 +0000823 <li>bug fixes: xmlDebugDumpNode on namespace node (Oleg Paraschenko)i,CDATA
824 push parser bug, xmlElemDump problem with XHTML1 doc,XML_FEATURE_xxx
825 clash with expat headers renamed XML_WITH_xxx, fix someoutput formatting
826 for meta element (Rob Richards), script and styleXHTML1 serialization
827 (David Madore), Attribute derivation fixups in XSD(Kasimier Buchcik),
828 better IDC error reports (Kasimier Buchcik)</li>
829 <li>improvements: add XML_SAVE_NO_EMPTY xmlSaveOption (Rob Richards),
830 addXML_SAVE_NO_XHTML xmlSaveOption, XML Schemas improvements preparing
831 forderive (Kasimier Buchcik).</li>
832 <li>documentation: generation of gtk-doc like docs, integration
833 withdevhelp.</li>
Daniel Veillard33b20b72005-09-12 21:43:20 +0000834</ul>
Daniel Veillard67952602006-01-05 15:29:44 +0000835
Daniel Veillardb3d14912005-09-04 20:47:39 +0000836<h3>2.6.21: Sep 4 2005</h3>
837<ul>
Daniel Veillard69839ba2006-06-06 13:27:03 +0000838 <li>build fixes: Cygwin portability fixes (Gerrit P. Haase),
839 callingconvention problems on Windows (Marcus Boerger), cleanups based on
840 Linus'sparse tool, update of win32/configure.js (Rob Richards), remove
841 warningson Windows(Marcus Boerger), compilation without SAX1, detection
842 of thePython binary, use $GCC inestad of $CC = 'gcc' (Andrew W.
843 Nosenko),compilation/link with threads and old gcc, compile problem by
844 C370 onZ/OS,</li>
845 <li>bug fixes: http_proxy environments (Peter Breitenlohner), HTML UTF-8bug
846 (Jiri Netolicky), XPath NaN compare bug (William Brack),htmlParseScript
847 potential bug, Schemas regexp handling of spaces, Base64Schemas
848 comparisons NIST passes, automata build error xsd:all,xmlGetNodePath for
849 namespaced attributes (Alexander Pohoyda), xmlSchemasforeign namespaces
850 handling, XML Schemas facet comparison (KupriyanovAnatolij),
851 xmlSchemaPSimpleTypeErr error report (Kasimier Buchcik), xml:namespace
852 ahndling in Schemas (Kasimier), empty model group in Schemas(Kasimier),
853 wilcard in Schemas (Kasimier), URI composition (William),xs:anyType in
854 Schemas (Kasimier), Python resolver emmitting errormessages directly,
855 Python xmlAttr.parent (Jakub Piotr Clapa), trying tofix the file path/URI
856 conversion, xmlTextReaderGetAttribute fix (RobRichards),
857 xmlSchemaFreeAnnot memleak (Kasimier), HTML UTF-8serialization, streaming
858 XPath, Schemas determinism detection problem,XInclude bug, Schemas
859 context type (Dean Hill), validation fix (DerekPoon),
860 xmlTextReaderGetAttribute[Ns] namespaces (Rob Richards), Schemastype fix
861 (Kuba Nowakowski), UTF-8 parser bug, error in encoding
862 handling,xmlGetLineNo fixes, bug on entities handling, entity name
863 extraction inerror handling with XInclude, text nodes in HTML body tags
864 (Gary Coady),xml:id and IDness at the treee level fixes, XPath streaming
865 patternsbugs.</li>
866 <li>improvements: structured interfaces for schemas and RNG error
867 reports(Marcus Boerger), optimization of the char data inner loop
868 parsing(thanks to Behdad Esfahbod for the idea), schematron validation
869 thoughnot finished yet, xmlSaveOption to omit XML declaration, keyref
870 matcherror reports (Kasimier), formal expression handling code not
871 pluggedyet, more lax mode for the HTML parser, parser XML_PARSE_COMPACT
872 optionfor text nodes allocation.</li>
Daniel Veillardb3d14912005-09-04 20:47:39 +0000873 <li>documentation: xmllint man page had --nonet duplicated</li>
874</ul>
Daniel Veillard67952602006-01-05 15:29:44 +0000875
Daniel Veillard78dfc9f2005-07-10 22:30:30 +0000876<h3>2.6.20: Jul 10 2005</h3>
877<ul>
Daniel Veillard69839ba2006-06-06 13:27:03 +0000878 <li>build fixes: Windows build (Rob Richards), Mingw compilation
879 (IgorZlatkovic), Windows Makefile (Igor), gcc warnings (Kasimier
880 andandriy@google.com), use gcc weak references to pthread to avoid
881 thepthread dependancy on Linux, compilation problem (Steve Nairn),
882 compilingof subset (Morten Welinder), IPv6/ss_family compilation (William
883 Brack),compilation when disabling parts of the library, standalone
884 testdistribution.</li>
885 <li>bug fixes: bug in lang(), memory cleanup on errors (William Brack),HTTP
886 query strings (Aron Stansvik), memory leak in DTD (William),
887 integeroverflow in XPath (William), nanoftp buffer size, pattern "." apth
888 fixup(Kasimier), leak in tree reported by Malcolm Rowe, replaceNode
889 patch(Brent Hendricks), CDATA with NULL content (Mark Vakoc), xml:base
890 fixupon XInclude (William), pattern fixes (William), attribute bug
891 inexclusive c14n (Aleksey Sanin), xml:space and xml:lang with SAX2
892 (RobRichards), namespace trouble in complex parsing (Malcolm Rowe), XSD
893 typeQNames fixes (Kasimier), XPath streaming fixups (William), RelaxNG
894 bug(Rob Richards), Schemas for Schemas fixes (Kasimier), removal of ID
895 (RobRichards), a small RelaxNG leak, HTML parsing in push mode bug
896 (JamesBursa), failure to detect UTF-8 parsing bugs in CDATA
897 sections,areBlanks() heuristic failure, duplicate attributes in DTD
898 bug(William).</li>
899 <li>improvements: lot of work on Schemas by Kasimier Buchcik both
900 onconformance and streaming, Schemas validation messages (Kasimier
901 Buchcik,Matthew Burgess), namespace removal at the python level
902 (BrentHendricks), Update to new Schemas regression tests from
903 W3C/Nist(Kasimier), xmlSchemaValidateFile() (Kasimier), implementation
904 ofxmlTextReaderReadInnerXml and xmlTextReaderReadOuterXml (James
905 Wert),standalone test framework and programs, new DOM import
906 APIsxmlDOMWrapReconcileNamespaces() xmlDOMWrapAdoptNode()
907 andxmlDOMWrapRemoveNode(), extension of xmllint capabilities for SAX
908 andSchemas regression tests, xmlStopParser() available in pull mode
909 too,ienhancement to xmllint --shell namespaces support, Windows port of
910 thestandalone testing tools (Kasimier and
911 William),xmlSchemaValidateStream() xmlSchemaSAXPlug() and
912 xmlSchemaSAXUnplug() SAXSchemas APIs, Schemas xmlReader support.</li>
Daniel Veillard78dfc9f2005-07-10 22:30:30 +0000913</ul>
Daniel Veillard67952602006-01-05 15:29:44 +0000914
Daniel Veillard771971f2005-04-02 10:49:51 +0000915<h3>2.6.19: Apr 02 2005</h3>
916<ul>
Daniel Veillard69839ba2006-06-06 13:27:03 +0000917 <li>build fixes: drop .la from RPMs, --with-minimum build fix
918 (WilliamBrack), use XML_SOCKLEN_T instead of SOCKLEN_T because it breaks
919 with AIX5.3 compiler, fixed elfgcchack.h generation and PLT reduction
920 code onLinux/ELF/gcc4</li>
921 <li>bug fixes: schemas type decimal fixups (William Brack), xmmlint
922 returncode (Gerry Murphy), small schemas fixes (Matthew Burgess and
923 GUYFabrice), workaround "DAV:" namespace brokeness in c14n (Aleksey
924 Sanin),segfault in Schemas (Kasimier Buchcik), Schemas attribute
925 validation(Kasimier), Prop related functions and xmlNewNodeEatName (Rob
926 Richards),HTML serialization of name attribute on a elements, Python
927 error handlersleaks and improvement (Brent Hendricks), uninitialized
928 variable inencoding code, Relax-NG validation bug, potential crash
929 ifgnorableWhitespace is NULL, xmlSAXParseDoc and xmlParseDoc
930 signatures,switched back to assuming UTF-8 in case no encoding is given
931 atserialization time</li>
932 <li>improvements: lot of work on Schemas by Kasimier Buchcik on
933 facetschecking and also mixed handling.</li>
Daniel Veillard771971f2005-04-02 10:49:51 +0000934 <li></li>
935</ul>
Daniel Veillard67952602006-01-05 15:29:44 +0000936
Daniel Veillard57c000e2005-03-13 18:34:29 +0000937<h3>2.6.18: Mar 13 2005</h3>
938<ul>
Daniel Veillard69839ba2006-06-06 13:27:03 +0000939 <li>build fixes: warnings (Peter Breitenlohner), testapi.c
940 generation,Bakefile support (Francesco Montorsi), Windows compilation
941 (Joel Reed),some gcc4 fixes, HP-UX portability fixes (Rick Jones).</li>
942 <li>bug fixes: xmlSchemaElementDump namespace (Kasimier Buchcik), push
943 andxmlreader stopping on non-fatal errors, thread support for
944 dictionnariesreference counting (Gary Coady), internal subset and push
945 problem, URLsaved in xmlCopyDoc, various schemas bug fixes (Kasimier),
946 Python pathsfixup (Stephane Bidoul), xmlGetNodePath and namespaces,
947 xmlSetNsProp fix(Mike Hommey), warning should not count as error (William
948 Brack),xmlCreatePushParser empty chunk, XInclude parser flags (William),
949 cleanupFTP and HTTP code to reuse the uri parsing and IPv6
950 (William),xmlTextWriterStartAttributeNS fix (Rob Richards),
951 XMLLINT_INDENT beingempty (William), xmlWriter bugs (Rob Richards),
952 multithreading on Windows(Rich Salz), xmlSearchNsByHref fix (Kasimier),
953 Python binding leak (BrentHendricks), aliasing bug exposed by gcc4 on
954 s390, xmlTextReaderNext bug(Rob Richards), Schemas decimal type fixes
955 (William Brack),xmlByteConsumed static buffer (Ben Maurer).</li>
956 <li>improvement: speedup parsing comments and DTDs, dictionnary support
957 forhash tables, Schemas Identity constraints (Kasimier), streaming
958 XPathsubset, xmlTextReaderReadString added (Bjorn Reese), Schemas
959 canonicalvalues handling (Kasimier), add xmlTextReaderByteConsumed
960 (AronStansvik),</li>
Daniel Veillard67952602006-01-05 15:29:44 +0000961 <li>Documentation: Wiki support (Joel Reed)</li>
Daniel Veillard57c000e2005-03-13 18:34:29 +0000962</ul>
Daniel Veillard67952602006-01-05 15:29:44 +0000963
Daniel Veillard298d9642005-01-16 20:01:55 +0000964<h3>2.6.17: Jan 16 2005</h3>
965<ul>
Daniel Veillard69839ba2006-06-06 13:27:03 +0000966 <li>build fixes: Windows, warnings removal (William Brack),maintainer-clean
967 dependency(William), build in a different directory(William), fixing
968 --with-minimum configure build (William), BeOS build(Marcin Konicki),
969 Python-2.4 detection (William), compilation on AIX (DanMcNichol)</li>
970 <li>bug fixes: xmlTextReaderHasAttributes (Rob Richards),
971 xmlCtxtReadFile()to use the catalog(s), loop on output (William Brack),
972 XPath memory leak,ID deallocation problem (Steve Shepard), debugDumpNode
973 crash (William),warning not using error callback (William), xmlStopParser
974 bug (William),UTF-16 with BOM on DTDs (William), namespace bug on empty
975 elements inpush mode (Rob Richards), line and col computations fixups
976 (AlekseySanin), xmlURIEscape fix (William), xmlXPathErr on bad range
977 (William),patterns with too many steps, bug in RNG choice optimization,
978 line numbersometimes missing.</li>
979 <li>improvements: XSD Schemas (Kasimier Buchcik), python
980 generator(William), xmlUTF8Strpos speedup (William), unicode Python
981 strings(William), XSD error reports (Kasimier Buchcik), Python __str__
982 callserialize().</li>
983 <li>new APIs: added xmlDictExists(), GetLineNumber and GetColumnNumber
984 forthe xmlReader (Aleksey Sanin), Dynamic Shared Libraries APIs (mostly
985 JoelReed), error extraction API from regexps, new XMLSave option for
986 format(Phil Shafer)</li>
987 <li>documentation: site improvement (John Fleck), FAQ entries(William).</li>
Daniel Veillard298d9642005-01-16 20:01:55 +0000988</ul>
989
Daniel Veillardc3d7cb42004-11-10 14:34:45 +0000990<h3>2.6.16: Nov 10 2004</h3>
991<ul>
Daniel Veillard69839ba2006-06-06 13:27:03 +0000992 <li>general hardening and bug fixing crossing all the API based on
993 newautomated regression testing</li>
Daniel Veillardc3d7cb42004-11-10 14:34:45 +0000994 <li>build fix: IPv6 build and test on AIX (Dodji Seketeli)</li>
Daniel Veillard69839ba2006-06-06 13:27:03 +0000995 <li>bug fixes: problem with XML::Libxml reported by Petr Pajas,
996 encodingconversion functions return values, UTF-8 bug affecting XPath
997 reported byMarkus Bertheau, catalog problem with NULL entries (William
998 Brack)</li>
999 <li>documentation: fix to xmllint man page, some API function
1000 descritpionwere updated.</li>
1001 <li>improvements: DTD validation APIs provided at the Python level
1002 (BrentHendricks)</li>
Daniel Veillardc3d7cb42004-11-10 14:34:45 +00001003</ul>
1004
Daniel Veillardc2f83d12004-10-27 22:59:21 +00001005<h3>2.6.15: Oct 27 2004</h3>
Daniel Veillard6927b102004-10-27 17:29:04 +00001006<ul>
1007 <li>security fixes on the nanoftp and nanohttp modules</li>
Daniel Veillard69839ba2006-06-06 13:27:03 +00001008 <li>build fixes: xmllint detection bug in configure, building outside
1009 thesource tree (Thomas Fitzsimmons)</li>
1010 <li>bug fixes: HTML parser on broken ASCII chars in names (William),
1011 Pythonpaths (Malcolm Tredinnick), xmlHasNsProp and default namespace
1012 (William),saving to python file objects (Malcolm Tredinnick), DTD lookup
1013 fix(Malcolm), save back &lt;group&gt; in catalogs (William), tree
1014 buildfixes (DV and Rob Richards), Schemas memory bug, structured error
1015 handleron Python 64bits, thread local memory deallocation, memory leak
1016 reportedby Volker Roth, xmlValidateDtd in the presence of an internal
1017 subset,entities and _private problem (William), xmlBuildRelativeURI
1018 error(William).</li>
1019 <li>improvements: better XInclude error reports (William), tree
1020 debuggingmodule and tests, convenience functions at the Reader API
1021 (GrahamBennett), add support for PI in the HTML parser.</li>
Daniel Veillard6927b102004-10-27 17:29:04 +00001022</ul>
1023
Daniel Veillard210818b2004-09-29 15:50:37 +00001024<h3>2.6.14: Sep 29 2004</h3>
1025<ul>
Daniel Veillard69839ba2006-06-06 13:27:03 +00001026 <li>build fixes: configure paths for xmllint and xsltproc,
1027 compilationwithout HTML parser, compilation warning cleanups (William
1028 Brack &amp;Malcolm Tredinnick), VMS makefile update (Craig Berry),</li>
1029 <li>bug fixes: xmlGetUTF8Char (William Brack), QName properties
1030 (KasimierBuchcik), XInclude testing, Notation serialization,
1031 UTF8ToISO8859xtranscoding (Mark Itzcovitz), lots of XML Schemas cleanup
1032 and fixes(Kasimier), ChangeLog cleanup (Stepan Kasal), memory fixes (Mark
1033 Vakoc),handling of failed realloc(), out of bound array adressing in
1034 Schemasdate handling, Python space/tabs cleanups (Malcolm Tredinnick),
1035 NMTOKENSE20 validation fix (Malcolm),</li>
1036 <li>improvements: added W3C XML Schemas testsuite (Kasimier Buchcik),
1037 addxmlSchemaValidateOneElement (Kasimier), Python exception
1038 hierearchy(Malcolm Tredinnick), Python libxml2 driver improvement
1039 (MalcolmTredinnick), Schemas support for
1040 xsi:schemaLocation,xsi:noNamespaceSchemaLocation, xsi:type (Kasimier
1041 Buchcik)</li>
Daniel Veillard210818b2004-09-29 15:50:37 +00001042</ul>
1043
Daniel Veillardd1de4a32004-08-31 13:43:07 +00001044<h3>2.6.13: Aug 31 2004</h3>
1045<ul>
Daniel Veillard69839ba2006-06-06 13:27:03 +00001046 <li>build fixes: Windows and zlib (Igor Zlatkovic), -O flag with
1047 gcc,Solaris compiler warning, fixing RPM BuildRequires,</li>
1048 <li>fixes: DTD loading on Windows (Igor), Schemas error reports
1049 APIs(Kasimier Buchcik), Schemas validation crash, xmlCheckUTF8 (William
1050 Brackand Julius Mittenzwei), Schemas facet check (Kasimier), default
1051 namespaceproblem (William), Schemas hexbinary empty values, encoding
1052 error couldgenrate a serialization loop.</li>
1053 <li>Improvements: Schemas validity improvements (Kasimier), added --pathand
1054 --load-trace options to xmllint</li>
Daniel Veillardd1de4a32004-08-31 13:43:07 +00001055 <li>documentation: tutorial update (John Fleck)</li>
1056</ul>
1057
Daniel Veillardb331fff2004-08-22 14:21:57 +00001058<h3>2.6.12: Aug 22 2004</h3>
1059<ul>
Daniel Veillard69839ba2006-06-06 13:27:03 +00001060 <li>build fixes: fix --with-minimum, elfgcchack.h fixes
1061 (PeterBreitenlohner), perl path lookup (William), diff on Solaris
1062 (AlbertChin), some 64bits cleanups.</li>
1063 <li>Python: avoid a warning with 2.3 (William Brack), tab and space
1064 mixes(William), wrapper generator fixes (William), Cygwin support (Gerrit
1065 P.Haase), node wrapper fix (Marc-Antoine Parent), XML Schemas
1066 support(Torkel Lyng)</li>
Daniel Veillardb331fff2004-08-22 14:21:57 +00001067 <li>Schemas: a lot of bug fixes and improvements from Kasimier Buchcik</li>
Daniel Veillard69839ba2006-06-06 13:27:03 +00001068 <li>fixes: RVT fixes (William), XPath context resets bug (William),
1069 memorydebug (Steve Hay), catalog white space handling (Peter
1070 Breitenlohner),xmlReader state after attribute reading (William),
1071 structured errorhandler (William), XInclude generated xml:base fixup
1072 (William), Windowsmemory reallocation problem (Steve Hay), Out of Memory
1073 conditionshandling (William and Olivier Andrieu), htmlNewDoc() charset
1074 bug,htmlReadMemory init (William), a posteriori validation DTD
1075 base(William), notations serialization missing, xmlGetNodePath
1076 (Dodji),xmlCheckUTF8 (Diego Tartara), missing line numbers on
1077 entity(William)</li>
1078 <li>improvements: DocBook catalog build scrip (William), xmlcatalog
1079 tool(Albert Chin), xmllint --c14n option, no_proxy environment (Mike
1080 Hommey),xmlParseInNodeContext() addition, extend xmllint --shell, allow
1081 XIncludeto not generate start/end nodes, extend xmllint --version to
1082 include CVStag (William)</li>
1083 <li>documentation: web pages fixes, validity API docs fixes
1084 (William)schemas API fix (Eric Haszlakiewicz), xmllint man page (John
1085 Fleck)</li>
Daniel Veillardb331fff2004-08-22 14:21:57 +00001086</ul>
1087
Daniel Veillard45cb0f42004-07-05 17:45:35 +00001088<h3>2.6.11: July 5 2004</h3>
1089<ul>
Daniel Veillard69839ba2006-06-06 13:27:03 +00001090 <li>Schemas: a lot of changes and improvements by Kasimier Buchcik
1091 forattributes, namespaces and simple types.</li>
1092 <li>build fixes: --with-minimum (William Brack), some gcc
1093 cleanup(William), --with-thread-alloc (William)</li>
1094 <li>portability: Windows binary package change (Igor Zlatkovic),
1095 Catalogpath on Windows</li>
1096 <li>documentation: update to the tutorial (John Fleck), xmllint return
1097 code(John Fleck), man pages (Ville Skytta),</li>
1098 <li>bug fixes: C14N bug serializing namespaces (Aleksey Sanin),
1099 testSAXproperly initialize the library (William), empty node set in
1100 XPath(William), xmlSchemas errors (William), invalid charref problem
1101 pointedby Morus Walter, XInclude xml:base generation (William), Relax-NG
1102 bugwith div processing (William), XPointer and xml:base
1103 problem(William),Reader and entities, xmllint return code for schemas
1104 (William), readerstreaming problem (Steve Ball), DTD serialization
1105 problem (William),libxml.m4 fixes (Mike Hommey), do not provide
1106 destructors as methods onPython classes, xmlReader buffer bug, Python
1107 bindings memory interfacesimprovement (with Stéphane Bidoul), Fixed the
1108 push parser to be back tosynchronous behaviour.</li>
1109 <li>improvement: custom per-thread I/O enhancement (Rob Richards),
1110 registernamespace in debug shell (Stefano Debenedetti), Python based
1111 regressiontest for non-Unix users (William), dynamically increase the
1112 number ofXPath extension functions in Python and fix a memory leak
1113 (Marc-AntoineParent and William)</li>
1114 <li>performance: hack done with Arjan van de Ven to reduce ELF footprintand
1115 generated code on Linux, plus use gcc runtime profiling to optimizethe
1116 code generated in the RPM packages.</li>
Daniel Veillard45cb0f42004-07-05 17:45:35 +00001117</ul>
1118
Daniel Veillard81205012004-05-18 03:06:41 +00001119<h3>2.6.10: May 17 2004</h3>
1120<ul>
1121 <li>Web page generated for ChangeLog</li>
1122 <li>build fixes: --without-html problems, make check without make all</li>
Daniel Veillard69839ba2006-06-06 13:27:03 +00001123 <li>portability: problem with xpath.c on Windows (MSC and Borland),
1124 memcmpvs. strncmp on Solaris, XPath tests on Windows (Mark Vakoc), C++ do
1125 notuse "list" as parameter name, make tests work with Python 1.5
1126 (EdDavis),</li>
1127 <li>improvements: made xmlTextReaderMode public, small buffers
1128 resizing(Morten Welinder), add --maxmem option to xmllint,
1129 addxmlPopInputCallback() for Matt Sergeant, refactoring of
1130 serializationescaping, added escaping customization</li>
1131 <li>bugfixes: xsd:extension (Taihei Goi), assorted regexp bugs
1132 (WilliamBrack), xmlReader end of stream problem, node deregistration with
1133 reader,URI escaping and filemanes, XHTML1 formatting (Nick Wellnhofer),
1134 regexptransition reduction (William), various XSD Schemas fixes
1135 (KasimierBuchcik), XInclude fallback problem (William), weird problems
1136 with DTD(William), structured error handler callback context (William),
1137 reversexmlEncodeSpecialChars() behaviour back to escaping '"'</li>
Daniel Veillard81205012004-05-18 03:06:41 +00001138</ul>
1139
Daniel Veillardeca726d2004-04-18 21:47:34 +00001140<h3>2.6.9: Apr 18 2004</h3>
1141<ul>
1142 <li>implement xml:id Working Draft, relaxed XPath id() checking</li>
Daniel Veillard69839ba2006-06-06 13:27:03 +00001143 <li>bugfixes: xmlCtxtReset (Brent Hendricks), line number and CDATA
1144 (DaveBeckett), Relax-NG compilation (William Brack), Regexp patches
1145 (withWilliam), xmlUriEscape (Mark Vakoc), a Relax-NG notAllowed problem
1146 (withWilliam), Relax-NG name classes compares (William), XInclude
1147 duplicatefallback (William), external DTD encoding detection (William), a
1148 DTDvalidation bug (William), xmlReader Close() fix, recusive
1149 extentionschemas</li>
1150 <li>improvements: use xmlRead* APIs in test tools (Mark Vakoc),
1151 indentingsave optimization, better handle IIS broken HTTP redirect
1152 behaviour (IanHummel), HTML parser frameset (James Bursa), libxml2-python
1153 RPMdependancy, XML Schemas union support (Kasimier Buchcik), warning
1154 removalclanup (William), keep ChangeLog compressed when installing from
1155 RPMs</li>
1156 <li>documentation: examples and xmlDocDumpMemory docs (John Fleck),
1157 newexample (load, xpath, modify, save), xmlCatalogDump() comments,</li>
1158 <li>Windows: Borland C++ builder (Eric Zurcher), work around
1159 Microsoftcompiler NaN handling bug (Mark Vakoc)</li>
Daniel Veillardeca726d2004-04-18 21:47:34 +00001160</ul>
1161
Daniel Veillard252004d2004-03-23 12:32:32 +00001162<h3>2.6.8: Mar 23 2004</h3>
1163<ul>
1164 <li>First step of the cleanup of the serialization code and APIs</li>
Daniel Veillard69839ba2006-06-06 13:27:03 +00001165 <li>XML Schemas: mixed content (Adam Dickmeiss), QName handling fixes
1166 (AdamDickmeiss), anyURI for "" (John Belmonte)</li>
Daniel Veillard252004d2004-03-23 12:32:32 +00001167 <li>Python: Canonicalization C14N support added (Anthony Carrico)</li>
1168 <li>xmlDocCopyNode() extension (William)</li>
Daniel Veillard69839ba2006-06-06 13:27:03 +00001169 <li>Relax-NG: fix when processing XInclude results (William),
1170 externalreference in interleave (William), missing error on
1171 &lt;choice&gt;failure (William), memory leak in schemas datatype
1172 facets.</li>
Daniel Veillard252004d2004-03-23 12:32:32 +00001173 <li>xmlWriter: patch for better DTD support (Alfred Mickautsch)</li>
Daniel Veillard69839ba2006-06-06 13:27:03 +00001174 <li>bug fixes: xmlXPathLangFunction memory leak (Mike Hommey and
1175 WilliamBrack), no ID errors if using HTML_PARSE_NOERROR, xmlcatalog
1176 fallbacks toURI on SYSTEM lookup failure, XInclude parse flags
1177 inheritance (William),XInclude and XPointer fixes for entities (William),
1178 XML parser bugreported by Holger Rauch, nanohttp fd leak (William),
1179 regexps chargroups '-' handling (William), dictionnary reference counting
1180 problems,do not close stderr.</li>
Daniel Veillard252004d2004-03-23 12:32:32 +00001181 <li>performance patches from Petr Pajas</li>
1182 <li>Documentation fixes: XML_CATALOG_FILES in man pages (Mike Hommey)</li>
Daniel Veillard69839ba2006-06-06 13:27:03 +00001183 <li>compilation and portability fixes: --without-valid, catalog
1184 cleanups(Peter Breitenlohner), MingW patch (Roland Schwingel),
1185 cross-compilationto Windows (Christophe de Vienne), --with-html-dir
1186 fixup (Julio MerinoVidal), Windows build (Eric Zurcher)</li>
Daniel Veillard252004d2004-03-23 12:32:32 +00001187</ul>
1188
Daniel Veillard92914492004-02-23 16:33:21 +00001189<h3>2.6.7: Feb 23 2004</h3>
1190<ul>
1191 <li>documentation: tutorial updates (John Fleck), benchmark results</li>
1192 <li>xmlWriter: updates and fixes (Alfred Mickautsch, Lucas Brasilino)</li>
1193 <li>XPath optimization (Petr Pajas)</li>
1194 <li>DTD ID handling optimization</li>
Daniel Veillard69839ba2006-06-06 13:27:03 +00001195 <li>bugfixes: xpath number with &gt; 19 fractional (William Brack),
1196 pushmode with unescaped '&gt;' characters, fix xmllint --stream --timing,
1197 fixxmllint --memory --stream memory usage,
1198 xmlAttrSerializeTxtContenthandling NULL, trying to fix Relax-NG/Perl
1199 interface.</li>
Daniel Veillard92914492004-02-23 16:33:21 +00001200 <li>python: 2.3 compatibility, whitespace fixes (Malcolm Tredinnick)</li>
1201 <li>Added relaxng option to xmllint --shell</li>
1202</ul>
1203
Daniel Veillard5c9547e2004-02-12 15:31:49 +00001204<h3>2.6.6: Feb 12 2004</h3>
1205<ul>
Daniel Veillard69839ba2006-06-06 13:27:03 +00001206 <li>nanohttp and nanoftp: buffer overflow error on URI parsing (Igor
1207 andWilliam) reported by Yuuichi Teranishi</li>
1208 <li>bugfixes: make test and path issues, xmlWriter attribute
1209 serialization(William Brack), xmlWriter indentation (William), schemas
1210 validation(Eric Haszlakiewicz), XInclude dictionnaries issues (William
1211 and OlegParaschenko), XInclude empty fallback (William), HTML warnings
1212 (William),XPointer in XInclude (William), Python namespace
1213 serialization,isolat1ToUTF8 bound error (Alfred Mickautsch), output of
1214 parameterentities in internal subset (William), internal subset bug in
1215 push mode,&lt;xs:all&gt; fix (Alexey Sarytchev)</li>
1216 <li>Build: fix for automake-1.8 (Alexander Winston), warnings
1217 removal(Philip Ludlam), SOCKLEN_T detection fixes (Daniel Richard),
1218 fix--with-minimum configuration.</li>
Daniel Veillard5c9547e2004-02-12 15:31:49 +00001219 <li>XInclude: allow the 2001 namespace without warning.</li>
Daniel Veillard69839ba2006-06-06 13:27:03 +00001220 <li>Documentation: missing example/index.html (John Fleck),
1221 versiondependancies (John Fleck)</li>
Daniel Veillard5c9547e2004-02-12 15:31:49 +00001222 <li>reader API: structured error reporting (Steve Ball)</li>
Daniel Veillard69839ba2006-06-06 13:27:03 +00001223 <li>Windows compilation: mingw, msys (Mikhail Grushinskiy),
1224 functionprototype (Cameron Johnson), MSVC6 compiler warnings,
1225 _WINSOCKAPI_patch</li>
1226 <li>Parsers: added xmlByteConsumed(ctxt) API to get the byte offest
1227 ininput.</li>
Daniel Veillard5c9547e2004-02-12 15:31:49 +00001228</ul>
1229
Daniel Veillard189f46b2004-01-25 21:03:04 +00001230<h3>2.6.5: Jan 25 2004</h3>
1231<ul>
Daniel Veillard69839ba2006-06-06 13:27:03 +00001232 <li>Bugfixes: dictionnaries for schemas (William Brack), regexp
1233 segfault(William), xs:all problem (William), a number of XPointer
1234 bugfixes(William), xmllint error go to stderr, DTD validation problem
1235 withnamespace, memory leak (William), SAX1 cleanup and minimal options
1236 fixes(Mark Vadoc), parser context reset on error (Shaun McCance), XPath
1237 unionevaluation problem (William) , xmlReallocLoc with NULL (Aleksey
1238 Sanin),XML Schemas double free (Steve Ball), XInclude with no href,
1239 argumentcallbacks order for XPath callbacks (Frederic Peters)</li>
1240 <li>Documentation: python scripts (William Brack), xslt stylesheets
1241 (JohnFleck), doc (Sven Zimmerman), I/O example.</li>
1242 <li>Python bindings: fixes (William), enum support (Stéphane
1243 Bidoul),structured error reporting (Stéphane Bidoul)</li>
1244 <li>XInclude: various fixes for conformance, problem related to
1245 dictionnaryreferences (William &amp; me), recursion (William)</li>
1246 <li>xmlWriter: indentation (Lucas Brasilino), memory leaks
1247 (AlfredMickautsch),</li>
Daniel Veillard189f46b2004-01-25 21:03:04 +00001248 <li>xmlSchemas: normalizedString datatype (John Belmonte)</li>
1249 <li>code cleanup for strings functions (William)</li>
1250 <li>Windows: compiler patches (Mark Vakoc)</li>
Daniel Veillard69839ba2006-06-06 13:27:03 +00001251 <li>Parser optimizations, a few new XPath and dictionnary APIs for
1252 futureXSLT optimizations.</li>
Daniel Veillard189f46b2004-01-25 21:03:04 +00001253</ul>
1254
Daniel Veillarde6e59cd2003-12-24 11:56:44 +00001255<h3>2.6.4: Dec 24 2003</h3>
1256<ul>
1257 <li>Windows build fixes (Igor Zlatkovic)</li>
Daniel Veillard189f46b2004-01-25 21:03:04 +00001258 <li>Some serious XInclude problems reported by Oleg Paraschenko and</li>
1259 <li>Unix and Makefile packaging fixes (me, William Brack,</li>
Daniel Veillard69839ba2006-06-06 13:27:03 +00001260 <li>Documentation improvements (John Fleck, William Brack), example
1261 fix(Lucas Brasilino)</li>
1262 <li>bugfixes: xmlTextReaderExpand() with xmlReaderWalker, XPath handling
1263 ofNULL strings (William Brack) , API building reader or parser
1264 fromfiledescriptor should not close it, changed XPath sorting to be
1265 stableagain (William Brack), xmlGetNodePath() generating '(null)'
1266 (WilliamBrack), DTD validation and namespace bug (William Brack), XML
1267 Schemasdouble inclusion behaviour</li>
Daniel Veillarde6e59cd2003-12-24 11:56:44 +00001268</ul>
1269
Daniel Veillardc480c4e2003-12-10 13:24:38 +00001270<h3>2.6.3: Dec 10 2003</h3>
1271<ul>
1272 <li>documentation updates and cleanup (DV, William Brack, John Fleck)</li>
Daniel Veillard69839ba2006-06-06 13:27:03 +00001273 <li>added a repository of examples, examples from Aleksey Sanin,
1274 DodjiSeketeli, Alfred Mickautsch</li>
1275 <li>Windows updates: Mark Vakoc, Igor Zlatkovic, Eric Zurcher,
1276 Mingw(Kenneth Haley)</li>
Daniel Veillardc480c4e2003-12-10 13:24:38 +00001277 <li>Unicode range checking (William Brack)</li>
1278 <li>code cleanup (William Brack)</li>
1279 <li>Python bindings: doc (John Fleck), bug fixes</li>
1280 <li>UTF-16 cleanup and BOM issues (William Brack)</li>
Daniel Veillard69839ba2006-06-06 13:27:03 +00001281 <li>bug fixes: ID and xmlReader validation, XPath (William Brack),xmlWriter
1282 (Alfred Mickautsch), hash.h inclusion problem, HTML parser(James Bursa),
1283 attribute defaulting and validation, some serializationcleanups,
1284 XML_GET_LINE macro, memory debug when using threads (WilliamBrack),
1285 serialization of attributes and entities content, xmlWriter(Daniel
1286 Schulman)</li>
1287 <li>XInclude bugfix, new APIs and update to the last version including
1288 thenamespace change.</li>
1289 <li>XML Schemas improvements: include (Robert Stepanek), import
1290 andnamespace handling, fixed the regression tests troubles, added
1291 examplesbased on Eric van der Vlist book, regexp fixes</li>
1292 <li>preliminary pattern support for streaming (needed for
1293 schemasconstraints), added xmlTextReaderPreservePattern() to collect
1294 subdocumentwhen streaming.</li>
Daniel Veillardc480c4e2003-12-10 13:24:38 +00001295 <li>various fixes in the structured error handling</li>
1296</ul>
1297
Daniel Veillard6d373a22003-11-04 10:26:43 +00001298<h3>2.6.2: Nov 4 2003</h3>
1299<ul>
1300 <li>XPath context unregistration fixes</li>
1301 <li>text node coalescing fixes (Mark Lilback)</li>
1302 <li>API to screate a W3C Schemas from an existing document (Steve Ball)</li>
1303 <li>BeOS patches (Marcin 'Shard' Konicki)</li>
1304 <li>xmlStrVPrintf function added (Aleksey Sanin)</li>
1305 <li>compilation fixes (Mark Vakoc)</li>
1306 <li>stdin parsing fix (William Brack)</li>
1307 <li>a posteriori DTD validation fixes</li>
Daniel Veillardc480c4e2003-12-10 13:24:38 +00001308 <li>xmlReader bug fixes: Walker fixes, python bindings</li>
Daniel Veillard6d373a22003-11-04 10:26:43 +00001309 <li>fixed xmlStopParser() to really stop the parser and errors</li>
Daniel Veillard69839ba2006-06-06 13:27:03 +00001310 <li>always generate line numbers when using the new xmlReadxxxfunctions</li>
Daniel Veillard6d373a22003-11-04 10:26:43 +00001311 <li>added XInclude support to the xmlReader interface</li>
1312 <li>implemented XML_PARSE_NONET parser option</li>
1313 <li>DocBook XSLT processing bug fixed</li>
1314 <li>HTML serialization for &lt;p&gt; elements (William Brack and me)</li>
1315 <li>XPointer failure in XInclude are now handled as resource errors</li>
Daniel Veillard69839ba2006-06-06 13:27:03 +00001316 <li>fixed xmllint --html to use the HTML serializer on output
1317 (added--xmlout to implement the previous behaviour of saving it using the
1318 XMLserializer)</li>
Daniel Veillard6d373a22003-11-04 10:26:43 +00001319</ul>
1320
Daniel Veillarde4e3f5d2003-10-28 23:06:32 +00001321<h3>2.6.1: Oct 28 2003</h3>
1322<ul>
1323 <li>Mostly bugfixes after the big 2.6.0 changes</li>
Daniel Veillard69839ba2006-06-06 13:27:03 +00001324 <li>Unix compilation patches: libxml.m4 (Patrick Welche), warnings
1325 cleanup(William Brack)</li>
1326 <li>Windows compilation patches (Joachim Bauch, Stephane Bidoul,
1327 IgorZlatkovic)</li>
Daniel Veillarde4e3f5d2003-10-28 23:06:32 +00001328 <li>xmlWriter bugfix (Alfred Mickautsch)</li>
1329 <li>chvalid.[ch]: couple of fixes from Stephane Bidoul</li>
Daniel Veillard69839ba2006-06-06 13:27:03 +00001330 <li>context reset: error state reset, push parser reset (GrahamBennett)</li>
Daniel Veillarde4e3f5d2003-10-28 23:06:32 +00001331 <li>context reuse: generate errors if file is not readable</li>
Daniel Veillard69839ba2006-06-06 13:27:03 +00001332 <li>defaulted attributes for element coming from internal entities(Stephane
1333 Bidoul)</li>
Daniel Veillarde4e3f5d2003-10-28 23:06:32 +00001334 <li>Python: tab and spaces mix (William Brack)</li>
1335 <li>Error handler could crash in DTD validation in 2.6.0</li>
1336 <li>xmlReader: do not use the document or element _private field</li>
1337 <li>testSAX.c: avoid a problem with some PIs (Massimo Morara)</li>
Daniel Veillard69839ba2006-06-06 13:27:03 +00001338 <li>general bug fixes: mandatory encoding in text decl, serializingDocument
1339 Fragment nodes, xmlSearchNs 2.6.0 problem (Kasimier Buchcik),XPath errors
1340 not reported, slow HTML parsing of large documents.</li>
Daniel Veillarde4e3f5d2003-10-28 23:06:32 +00001341</ul>
1342
Daniel Veillard3e35f8e2003-10-21 00:05:38 +00001343<h3>2.6.0: Oct 20 2003</h3>
1344<ul>
Daniel Veillard69839ba2006-06-06 13:27:03 +00001345 <li>Major revision release: should be API and ABI compatible but got a
1346 lotof change</li>
1347 <li>Increased the library modularity, far more options can be stripped
1348 out,a --with-minimum configuration will weight around 160KBytes</li>
1349 <li>Use per parser and per document dictionnary, allocate names and
1350 smalltext nodes from the dictionnary</li>
1351 <li>Switch to a SAX2 like parser rewrote most of the XML parser
1352 core,provides namespace resolution and defaulted attributes, minimize
1353 memoryallocations and copies, namespace checking and specific error
1354 handling,immutable buffers, make predefined entities static structures,
1355 etc...</li>
1356 <li>rewrote all the error handling in the library, all errors can
1357 beintercepted at a structured level, with precise
1358 informationavailable.</li>
1359 <li>New simpler and more generic XML and HTML parser APIs, allowing
1360 toeasilly modify the parsing options and reuse parser context for
1361 multipleconsecutive documents.</li>
1362 <li>Similar new APIs for the xmlReader, for options and reuse, provided
1363 newfunctions to access content as const strings, use them for
1364 Pythonbindings</li>
1365 <li>a lot of other smaller API improvements: xmlStrPrintf (Aleksey
1366 Sanin),Walker i.e. reader on a document tree based on Alfred Mickautsch
1367 code,make room in nodes for line numbers, reference counting and future
1368 PSVIextensions, generation of character ranges to be checked with
1369 fasteralgorithm (William), xmlParserMaxDepth (Crutcher Dunnavant),
1370 bufferaccess</li>
Daniel Veillard3e35f8e2003-10-21 00:05:38 +00001371 <li>New xmlWriter API provided by Alfred Mickautsch</li>
1372 <li>Schemas: base64 support by Anthony Carrico</li>
Daniel Veillard69839ba2006-06-06 13:27:03 +00001373 <li>Parser&lt;-&gt;HTTP integration fix, proper processing of the
1374 Mime-Typeand charset informations if available.</li>
1375 <li>Relax-NG: bug fixes including the one reported by Martijn Faassen
1376 andzeroOrMore, better error reporting.</li>
1377 <li>Python bindings (Stéphane Bidoul), never use stdout for
1378 errorsoutput</li>
1379 <li>Portability: all the headers have macros for export and
1380 callingconvention definitions (Igor Zlatkovic), VMS update (Craig A.
1381 Berry),Windows: threads (Jesse Pelton), Borland compiler (Eric Zurcher,
1382 Igor),Mingw (Igor), typos (Mark Vakoc), beta version (Stephane
1383 Bidoul),warning cleanups on AIX and MIPS compilers (William Brack), BeOS
1384 (Marcin'Shard' Konicki)</li>
1385 <li>Documentation fixes and README (William Brack), search fix
1386 (William),tutorial updates (John Fleck), namespace docs (Stefan Kost)</li>
1387 <li>Bug fixes: xmlCleanupParser (Dave Beckett), threading
1388 uninitializedmutexes, HTML doctype lowercase, SAX/IO (William),
1389 compression detectionand restore (William), attribute declaration in DTDs
1390 (William), namespaceon attribute in HTML output (William), input filename
1391 (Rob Richards),namespace DTD validation, xmlReplaceNode (Chris Ryland),
1392 I/O callbacks(Markus Keim), CDATA serialization (Shaun McCance),
1393 xmlReader (PeterDerr), high codepoint charref like &amp;#x10FFFF;, buffer
1394 access in pushmode (Justin Fletcher), TLS threads on Windows (Jesse
1395 Pelton), XPath bug(William), xmlCleanupParser (Marc Liyanage), CDATA
1396 output (William), HTTPerror handling.</li>
1397 <li>xmllint options: --dtdvalidfpi for Tobias Reif, --sax1 for
1398 compattesting, --nodict for building without tree dictionnary, --nocdata
1399 toreplace CDATA by text, --nsclean to remove surperfluous
1400 namespacedeclarations</li>
Daniel Veillard3e35f8e2003-10-21 00:05:38 +00001401 <li>added xml2-config --libtool-libs option from Kevin P. Fleming</li>
Daniel Veillard69839ba2006-06-06 13:27:03 +00001402 <li>a lot of profiling and tuning of the code, speedup patch
1403 forxmlSearchNs() by Luca Padovani. The xmlReader should do far
1404 lessallocation and it speed should get closer to SAX. Chris Anderson
1405 workedon speeding and cleaning up repetitive checking code.</li>
Daniel Veillard3e35f8e2003-10-21 00:05:38 +00001406 <li>cleanup of "make tests"</li>
1407 <li>libxml-2.0-uninstalled.pc from Malcolm Tredinnick</li>
Daniel Veillard69839ba2006-06-06 13:27:03 +00001408 <li>deactivated the broken docBook SGML parser code and plugged the
1409 XMLparser instead.</li>
Daniel Veillard3e35f8e2003-10-21 00:05:38 +00001410</ul>
1411
Daniel Veillardeec1ae92003-09-09 13:11:01 +00001412<h3>2.5.11: Sep 9 2003</h3>
1413
1414<p>A bugfix only release:</p>
1415<ul>
1416 <li>risk of crash in Relax-NG</li>
1417 <li>risk of crash when using multithreaded programs</li>
1418</ul>
1419
Daniel Veillardcfba2fe2003-08-15 00:33:43 +00001420<h3>2.5.10: Aug 15 2003</h3>
1421
1422<p>A bugfixes only release</p>
1423<ul>
1424 <li>Windows Makefiles (William Brack)</li>
1425 <li>UTF-16 support fixes (Mark Itzcovitz)</li>
Daniel Veillard69839ba2006-06-06 13:27:03 +00001426 <li>Makefile and portability (William Brack) automake, Linux alpha, Mingwon
1427 Windows (Mikhail Grushinskiy)</li>
Daniel Veillardcfba2fe2003-08-15 00:33:43 +00001428 <li>HTML parser (Oliver Stoeneberg)</li>
1429 <li>XInclude performance problem reported by Kevin Ruscoe</li>
1430 <li>XML parser performance problem reported by Grant Goodale</li>
1431 <li>xmlSAXParseDTD() bug fix from Malcolm Tredinnick</li>
Daniel Veillardeec1ae92003-09-09 13:11:01 +00001432 <li>and a couple other cleanup</li>
Daniel Veillardcfba2fe2003-08-15 00:33:43 +00001433</ul>
1434
Daniel Veillard83ee40d2003-08-09 22:24:09 +00001435<h3>2.5.9: Aug 9 2003</h3>
1436<ul>
Daniel Veillard69839ba2006-06-06 13:27:03 +00001437 <li>bugfixes: IPv6 portability, xmlHasNsProp (Markus Keim), Windows
1438 build(Wiliam Brake, Jesse Pelton, Igor), Schemas (Peter Sobisch),
1439 threading(Rob Richards), hexBinary type (), UTF-16 BOM (Dodji
1440 Seketeli),xmlReader, Relax-NG schemas compilation, namespace handling,
1441 EXSLT (SeanGriffin), HTML parsing problem (William Brack), DTD validation
1442 for mixedcontent + namespaces, HTML serialization, library
1443 initialization,progressive HTML parser</li>
Daniel Veillard83ee40d2003-08-09 22:24:09 +00001444 <li>better interfaces for Relax-NG error handling (Joachim Bauch, )</li>
1445 <li>adding xmlXIncludeProcessTree() for XInclud'ing in a subtree</li>
1446 <li>doc fixes and improvements (John Fleck)</li>
1447 <li>configure flag for -with-fexceptions when embedding in C++</li>
1448 <li>couple of new UTF-8 helper functions (William Brack)</li>
1449 <li>general encoding cleanup + ISO-8859-x without iconv (Peter Jacobi)</li>
1450 <li>xmlTextReader cleanup + enum for node types (Bjorn Reese)</li>
Daniel Veillard69839ba2006-06-06 13:27:03 +00001451 <li>general compilation/warning cleanup Solaris/HP-UX/...
1452 (WilliamBrack)</li>
Daniel Veillard83ee40d2003-08-09 22:24:09 +00001453</ul>
1454
Daniel Veillard560c2a42003-07-06 21:13:49 +00001455<h3>2.5.8: Jul 6 2003</h3>
1456<ul>
Daniel Veillard69839ba2006-06-06 13:27:03 +00001457 <li>bugfixes: XPath, XInclude, file/URI mapping, UTF-16 save
1458 (MarkItzcovitz), UTF-8 checking, URI saving, error printing (William
1459 Brack),PI related memleak, compilation without schemas or without xpath
1460 (JoergSchmitz-Linneweber/Garry Pennington), xmlUnlinkNode problem with
1461 DTDs,rpm problem on , i86_64, removed a few compilation problems from
1462 2.5.7,xmlIOParseDTD, and xmlSAXParseDTD (Malcolm Tredinnick)</li>
Daniel Veillard560c2a42003-07-06 21:13:49 +00001463 <li>portability: DJGPP (MsDos) , OpenVMS (Craig A. Berry)</li>
1464 <li>William Brack fixed multithreading lock problems</li>
1465 <li>IPv6 patch for FTP and HTTP accesses (Archana Shah/Wipro)</li>
Daniel Veillard69839ba2006-06-06 13:27:03 +00001466 <li>Windows fixes (Igor Zlatkovic, Eric Zurcher), threading
1467 (StéphaneBidoul)</li>
Daniel Veillard560c2a42003-07-06 21:13:49 +00001468 <li>A few W3C Schemas Structure improvements</li>
1469 <li>W3C Schemas Datatype improvements (Charlie Bozeman)</li>
Daniel Veillard69839ba2006-06-06 13:27:03 +00001470 <li>Python bindings for thread globals (Stéphane Bidoul), and
1471 method/classgenerator</li>
Daniel Veillard83ee40d2003-08-09 22:24:09 +00001472 <li>added --nonet option to xmllint</li>
Daniel Veillard560c2a42003-07-06 21:13:49 +00001473 <li>documentation improvements (John Fleck)</li>
1474</ul>
1475
Daniel Veillard92fc02c2003-04-24 23:12:35 +00001476<h3>2.5.7: Apr 25 2003</h3>
1477<ul>
Daniel Veillard69839ba2006-06-06 13:27:03 +00001478 <li>Relax-NG: Compiling to regexp and streaming validation on top of
1479 thexmlReader interface, added to xmllint --stream</li>
Daniel Veillard92fc02c2003-04-24 23:12:35 +00001480 <li>xmlReader: Expand(), Next() and DOM access glue, bug fixes</li>
1481 <li>Support for large files: RGN validated a 4.5GB instance</li>
1482 <li>Thread support is now configured in by default</li>
Daniel Veillard69839ba2006-06-06 13:27:03 +00001483 <li>Fixes: update of the Trio code (Bjorn), WXS Date and Duration
1484 fixes(Charles Bozeman), DTD and namespaces (Brent Hendricks), HTML push
1485 parserand zero bytes handling, some missing Windows file path
1486 conversions,behaviour of the parser and validator in the presence of "out
1487 of memory"error conditions</li>
1488 <li>extended the API to be able to plug a garbage collecting
1489 memoryallocator, added xmlMallocAtomic() and modified the
1490 allocationsaccordingly.</li>
1491 <li>Performances: removed excessive malloc() calls, speedup of the push
1492 andxmlReader interfaces, removed excessive thread locking</li>
Daniel Veillard92fc02c2003-04-24 23:12:35 +00001493 <li>Documentation: man page (John Fleck), xmlReader documentation</li>
1494 <li>Python: adding binding for xmlCatalogAddLocal (Brent M Hendricks)</li>
1495</ul>
1496
Daniel Veillardc2d4a932003-04-01 11:13:05 +00001497<h3>2.5.6: Apr 1 2003</h3>
1498<ul>
Daniel Veillard69839ba2006-06-06 13:27:03 +00001499 <li>Fixed W3C XML Schemas datatype, should be compliant now except
1500 forbinHex and base64 which are not supported yet.</li>
1501 <li>bug fixes: non-ASCII IDs, HTML output, XInclude on large docs
1502 andXInclude entities handling, encoding detection on external subsets,
1503 XMLSchemas bugs and memory leaks, HTML parser (James Bursa)</li>
Daniel Veillardc2d4a932003-04-01 11:13:05 +00001504 <li>portability: python/trio (Albert Chin), Sun compiler warnings</li>
1505 <li>documentation: added --relaxng option to xmllint man page (John)</li>
Daniel Veillard69839ba2006-06-06 13:27:03 +00001506 <li>improved error reporting: xml:space, start/end tag mismatches, Relax
1507 NGerrors</li>
Daniel Veillardc2d4a932003-04-01 11:13:05 +00001508</ul>
1509
1510<h3>2.5.5: Mar 24 2003</h3>
Daniel Veillardd8da01c2003-03-24 15:58:23 +00001511<ul>
Daniel Veillard69839ba2006-06-06 13:27:03 +00001512 <li>Lot of fixes on the Relax NG implementation. More testing
1513 includingDocBook and TEI examples.</li>
Daniel Veillardd8da01c2003-03-24 15:58:23 +00001514 <li>Increased the support for W3C XML Schemas datatype</li>
1515 <li>Several bug fixes in the URI handling layer</li>
Daniel Veillard69839ba2006-06-06 13:27:03 +00001516 <li>Bug fixes: HTML parser, xmlReader, DTD validation, XPath,
1517 encodingconversion, line counting in the parser.</li>
Daniel Veillardd8da01c2003-03-24 15:58:23 +00001518 <li>Added support for $XMLLINT_INDENT environment variable, FTP delete</li>
1519 <li>Fixed the RPM spec file name</li>
1520</ul>
1521
Daniel Veillard17bed982003-02-24 20:11:43 +00001522<h3>2.5.4: Feb 20 2003</h3>
1523<ul>
Daniel Veillard69839ba2006-06-06 13:27:03 +00001524 <li>Conformance testing and lot of fixes on Relax NG and
1525 XIncludeimplementation</li>
Daniel Veillard17bed982003-02-24 20:11:43 +00001526 <li>Implementation of XPointer element() scheme</li>
Daniel Veillard69839ba2006-06-06 13:27:03 +00001527 <li>Bug fixes: XML parser, XInclude entities merge, validity checking
1528 onnamespaces,
1529 <p>2 serialization bugs, node info generation problems, a DTD
1530 regexpgeneration problem.</p>
Daniel Veillard17bed982003-02-24 20:11:43 +00001531 </li>
1532 <li>Portability: windows updates and path canonicalization (Igor)</li>
1533 <li>A few typo fixes (Kjartan Maraas)</li>
1534 <li>Python bindings generator fixes (Stephane Bidoul)</li>
1535</ul>
1536
Daniel Veillard1d788d22003-02-10 16:21:58 +00001537<h3>2.5.3: Feb 10 2003</h3>
1538<ul>
Daniel Veillard69839ba2006-06-06 13:27:03 +00001539 <li>RelaxNG and XML Schemas datatypes improvements, and added a
1540 firstversion of RelaxNG Python bindings</li>
1541 <li>Fixes: XLink (Sean Chittenden), XInclude (Sean Chittenden), API fix
1542 forserializing namespace nodes, encoding conversion bug,
1543 XHTML1serialization</li>
Daniel Veillard1d788d22003-02-10 16:21:58 +00001544 <li>Portability fixes: Windows (Igor), AMD 64bits RPM spec file</li>
1545</ul>
1546
Daniel Veillard72fef162003-02-05 14:31:19 +00001547<h3>2.5.2: Feb 5 2003</h3>
1548<ul>
1549 <li>First implementation of RelaxNG, added --relaxng flag to xmllint</li>
1550 <li>Schemas support now compiled in by default.</li>
Daniel Veillard69839ba2006-06-06 13:27:03 +00001551 <li>Bug fixes: DTD validation, namespace checking, XInclude and
1552 entities,delegateURI in XML Catalogs, HTML parser, XML reader (Stéphane
1553 Bidoul),XPath parser and evaluation, UTF8ToUTF8 serialization, XML
1554 reader memoryconsumption, HTML parser, HTML serialization in the presence
1555 ofnamespaces</li>
Daniel Veillard72fef162003-02-05 14:31:19 +00001556 <li>added an HTML API to check elements and attributes.</li>
Daniel Veillard69839ba2006-06-06 13:27:03 +00001557 <li>Documentation improvement, PDF for the tutorial (John Fleck),
1558 docpatches (Stefan Kost)</li>
Daniel Veillard72fef162003-02-05 14:31:19 +00001559 <li>Portability fixes: NetBSD (Julio Merino), Windows (Igor Zlatkovic)</li>
Daniel Veillard69839ba2006-06-06 13:27:03 +00001560 <li>Added python bindings for XPointer, contextual error reporting(Stéphane
1561 Bidoul)</li>
Daniel Veillard72fef162003-02-05 14:31:19 +00001562 <li>URI/file escaping problems (Stefano Zacchiroli)</li>
Daniel Veillardcf27f7c2002-04-30 07:12:39 +00001563</ul>
1564
Daniel Veillarde2830f12003-01-08 17:47:49 +00001565<h3>2.5.1: Jan 8 2003</h3>
1566<ul>
1567 <li>Fixes a memory leak and configuration/compilation problems in 2.5.0</li>
1568 <li>documentation updates (John)</li>
1569 <li>a couple of XmlTextReader fixes</li>
1570</ul>
1571
Daniel Veillard7b4b2f92003-01-06 13:11:20 +00001572<h3>2.5.0: Jan 6 2003</h3>
1573<ul>
Daniel Veillard69839ba2006-06-06 13:27:03 +00001574 <li>New <a href="xmlreader.html">XmltextReader interface</a>based on C#API
1575 (with help of Stéphane Bidoul)</li>
Daniel Veillard7b4b2f92003-01-06 13:11:20 +00001576 <li>Windows: more exports, including the new API (Igor)</li>
1577 <li>XInclude fallback fix</li>
Daniel Veillard69839ba2006-06-06 13:27:03 +00001578 <li>Python: bindings for the new API, packaging (Stéphane
1579 Bidoul),drv_libxml2.py Python xml.sax driver (Stéphane Bidoul), fixes,
1580 speedupand iterators for Python-2.2 (Hannu Krosing)</li>
1581 <li>Tutorial fixes (john Fleck and Niraj Tolia) xmllint man
1582 update(John)</li>
Daniel Veillard7b4b2f92003-01-06 13:11:20 +00001583 <li>Fix an XML parser bug raised by Vyacheslav Pindyura</li>
1584 <li>Fix for VMS serialization (Nigel Hall) and config (Craig A. Berry)</li>
1585 <li>Entities handling fixes</li>
Daniel Veillard69839ba2006-06-06 13:27:03 +00001586 <li>new API to optionally track node creation and deletion
1587 (LukasSchroeder)</li>
Daniel Veillard7b4b2f92003-01-06 13:11:20 +00001588 <li>Added documentation for the XmltextReader interface and some <a
1589 href="guidelines.html">XML guidelines</a></li>
1590</ul>
1591
Daniel Veillardc1eed322002-12-12 11:01:32 +00001592<h3>2.4.30: Dec 12 2002</h3>
1593<ul>
1594 <li>2.4.29 broke the python bindings, rereleasing</li>
Daniel Veillard69839ba2006-06-06 13:27:03 +00001595 <li>Improvement/fixes of the XML API generator, and couple of minor
1596 codefixes.</li>
Daniel Veillardc1eed322002-12-12 11:01:32 +00001597</ul>
1598
Daniel Veillard9b4bb4d2002-12-11 19:28:47 +00001599<h3>2.4.29: Dec 11 2002</h3>
1600<ul>
Daniel Veillard69839ba2006-06-06 13:27:03 +00001601 <li>Windows fixes (Igor): Windows CE port, pthread linking, python
1602 bindings(Stéphane Bidoul), Mingw (Magnus Henoch), and export list
1603 updates</li>
Daniel Veillard9b4bb4d2002-12-11 19:28:47 +00001604 <li>Fix for prev in python bindings (ERDI Gergo)</li>
1605 <li>Fix for entities handling (Marcus Clarke)</li>
Daniel Veillard69839ba2006-06-06 13:27:03 +00001606 <li>Refactored the XML and HTML dumps to a single code path, fixed
1607 XHTML1dump</li>
Daniel Veillard9b4bb4d2002-12-11 19:28:47 +00001608 <li>Fix for URI parsing when handling URNs with fragment identifiers</li>
1609 <li>Fix for HTTP URL escaping problem</li>
1610 <li>added an TextXmlReader (C#) like API (work in progress)</li>
Daniel Veillard69839ba2006-06-06 13:27:03 +00001611 <li>Rewrote the API in XML generation script, includes a C parser and
1612 savesmore informations needed for C# bindings</li>
Daniel Veillard9b4bb4d2002-12-11 19:28:47 +00001613</ul>
1614
Daniel Veillardf9c4cad2002-11-22 15:57:07 +00001615<h3>2.4.28: Nov 22 2002</h3>
1616<ul>
1617 <li>a couple of python binding fixes</li>
1618 <li>2 bug fixes in the XML push parser</li>
1619 <li>potential memory leak removed (Martin Stoilov)</li>
1620 <li>fix to the configure script for Unix (Dimitri Papadopoulos)</li>
1621 <li>added encoding support for XInclude parse="text"</li>
1622 <li>autodetection of XHTML1 and specific serialization rules added</li>
Daniel Veillard9b4bb4d2002-12-11 19:28:47 +00001623 <li>nasty threading bug fixed (William Brack)</li>
Daniel Veillardf9c4cad2002-11-22 15:57:07 +00001624</ul>
1625
Daniel Veillarddad3f682002-11-17 16:47:27 +00001626<h3>2.4.27: Nov 17 2002</h3>
1627<ul>
1628 <li>fixes for the Python bindings</li>
Daniel Veillard69839ba2006-06-06 13:27:03 +00001629 <li>a number of bug fixes: SGML catalogs,
1630 xmlParseBalancedChunkMemory(),HTML parser, Schemas (Charles Bozeman),
1631 document fragment support(Christian Glahn), xmlReconciliateNs (Brian
1632 Stafford), XPointer,xmlFreeNode(), xmlSAXParseMemory (Peter Jones),
1633 xmlGetNodePath (PetrPajas), entities processing</li>
Daniel Veillarddad3f682002-11-17 16:47:27 +00001634 <li>added grep to xmllint --shell</li>
1635 <li>VMS update patch from Craig A. Berry</li>
Daniel Veillard69839ba2006-06-06 13:27:03 +00001636 <li>cleanup of the Windows build with support for more compilers
1637 (Igor),better thread support on Windows</li>
Daniel Veillarddad3f682002-11-17 16:47:27 +00001638 <li>cleanup of Unix Makefiles and spec file</li>
1639 <li>Improvements to the documentation (John Fleck)</li>
1640</ul>
1641
Daniel Veillard48267432002-10-18 11:21:38 +00001642<h3>2.4.26: Oct 18 2002</h3>
1643<ul>
1644 <li>Patches for Windows CE port, improvements on Windows paths handling</li>
Daniel Veillard69839ba2006-06-06 13:27:03 +00001645 <li>Fixes to the validation code (DTD and Schemas), xmlNodeGetPath() ,HTML
1646 serialization, Namespace compliance, and a number of smallproblems</li>
Daniel Veillard48267432002-10-18 11:21:38 +00001647</ul>
1648
Daniel Veillarde16b5742002-09-26 17:50:03 +00001649<h3>2.4.25: Sep 26 2002</h3>
1650<ul>
Daniel Veillard69839ba2006-06-06 13:27:03 +00001651 <li>A number of bug fixes: XPath, validation, Python bindings, DOM andtree,
1652 xmlI/O, Html</li>
Daniel Veillarde16b5742002-09-26 17:50:03 +00001653 <li>Serious rewrite of XInclude</li>
Daniel Veillard69839ba2006-06-06 13:27:03 +00001654 <li>Made XML Schemas regexp part of the default build and APIs, small
1655 fixand improvement of the regexp core</li>
Daniel Veillarde16b5742002-09-26 17:50:03 +00001656 <li>Changed the validation code to reuse XML Schemas regexp APIs</li>
Daniel Veillard69839ba2006-06-06 13:27:03 +00001657 <li>Better handling of Windows file paths, improvement of Makefiles
1658 (Igor,Daniel Gehriger, Mark Vakoc)</li>
1659 <li>Improved the python I/O bindings, the tests, added resolver and
1660 regexpAPIs</li>
Daniel Veillarde16b5742002-09-26 17:50:03 +00001661 <li>New logos from Marc Liyanage</li>
1662 <li>Tutorial improvements: John Fleck, Christopher Harris</li>
Daniel Veillard69839ba2006-06-06 13:27:03 +00001663 <li>Makefile: Fixes for AMD x86_64 (Mandrake), DESTDIR
1664 (ChristopheMerlet)</li>
Daniel Veillarde16b5742002-09-26 17:50:03 +00001665 <li>removal of all stderr/perror use for error reporting</li>
1666 <li>Better error reporting: XPath and DTD validation</li>
1667 <li>update of the trio portability layer (Bjorn Reese)</li>
1668</ul>
1669
Daniel Veillard42766c02002-08-22 20:52:17 +00001670<p><strong>2.4.24: Aug 22 2002</strong></p>
1671<ul>
1672 <li>XPath fixes (William), xf:escape-uri() (Wesley Terpstra)</li>
Daniel Veillard69839ba2006-06-06 13:27:03 +00001673 <li>Python binding fixes: makefiles (William), generator, rpm build,
1674 x86-64(fcrozat)</li>
Daniel Veillard42766c02002-08-22 20:52:17 +00001675 <li>HTML &lt;style&gt; and boolean attributes serializer fixes</li>
1676 <li>C14N improvements by Aleksey</li>
Daniel Veillarde1662542002-08-28 11:50:59 +00001677 <li>doc cleanups: Rick Jones</li>
Daniel Veillard42766c02002-08-22 20:52:17 +00001678 <li>Windows compiler makefile updates: Igor and Elizabeth Barham</li>
1679 <li>XInclude: implementation of fallback and xml:base fixup added</li>
1680</ul>
1681
Daniel Veillard782afda2002-07-08 15:12:49 +00001682<h3>2.4.23: July 6 2002</h3>
1683<ul>
1684 <li>performances patches: Peter Jacobi</li>
1685 <li>c14n fixes, testsuite and performances: Aleksey Sanin</li>
1686 <li>added xmlDocFormatDump: Chema Celorio</li>
1687 <li>new tutorial: John Fleck</li>
Daniel Veillard69839ba2006-06-06 13:27:03 +00001688 <li>new hash functions and performances: Sander Vesik, portability fix
1689 fromPeter Jacobi</li>
1690 <li>a number of bug fixes: XPath (William Brack, Richard Jinks), XML
1691 andHTML parsers, ID lookup function</li>
Daniel Veillard782afda2002-07-08 15:12:49 +00001692 <li>removal of all remaining sprintf: Aleksey Sanin</li>
1693</ul>
1694
Daniel Veillardc0801af2002-05-28 16:28:42 +00001695<h3>2.4.22: May 27 2002</h3>
1696<ul>
Daniel Veillard69839ba2006-06-06 13:27:03 +00001697 <li>a number of bug fixes: configure scripts, base handling, parser,
1698 memoryusage, HTML parser, XPath, documentation (Christian
1699 Cornelssen),indentation, URI parsing</li>
1700 <li>Optimizations for XMLSec, fixing and making public some of the
1701 networkprotocol handlers (Aleksey)</li>
Daniel Veillardc0801af2002-05-28 16:28:42 +00001702 <li>performance patch from Gary Pennington</li>
Daniel Veillard69839ba2006-06-06 13:27:03 +00001703 <li>Charles Bozeman provided date and time support for XML
1704 Schemasdatatypes</li>
Daniel Veillardc0801af2002-05-28 16:28:42 +00001705</ul>
1706
Daniel Veillardcf27f7c2002-04-30 07:12:39 +00001707<h3>2.4.21: Apr 29 2002</h3>
1708
Daniel Veillard69839ba2006-06-06 13:27:03 +00001709<p>This release is both a bug fix release and also contains the early
1710XMLSchemas <a href="http://www.w3.org/TR/xmlschema-1/">structures</a>and <a
1711href="http://www.w3.org/TR/xmlschema-2/">datatypes</a>code, beware,
1712allinterfaces are likely to change, there is huge holes, it is clearly a work
1713inprogress and don't even think of putting this code in a production
1714system,it's actually not compiled in by default. The real fixes are:</p>
Daniel Veillardcf27f7c2002-04-30 07:12:39 +00001715<ul>
1716 <li>a couple of bugs or limitations introduced in 2.4.20</li>
1717 <li>patches for Borland C++ and MSC by Igor</li>
Daniel Veillard69839ba2006-06-06 13:27:03 +00001718 <li>some fixes on XPath strings and conformance patches by RichardJinks</li>
Daniel Veillardcf27f7c2002-04-30 07:12:39 +00001719 <li>patch from Aleksey for the ExcC14N specification</li>
1720 <li>OSF/1 bug fix by Bjorn</li>
Daniel Veillardaf43f632002-03-08 15:05:20 +00001721</ul>
1722
Daniel Veillarda7084cd2002-04-15 17:12:47 +00001723<h3>2.4.20: Apr 15 2002</h3>
1724<ul>
Daniel Veillard63d83142002-05-20 06:51:05 +00001725 <li>bug fixes: file descriptor leak, XPath, HTML output, DTD validation</li>
Daniel Veillarda7084cd2002-04-15 17:12:47 +00001726 <li>XPath conformance testing by Richard Jinks</li>
Daniel Veillard69839ba2006-06-06 13:27:03 +00001727 <li>Portability fixes: Solaris, MPE/iX, Windows, OSF/1, python
1728 bindings,libxml.m4</li>
Daniel Veillarda7084cd2002-04-15 17:12:47 +00001729</ul>
1730
Daniel Veillard19274092002-03-25 16:48:03 +00001731<h3>2.4.19: Mar 25 2002</h3>
1732<ul>
Daniel Veillard69839ba2006-06-06 13:27:03 +00001733 <li>bug fixes: half a dozen XPath bugs, Validation, ISO-Latin to
1734 UTF8encoder</li>
Daniel Veillard19274092002-03-25 16:48:03 +00001735 <li>portability fixes in the HTTP code</li>
Daniel Veillardb2fb8ed2002-04-01 09:33:12 +00001736 <li>memory allocation checks using valgrind, and profiling tests</li>
Daniel Veillard19274092002-03-25 16:48:03 +00001737 <li>revamp of the Windows build and Makefiles</li>
1738</ul>
1739
Daniel Veillard34ce8be2002-03-18 19:37:11 +00001740<h3>2.4.18: Mar 18 2002</h3>
1741<ul>
Daniel Veillard69839ba2006-06-06 13:27:03 +00001742 <li>bug fixes: tree, SAX, canonicalization, validation,
1743 portability,XPath</li>
Daniel Veillard34ce8be2002-03-18 19:37:11 +00001744 <li>removed the --with-buffer option it was becoming unmaintainable</li>
1745 <li>serious cleanup of the Python makefiles</li>
1746 <li>speedup patch to XPath very effective for DocBook stylesheets</li>
1747 <li>Fixes for Windows build, cleanup of the documentation</li>
1748</ul>
1749
Daniel Veillardaf43f632002-03-08 15:05:20 +00001750<h3>2.4.17: Mar 8 2002</h3>
1751<ul>
Daniel Veillard69839ba2006-06-06 13:27:03 +00001752 <li>a lot of bug fixes, including "namespace nodes have no parents
1753 inXPath"</li>
1754 <li>fixed/improved the Python wrappers, added more examples and
1755 moreregression tests, XPath extension functions can now return
1756 node-sets</li>
Daniel Veillard63d83142002-05-20 06:51:05 +00001757 <li>added the XML Canonicalization support from Aleksey Sanin</li>
Daniel Veillard3d6ae1c2001-08-15 13:12:39 +00001758</ul>
1759
Daniel Veillard5f4b5992002-02-20 10:22:49 +00001760<h3>2.4.16: Feb 20 2002</h3>
1761<ul>
Daniel Veillard69839ba2006-06-06 13:27:03 +00001762 <li>a lot of bug fixes, most of them were triggered by the XML
1763 Testsuitefrom OASIS and W3C. Compliance has been significantly
1764 improved.</li>
Daniel Veillard5f4b5992002-02-20 10:22:49 +00001765 <li>a couple of portability fixes too.</li>
1766</ul>
1767
Daniel Veillard397ff112002-02-11 18:27:20 +00001768<h3>2.4.15: Feb 11 2002</h3>
1769<ul>
1770 <li>Fixed the Makefiles, especially the python module ones</li>
1771 <li>A few bug fixes and cleanup</li>
1772 <li>Includes cleanup</li>
1773</ul>
1774
Daniel Veillardb6c1e2f2002-02-08 14:52:52 +00001775<h3>2.4.14: Feb 8 2002</h3>
1776<ul>
Daniel Veillard63d83142002-05-20 06:51:05 +00001777 <li>Change of License to the <a
Daniel Veillard69839ba2006-06-06 13:27:03 +00001778 href="http://www.opensource.org/licenses/mit-license.html">MITLicense</a>basically
1779 for integration in XFree86 codebase, and removingconfusion around the
1780 previous dual-licensing</li>
1781 <li>added Python bindings, beta software but should already be
1782 quitecomplete</li>
1783 <li>a large number of fixes and cleanups, especially for all
1784 treemanipulations</li>
1785 <li>cleanup of the headers, generation of a reference API definition
1786 inXML</li>
Daniel Veillardb6c1e2f2002-02-08 14:52:52 +00001787</ul>
1788
1789<h3>2.4.13: Jan 14 2002</h3>
Daniel Veillard744683d2002-01-14 17:30:20 +00001790<ul>
1791 <li>update of the documentation: John Fleck and Charlie Bozeman</li>
1792 <li>cleanup of timing code from Justin Fletcher</li>
Daniel Veillard69839ba2006-06-06 13:27:03 +00001793 <li>fixes for Windows and initial thread support on Win32: Igor and
1794 SergueiNarojnyi</li>
Daniel Veillard744683d2002-01-14 17:30:20 +00001795 <li>Cygwin patch from Robert Collins</li>
1796 <li>added xmlSetEntityReferenceFunc() for Keith Isdale work on xsldbg</li>
1797</ul>
1798
Daniel Veillardef90ba72001-12-07 14:24:22 +00001799<h3>2.4.12: Dec 7 2001</h3>
1800<ul>
Daniel Veillard69839ba2006-06-06 13:27:03 +00001801 <li>a few bug fixes: thread (Gary Pennington), xmllint (Geert
1802 Kloosterman),XML parser (Robin Berjon), XPointer (Danny Jamshy), I/O
1803 cleanups(robert)</li>
Daniel Veillardef90ba72001-12-07 14:24:22 +00001804 <li>Eric Lavigne contributed project files for MacOS</li>
1805 <li>some makefiles cleanups</li>
1806</ul>
1807
Daniel Veillarda4871052001-11-26 13:19:48 +00001808<h3>2.4.11: Nov 26 2001</h3>
1809<ul>
Daniel Veillard69839ba2006-06-06 13:27:03 +00001810 <li>fixed a couple of errors in the includes, fixed a few bugs, some
1811 codecleanups</li>
Daniel Veillarda4871052001-11-26 13:19:48 +00001812 <li>xmllint man pages improvement by Heiko Rupp</li>
1813 <li>updated VMS build instructions from John A Fotheringham</li>
1814 <li>Windows Makefiles updates from Igor</li>
1815</ul>
1816
Daniel Veillard43d3f612001-11-10 11:57:23 +00001817<h3>2.4.10: Nov 10 2001</h3>
1818<ul>
1819 <li>URI escaping fix (Joel Young)</li>
1820 <li>added xmlGetNodePath() (for paths or XPointers generation)</li>
1821 <li>Fixes namespace handling problems when using DTD and validation</li>
Daniel Veillard69839ba2006-06-06 13:27:03 +00001822 <li>improvements on xmllint: Morus Walter patches for --format and--encode,
1823 Stefan Kost and Heiko Rupp improvements on the --shell</li>
Daniel Veillard43d3f612001-11-10 11:57:23 +00001824 <li>fixes for xmlcatalog linking pointed by Weiqi Gao</li>
1825 <li>fixes to the HTML parser</li>
1826</ul>
1827
1828<h3>2.4.9: Nov 6 2001</h3>
1829<ul>
1830 <li>fixes more catalog bugs</li>
1831 <li>avoid a compilation problem, improve xmlGetLineNo()</li>
1832</ul>
1833
Daniel Veillarded421aa2001-11-04 21:22:45 +00001834<h3>2.4.8: Nov 4 2001</h3>
1835<ul>
Daniel Veillard69839ba2006-06-06 13:27:03 +00001836 <li>fixed SGML catalogs broken in previous release, updated
1837 xmlcatalogtool</li>
Daniel Veillarded421aa2001-11-04 21:22:45 +00001838 <li>fixed a compile errors and some includes troubles.</li>
1839</ul>
1840
Daniel Veillard52dcab32001-10-30 12:51:17 +00001841<h3>2.4.7: Oct 30 2001</h3>
1842<ul>
1843 <li>exported some debugging interfaces</li>
1844 <li>serious rewrite of the catalog code</li>
Daniel Veillard69839ba2006-06-06 13:27:03 +00001845 <li>integrated Gary Pennington thread safety patch, added configure
1846 optionand regression tests</li>
Daniel Veillard52dcab32001-10-30 12:51:17 +00001847 <li>removed an HTML parser bug</li>
1848 <li>fixed a couple of potentially serious validation bugs</li>
1849 <li>integrated the SGML DocBook support in xmllint</li>
1850 <li>changed the nanoftp anonymous login passwd</li>
1851 <li>some I/O cleanup and a couple of interfaces for Perl wrapper</li>
1852 <li>general bug fixes</li>
1853 <li>updated xmllint man page by John Fleck</li>
1854 <li>some VMS and Windows updates</li>
1855</ul>
1856
Daniel Veillard60087f32001-10-10 09:45:09 +00001857<h3>2.4.6: Oct 10 2001</h3>
1858<ul>
Daniel Veillard52dcab32001-10-30 12:51:17 +00001859 <li>added an updated man pages by John Fleck</li>
Daniel Veillard60087f32001-10-10 09:45:09 +00001860 <li>portability and configure fixes</li>
1861 <li>an infinite loop on the HTML parser was removed (William)</li>
1862 <li>Windows makefile patches from Igor</li>
Daniel Veillard63d83142002-05-20 06:51:05 +00001863 <li>fixed half a dozen bugs reported for libxml or libxslt</li>
Daniel Veillard60087f32001-10-10 09:45:09 +00001864 <li>updated xmlcatalog to be able to modify SGML super catalogs</li>
1865</ul>
1866
Daniel Veillarddadd0872001-09-15 09:21:44 +00001867<h3>2.4.5: Sep 14 2001</h3>
1868<ul>
1869 <li>Remove a few annoying bugs in 2.4.4</li>
Daniel Veillard69839ba2006-06-06 13:27:03 +00001870 <li>forces the HTML serializer to output decimal charrefs since someversion
1871 of Netscape can't handle hexadecimal ones</li>
Daniel Veillarddadd0872001-09-15 09:21:44 +00001872</ul>
1873
1874<h3>1.8.16: Sep 14 2001</h3>
1875<ul>
Daniel Veillard69839ba2006-06-06 13:27:03 +00001876 <li>maintenance release of the old libxml1 branch, couple of bug
1877 andportability fixes</li>
Daniel Veillarddadd0872001-09-15 09:21:44 +00001878</ul>
1879
Daniel Veillard04382ae2001-09-12 18:51:30 +00001880<h3>2.4.4: Sep 12 2001</h3>
1881<ul>
Daniel Veillard69839ba2006-06-06 13:27:03 +00001882 <li>added --convert to xmlcatalog, bug fixes and cleanups of XMLCatalog</li>
Daniel Veillard04382ae2001-09-12 18:51:30 +00001883 <li>a few bug fixes and some portability changes</li>
1884 <li>some documentation cleanups</li>
1885</ul>
1886
Daniel Veillard39936902001-08-24 00:49:01 +00001887<h3>2.4.3: Aug 23 2001</h3>
1888<ul>
1889 <li>XML Catalog support see the doc</li>
1890 <li>New NaN/Infinity floating point code</li>
1891 <li>A few bug fixes</li>
1892</ul>
1893
1894<h3>2.4.2: Aug 15 2001</h3>
Daniel Veillard3d6ae1c2001-08-15 13:12:39 +00001895<ul>
1896 <li>adds xmlLineNumbersDefault() to control line number generation</li>
1897 <li>lot of bug fixes</li>
Daniel Veillard63d83142002-05-20 06:51:05 +00001898 <li>the Microsoft MSC projects files should now be up to date</li>
Daniel Veillard3d6ae1c2001-08-15 13:12:39 +00001899 <li>inheritance of namespaces from DTD defaulted attributes</li>
1900 <li>fixes a serious potential security bug</li>
1901 <li>added a --format option to xmllint</li>
1902</ul>
1903
1904<h3>2.4.1: July 24 2001</h3>
1905<ul>
1906 <li>possibility to keep line numbers in the tree</li>
1907 <li>some computation NaN fixes</li>
1908 <li>extension of the XPath API</li>
1909 <li>cleanup for alpha and ia64 targets</li>
1910 <li>patch to allow saving through HTTP PUT or POST</li>
Daniel Veillard09ab7e12001-07-10 15:49:44 +00001911</ul>
1912
1913<h3>2.4.0: July 10 2001</h3>
1914<ul>
1915 <li>Fixed a few bugs in XPath, validation, and tree handling.</li>
Daniel Veillard69839ba2006-06-06 13:27:03 +00001916 <li>Fixed XML Base implementation, added a couple of examples to
1917 theregression tests</li>
Daniel Veillard09ab7e12001-07-10 15:49:44 +00001918 <li>A bit of cleanup</li>
Daniel Veillardab8500d2000-10-15 21:06:19 +00001919</ul>
1920
Daniel Veillard5b43fde2001-07-05 23:31:40 +00001921<h3>2.3.14: July 5 2001</h3>
1922<ul>
Daniel Veillard69839ba2006-06-06 13:27:03 +00001923 <li>fixed some entities problems and reduce memory requirement
1924 whensubstituting them</li>
1925 <li>lots of improvements in the XPath queries interpreter can
1926 besubstantially faster</li>
Daniel Veillard5b43fde2001-07-05 23:31:40 +00001927 <li>Makefiles and configure cleanups</li>
1928 <li>Fixes to XPath variable eval, and compare on empty node set</li>
1929 <li>HTML tag closing bug fixed</li>
Daniel Veillard63d83142002-05-20 06:51:05 +00001930 <li>Fixed an URI reference computation problem when validating</li>
Daniel Veillard5b43fde2001-07-05 23:31:40 +00001931</ul>
1932
Daniel Veillard2adbb512001-06-28 16:20:36 +00001933<h3>2.3.13: June 28 2001</h3>
1934<ul>
1935 <li>2.3.12 configure.in was broken as well as the push mode XML parser</li>
1936 <li>a few more fixes for compilation on Windows MSC by Yon Derek</li>
1937</ul>
1938
1939<h3>1.8.14: June 28 2001</h3>
1940<ul>
1941 <li>Zbigniew Chyla gave a patch to use the old XML parser in push mode</li>
1942 <li>Small Makefile fix</li>
1943</ul>
1944
Daniel Veillard11648102001-06-26 16:08:24 +00001945<h3>2.3.12: June 26 2001</h3>
1946<ul>
1947 <li>lots of cleanup</li>
1948 <li>a couple of validation fix</li>
1949 <li>fixed line number counting</li>
1950 <li>fixed serious problems in the XInclude processing</li>
1951 <li>added support for UTF8 BOM at beginning of entities</li>
Daniel Veillard69839ba2006-06-06 13:27:03 +00001952 <li>fixed a strange gcc optimizer bugs in xpath handling of float,
1953 gcc-3.0miscompile uri.c (William), Thomas Leitner provided a fix for
1954 theoptimizer on Tru64</li>
1955 <li>incorporated Yon Derek and Igor Zlatkovic fixes and improvements
1956 forcompilation on Windows MSC</li>
Daniel Veillard11648102001-06-26 16:08:24 +00001957 <li>update of libxml-doc.el (Felix Natter)</li>
1958 <li>fixed 2 bugs in URI normalization code</li>
1959</ul>
1960
Daniel Veillarde3c81b52001-06-17 14:50:34 +00001961<h3>2.3.11: June 17 2001</h3>
1962<ul>
Daniel Veillard69839ba2006-06-06 13:27:03 +00001963 <li>updates to trio, Makefiles and configure should fix some
1964 portabilityproblems (alpha)</li>
1965 <li>fixed some HTML serialization problems (pre, script, and
1966 block/inlinehandling), added encoding aware APIs, cleanup of this
1967 code</li>
Daniel Veillarde3c81b52001-06-17 14:50:34 +00001968 <li>added xmlHasNsProp()</li>
Daniel Veillard69839ba2006-06-06 13:27:03 +00001969 <li>implemented a specific PI for encoding support in the DocBook
1970 SGMLparser</li>
1971 <li>some XPath fixes (-Infinity, / as a function parameter and
1972 namespacesnode selection)</li>
Daniel Veillarde3c81b52001-06-17 14:50:34 +00001973 <li>fixed a performance problem and an error in the validation code</li>
1974 <li>fixed XInclude routine to implement the recursive behaviour</li>
1975 <li>fixed xmlFreeNode problem when libxml is included statically twice</li>
1976 <li>added --version to xmllint for bug reports</li>
1977</ul>
1978
Daniel Veillard2e4f1882001-06-01 10:11:57 +00001979<h3>2.3.10: June 1 2001</h3>
1980<ul>
1981 <li>fixed the SGML catalog support</li>
Daniel Veillard69839ba2006-06-06 13:27:03 +00001982 <li>a number of reported bugs got fixed, in XPath, iconv detection,XInclude
1983 processing</li>
Daniel Veillard2e4f1882001-06-01 10:11:57 +00001984 <li>XPath string function should now handle unicode correctly</li>
1985</ul>
1986
Daniel Veillard4623acd2001-05-19 15:13:15 +00001987<h3>2.3.9: May 19 2001</h3>
1988
1989<p>Lots of bugfixes, and added a basic SGML catalog support:</p>
1990<ul>
1991 <li>HTML push bugfix #54891 and another patch from Jonas Borgström</li>
Daniel Veillard63d83142002-05-20 06:51:05 +00001992 <li>some serious speed optimization again</li>
Daniel Veillard4623acd2001-05-19 15:13:15 +00001993 <li>some documentation cleanups</li>
Daniel Veillard63d83142002-05-20 06:51:05 +00001994 <li>trying to get better linking on Solaris (-R)</li>
Daniel Veillard4623acd2001-05-19 15:13:15 +00001995 <li>XPath API cleanup from Thomas Broyer</li>
Daniel Veillard69839ba2006-06-06 13:27:03 +00001996 <li>Validation bug fixed #54631, added a patch from Gary Pennington,
1997 fixedxmlValidGetValidElements()</li>
Daniel Veillard4623acd2001-05-19 15:13:15 +00001998 <li>Added an INSTALL file</li>
1999 <li>Attribute removal added to API: #54433</li>
2000 <li>added a basic support for SGML catalogs</li>
2001 <li>fixed xmlKeepBlanksDefault(0) API</li>
2002 <li>bugfix in xmlNodeGetLang()</li>
2003 <li>fixed a small configure portability problem</li>
2004 <li>fixed an inversion of SYSTEM and PUBLIC identifier in HTML document</li>
2005</ul>
2006
Daniel Veillarda265af72001-05-14 11:13:58 +00002007<h3>1.8.13: May 14 2001</h3>
2008<ul>
2009 <li>bugfixes release of the old libxml1 branch used by Gnome</li>
2010</ul>
2011
Daniel Veillard3bbbe6f2001-05-03 11:15:37 +00002012<h3>2.3.8: May 3 2001</h3>
2013<ul>
2014 <li>Integrated an SGML DocBook parser for the Gnome project</li>
2015 <li>Fixed a few things in the HTML parser</li>
Daniel Veillard69839ba2006-06-06 13:27:03 +00002016 <li>Fixed some XPath bugs raised by XSLT use, tried to fix the
2017 floatingpoint portability issue</li>
2018 <li>Speed improvement (8M/s for SAX, 3M/s for DOM, 1.5M/s forDOM+validation
2019 using the XML REC as input and a 700MHz celeron).</li>
Daniel Veillard3bbbe6f2001-05-03 11:15:37 +00002020 <li>incorporated more Windows cleanup</li>
2021 <li>added xmlSaveFormatFile()</li>
2022 <li>fixed problems in copying nodes with entities references (gdome)</li>
2023 <li>removed some troubles surrounding the new validation module</li>
2024</ul>
2025
Daniel Veillarda41123c2001-04-22 19:31:20 +00002026<h3>2.3.7: April 22 2001</h3>
2027<ul>
2028 <li>lots of small bug fixes, corrected XPointer</li>
Daniel Veillard63d83142002-05-20 06:51:05 +00002029 <li>Non deterministic content model validation support</li>
Daniel Veillarda41123c2001-04-22 19:31:20 +00002030 <li>added xmlDocCopyNode for gdome2</li>
2031 <li>revamped the way the HTML parser handles end of tags</li>
Daniel Veillard63d83142002-05-20 06:51:05 +00002032 <li>XPath: corrections of namespaces support and number formatting</li>
Daniel Veillarda41123c2001-04-22 19:31:20 +00002033 <li>Windows: Igor Zlatkovic patches for MSC compilation</li>
Daniel Veillard63d83142002-05-20 06:51:05 +00002034 <li>HTML output fixes from P C Chow and William M. Brack</li>
Daniel Veillarda41123c2001-04-22 19:31:20 +00002035 <li>Improved validation speed sensible for DocBook</li>
2036 <li>fixed a big bug with ID declared in external parsed entities</li>
2037 <li>portability fixes, update of Trio from Bjorn Reese</li>
2038</ul>
2039
Daniel Veillardafc73112001-04-11 11:51:41 +00002040<h3>2.3.6: April 8 2001</h3>
2041<ul>
Daniel Veillard69839ba2006-06-06 13:27:03 +00002042 <li>Code cleanup using extreme gcc compiler warning options, found
2043 andcleared half a dozen potential problem</li>
Daniel Veillardafc73112001-04-11 11:51:41 +00002044 <li>the Eazel team found an XML parser bug</li>
Daniel Veillard69839ba2006-06-06 13:27:03 +00002045 <li>cleaned up the user of some of the string formatting function. used
2046 thetrio library code to provide the one needed when the platform is
2047 missingthem</li>
2048 <li>xpath: removed a memory leak and fixed the predicate evaluationproblem,
2049 extended the testsuite and cleaned up the result. XPointer seemsbroken
2050 ...</li>
Daniel Veillardafc73112001-04-11 11:51:41 +00002051</ul>
2052
Daniel Veillard56a4cb82001-03-24 17:00:36 +00002053<h3>2.3.5: Mar 23 2001</h3>
2054<ul>
Daniel Veillard69839ba2006-06-06 13:27:03 +00002055 <li>Biggest change is separate parsing and evaluation of XPath
2056 expressions,there is some new APIs for this too</li>
2057 <li>included a number of bug fixes(XML push parser, 51876,
2058 notations,52299)</li>
Daniel Veillard56a4cb82001-03-24 17:00:36 +00002059 <li>Fixed some portability issues</li>
2060</ul>
2061
Daniel Veillarde356c282001-03-10 12:32:04 +00002062<h3>2.3.4: Mar 10 2001</h3>
2063<ul>
2064 <li>Fixed bugs #51860 and #51861</li>
Daniel Veillard69839ba2006-06-06 13:27:03 +00002065 <li>Added a global variable xmlDefaultBufferSize to allow default
2066 buffersize to be application tunable.</li>
2067 <li>Some cleanup in the validation code, still a bug left and this
2068 partshould probably be rewritten to support ambiguous content model
2069 :-\</li>
2070 <li>Fix a couple of serious bugs introduced or raised by changes in
2071 2.3.3parser</li>
Daniel Veillarde356c282001-03-10 12:32:04 +00002072 <li>Fixed another bug in xmlNodeGetContent()</li>
2073 <li>Bjorn fixed XPath node collection and Number formatting</li>
2074 <li>Fixed a loop reported in the HTML parsing</li>
Daniel Veillard69839ba2006-06-06 13:27:03 +00002075 <li>blank space are reported even if the Dtd content model proves that
2076 theyare formatting spaces, this is for XML conformance</li>
Daniel Veillarde356c282001-03-10 12:32:04 +00002077</ul>
2078
Daniel Veillardb402c072001-03-01 17:28:58 +00002079<h3>2.3.3: Mar 1 2001</h3>
2080<ul>
2081 <li>small change in XPath for XSLT</li>
2082 <li>documentation cleanups</li>
2083 <li>fix in validation by Gary Pennington</li>
2084 <li>serious parsing performances improvements</li>
2085</ul>
2086
Daniel Veillardec70e912001-02-26 20:10:45 +00002087<h3>2.3.2: Feb 24 2001</h3>
Daniel Veillard71681102001-02-24 17:48:53 +00002088<ul>
2089 <li>chasing XPath bugs, found a bunch, completed some TODO</li>
2090 <li>fixed a Dtd parsing bug</li>
2091 <li>fixed a bug in xmlNodeGetContent</li>
2092 <li>ID/IDREF support partly rewritten by Gary Pennington</li>
2093</ul>
2094
Daniel Veillardec70e912001-02-26 20:10:45 +00002095<h3>2.3.1: Feb 15 2001</h3>
Daniel Veillard6e6a6cc2001-02-15 15:55:44 +00002096<ul>
2097 <li>some XPath and HTML bug fixes for XSLT</li>
Daniel Veillard69839ba2006-06-06 13:27:03 +00002098 <li>small extension of the hash table interfaces for DOM
2099 gdome2implementation</li>
Daniel Veillard6e6a6cc2001-02-15 15:55:44 +00002100 <li>A few bug fixes</li>
2101</ul>
2102
Daniel Veillardec70e912001-02-26 20:10:45 +00002103<h3>2.3.0: Feb 8 2001 (2.2.12 was on 25 Jan but I didn't kept track)</h3>
Daniel Veillard6e6a6cc2001-02-15 15:55:44 +00002104<ul>
2105 <li>Lots of XPath bug fixes</li>
Daniel Veillard69839ba2006-06-06 13:27:03 +00002106 <li>Add a mode with Dtd lookup but without validation error reporting
2107 forXSLT</li>
Daniel Veillard6e6a6cc2001-02-15 15:55:44 +00002108 <li>Add support for text node without escaping (XSLT)</li>
2109 <li>bug fixes for xmlCheckFilename</li>
2110 <li>validation code bug fixes from Gary Pennington</li>
2111 <li>Patch from Paul D. Smith correcting URI path normalization</li>
Daniel Veillard69839ba2006-06-06 13:27:03 +00002112 <li>Patch to allow simultaneous install of libxml-devel
2113 andlibxml2-devel</li>
Daniel Veillard6e6a6cc2001-02-15 15:55:44 +00002114 <li>the example Makefile is now fixed</li>
2115 <li>added HTML to the RPM packages</li>
2116 <li>tree copying bugfixes</li>
2117 <li>updates to Windows makefiles</li>
Daniel Veillard63d83142002-05-20 06:51:05 +00002118 <li>optimization patch from Bjorn Reese</li>
Daniel Veillard6e6a6cc2001-02-15 15:55:44 +00002119</ul>
2120
Daniel Veillardec70e912001-02-26 20:10:45 +00002121<h3>2.2.11: Jan 4 2001</h3>
Daniel Veillard503b8932001-01-05 06:36:31 +00002122<ul>
2123 <li>bunch of bug fixes (memory I/O, xpath, ftp/http, ...)</li>
2124 <li>added htmlHandleOmittedElem()</li>
2125 <li>Applied Bjorn Reese's IPV6 first patch</li>
2126 <li>Applied Paul D. Smith patches for validation of XInclude results</li>
Daniel Veillard82687162001-01-22 15:32:01 +00002127 <li>added XPointer xmlns() new scheme support</li>
Daniel Veillard503b8932001-01-05 06:36:31 +00002128</ul>
2129
Daniel Veillard2ddd23d2000-11-25 10:42:19 +00002130<h3>2.2.10: Nov 25 2000</h3>
Daniel Veillard9d343c42000-11-25 10:12:43 +00002131<ul>
2132 <li>Fix the Windows problems of 2.2.8</li>
2133 <li>integrate OpenVMS patches</li>
2134 <li>better handling of some nasty HTML input</li>
2135 <li>Improved the XPointer implementation</li>
2136 <li>integrate a number of provided patches</li>
2137</ul>
2138
Daniel Veillard2ddd23d2000-11-25 10:42:19 +00002139<h3>2.2.9: Nov 25 2000</h3>
2140<ul>
2141 <li>erroneous release :-(</li>
2142</ul>
2143
Daniel Veillard28929b22000-11-13 18:22:49 +00002144<h3>2.2.8: Nov 13 2000</h3>
2145<ul>
Daniel Veillard69839ba2006-06-06 13:27:03 +00002146 <li>First version of <a
2147 href="http://www.w3.org/TR/xinclude">XInclude</a>support</li>
Daniel Veillard28929b22000-11-13 18:22:49 +00002148 <li>Patch in conditional section handling</li>
2149 <li>updated MS compiler project</li>
2150 <li>fixed some XPath problems</li>
2151 <li>added an URI escaping function</li>
2152 <li>some other bug fixes</li>
2153</ul>
2154
2155<h3>2.2.7: Oct 31 2000</h3>
2156<ul>
2157 <li>added message redirection</li>
2158 <li>XPath improvements (thanks TOM !)</li>
2159 <li>xmlIOParseDTD() added</li>
2160 <li>various small fixes in the HTML, URI, HTTP and XPointer support</li>
2161 <li>some cleanup of the Makefile, autoconf and the distribution content</li>
2162</ul>
2163
Daniel Veillard29a11cc2000-10-25 13:32:39 +00002164<h3>2.2.6: Oct 25 2000:</h3>
2165<ul>
Daniel Veillard69839ba2006-06-06 13:27:03 +00002166 <li>Added an hash table module, migrated a number of internal structure
2167 tothose</li>
Daniel Veillard29a11cc2000-10-25 13:32:39 +00002168 <li>Fixed a posteriori validation problems</li>
2169 <li>HTTP module cleanups</li>
Daniel Veillard69839ba2006-06-06 13:27:03 +00002170 <li>HTML parser improvements (tag errors, script/style handling,
2171 attributenormalization)</li>
Daniel Veillard29a11cc2000-10-25 13:32:39 +00002172 <li>coalescing of adjacent text nodes</li>
2173 <li>couple of XPath bug fixes, exported the internal API</li>
2174</ul>
2175
Daniel Veillardab8500d2000-10-15 21:06:19 +00002176<h3>2.2.5: Oct 15 2000:</h3>
Daniel Veillard4c3a2031999-11-19 17:46:26 +00002177<ul>
Daniel Veillard189446d2000-10-13 10:23:06 +00002178 <li>XPointer implementation and testsuite</li>
Daniel Veillard69839ba2006-06-06 13:27:03 +00002179 <li>Lot of XPath fixes, added variable and functions registration,
2180 moretests</li>
2181 <li>Portability fixes, lots of enhancements toward an easy Windows buildand
2182 release</li>
Daniel Veillard189446d2000-10-13 10:23:06 +00002183 <li>Late validation fixes</li>
2184 <li>Integrated a lot of contributed patches</li>
2185 <li>added memory management docs</li>
Daniel Veillardab8500d2000-10-15 21:06:19 +00002186 <li>a performance problem when using large buffer seems fixed</li>
Daniel Veillard189446d2000-10-13 10:23:06 +00002187</ul>
2188
2189<h3>2.2.4: Oct 1 2000:</h3>
2190<ul>
2191 <li>main XPath problem fixed</li>
2192 <li>Integrated portability patches for Windows</li>
2193 <li>Serious bug fixes on the URI and HTML code</li>
Daniel Veillard361d8452000-04-03 19:48:13 +00002194</ul>
2195
Daniel Veillardd5f97f82000-09-17 16:38:14 +00002196<h3>2.2.3: Sep 17 2000</h3>
2197<ul>
2198 <li>bug fixes</li>
2199 <li>cleanup of entity handling code</li>
Daniel Veillard69839ba2006-06-06 13:27:03 +00002200 <li>overall review of all loops in the parsers, all sprintf usage has
2201 beenchecked too</li>
2202 <li>Far better handling of larges Dtd. Validating against DocBook XML
2203 Dtdworks smoothly now.</li>
Daniel Veillardd5f97f82000-09-17 16:38:14 +00002204</ul>
2205
2206<h3>1.8.10: Sep 6 2000</h3>
2207<ul>
2208 <li>bug fix release for some Gnome projects</li>
2209</ul>
2210
2211<h3>2.2.2: August 12 2000</h3>
Daniel Veillard786d7c82000-08-12 23:38:57 +00002212<ul>
2213 <li>mostly bug fixes</li>
Daniel Veillardec78c0f2000-08-25 10:25:23 +00002214 <li>started adding routines to access xml parser context options</li>
Daniel Veillard786d7c82000-08-12 23:38:57 +00002215</ul>
2216
Daniel Veillardd5f97f82000-09-17 16:38:14 +00002217<h3>2.2.1: July 21 2000</h3>
Daniel Veillarda2679fa2000-07-22 02:38:15 +00002218<ul>
2219 <li>a purely bug fixes release</li>
2220 <li>fixed an encoding support problem when parsing from a memory block</li>
2221 <li>fixed a DOCTYPE parsing problem</li>
Daniel Veillard69839ba2006-06-06 13:27:03 +00002222 <li>removed a bug in the function allowing to override the memoryallocation
2223 routines</li>
Daniel Veillarda2679fa2000-07-22 02:38:15 +00002224</ul>
2225
Daniel Veillardd5f97f82000-09-17 16:38:14 +00002226<h3>2.2.0: July 14 2000</h3>
Daniel Veillard94e90602000-07-17 14:38:19 +00002227<ul>
2228 <li>applied a lot of portability fixes</li>
Daniel Veillard69839ba2006-06-06 13:27:03 +00002229 <li>better encoding support/cleanup and saving (content is now
2230 alwaysencoded in UTF-8)</li>
Daniel Veillard94e90602000-07-17 14:38:19 +00002231 <li>the HTML parser now correctly handles encodings</li>
2232 <li>added xmlHasProp()</li>
2233 <li>fixed a serious problem with &amp;#38;</li>
2234 <li>propagated the fix to FTP client</li>
2235 <li>cleanup, bugfixes, etc ...</li>
Daniel Veillard69839ba2006-06-06 13:27:03 +00002236 <li>Added a page about <a href="encoding.html">libxml
2237 Internationalizationsupport</a></li>
Daniel Veillard94e90602000-07-17 14:38:19 +00002238</ul>
2239
Daniel Veillard60979bd2000-07-10 12:17:33 +00002240<h3>1.8.9: July 9 2000</h3>
2241<ul>
2242 <li>fixed the spec the RPMs should be better</li>
Daniel Veillard69839ba2006-06-06 13:27:03 +00002243 <li>fixed a serious bug in the FTP implementation, released 1.8.9 to
2244 solverpmfind users problem</li>
Daniel Veillard60979bd2000-07-10 12:17:33 +00002245</ul>
2246
Daniel Veillard6388e172000-07-03 16:07:19 +00002247<h3>2.1.1: July 1 2000</h3>
2248<ul>
2249 <li>fixes a couple of bugs in the 2.1.0 packaging</li>
2250 <li>improvements on the HTML parser</li>
2251</ul>
2252
Daniel Veillard3f6f7f62000-06-30 17:58:25 +00002253<h3>2.1.0 and 1.8.8: June 29 2000</h3>
2254<ul>
Daniel Veillard69839ba2006-06-06 13:27:03 +00002255 <li>1.8.8 is mostly a commodity package for upgrading to libxml2
2256 accordingto <a href="upgrade.html">new instructions</a>. It fixes a nasty
2257 problemabout &amp;#38; charref parsing</li>
2258 <li>2.1.0 also ease the upgrade from libxml v1 to the recent version.
2259 italso contains numerous fixes and enhancements:
Daniel Veillard3f6f7f62000-06-30 17:58:25 +00002260 <ul>
2261 <li>added xmlStopParser() to stop parsing</li>
2262 <li>improved a lot parsing speed when there is large CDATA blocs</li>
2263 <li>includes XPath patches provided by Picdar Technology</li>
Daniel Veillard69839ba2006-06-06 13:27:03 +00002264 <li>tried to fix as much as possible DTD validation and
2265 namespacerelated problems</li>
Daniel Veillard3f6f7f62000-06-30 17:58:25 +00002266 <li>output to a given encoding has been added/tested</li>
2267 <li>lot of various fixes</li>
2268 </ul>
2269 </li>
2270</ul>
2271
Daniel Veillarde0aed302000-04-16 08:52:20 +00002272<h3>2.0.0: Apr 12 2000</h3>
Daniel Veillard361d8452000-04-03 19:48:13 +00002273<ul>
Daniel Veillard69839ba2006-06-06 13:27:03 +00002274 <li>First public release of libxml2. If you are using libxml, it's a
2275 goodidea to check the 1.x to 2.x upgrade instructions. NOTE: while
2276 initiallyscheduled for Apr 3 the release occurred only on Apr 12 due to
2277 massiveworkload.</li>
2278 <li>The include are now located under $prefix/include/libxml (instead
2279 of$prefix/include/gnome-xml), they also are referenced by
Daniel Veillard60979bd2000-07-10 12:17:33 +00002280 <pre>#include &lt;libxml/xxx.h&gt;</pre>
Daniel Veillarde0aed302000-04-16 08:52:20 +00002281 <p>instead of</p>
Daniel Veillard361d8452000-04-03 19:48:13 +00002282 <pre>#include "xxx.h"</pre>
2283 </li>
Daniel Veillard8f621982000-03-20 13:07:15 +00002284 <li>a new URI module for parsing URIs and following strictly RFC 2396</li>
Daniel Veillard69839ba2006-06-06 13:27:03 +00002285 <li>the memory allocation routines used by libxml can now be
2286 overloadeddynamically by using xmlMemSetup()</li>
2287 <li>The previously CVS only tool tester has been
2288 renamed<strong>xmllint</strong>and is now installed as part of the
2289 libxml2package</li>
2290 <li>The I/O interface has been revamped. There is now ways to plug
2291 inspecific I/O modules, either at the URI scheme detection level
2292 usingxmlRegisterInputCallbacks() or by passing I/O functions when
2293 creating aparser context using xmlCreateIOParserCtxt()</li>
2294 <li>there is a C preprocessor macro LIBXML_VERSION providing the
2295 versionnumber of the libxml module in use</li>
2296 <li>a number of optional features of libxml can now be excluded atconfigure
2297 time (FTP/HTTP/HTML/XPath/Debug)</li>
Daniel Veillardedfb29b2000-03-14 19:59:05 +00002298</ul>
2299
2300<h3>2.0.0beta: Mar 14 2000</h3>
2301<ul>
2302 <li>This is a first Beta release of libxml version 2</li>
Daniel Veillard69839ba2006-06-06 13:27:03 +00002303 <li>It's available only from<a
2304 href="ftp://xmlsoft.org/libxml2/">xmlsoft.orgFTP</a>, it's packaged as
2305 libxml2-2.0.0beta and available as tar andRPMs</li>
2306 <li>This version is now the head in the Gnome CVS base, the old one
2307 isavailable under the tag LIB_XML_1_X</li>
2308 <li>This includes a very large set of changes. From a programmatic pointof
2309 view applications should not have to be modified too much, check the<a
2310 href="upgrade.html">upgrade page</a></li>
Daniel Veillardedfb29b2000-03-14 19:59:05 +00002311 <li>Some interfaces may changes (especially a bit about encoding).</li>
2312 <li>the updates includes:
Daniel Veillard6c8b1172000-03-01 00:40:41 +00002313 <ul>
Daniel Veillard69839ba2006-06-06 13:27:03 +00002314 <li>fix I18N support. ISO-Latin-x/UTF-8/UTF-16 (nearly) seems
2315 correctlyhandled now</li>
2316 <li>Better handling of entities, especially well-formedness checkingand
2317 proper PEref extensions in external subsets</li>
Daniel Veillard6c8b1172000-03-01 00:40:41 +00002318 <li>DTD conditional sections</li>
Daniel Veillard63d83142002-05-20 06:51:05 +00002319 <li>Validation now correctly handle entities content</li>
Daniel Veillard69839ba2006-06-06 13:27:03 +00002320 <li><a
2321 href="http://rpmfind.net/tools/gdome/messages/0039.html">changestructures
2322 to accommodate DOM</a></li>
Daniel Veillard6c8b1172000-03-01 00:40:41 +00002323 </ul>
2324 </li>
Daniel Veillardedfb29b2000-03-14 19:59:05 +00002325 <li>Serious progress were made toward compliance, <a
Daniel Veillard69839ba2006-06-06 13:27:03 +00002326 href="conf/result.html">here are the result of the test</a>against
2327 theOASIS testsuite (except the Japanese tests since I don't support
2328 thatencoding yet). This URL is rebuilt every couple of hours using the
2329 CVShead version.</li>
Daniel Veillarde41f2b72000-01-30 20:00:07 +00002330</ul>
2331
Daniel Veillardf13e1ed2000-03-06 07:41:49 +00002332<h3>1.8.7: Mar 6 2000</h3>
2333<ul>
2334 <li>This is a bug fix release:</li>
Daniel Veillard69839ba2006-06-06 13:27:03 +00002335 <li>It is possible to disable the ignorable blanks heuristic used
2336 bylibxml-1.x, a new function xmlKeepBlanksDefault(0) will allow this.
2337 Notethat for adherence to XML spec, this behaviour will be disabled
2338 bydefault in 2.x . The same function will allow to keep compatibility
2339 forold code.</li>
2340 <li>Blanks in &lt;a&gt; &lt;/a&gt; constructs are not ignored
2341 anymore,avoiding heuristic is really the Right Way :-\</li>
2342 <li>The unchecked use of snprintf which was breaking
2343 libxml-1.8.6compilation on some platforms has been fixed</li>
2344 <li>nanoftp.c nanohttp.c: Fixed '#' and '?' stripping when
2345 processingURIs</li>
Daniel Veillardf13e1ed2000-03-06 07:41:49 +00002346</ul>
2347
Daniel Veillarde41f2b72000-01-30 20:00:07 +00002348<h3>1.8.6: Jan 31 2000</h3>
2349<ul>
2350 <li>added a nanoFTP transport module, debugged until the new version of <a
Daniel Veillard69839ba2006-06-06 13:27:03 +00002351 href="http://rpmfind.net/linux/rpm2html/rpmfind.html">rpmfind</a>can
2352 useit without troubles</li>
Daniel Veillardda07c342000-01-25 18:31:22 +00002353</ul>
2354
2355<h3>1.8.5: Jan 21 2000</h3>
2356<ul>
Daniel Veillard0142b842000-01-14 14:45:24 +00002357 <li>adding APIs to parse a well balanced chunk of XML (production <a
Daniel Veillard69839ba2006-06-06 13:27:03 +00002358 href="http://www.w3.org/TR/REC-xml#NT-content">[43] content</a>of theXML
2359 spec)</li>
Daniel Veillard461a66c2000-01-18 18:01:01 +00002360 <li>fixed a hideous bug in xmlGetProp pointed by Rune.Djurhuus@fast.no</li>
Daniel Veillard69839ba2006-06-06 13:27:03 +00002361 <li>Jody Goldberg &lt;jgoldberg@home.com&gt; provided another patch
2362 tryingto solve the zlib checks problems</li>
2363 <li>The current state in gnome CVS base is expected to ship as 1.8.5
2364 withgnumeric soon</li>
Daniel Veillard0142b842000-01-14 14:45:24 +00002365</ul>
2366
2367<h3>1.8.4: Jan 13 2000</h3>
2368<ul>
2369 <li>bug fixes, reintroduced xmlNewGlobalNs(), fixed xmlNewNs()</li>
2370 <li>all exit() call should have been removed from libxml</li>
2371 <li>fixed a problem with INCLUDE_WINSOCK on WIN32 platform</li>
2372 <li>added newDocFragment()</li>
Daniel Veillardf84f71f2000-01-05 19:54:23 +00002373</ul>
2374
2375<h3>1.8.3: Jan 5 2000</h3>
2376<ul>
2377 <li>a Push interface for the XML and HTML parsers</li>
Daniel Veillardf13e1ed2000-03-06 07:41:49 +00002378 <li>a shell-like interface to the document tree (try tester --shell :-)</li>
Daniel Veillard63d83142002-05-20 06:51:05 +00002379 <li>lots of bug fixes and improvement added over XMas holidays</li>
Daniel Veillard437b87b2000-01-03 17:30:46 +00002380 <li>fixed the DTD parsing code to work with the xhtml DTD</li>
Daniel Veillardf84f71f2000-01-05 19:54:23 +00002381 <li>added xmlRemoveProp(), xmlRemoveID() and xmlRemoveRef()</li>
2382 <li>Fixed bugs in xmlNewNs()</li>
Daniel Veillard69839ba2006-06-06 13:27:03 +00002383 <li>External entity loading code has been revamped, now it
2384 usesxmlLoadExternalEntity(), some fix on entities processing were
2385 added</li>
Daniel Veillard437b87b2000-01-03 17:30:46 +00002386 <li>cleaned up WIN32 includes of socket stuff</li>
Daniel Veillard5cb5ab81999-12-21 15:35:29 +00002387</ul>
2388
2389<h3>1.8.2: Dec 21 1999</h3>
2390<ul>
Daniel Veillard69839ba2006-06-06 13:27:03 +00002391 <li>I got another problem with includes and C++, I hope this issue is
2392 fixedfor good this time</li>
2393 <li>Added a few tree modification functions:
2394 xmlReplaceNode,xmlAddPrevSibling, xmlAddNextSibling, xmlNodeSetName
2395 andxmlDocSetRootElement</li>
Daniel Veillard5cb5ab81999-12-21 15:35:29 +00002396 <li>Tried to improve the HTML output with help from <a
2397 href="mailto:clahey@umich.edu">Chris Lahey</a></li>
Daniel Veillarde4e51311999-12-18 15:32:46 +00002398</ul>
Daniel Veillardb24054a1999-12-18 15:32:46 +00002399
Daniel Veillarde4e51311999-12-18 15:32:46 +00002400<h3>1.8.1: Dec 18 1999</h3>
2401<ul>
Daniel Veillard69839ba2006-06-06 13:27:03 +00002402 <li>various patches to avoid troubles when using libxml with C++
2403 compilersthe "namespace" keyword and C escaping in include files</li>
Daniel Veillarde4e51311999-12-18 15:32:46 +00002404 <li>a problem in one of the core macros IS_CHAR was corrected</li>
Daniel Veillard69839ba2006-06-06 13:27:03 +00002405 <li>fixed a bug introduced in 1.8.0 breaking default namespace
2406 processing,and more specifically the Dia application</li>
2407 <li>fixed a posteriori validation (validation after parsing, or by using
2408 aDtd not specified in the original document)</li>
Daniel Veillardb24054a1999-12-18 15:32:46 +00002409 <li>fixed a bug in</li>
Daniel Veillard10a2c651999-12-12 13:03:50 +00002410</ul>
2411
2412<h3>1.8.0: Dec 12 1999</h3>
2413<ul>
2414 <li>cleanup, especially memory wise</li>
Daniel Veillard69839ba2006-06-06 13:27:03 +00002415 <li>the parser should be more reliable, especially the HTML one, it
2416 shouldnot crash, whatever the input !</li>
2417 <li>Integrated various patches, especially a speedup improvement for
2418 largedataset from <a href="mailto:cnygard@bellatlantic.net">Carl
2419 Nygard</a>,configure with --with-buffers to enable them.</li>
Daniel Veillard10a2c651999-12-12 13:03:50 +00002420 <li>attribute normalization, oops should have been added long ago !</li>
Daniel Veillard69839ba2006-06-06 13:27:03 +00002421 <li>attributes defaulted from DTDs should be available, xmlSetProp()
2422 nowdoes entities escaping by default.</li>
Daniel Veillard4c3a2031999-11-19 17:46:26 +00002423</ul>
Daniel Veillard35008381999-10-25 13:15:52 +00002424
2425<h3>1.7.4: Oct 25 1999</h3>
Daniel Veillard2f4dfc41999-09-24 14:03:48 +00002426<ul>
Daniel Veillard35008381999-10-25 13:15:52 +00002427 <li>Lots of HTML improvement</li>
2428 <li>Fixed some errors when saving both XML and HTML</li>
2429 <li>More examples, the regression tests should now look clean</li>
2430 <li>Fixed a bug with contiguous charref</li>
2431</ul>
2432
2433<h3>1.7.3: Sep 29 1999</h3>
2434<ul>
2435 <li>portability problems fixed</li>
Daniel Veillard69839ba2006-06-06 13:27:03 +00002436 <li>snprintf was used unconditionally, leading to link problems on
2437 systemwere it's not available, fixed</li>
Daniel Veillard2f4dfc41999-09-24 14:03:48 +00002438</ul>
2439
2440<h3>1.7.1: Sep 24 1999</h3>
2441<ul>
Daniel Veillard69839ba2006-06-06 13:27:03 +00002442 <li>The basic type for strings manipulated by libxml has been renamed
2443 in1.7.1 from <strong>CHAR</strong>to <strong>xmlChar</strong>. The
2444 reasonis that CHAR was conflicting with a predefined type on Windows.
2445 Howeveron non WIN32 environment, compatibility is provided by the way of
2446 a<strong>#define </strong>.</li>
2447 <li>Changed another error : the use of a structure field called errno,
2448 andleading to troubles on platforms where it's a macro</li>
Daniel Veillard2f4dfc41999-09-24 14:03:48 +00002449</ul>
2450
Daniel Veillard63d83142002-05-20 06:51:05 +00002451<h3>1.7.0: Sep 23 1999</h3>
Daniel Veillard2f4dfc41999-09-24 14:03:48 +00002452<ul>
2453 <li>Added the ability to fetch remote DTD or parsed entities, see the <a
Daniel Veillard69839ba2006-06-06 13:27:03 +00002454 href="html/libxml-nanohttp.html">nanohttp</a>module.</li>
2455 <li>Added an errno to report errors by another mean than a simple
2456 printflike callback</li>
Daniel Veillard2f4dfc41999-09-24 14:03:48 +00002457 <li>Finished ID/IDREF support and checking when validation</li>
2458 <li>Serious memory leaks fixed (there is now a <a
Daniel Veillard69839ba2006-06-06 13:27:03 +00002459 href="html/libxml-xmlmemory.html">memory wrapper</a>module)</li>
2460 <li>Improvement of <a
2461 href="http://www.w3.org/TR/xpath">XPath</a>implementation</li>
Daniel Veillard2f4dfc41999-09-24 14:03:48 +00002462 <li>Added an HTML parser front-end</li>
2463</ul>
2464
2465<h2><a name="XML">XML</a></h2>
Daniel Veillardc8eab3a1999-09-04 18:27:23 +00002466
Daniel Veillard69839ba2006-06-06 13:27:03 +00002467<p><a href="http://www.w3.org/TR/REC-xml">XML is a
2468standard</a>formarkup-based structured documents. Here is <a
2469name="example">an example XMLdocument</a>:</p>
Daniel Veillard60979bd2000-07-10 12:17:33 +00002470<pre>&lt;?xml version="1.0"?&gt;
2471&lt;EXAMPLE prop1="gnome is great" prop2="&amp;amp; linux too"&gt;
2472 &lt;head&gt;
2473 &lt;title&gt;Welcome to Gnome&lt;/title&gt;
2474 &lt;/head&gt;
2475 &lt;chapter&gt;
2476 &lt;title&gt;The Linux adventure&lt;/title&gt;
2477 &lt;p&gt;bla bla bla ...&lt;/p&gt;
2478 &lt;image href="linus.gif"/&gt;
2479 &lt;p&gt;...&lt;/p&gt;
2480 &lt;/chapter&gt;
2481&lt;/EXAMPLE&gt;</pre>
Daniel Veillardb05deb71999-08-10 19:04:08 +00002482
Daniel Veillard69839ba2006-06-06 13:27:03 +00002483<p>The first line specifies that it is an XML document and gives
2484usefulinformation about its encoding. Then the rest of the document is a
2485textformat whose structure is specified by tags between brackets.
2486<strong>Eachtag opened has to be closed</strong>. XML is pedantic about this.
2487However, ifa tag is empty (no content), a single tag can serve as both the
2488opening andclosing tag if it ends with <code>/&gt;</code>rather than
2489with<code>&gt;</code>. Note that, for example, the image tag has no content
2490(justan attribute) and is closed by ending the tag with
2491<code>/&gt;</code>.</p>
Daniel Veillardccb09631998-10-27 06:21:04 +00002492
Daniel Veillard69839ba2006-06-06 13:27:03 +00002493<p>XML can be applied successfully to a wide range of tasks, ranging fromlong
2494term structured document maintenance (where it follows the steps ofSGML) to
2495simple data encoding mechanisms like configuration file formatting(glade),
2496spreadsheets (gnumeric), or even shorter lived documents such asWebDAV where
2497it is used to encode remote calls between a client and aserver.</p>
Daniel Veillardc8eab3a1999-09-04 18:27:23 +00002498
Daniel Veillard82687162001-01-22 15:32:01 +00002499<h2><a name="XSLT">XSLT</a></h2>
2500
Daniel Veillard6e6a6cc2001-02-15 15:55:44 +00002501<p>Check <a href="http://xmlsoft.org/XSLT">the separate libxslt page</a></p>
2502
Daniel Veillard69839ba2006-06-06 13:27:03 +00002503<p><a href="http://www.w3.org/TR/xslt">XSL Transformations</a>, is alanguage
2504for transforming XML documents into other XML documents (orHTML/textual
2505output).</p>
Daniel Veillard82687162001-01-22 15:32:01 +00002506
Daniel Veillard69839ba2006-06-06 13:27:03 +00002507<p>A separate library called libxslt is available implementing XSLT-1.0
2508forlibxml2. This module "libxslt" too can be found in the Gnome CVS base.</p>
Daniel Veillard82687162001-01-22 15:32:01 +00002509
Daniel Veillard29f61002005-08-06 09:07:15 +00002510<p>You can check the progresses on the libxslt <a
2511href="http://xmlsoft.org/XSLT/ChangeLog.html">Changelog</a>.</p>
Daniel Veillard6dbcaf82002-02-20 14:37:47 +00002512
2513<h2><a name="Python">Python and bindings</a></h2>
2514
Daniel Veillard69839ba2006-06-06 13:27:03 +00002515<p>There are a number of language bindings and wrappers available forlibxml2,
2516the list below is not exhaustive. Please contact the <a
2517href="http://mail.gnome.org/mailman/listinfo/xml-bindings">xml-bindings@gnome.org</a>(<a
2518href="http://mail.gnome.org/archives/xml-bindings/">archives</a>) inorder to
2519get updates to this list or to discuss the specific topic of libxml2or
2520libxslt wrappers or bindings:</p>
Daniel Veillard6dbcaf82002-02-20 14:37:47 +00002521<ul>
Daniel Veillard69839ba2006-06-06 13:27:03 +00002522 <li><a href="http://libxmlplusplus.sourceforge.net/">Libxml++</a>seems
2523 themost up-to-date C++ bindings for libxml2, check the <a
2524 href="http://libxmlplusplus.sourceforge.net/reference/html/hierarchy.html">documentation</a>and
2525 the <a
Daniel Veillardc14401e2002-11-20 14:28:17 +00002526 href="http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/libxmlplusplus/libxml%2b%2b/examples/">examples</a>.</li>
Daniel Veillard69839ba2006-06-06 13:27:03 +00002527 <li>There is another <a href="http://libgdome-cpp.berlios.de/">C++
2528 wrapperbased on the gdome2 bindings</a>maintained by Tobias Peters.</li>
Daniel Veillard9b6fd302002-05-13 12:06:47 +00002529 <li>and a third C++ wrapper by Peter Jones &lt;pjones@pmade.org&gt;
2530 <p>Website: <a
2531 href="http://pmade.org/pjones/software/xmlwrapp/">http://pmade.org/pjones/software/xmlwrapp/</a></p>
2532 </li>
Daniel Veillard6dbcaf82002-02-20 14:37:47 +00002533 <li><a
Daniel Veillard69839ba2006-06-06 13:27:03 +00002534 href="http://mail.gnome.org/archives/xml/2001-March/msg00014.html">MattSergeant</a>developed
2535 <a href="http://axkit.org/download/">XML::LibXSLT</a>, a Perl wrapper
2536 forlibxml2/libxslt as part of the <a href="http://axkit.com/">AxKit
2537 XMLapplication server</a>.</li>
Daniel Veillard4ac494b2003-09-18 15:08:00 +00002538 <li>If you're interested into scripting XML processing, have a look at <a
Daniel Veillard69839ba2006-06-06 13:27:03 +00002539 href="http://xsh.sourceforge.net/">XSH</a>an XML editing shell based
2540 onLibxml2 Perl bindings.</li>
2541 <li><a href="mailto:dkuhlman@cutter.rexx.com">Dave Kuhlman</a>provides
2542 anearlier version of the libxml/libxslt <a
Daniel Veillard0b28e882002-07-24 23:47:05 +00002543 href="http://www.rexx.com/~dkuhlman">wrappers for Python</a>.</li>
Daniel Veillard21473672002-06-17 07:29:22 +00002544 <li>Gopal.V and Peter Minten develop <a
Daniel Veillard69839ba2006-06-06 13:27:03 +00002545 href="http://savannah.gnu.org/projects/libxmlsharp">libxml#</a>, a set
2546 ofC# libxml2 bindings.</li>
Daniel Veillard6dbcaf82002-02-20 14:37:47 +00002547 <li>Petr Kozelka provides <a
Daniel Veillard69839ba2006-06-06 13:27:03 +00002548 href="http://sourceforge.net/projects/libxml2-pas">Pascal units to
2549 gluelibxml2</a>with Kylix, Delphi and other Pascal compilers.</li>
Daniel Veillardb2fb8ed2002-04-01 09:33:12 +00002550 <li>Uwe Fechner also provides <a
Daniel Veillard69839ba2006-06-06 13:27:03 +00002551 href="http://sourceforge.net/projects/idom2-pas/">idom2</a>, a
2552 DOM2implementation for Kylix2/D5/D6 from Borland.</li>
2553 <li>There is <a href="http://libxml.rubyforge.org/">bindings for
2554 Ruby</a>and libxml2 bindings are also available in Ruby through the <a
2555 href="http://libgdome-ruby.berlios.de/">libgdome-ruby</a>modulemaintained
2556 by Tobias Peters.</li>
Daniel Veillardaf43f632002-03-08 15:05:20 +00002557 <li>Steve Ball and contributors maintains <a
Daniel Veillard69839ba2006-06-06 13:27:03 +00002558 href="http://tclxml.sourceforge.net/">libxml2 and libxslt bindings
2559 forTcl</a>.</li>
Daniel Veillard142fb212005-04-07 12:48:10 +00002560 <li>libxml2 and libxslt is the default XML library for PHP5.</li>
Daniel Veillard69839ba2006-06-06 13:27:03 +00002561 <li><a href="http://savannah.gnu.org/projects/classpathx/">LibxmlJ</a>isan
2562 effort to create a 100% JAXP-compatible Java wrapper for libxml2
2563 andlibxslt as part of GNU ClasspathX project.</li>
2564 <li>Patrick McPhee provides Rexx bindings fof libxml2 and libxslt, look
2565 for<a href="http://www.interlog.com/~ptjm/software.html">RexxXML</a>.</li>
Daniel Veillard67952602006-01-05 15:29:44 +00002566 <li><a
Daniel Veillard69839ba2006-06-06 13:27:03 +00002567 href="http://www.satimage.fr/software/en/xml_suite.html">Satimage</a>provides
2568 <a
2569 href="http://www.satimage.fr/software/en/downloads_osaxen.html">XMLLibosax</a>.
2570 This is an osax for Mac OS X with a set of commands toimplement in
2571 AppleScript the XML DOM, XPATH and XSLT. Also includescommands for
2572 Property-lists (Apple's fast lookup table XML format.)</li>
Daniel Veillard67952602006-01-05 15:29:44 +00002573 <li>Francesco Montorsi developped <a
Daniel Veillard69839ba2006-06-06 13:27:03 +00002574 href="https://sourceforge.net/project/showfiles.php?group_id=51305&amp;package_id=45182">wxXml2</a>wrappers
2575 that interface libxml2, allowing wxWidgets applications toload/save/edit
2576 XML instances.</li>
Daniel Veillard6dbcaf82002-02-20 14:37:47 +00002577</ul>
2578
Daniel Veillard69839ba2006-06-06 13:27:03 +00002579<p>The distribution includes a set of Python bindings, which are guaranteedto
2580be maintained as part of the library in the future, though the
2581Pythoninterface have not yet reached the completeness of the C API.</p>
Daniel Veillard7b4b2f92003-01-06 13:11:20 +00002582
Daniel Veillard69839ba2006-06-06 13:27:03 +00002583<p>Note that some of the Python purist dislike the default set of
2584Pythonbindings, rather than complaining I suggest they have a look at <a
2585href="http://codespeak.net/lxml/">lxml the more pythonic bindings for
2586libxml2and libxslt</a>and <a
2587href="http://codespeak.net/mailman/listinfo/lxml-dev">help
2588MartijnFaassen</a>complete those.</p>
Daniel Veillard929746e2005-05-11 11:08:22 +00002589
Daniel Veillard69839ba2006-06-06 13:27:03 +00002590<p><a href="mailto:stephane.bidoul@softwareag.com">Stéphane
2591Bidoul</a>maintains <a href="http://users.skynet.be/sbi/libxml-python/">a
2592Windows portof the Python bindings</a>.</p>
Daniel Veillardaf43f632002-03-08 15:05:20 +00002593
Daniel Veillard69839ba2006-06-06 13:27:03 +00002594<p>Note to people interested in building bindings, the API is formalized as<a
2595href="libxml2-api.xml">an XML API description file</a>which allows toautomate
2596a large part of the Python bindings, this includes functiondescriptions,
2597enums, structures, typedefs, etc... The Python script used tobuild the
2598bindings is python/generator.py in the source distribution.</p>
Daniel Veillard7ef0fcb2002-12-14 10:38:55 +00002599
Daniel Veillardaf43f632002-03-08 15:05:20 +00002600<p>To install the Python bindings there are 2 options:</p>
Daniel Veillard0b79dfe2002-02-23 13:02:31 +00002601<ul>
Daniel Veillardaf43f632002-03-08 15:05:20 +00002602 <li>If you use an RPM based distribution, simply install the <a
Daniel Veillard69839ba2006-06-06 13:27:03 +00002603 href="http://rpmfind.net/linux/rpm2html/search.php?query=libxml2-python">libxml2-pythonRPM</a>(and
2604 if needed the <a
2605 href="http://rpmfind.net/linux/rpm2html/search.php?query=libxslt-python">libxslt-pythonRPM</a>).</li>
2606 <li>Otherwise use the <a
2607 href="ftp://xmlsoft.org/libxml2/python/">libxml2-pythonmodule
2608 distribution</a>corresponding to your installed version oflibxml2 and
2609 libxslt. Note that to install it you will need both libxml2and libxslt
2610 installed and run "python setup.py build install" in themodule tree.</li>
Daniel Veillard0b79dfe2002-02-23 13:02:31 +00002611</ul>
Daniel Veillardaf43f632002-03-08 15:05:20 +00002612
Daniel Veillard69839ba2006-06-06 13:27:03 +00002613<p>The distribution includes a set of examples and regression tests for
2614thepython bindings in the <code>python/tests</code>directory. Here are
2615someexcerpts from those tests:</p>
Daniel Veillard6dbcaf82002-02-20 14:37:47 +00002616
2617<h3>tst.py:</h3>
2618
2619<p>This is a basic test of the file interface and DOM navigation:</p>
MST 2003 John Fleck2dffb762003-11-29 04:41:24 +00002620<pre>import libxml2, sys
Daniel Veillard6dbcaf82002-02-20 14:37:47 +00002621
2622doc = libxml2.parseFile("tst.xml")
2623if doc.name != "tst.xml":
2624 print "doc.name failed"
2625 sys.exit(1)
2626root = doc.children
2627if root.name != "doc":
2628 print "root.name failed"
2629 sys.exit(1)
2630child = root.children
2631if child.name != "foo":
2632 print "child.name failed"
2633 sys.exit(1)
2634doc.freeDoc()</pre>
2635
Daniel Veillard69839ba2006-06-06 13:27:03 +00002636<p>The Python module is called libxml2; parseFile is the equivalent
2637ofxmlParseFile (most of the bindings are automatically generated, and the
2638xmlprefix is removed and the casing convention are kept). All node seen at
2639thebinding level share the same subset of accessors:</p>
Daniel Veillard6dbcaf82002-02-20 14:37:47 +00002640<ul>
Daniel Veillard69839ba2006-06-06 13:27:03 +00002641 <li><code>name</code>: returns the node name</li>
2642 <li><code>type</code>: returns a string indicating the node type</li>
2643 <li><code>content</code>: returns the content of the node, it is based
2644 onxmlNodeGetContent() and hence is recursive.</li>
2645 <li><code>parent</code>, <code>children</code>,
2646 <code>last</code>,<code>next</code>, <code>prev</code>,
2647 <code>doc</code>,<code>properties</code>: pointing to the associated
2648 element in the tree,those may return None in case no such link
2649 exists.</li>
Daniel Veillard6dbcaf82002-02-20 14:37:47 +00002650</ul>
2651
Daniel Veillard69839ba2006-06-06 13:27:03 +00002652<p>Also note the need to explicitly deallocate documents with freeDoc()
2653.Reference counting for libxml2 trees would need quite a lot of work
2654tofunction properly, and rather than risk memory leaks if not
2655implementedcorrectly it sounds safer to have an explicit function to free a
2656tree. Thewrapper python objects like doc, root or child are them
2657automatically garbagecollected.</p>
Daniel Veillard6dbcaf82002-02-20 14:37:47 +00002658
2659<h3>validate.py:</h3>
2660
Daniel Veillard69839ba2006-06-06 13:27:03 +00002661<p>This test check the validation interfaces and redirection of
2662errormessages:</p>
Daniel Veillard6dbcaf82002-02-20 14:37:47 +00002663<pre>import libxml2
2664
Daniel Veillard63d83142002-05-20 06:51:05 +00002665#deactivate error messages from the validation
Daniel Veillard6dbcaf82002-02-20 14:37:47 +00002666def noerr(ctx, str):
2667 pass
2668
2669libxml2.registerErrorHandler(noerr, None)
2670
2671ctxt = libxml2.createFileParserCtxt("invalid.xml")
2672ctxt.validate(1)
2673ctxt.parseDocument()
2674doc = ctxt.doc()
2675valid = ctxt.isValid()
2676doc.freeDoc()
2677if valid != 0:
Daniel Veillard63d83142002-05-20 06:51:05 +00002678 print "validity check failed"</pre>
Daniel Veillard6dbcaf82002-02-20 14:37:47 +00002679
Daniel Veillard69839ba2006-06-06 13:27:03 +00002680<p>The first thing to notice is the call to registerErrorHandler(), itdefines
2681a new error handler global to the library. It is used to avoid seeingthe
2682error messages when trying to validate the invalid document.</p>
Daniel Veillard6dbcaf82002-02-20 14:37:47 +00002683
Daniel Veillard69839ba2006-06-06 13:27:03 +00002684<p>The main interest of that test is the creation of a parser context
2685withcreateFileParserCtxt() and how the behaviour can be changed before
2686callingparseDocument() . Similarly the informations resulting from the
2687parsing phaseare also available using context methods.</p>
Daniel Veillard6dbcaf82002-02-20 14:37:47 +00002688
Daniel Veillard69839ba2006-06-06 13:27:03 +00002689<p>Contexts like nodes are defined as class and the libxml2 wrappers maps
2690theC function interfaces in terms of objects method as much as possible.
2691Thebest to get a complete view of what methods are supported is to look at
2692thelibxml2.py module containing all the wrappers.</p>
Daniel Veillard6dbcaf82002-02-20 14:37:47 +00002693
2694<h3>push.py:</h3>
2695
2696<p>This test show how to activate the push parser interface:</p>
2697<pre>import libxml2
2698
2699ctxt = libxml2.createPushParser(None, "&lt;foo", 4, "test.xml")
2700ctxt.parseChunk("/&gt;", 2, 1)
2701doc = ctxt.doc()
2702
2703doc.freeDoc()</pre>
2704
Daniel Veillard69839ba2006-06-06 13:27:03 +00002705<p>The context is created with a special call based on
2706thexmlCreatePushParser() from the C library. The first argument is an
2707optionalSAX callback object, then the initial set of data, the length and the
2708name ofthe resource in case URI-References need to be computed by the
2709parser.</p>
Daniel Veillard6dbcaf82002-02-20 14:37:47 +00002710
Daniel Veillard69839ba2006-06-06 13:27:03 +00002711<p>Then the data are pushed using the parseChunk() method, the last
2712callsetting the third argument terminate to 1.</p>
Daniel Veillard6dbcaf82002-02-20 14:37:47 +00002713
2714<h3>pushSAX.py:</h3>
2715
Daniel Veillard69839ba2006-06-06 13:27:03 +00002716<p>this test show the use of the event based parsing interfaces. In this
2717casethe parser does not build a document, but provides callback information
2718asthe parser makes progresses analyzing the data being provided:</p>
Daniel Veillard6dbcaf82002-02-20 14:37:47 +00002719<pre>import libxml2
2720log = ""
2721
2722class callback:
2723 def startDocument(self):
2724 global log
2725 log = log + "startDocument:"
2726
2727 def endDocument(self):
2728 global log
2729 log = log + "endDocument:"
2730
2731 def startElement(self, tag, attrs):
2732 global log
2733 log = log + "startElement %s %s:" % (tag, attrs)
2734
2735 def endElement(self, tag):
2736 global log
2737 log = log + "endElement %s:" % (tag)
2738
2739 def characters(self, data):
2740 global log
2741 log = log + "characters: %s:" % (data)
2742
2743 def warning(self, msg):
2744 global log
2745 log = log + "warning: %s:" % (msg)
2746
2747 def error(self, msg):
2748 global log
2749 log = log + "error: %s:" % (msg)
2750
2751 def fatalError(self, msg):
2752 global log
2753 log = log + "fatalError: %s:" % (msg)
2754
2755handler = callback()
2756
2757ctxt = libxml2.createPushParser(handler, "&lt;foo", 4, "test.xml")
2758chunk = " url='tst'&gt;b"
2759ctxt.parseChunk(chunk, len(chunk), 0)
2760chunk = "ar&lt;/foo&gt;"
2761ctxt.parseChunk(chunk, len(chunk), 1)
2762
Daniel Veillardfcbfa2d2002-02-21 17:54:27 +00002763reference = "startDocument:startElement foo {'url': 'tst'}:" + \
2764 "characters: bar:endElement foo:endDocument:"
Daniel Veillard6dbcaf82002-02-20 14:37:47 +00002765if log != reference:
2766 print "Error got: %s" % log
Daniel Veillard63d83142002-05-20 06:51:05 +00002767 print "Expected: %s" % reference</pre>
Daniel Veillard6dbcaf82002-02-20 14:37:47 +00002768
Daniel Veillard69839ba2006-06-06 13:27:03 +00002769<p>The key object in that test is the handler, it provides a number of
2770entrypoints which can be called by the parser as it makes progresses to
2771indicatethe information set obtained. The full set of callback is larger than
2772whatthe callback class in that specific example implements (see the
2773SAXdefinition for a complete list). The wrapper will only call those supplied
2774bythe object when activated. The startElement receives the names of the
2775elementand a dictionary containing the attributes carried by this element.</p>
Daniel Veillard6dbcaf82002-02-20 14:37:47 +00002776
Daniel Veillard69839ba2006-06-06 13:27:03 +00002777<p>Also note that the reference string generated from the callback shows
2778asingle character call even though the string "bar" is passed to the
2779parserfrom 2 different call to parseChunk()</p>
Daniel Veillard6dbcaf82002-02-20 14:37:47 +00002780
2781<h3>xpath.py:</h3>
2782
Daniel Veillard63d83142002-05-20 06:51:05 +00002783<p>This is a basic test of XPath wrappers support</p>
Daniel Veillard6dbcaf82002-02-20 14:37:47 +00002784<pre>import libxml2
2785
2786doc = libxml2.parseFile("tst.xml")
2787ctxt = doc.xpathNewContext()
2788res = ctxt.xpathEval("//*")
2789if len(res) != 2:
2790 print "xpath query: wrong node set size"
2791 sys.exit(1)
2792if res[0].name != "doc" or res[1].name != "foo":
2793 print "xpath query: wrong node set value"
2794 sys.exit(1)
2795doc.freeDoc()
2796ctxt.xpathFreeContext()</pre>
2797
Daniel Veillard69839ba2006-06-06 13:27:03 +00002798<p>This test parses a file, then create an XPath context to evaluate
2799XPathexpression on it. The xpathEval() method execute an XPath query and
2800returnsthe result mapped in a Python way. String and numbers are natively
2801converted,and node sets are returned as a tuple of libxml2 Python nodes
2802wrappers. Likethe document, the XPath context need to be freed explicitly,
2803also not thatthe result of the XPath query may point back to the document
2804tree and hencethe document must be freed after the result of the query is
2805used.</p>
Daniel Veillard6dbcaf82002-02-20 14:37:47 +00002806
2807<h3>xpathext.py:</h3>
2808
Daniel Veillard69839ba2006-06-06 13:27:03 +00002809<p>This test shows how to extend the XPath engine with functions written
2810inpython:</p>
Daniel Veillard6dbcaf82002-02-20 14:37:47 +00002811<pre>import libxml2
2812
2813def foo(ctx, x):
2814 return x + 1
2815
2816doc = libxml2.parseFile("tst.xml")
2817ctxt = doc.xpathNewContext()
2818libxml2.registerXPathFunction(ctxt._o, "foo", None, foo)
2819res = ctxt.xpathEval("foo(1)")
2820if res != 2:
2821 print "xpath extension failure"
2822doc.freeDoc()
2823ctxt.xpathFreeContext()</pre>
2824
Daniel Veillard69839ba2006-06-06 13:27:03 +00002825<p>Note how the extension function is registered with the context (but
2826thatpart is not yet finalized, this may change slightly in the future).</p>
Daniel Veillard6dbcaf82002-02-20 14:37:47 +00002827
2828<h3>tstxpath.py:</h3>
2829
Daniel Veillard69839ba2006-06-06 13:27:03 +00002830<p>This test is similar to the previous one but shows how the
2831extensionfunction can access the XPath evaluation context:</p>
Daniel Veillard6dbcaf82002-02-20 14:37:47 +00002832<pre>def foo(ctx, x):
2833 global called
2834
2835 #
2836 # test that access to the XPath evaluation contexts
2837 #
2838 pctxt = libxml2.xpathParserContext(_obj=ctx)
2839 ctxt = pctxt.context()
2840 called = ctxt.function()
2841 return x + 1</pre>
2842
Daniel Veillard69839ba2006-06-06 13:27:03 +00002843<p>All the interfaces around the XPath parser(or rather evaluation)
2844contextare not finalized, but it should be sufficient to do contextual work
2845at theevaluation point.</p>
Daniel Veillard6dbcaf82002-02-20 14:37:47 +00002846
2847<h3>Memory debugging:</h3>
2848
2849<p>last but not least, all tests starts with the following prologue:</p>
2850<pre>#memory debug specific
Daniel Veillardaf43f632002-03-08 15:05:20 +00002851libxml2.debugMemory(1)</pre>
Daniel Veillard6dbcaf82002-02-20 14:37:47 +00002852
2853<p>and ends with the following epilogue:</p>
2854<pre>#memory debug specific
2855libxml2.cleanupParser()
2856if libxml2.debugMemory(1) == 0:
2857 print "OK"
2858else:
2859 print "Memory leak %d bytes" % (libxml2.debugMemory(1))
2860 libxml2.dumpMemory()</pre>
2861
Daniel Veillard69839ba2006-06-06 13:27:03 +00002862<p>Those activate the memory debugging interface of libxml2 where
2863allallocated block in the library are tracked. The prologue then cleans up
2864thelibrary state and checks that all allocated memory has been freed. If not
2865itcalls dumpMemory() which saves that list in a <code>.memdump</code>file.</p>
Daniel Veillard82687162001-01-22 15:32:01 +00002866
Daniel Veillard8a469172003-06-12 16:05:07 +00002867<h2><a name="architecture">libxml2 architecture</a></h2>
Daniel Veillard4540be42000-08-19 16:40:28 +00002868
Daniel Veillard69839ba2006-06-06 13:27:03 +00002869<p>Libxml2 is made of multiple components; some of them are optional, andmost
2870of the block interfaces are public. The main components are:</p>
Daniel Veillard4540be42000-08-19 16:40:28 +00002871<ul>
2872 <li>an Input/Output layer</li>
Daniel Veillard91e9d582001-02-26 07:31:12 +00002873 <li>FTP and HTTP client layers (optional)</li>
Daniel Veillard4540be42000-08-19 16:40:28 +00002874 <li>an Internationalization layer managing the encodings support</li>
Daniel Veillard91e9d582001-02-26 07:31:12 +00002875 <li>a URI module</li>
Daniel Veillard4540be42000-08-19 16:40:28 +00002876 <li>the XML parser and its basic SAX interface</li>
Daniel Veillard91e9d582001-02-26 07:31:12 +00002877 <li>an HTML parser using the same SAX interface (optional)</li>
Daniel Veillard4540be42000-08-19 16:40:28 +00002878 <li>a SAX tree module to build an in-memory DOM representation</li>
2879 <li>a tree module to manipulate the DOM representation</li>
Daniel Veillard91e9d582001-02-26 07:31:12 +00002880 <li>a validation module using the DOM representation (optional)</li>
Daniel Veillard69839ba2006-06-06 13:27:03 +00002881 <li>an XPath module for global lookup in a DOM representation(optional)</li>
Daniel Veillard91e9d582001-02-26 07:31:12 +00002882 <li>a debug module (optional)</li>
Daniel Veillard4540be42000-08-19 16:40:28 +00002883</ul>
2884
2885<p>Graphically this gives the following:</p>
2886
2887<p><img src="libxml.gif" alt="a graphical view of the various"></p>
2888
2889<p></p>
2890
Daniel Veillard2f4dfc41999-09-24 14:03:48 +00002891<h2><a name="tree">The tree output</a></h2>
Daniel Veillardb05deb71999-08-10 19:04:08 +00002892
Daniel Veillard69839ba2006-06-06 13:27:03 +00002893<p>The parser returns a tree built during the document analysis. The
2894valuereturned is an <strong>xmlDocPtr</strong>(i.e., a pointer to
2895an<strong>xmlDoc</strong>structure). This structure contains information
2896suchas the file name, the document type, and a
2897<strong>children</strong>pointerwhich is the root of the document (or more
2898exactly the first child under theroot which is the document). The tree is
2899made of <strong>xmlNode</strong>s,chained in double-linked lists of siblings
2900and with a children&lt;-&gt;parentrelationship. An xmlNode can also carry
2901properties (a chain of xmlAttrstructures). An attribute may have a value
2902which is a list of TEXT orENTITY_REF nodes.</p>
Daniel Veillardb05deb71999-08-10 19:04:08 +00002903
Daniel Veillard69839ba2006-06-06 13:27:03 +00002904<p>Here is an example (erroneous with respect to the XML spec since
2905thereshould be only one ELEMENT under the root):</p>
Daniel Veillardb05deb71999-08-10 19:04:08 +00002906
2907<p><img src="structure.gif" alt=" structure.gif "></p>
2908
Daniel Veillard69839ba2006-06-06 13:27:03 +00002909<p>In the source package there is a small program (not installed by
2910default)called <strong>xmllint</strong>which parses XML files given as
2911argument andprints them back as parsed. This is useful for detecting errors
2912both in XMLcode and in the XML parser itself. It has an option
2913<strong>--debug</strong>which prints the actual in-memory structure of the
2914document; here is theresult with the <a href="#example">example</a>given
2915before:</p>
Daniel Veillard10c6a8f1998-10-28 01:00:12 +00002916<pre>DOCUMENT
2917version=1.0
2918standalone=true
2919 ELEMENT EXAMPLE
2920 ATTRIBUTE prop1
2921 TEXT
2922 content=gnome is great
2923 ATTRIBUTE prop2
2924 ENTITY_REF
2925 TEXT
Daniel Veillard0142b842000-01-14 14:45:24 +00002926 content= linux too
Daniel Veillard402e8c82000-02-29 22:57:47 +00002927 ELEMENT head
Daniel Veillard10c6a8f1998-10-28 01:00:12 +00002928 ELEMENT title
Daniel Veillard25940b71998-10-29 05:51:30 +00002929 TEXT
2930 content=Welcome to Gnome
Daniel Veillard10c6a8f1998-10-28 01:00:12 +00002931 ELEMENT chapter
2932 ELEMENT title
Daniel Veillard25940b71998-10-29 05:51:30 +00002933 TEXT
2934 content=The Linux adventure
Daniel Veillard10c6a8f1998-10-28 01:00:12 +00002935 ELEMENT p
Daniel Veillard25940b71998-10-29 05:51:30 +00002936 TEXT
2937 content=bla bla bla ...
Daniel Veillard10c6a8f1998-10-28 01:00:12 +00002938 ELEMENT image
2939 ATTRIBUTE href
2940 TEXT
2941 content=linus.gif
2942 ELEMENT p
Daniel Veillard25940b71998-10-29 05:51:30 +00002943 TEXT
2944 content=...</pre>
Daniel Veillardb05deb71999-08-10 19:04:08 +00002945
Daniel Veillard88f00ae2000-03-02 00:15:55 +00002946<p>This should be useful for learning the internal representation model.</p>
Daniel Veillardccb09631998-10-27 06:21:04 +00002947
Daniel Veillard2f4dfc41999-09-24 14:03:48 +00002948<h2><a name="interface">The SAX interface</a></h2>
Daniel Veillardc8eab3a1999-09-04 18:27:23 +00002949
Daniel Veillard69839ba2006-06-06 13:27:03 +00002950<p>Sometimes the DOM tree output is just too large to fit reasonably
2951intomemory. In that case (and if you don't expect to save back the XML
2952documentloaded using libxml), it's better to use the SAX interface of libxml.
2953SAX isa <strong>callback-based interface</strong>to the parser. Before
2954parsing,the application layer registers a customized set of callbacks which
2955arecalled by the library as it progresses through the XML input.</p>
Daniel Veillardc8eab3a1999-09-04 18:27:23 +00002956
Daniel Veillard69839ba2006-06-06 13:27:03 +00002957<p>To get more detailed step-by-step guidance on using the SAX interface
2958oflibxml, see the <a
2959href="http://www.daa.com.au/~james/gnome/xml-sax/xml-sax.html">nicedocumentation</a>.written
2960by <a href="mailto:james@daa.com.au">JamesHenstridge</a>.</p>
Daniel Veillardc8eab3a1999-09-04 18:27:23 +00002961
Daniel Veillard69839ba2006-06-06 13:27:03 +00002962<p>You can debug the SAX behaviour by using the
2963<strong>testSAX</strong>program located in the gnome-xml module (it's usually
2964not shipped in thebinary packages of libxml, but you can find it in the tar
2965sourcedistribution). Here is the sequence of callbacks that would be reported
2966bytestSAX when parsing the example XML document shown earlier:</p>
Daniel Veillardc8eab3a1999-09-04 18:27:23 +00002967<pre>SAX.setDocumentLocator()
2968SAX.startDocument()
2969SAX.getEntity(amp)
2970SAX.startElement(EXAMPLE, prop1='gnome is great', prop2='&amp;amp; linux too')
2971SAX.characters( , 3)
2972SAX.startElement(head)
2973SAX.characters( , 4)
2974SAX.startElement(title)
2975SAX.characters(Welcome to Gnome, 16)
2976SAX.endElement(title)
2977SAX.characters( , 3)
2978SAX.endElement(head)
2979SAX.characters( , 3)
2980SAX.startElement(chapter)
2981SAX.characters( , 4)
2982SAX.startElement(title)
2983SAX.characters(The Linux adventure, 19)
2984SAX.endElement(title)
2985SAX.characters( , 4)
2986SAX.startElement(p)
2987SAX.characters(bla bla bla ..., 15)
2988SAX.endElement(p)
2989SAX.characters( , 4)
2990SAX.startElement(image, href='linus.gif')
2991SAX.endElement(image)
2992SAX.characters( , 4)
2993SAX.startElement(p)
2994SAX.characters(..., 3)
2995SAX.endElement(p)
2996SAX.characters( , 3)
2997SAX.endElement(chapter)
2998SAX.characters( , 1)
2999SAX.endElement(EXAMPLE)
3000SAX.endDocument()</pre>
3001
Daniel Veillard69839ba2006-06-06 13:27:03 +00003002<p>Most of the other interfaces of libxml2 are based on the DOM
3003tree-buildingfacility, so nearly everything up to the end of this document
3004presupposes theuse of the standard DOM tree build. Note that the DOM tree
3005itself is built bya set of registered default callbacks, without internal
3006specificinterface.</p>
Daniel Veillardc8eab3a1999-09-04 18:27:23 +00003007
Daniel Veillardb8cfbd12001-10-25 10:53:28 +00003008<h2><a name="Validation">Validation &amp; DTDs</a></h2>
3009
3010<p>Table of Content:</p>
3011<ol>
3012 <li><a href="#General5">General overview</a></li>
3013 <li><a href="#definition">The definition</a></li>
3014 <li><a href="#Simple">Simple rules</a>
3015 <ol>
Daniel Veillard9c466822001-10-25 12:03:39 +00003016 <li><a href="#reference">How to reference a DTD from a document</a></li>
Daniel Veillardb8cfbd12001-10-25 10:53:28 +00003017 <li><a href="#Declaring">Declaring elements</a></li>
3018 <li><a href="#Declaring1">Declaring attributes</a></li>
3019 </ol>
3020 </li>
3021 <li><a href="#Some">Some examples</a></li>
3022 <li><a href="#validate">How to validate</a></li>
3023 <li><a href="#Other">Other resources</a></li>
3024</ol>
3025
3026<h3><a name="General5">General overview</a></h3>
3027
3028<p>Well what is validation and what is a DTD ?</p>
3029
Daniel Veillard69839ba2006-06-06 13:27:03 +00003030<p>DTD is the acronym for Document Type Definition. This is a description
3031ofthe content for a family of XML files. This is part of the XML
30321.0specification, and allows one to describe and verify that a given
3033documentinstance conforms to the set of rules detailing its structure and
3034content.</p>
Daniel Veillardb8cfbd12001-10-25 10:53:28 +00003035
Daniel Veillard69839ba2006-06-06 13:27:03 +00003036<p>Validation is the process of checking a document against a DTD
3037(moregenerally against a set of construction rules).</p>
Daniel Veillardb8cfbd12001-10-25 10:53:28 +00003038
Daniel Veillard69839ba2006-06-06 13:27:03 +00003039<p>The validation process and building DTDs are the two most difficult
3040partsof the XML life cycle. Briefly a DTD defines all the possible elements
3041to befound within your document, what is the formal shape of your document
3042tree(by defining the allowed content of an element; either text, a
3043regularexpression for the allowed list of children, or mixed content i.e.
3044both textand children). The DTD also defines the valid attributes for all
3045elements andthe types of those attributes.</p>
Daniel Veillardb8cfbd12001-10-25 10:53:28 +00003046
3047<h3><a name="definition1">The definition</a></h3>
3048
Daniel Veillard69839ba2006-06-06 13:27:03 +00003049<p>The <a href="http://www.w3.org/TR/REC-xml">W3C XML Recommendation</a>(<a
3050href="http://www.xml.com/axml/axml.html">Tim Bray's annotated version
3051ofRev1</a>):</p>
Daniel Veillardb8cfbd12001-10-25 10:53:28 +00003052<ul>
Daniel Veillard69839ba2006-06-06 13:27:03 +00003053 <li><a
3054 href="http://www.w3.org/TR/REC-xml#elemdecls">Declaringelements</a></li>
3055 <li><a
3056 href="http://www.w3.org/TR/REC-xml#attdecls">Declaringattributes</a></li>
Daniel Veillardb8cfbd12001-10-25 10:53:28 +00003057</ul>
3058
Daniel Veillard69839ba2006-06-06 13:27:03 +00003059<p>(unfortunately) all this is inherited from the SGML world, the syntax
3060isancient...</p>
Daniel Veillardb8cfbd12001-10-25 10:53:28 +00003061
3062<h3><a name="Simple1">Simple rules</a></h3>
3063
Daniel Veillard69839ba2006-06-06 13:27:03 +00003064<p>Writing DTDs can be done in many ways. The rules to build them if you
3065needsomething permanent or something which can evolve over time can be
3066radicallydifferent. Really complex DTDs like DocBook ones are flexible but
3067quiteharder to design. I will just focus on DTDs for a formats with a fixed
3068simplestructure. It is just a set of basic rules, and definitely not
3069exhaustive norusable for complex DTD design.</p>
Daniel Veillardb8cfbd12001-10-25 10:53:28 +00003070
3071<h4><a name="reference1">How to reference a DTD from a document</a>:</h4>
3072
Daniel Veillard69839ba2006-06-06 13:27:03 +00003073<p>Assuming the top element of the document is <code>spec</code>and the dtdis
3074placed in the file <code>mydtd</code>in the subdirectory<code>dtds</code>of
3075the directory from where the document were loaded:</p>
Daniel Veillardb8cfbd12001-10-25 10:53:28 +00003076
3077<p><code>&lt;!DOCTYPE spec SYSTEM "dtds/mydtd"&gt;</code></p>
3078
3079<p>Notes:</p>
3080<ul>
Daniel Veillard0b28e882002-07-24 23:47:05 +00003081 <li>The system string is actually an URI-Reference (as defined in <a
Daniel Veillard69839ba2006-06-06 13:27:03 +00003082 href="http://www.ietf.org/rfc/rfc2396.txt">RFC 2396</a>) so you can use
3083 afull URL string indicating the location of your DTD on the Web. This is
3084 areally good thing to do if you want others to validate your
3085 document.</li>
3086 <li>It is also possible to associate a <code>PUBLIC</code>identifier
3087 (amagic string) so that the DTD is looked up in catalogs on the client
3088 sidewithout having to locate it on the web.</li>
3089 <li>A DTD contains a set of element and attribute declarations, but
3090 theydon't define what the root of the document should be. This is
3091 explicitlytold to the parser/validator as the first element of
3092 the<code>DOCTYPE</code>declaration.</li>
Daniel Veillardb8cfbd12001-10-25 10:53:28 +00003093</ul>
3094
3095<h4><a name="Declaring2">Declaring elements</a>:</h4>
3096
3097<p>The following declares an element <code>spec</code>:</p>
3098
3099<p><code>&lt;!ELEMENT spec (front, body, back?)&gt;</code></p>
3100
Daniel Veillard69839ba2006-06-06 13:27:03 +00003101<p>It also expresses that the spec element contains one
3102<code>front</code>,one <code>body</code>and one optional
3103<code>back</code>children elements inthis order. The declaration of one
3104element of the structure and its contentare done in a single declaration.
3105Similarly the following declares<code>div1</code>elements:</p>
Daniel Veillardb8cfbd12001-10-25 10:53:28 +00003106
Daniel Veillard51737272002-01-23 23:10:38 +00003107<p><code>&lt;!ELEMENT div1 (head, (p | list | note)*, div2?)&gt;</code></p>
Daniel Veillardb8cfbd12001-10-25 10:53:28 +00003108
Daniel Veillard69839ba2006-06-06 13:27:03 +00003109<p>which means div1 contains one <code>head</code>then a series of
3110optional<code>p</code>, <code>list</code>s and <code>note</code>s and then
3111anoptional <code>div2</code>. And last but not least an element can
3112containtext:</p>
Daniel Veillardb8cfbd12001-10-25 10:53:28 +00003113
3114<p><code>&lt;!ELEMENT b (#PCDATA)&gt;</code></p>
3115
Daniel Veillard69839ba2006-06-06 13:27:03 +00003116<p><code>b</code>contains text or being of mixed content (text and elementsin
3117no particular order):</p>
Daniel Veillardb8cfbd12001-10-25 10:53:28 +00003118
3119<p><code>&lt;!ELEMENT p (#PCDATA|a|ul|b|i|em)*&gt;</code></p>
3120
Daniel Veillard69839ba2006-06-06 13:27:03 +00003121<p><code>p </code>can contain text or <code>a</code>,
3122<code>ul</code>,<code>b</code>, <code>i </code>or <code>em</code>elements in
3123no particularorder.</p>
Daniel Veillardb8cfbd12001-10-25 10:53:28 +00003124
3125<h4><a name="Declaring1">Declaring attributes</a>:</h4>
3126
Daniel Veillard0b28e882002-07-24 23:47:05 +00003127<p>Again the attributes declaration includes their content definition:</p>
Daniel Veillardb8cfbd12001-10-25 10:53:28 +00003128
3129<p><code>&lt;!ATTLIST termdef name CDATA #IMPLIED&gt;</code></p>
3130
Daniel Veillard69839ba2006-06-06 13:27:03 +00003131<p>means that the element <code>termdef</code>can have a
3132<code>name</code>attribute containing text (<code>CDATA</code>) and which is
3133optional(<code>#IMPLIED</code>). The attribute value can also be defined
3134within aset:</p>
Daniel Veillardb8cfbd12001-10-25 10:53:28 +00003135
Daniel Veillard69839ba2006-06-06 13:27:03 +00003136<p><code>&lt;!ATTLIST list type
3137(bullets|ordered|glossary)"ordered"&gt;</code></p>
Daniel Veillardb8cfbd12001-10-25 10:53:28 +00003138
Daniel Veillard69839ba2006-06-06 13:27:03 +00003139<p>means <code>list</code>element have a <code>type</code>attribute with
31403allowed values "bullets", "ordered" or "glossary" and which default
3141to"ordered" if the attribute is not explicitly specified.</p>
Daniel Veillardb8cfbd12001-10-25 10:53:28 +00003142
Daniel Veillard69839ba2006-06-06 13:27:03 +00003143<p>The content type of an attribute can be text
3144(<code>CDATA</code>),anchor/reference/references(<code>ID</code>/<code>IDREF</code>/<code>IDREFS</code>),
3145entity(ies)(<code>ENTITY</code>/<code>ENTITIES</code>) or
3146name(s)(<code>NMTOKEN</code>/<code>NMTOKENS</code>). The following defines
3147that a<code>chapter</code>element can have an optional
3148<code>id</code>attributeof type <code>ID</code>, usable for reference from
3149attribute of typeIDREF:</p>
Daniel Veillardb8cfbd12001-10-25 10:53:28 +00003150
3151<p><code>&lt;!ATTLIST chapter id ID #IMPLIED&gt;</code></p>
3152
Daniel Veillard69839ba2006-06-06 13:27:03 +00003153<p>The last value of an attribute definition can be
3154<code>#REQUIRED</code>meaning that the attribute has to be given,
3155<code>#IMPLIED</code>meaning that it is optional, or the default value
3156(possibly prefixed by<code>#FIXED</code>if it is the only allowed).</p>
Daniel Veillardb8cfbd12001-10-25 10:53:28 +00003157
3158<p>Notes:</p>
3159<ul>
Daniel Veillard69839ba2006-06-06 13:27:03 +00003160 <li>Usually the attributes pertaining to a given element are declared in
3161 asingle expression, but it is just a convention adopted by a lot of
3162 DTDwriters:
Daniel Veillardb8cfbd12001-10-25 10:53:28 +00003163 <pre>&lt;!ATTLIST termdef
3164 id ID #REQUIRED
3165 name CDATA #IMPLIED&gt;</pre>
Daniel Veillard69839ba2006-06-06 13:27:03 +00003166 <p>The previous construct defines both
3167 <code>id</code>and<code>name</code>attributes for the element
3168 <code>termdef</code>.</p>
Daniel Veillardb8cfbd12001-10-25 10:53:28 +00003169 </li>
3170</ul>
3171
3172<h3><a name="Some1">Some examples</a></h3>
3173
Daniel Veillard69839ba2006-06-06 13:27:03 +00003174<p>The directory <code>test/valid/dtds/</code>in the libxml2
3175distributioncontains some complex DTD examples. The example in the
3176file<code>test/valid/dia.xml</code>shows an XML file where the simple DTD
3177isdirectly included within the document.</p>
Daniel Veillardb8cfbd12001-10-25 10:53:28 +00003178
3179<h3><a name="validate1">How to validate</a></h3>
3180
Daniel Veillard69839ba2006-06-06 13:27:03 +00003181<p>The simplest way is to use the xmllint program included with libxml.
3182The<code>--valid</code>option turns-on validation of the files given as
3183input.For example the following validates a copy of the first revision of the
3184XML1.0 specification:</p>
Daniel Veillardb8cfbd12001-10-25 10:53:28 +00003185
3186<p><code>xmllint --valid --noout test/valid/REC-xml-19980210.xml</code></p>
3187
Daniel Veillard0b28e882002-07-24 23:47:05 +00003188<p>the -- noout is used to disable output of the resulting tree.</p>
Daniel Veillardb8cfbd12001-10-25 10:53:28 +00003189
Daniel Veillard69839ba2006-06-06 13:27:03 +00003190<p>The <code>--dtdvalid dtd</code>allows validation of the document(s)against
3191a given DTD.</p>
Daniel Veillardb8cfbd12001-10-25 10:53:28 +00003192
Daniel Veillard8a469172003-06-12 16:05:07 +00003193<p>Libxml2 exports an API to handle DTDs and validation, check the <a
Daniel Veillard69839ba2006-06-06 13:27:03 +00003194href="http://xmlsoft.org/html/libxml-valid.html">associateddescription</a>.</p>
Daniel Veillardb8cfbd12001-10-25 10:53:28 +00003195
3196<h3><a name="Other1">Other resources</a></h3>
3197
Daniel Veillard69839ba2006-06-06 13:27:03 +00003198<p>DTDs are as old as SGML. So there may be a number of examples on-line,
3199Iwill just list one for now, others pointers welcome:</p>
Daniel Veillardb8cfbd12001-10-25 10:53:28 +00003200<ul>
3201 <li><a href="http://www.xml101.com:8081/dtd/">XML-101 DTD</a></li>
3202</ul>
3203
Daniel Veillard69839ba2006-06-06 13:27:03 +00003204<p>I suggest looking at the examples found under test/valid/dtd and any ofthe
3205large number of books available on XML. The dia example in test/validshould
3206be both simple and complete enough to allow you to build your own.</p>
Daniel Veillardb8cfbd12001-10-25 10:53:28 +00003207
3208<p></p>
3209
3210<h2><a name="Memory">Memory Management</a></h2>
3211
3212<p>Table of Content:</p>
3213<ol>
3214 <li><a href="#General3">General overview</a></li>
Daniel Veillard8a469172003-06-12 16:05:07 +00003215 <li><a href="#setting">Setting libxml2 set of memory routines</a></li>
Daniel Veillardb8cfbd12001-10-25 10:53:28 +00003216 <li><a href="#cleanup">Cleaning up after parsing</a></li>
3217 <li><a href="#Debugging">Debugging routines</a></li>
3218 <li><a href="#General4">General memory requirements</a></li>
3219</ol>
3220
3221<h3><a name="General3">General overview</a></h3>
3222
3223<p>The module <code><a
Daniel Veillard69839ba2006-06-06 13:27:03 +00003224href="http://xmlsoft.org/html/libxml-xmlmemory.html">xmlmemory.h</a></code>provides
3225the interfaces to the libxml2 memory system:</p>
Daniel Veillardb8cfbd12001-10-25 10:53:28 +00003226<ul>
Daniel Veillard69839ba2006-06-06 13:27:03 +00003227 <li>libxml2 does not use the libc memory allocator directly but
3228 xmlFree(),xmlMalloc() and xmlRealloc()</li>
3229 <li>those routines can be reallocated to a specific set of routine,
3230 bydefault the libc ones i.e. free(), malloc() and realloc()</li>
Daniel Veillardb8cfbd12001-10-25 10:53:28 +00003231 <li>the xmlmemory.c module includes a set of debugging routine</li>
3232</ul>
3233
Daniel Veillard8a469172003-06-12 16:05:07 +00003234<h3><a name="setting">Setting libxml2 set of memory routines</a></h3>
Daniel Veillardb8cfbd12001-10-25 10:53:28 +00003235
Daniel Veillard69839ba2006-06-06 13:27:03 +00003236<p>It is sometimes useful to not use the default memory allocator, either
3237fordebugging, analysis or to implement a specific behaviour on memory
3238management(like on embedded systems). Two function calls are available to do
3239so:</p>
Daniel Veillardb8cfbd12001-10-25 10:53:28 +00003240<ul>
Daniel Veillardb8cfbd12001-10-25 10:53:28 +00003241 <li><a
Daniel Veillard69839ba2006-06-06 13:27:03 +00003242 href="http://xmlsoft.org/html/libxml-xmlmemory.html">xmlMemGet()</a>which
3243 return the current set of functions in use by the parser</li>
3244 <li><a
3245 href="http://xmlsoft.org/html/libxml-xmlmemory.html">xmlMemSetup()</a>which
3246 allow to set up a new set of memory allocation functions</li>
Daniel Veillardb8cfbd12001-10-25 10:53:28 +00003247</ul>
3248
Daniel Veillard69839ba2006-06-06 13:27:03 +00003249<p>Of course a call to xmlMemSetup() should probably be done before
3250callingany other libxml2 routines (unless you are sure your allocations
3251routines arecompatibles).</p>
Daniel Veillardb8cfbd12001-10-25 10:53:28 +00003252
3253<h3><a name="cleanup">Cleaning up after parsing</a></h3>
3254
Daniel Veillard69839ba2006-06-06 13:27:03 +00003255<p>Libxml2 is not stateless, there is a few set of memory structures
3256needingallocation before the parser is fully functional (some encoding
3257structuresfor example). This also mean that once parsing is finished there is
3258a tinyamount of memory (a few hundred bytes) which can be recollected if you
3259don'treuse the parser immediately:</p>
Daniel Veillardb8cfbd12001-10-25 10:53:28 +00003260<ul>
Daniel Veillard69839ba2006-06-06 13:27:03 +00003261 <li><a
3262 href="http://xmlsoft.org/html/libxml-parser.html">xmlCleanupParser()</a>is
3263 a centralized routine to free the parsing states. Note that itwon't
3264 deallocate any produced tree if any (use the xmlFreeDoc() andrelated
3265 routines for this).</li>
3266 <li><a
3267 href="http://xmlsoft.org/html/libxml-parser.html">xmlInitParser()</a>is
3268 the dual routine allowing to preallocate the parsing statewhich can be
3269 useful for example to avoid initialization reentrancyproblems when using
3270 libxml2 in multithreaded applications</li>
Daniel Veillardb8cfbd12001-10-25 10:53:28 +00003271</ul>
3272
Daniel Veillard69839ba2006-06-06 13:27:03 +00003273<p>Generally xmlCleanupParser() is safe, if needed the state will be
3274rebuildat the next invocation of parser routines, but be careful of the
3275consequencesin multithreaded applications.</p>
Daniel Veillardb8cfbd12001-10-25 10:53:28 +00003276
3277<h3><a name="Debugging">Debugging routines</a></h3>
3278
Daniel Veillard69839ba2006-06-06 13:27:03 +00003279<p>When configured using --with-mem-debug flag (off by default), libxml2
3280usesa set of memory allocation debugging routines keeping track of all
3281allocatedblocks and the location in the code where the routine was called. A
3282couple ofother debugging routines allow to dump the memory allocated infos to
3283a fileor call a specific routine when a given block number is allocated:</p>
Daniel Veillardb8cfbd12001-10-25 10:53:28 +00003284<ul>
3285 <li><a
Daniel Veillard69839ba2006-06-06 13:27:03 +00003286 href="http://xmlsoft.org/html/libxml-xmlmemory.html">xmlMallocLoc()</a><a
3287 href="http://xmlsoft.org/html/libxml-xmlmemory.html">xmlReallocLoc()</a>and
Daniel Veillardaf43f632002-03-08 15:05:20 +00003288 <a
Daniel Veillard69839ba2006-06-06 13:27:03 +00003289 href="http://xmlsoft.org/html/libxml-xmlmemory.html">xmlMemStrdupLoc()</a>are
3290 the memory debugging replacement allocation routines</li>
3291 <li><a
3292 href="http://xmlsoft.org/html/libxml-xmlmemory.html">xmlMemoryDump()</a>dumps
3293 all the informations about the allocated memory block leftsin the
3294 <code>.memdump</code>file</li>
Daniel Veillardb8cfbd12001-10-25 10:53:28 +00003295</ul>
3296
Daniel Veillard69839ba2006-06-06 13:27:03 +00003297<p>When developing libxml2 memory debug is enabled, the tests programs
3298callxmlMemoryDump () and the "make test" regression tests will check for
3299anymemory leak during the full regression test sequence, this helps a
3300lotensuring that libxml2 does not leak memory and bullet proof
3301memoryallocations use (some libc implementations are known to be far too
3302permissiveresulting in major portability problems!).</p>
Daniel Veillardb8cfbd12001-10-25 10:53:28 +00003303
Daniel Veillard69839ba2006-06-06 13:27:03 +00003304<p>If the .memdump reports a leak, it displays the allocation function
3305andalso tries to give some informations about the content and structure of
3306theallocated blocks left. This is sufficient in most cases to find the
3307culprit,but not always. Assuming the allocation problem is reproducible, it
3308ispossible to find more easily:</p>
Daniel Veillardb8cfbd12001-10-25 10:53:28 +00003309<ol>
3310 <li>write down the block number xxxx not allocated</li>
Daniel Veillard69839ba2006-06-06 13:27:03 +00003311 <li>export the environment variable XML_MEM_BREAKPOINT=xxxx , the
3312 easiestwhen using GDB is to simply give the command
Daniel Veillard75794822002-04-11 16:24:32 +00003313 <p><code>set environment XML_MEM_BREAKPOINT xxxx</code></p>
3314 <p>before running the program.</p>
3315 </li>
Daniel Veillard69839ba2006-06-06 13:27:03 +00003316 <li>run the program under a debugger and set a breakpoint
3317 onxmlMallocBreakpoint() a specific function called when this precise
3318 blockis allocated</li>
3319 <li>when the breakpoint is reached you can then do a fine analysis of
3320 theallocation an step to see the condition resulting in the
3321 missingdeallocation.</li>
Daniel Veillardb8cfbd12001-10-25 10:53:28 +00003322</ol>
3323
Daniel Veillard69839ba2006-06-06 13:27:03 +00003324<p>I used to use a commercial tool to debug libxml2 memory problems but
3325afternoticing that it was not detecting memory leaks that simple mechanism
3326wasused and proved extremely efficient until now. Lately I have also used <a
3327href="http://developer.kde.org/~sewardj/">valgrind</a>with quite somesuccess,
3328it is tied to the i386 architecture since it works by emulating theprocessor
3329and instruction set, it is slow but extremely efficient, i.e. itspot memory
3330usage errors in a very precise way.</p>
Daniel Veillardb8cfbd12001-10-25 10:53:28 +00003331
3332<h3><a name="General4">General memory requirements</a></h3>
3333
Daniel Veillard69839ba2006-06-06 13:27:03 +00003334<p>How much libxml2 memory require ? It's hard to tell in average it
3335dependsof a number of things:</p>
Daniel Veillardb8cfbd12001-10-25 10:53:28 +00003336<ul>
Daniel Veillard69839ba2006-06-06 13:27:03 +00003337 <li>the parser itself should work in a fixed amount of memory, except
3338 forinformation maintained about the stacks of names and entities
3339 locations.The I/O and encoding handlers will probably account for a few
3340 KBytes.This is true for both the XML and HTML parser (though the HTML
3341 parserneed more state).</li>
3342 <li>If you are generating the DOM tree then memory requirements will
3343 grownearly linear with the size of the data. In general for a
3344 balancedtextual document the internal memory requirement is about 4 times
3345 thesize of the UTF8 serialization of this document (example the
3346 XML-1.0recommendation is a bit more of 150KBytes and takes 650KBytes of
3347 mainmemory when parsed). Validation will add a amount of memory required
3348 formaintaining the external Dtd state which should be linear with
3349 thecomplexity of the content model defined by the Dtd</li>
3350 <li>If you need to work with fixed memory requirements or don't need
3351 thefull DOM tree then using the <a
3352 href="xmlreader.html">xmlReaderinterface</a>is probably the best way to
3353 proceed, it still allows tovalidate or operate on subset of the tree if
3354 needed.</li>
3355 <li>If you don't care about the advanced features of libxml2
3356 likevalidation, DOM, XPath or XPointer, don't use entities, need to work
3357 withfixed memory requirements, and try to get the fastest parsing
3358 possiblethen the SAX interface should be used, but it has known
3359 restrictions.</li>
Daniel Veillardb8cfbd12001-10-25 10:53:28 +00003360</ul>
3361
3362<p></p>
3363
3364<h2><a name="Encodings">Encodings support</a></h2>
3365
Daniel Veillard69839ba2006-06-06 13:27:03 +00003366<p>If you are not really familiar with Internationalization (usual shortcutis
3367I18N) , Unicode, characters and glyphs, I suggest you read a <a
3368href="http://www.tbray.org/ongoing/When/200x/2003/04/06/Unicode">presentation</a>by
3369Tim Bray on Unicode and why you should care about it.</p>
Daniel Veillard67952602006-01-05 15:29:44 +00003370
Daniel Veillard69839ba2006-06-06 13:27:03 +00003371<p>If you don't understand why <b>it does not make sense to have a
3372stringwithout knowing what encoding it uses</b>, then as Joel Spolsky said <a
3373href="http://www.joelonsoftware.com/articles/Unicode.html">please do notwrite
3374another line of code until you finish reading that article.</a>. It isa
3375prerequisite to understand this page, and avoid a lot of problems
3376withlibxml2, XML or text processing in general.</p>
Daniel Veillarde5d68de2005-03-10 15:03:40 +00003377
Daniel Veillardb8cfbd12001-10-25 10:53:28 +00003378<p>Table of Content:</p>
3379<ol>
Daniel Veillard69839ba2006-06-06 13:27:03 +00003380 <li><a href="encoding.html#What">What does internationalization supportmean
3381 ?</a></li>
3382 <li><a href="encoding.html#internal">The internal encoding, how
3383 andwhy</a></li>
Daniel Veillardb8cfbd12001-10-25 10:53:28 +00003384 <li><a href="encoding.html#implemente">How is it implemented ?</a></li>
3385 <li><a href="encoding.html#Default">Default supported encodings</a></li>
Daniel Veillard69839ba2006-06-06 13:27:03 +00003386 <li><a href="encoding.html#extend">How to extend the
3387 existingsupport</a></li>
Daniel Veillardb8cfbd12001-10-25 10:53:28 +00003388</ol>
3389
3390<h3><a name="What">What does internationalization support mean ?</a></h3>
3391
Daniel Veillard69839ba2006-06-06 13:27:03 +00003392<p>XML was designed from the start to allow the support of any character
3393setby using Unicode. Any conformant XML parser has to support the UTF-8
3394andUTF-16 default encodings which can both express the full unicode ranges.
3395UTF8is a variable length encoding whose greatest points are to reuse the
3396sameencoding for ASCII and to save space for Western encodings, but it is a
3397bitmore complex to handle in practice. UTF-16 use 2 bytes per character
3398(andsometimes combines two pairs), it makes implementation easier, but looks
3399abit overkill for Western languages encoding. Moreover the XML
3400specificationallows the document to be encoded in other encodings at the
3401condition thatthey are clearly labeled as such. For example the following is
3402a wellformedXML document encoded in ISO-8859-1 and using accentuated letters
3403that weFrench like for both markup and content:</p>
Daniel Veillardb8cfbd12001-10-25 10:53:28 +00003404<pre>&lt;?xml version="1.0" encoding="ISO-8859-1"?&gt;
3405&lt;très&gt;là&lt;/très&gt;</pre>
3406
Daniel Veillard8a469172003-06-12 16:05:07 +00003407<p>Having internationalization support in libxml2 means the following:</p>
Daniel Veillardb8cfbd12001-10-25 10:53:28 +00003408<ul>
3409 <li>the document is properly parsed</li>
3410 <li>informations about it's encoding are saved</li>
3411 <li>it can be modified</li>
3412 <li>it can be saved in its original encoding</li>
Daniel Veillard69839ba2006-06-06 13:27:03 +00003413 <li>it can also be saved in another encoding supported by libxml2
3414 (forexample straight UTF8 or even an ASCII form)</li>
Daniel Veillardb8cfbd12001-10-25 10:53:28 +00003415</ul>
3416
Daniel Veillard69839ba2006-06-06 13:27:03 +00003417<p>Another very important point is that the whole libxml2 API, with
3418theexception of a few routines to read with a specific encoding or save to
3419aspecific encoding, is completely agnostic about the original encoding of
3420thedocument.</p>
Daniel Veillardb8cfbd12001-10-25 10:53:28 +00003421
Daniel Veillard69839ba2006-06-06 13:27:03 +00003422<p>It should be noted too that the HTML parser embedded in libxml2 now
3423obeythe same rules too, the following document will be (as of 2.2.2) handled
3424inan internationalized fashion by libxml2 too:</p>
Daniel Veillardb8cfbd12001-10-25 10:53:28 +00003425<pre>&lt;!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"
3426 "http://www.w3.org/TR/REC-html40/loose.dtd"&gt;
3427&lt;html lang="fr"&gt;
3428&lt;head&gt;
3429 &lt;META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=ISO-8859-1"&gt;
3430&lt;/head&gt;
3431&lt;body&gt;
3432&lt;p&gt;W3C crée des standards pour le Web.&lt;/body&gt;
3433&lt;/html&gt;</pre>
3434
3435<h3><a name="internal">The internal encoding, how and why</a></h3>
3436
Daniel Veillard69839ba2006-06-06 13:27:03 +00003437<p>One of the core decisions was to force all documents to be converted to
3438adefault internal encoding, and that encoding to be UTF-8, here are
3439therationales for those choices:</p>
Daniel Veillardb8cfbd12001-10-25 10:53:28 +00003440<ul>
Daniel Veillard69839ba2006-06-06 13:27:03 +00003441 <li>keeping the native encoding in the internal form would force the
3442 libxmlusers (or the code associated) to be fully aware of the encoding of
3443 theoriginal document, for examples when adding a text node to a
3444 document,the content would have to be provided in the document encoding,
3445 i.e. theclient code would have to check it before hand, make sure it's
3446 conformantto the encoding, etc ... Very hard in practice, though in some
3447 specificcases this may make sense.</li>
3448 <li>the second decision was which encoding. From the XML spec only UTF8
3449 andUTF16 really makes sense as being the two only encodings for which
3450 thereis mandatory support. UCS-4 (32 bits fixed size encoding) could
3451 beconsidered an intelligent choice too since it's a direct Unicode
3452 mappingsupport. I selected UTF-8 on the basis of efficiency and
3453 compatibilitywith surrounding software:
Daniel Veillardb8cfbd12001-10-25 10:53:28 +00003454 <ul>
Daniel Veillard69839ba2006-06-06 13:27:03 +00003455 <li>UTF-8 while a bit more complex to convert from/to (i.e.
3456 slightlymore costly to import and export CPU wise) is also far more
3457 compactthan UTF-16 (and UCS-4) for a majority of the documents I see
3458 it usedfor right now (RPM RDF catalogs, advogato data, various
3459 configurationfile formats, etc.) and the key point for today's
3460 computerarchitecture is efficient uses of caches. If one nearly
3461 double thememory requirement to store the same amount of data, this
3462 will trashcaches (main memory/external caches/internal caches) and my
3463 take isthat this harms the system far more than the CPU requirements
3464 neededfor the conversion to UTF-8</li>
3465 <li>Most of libxml2 version 1 users were using it with straight
3466 ASCIImost of the time, doing the conversion with an internal
3467 encodingrequiring all their code to be rewritten was a serious
3468 show-stopperfor using UTF-16 or UCS-4.</li>
3469 <li>UTF-8 is being used as the de-facto internal encoding standard
3470 forrelated code like the <a
3471 href="http://www.pango.org/">pango</a>upcoming Gnome text widget, and
3472 a lot of Unix code (yet another placewhere Unix programmer base takes
3473 a different approach from Microsoft- they are using UTF-16)</li>
Daniel Veillardb8cfbd12001-10-25 10:53:28 +00003474 </ul>
3475 </li>
3476</ul>
3477
Daniel Veillard8a469172003-06-12 16:05:07 +00003478<p>What does this mean in practice for the libxml2 user:</p>
Daniel Veillardb8cfbd12001-10-25 10:53:28 +00003479<ul>
Daniel Veillard69839ba2006-06-06 13:27:03 +00003480 <li>xmlChar, the libxml2 data type is a byte, those bytes must be
3481 assembledas UTF-8 valid strings. The proper way to terminate an xmlChar *
3482 stringis simply to append 0 byte, as usual.</li>
3483 <li>One just need to make sure that when using chars outside the ASCII
3484 set,the values has been properly converted to UTF-8</li>
Daniel Veillardb8cfbd12001-10-25 10:53:28 +00003485</ul>
3486
3487<h3><a name="implemente">How is it implemented ?</a></h3>
3488
Daniel Veillard69839ba2006-06-06 13:27:03 +00003489<p>Let's describe how all this works within libxml, basically the
3490I18N(internationalization) support get triggered only during I/O operation,
3491i.e.when reading a document or saving one. Let's look first at the
3492readingsequence:</p>
Daniel Veillardb8cfbd12001-10-25 10:53:28 +00003493<ol>
Daniel Veillard69839ba2006-06-06 13:27:03 +00003494 <li>when a document is processed, we usually don't know the encoding,
3495 asimple heuristic allows to detect UTF-16 and UCS-4 from encodings
3496 wherethe ASCII range (0-0x7F) maps with ASCII</li>
3497 <li>the xml declaration if available is parsed, including the
3498 encodingdeclaration. At that point, if the autodetected encoding is
3499 differentfrom the one declared a call to xmlSwitchEncoding() is
3500 issued.</li>
3501 <li>If there is no encoding declaration, then the input has to be in
3502 eitherUTF-8 or UTF-16, if it is not then at some point when processing
3503 theinput, the converter/checker of UTF-8 form will raise an encoding
3504 error.You may end-up with a garbled document, or no document at all !
3505 Example:
Daniel Veillardb8cfbd12001-10-25 10:53:28 +00003506 <pre>~/XML -&gt; ./xmllint err.xml
3507err.xml:1: error: Input is not proper UTF-8, indicate encoding !
3508&lt;très&gt;là&lt;/très&gt;
3509 ^
3510err.xml:1: error: Bytes: 0xE8 0x73 0x3E 0x6C
3511&lt;très&gt;là&lt;/très&gt;
3512 ^</pre>
3513 </li>
Daniel Veillard69839ba2006-06-06 13:27:03 +00003514 <li>xmlSwitchEncoding() does an encoding name lookup, canonicalize it,
3515 andthen search the default registered encoding converters for that
3516 encoding.If it's not within the default set and iconv() support has been
3517 compiledit, it will ask iconv for such an encoder. If this fails then the
3518 parserwill report an error and stops processing:
Daniel Veillardb8cfbd12001-10-25 10:53:28 +00003519 <pre>~/XML -&gt; ./xmllint err2.xml
3520err2.xml:1: error: Unsupported encoding UnsupportedEnc
3521&lt;?xml version="1.0" encoding="UnsupportedEnc"?&gt;
3522 ^</pre>
3523 </li>
Daniel Veillard69839ba2006-06-06 13:27:03 +00003524 <li>From that point the encoder processes progressively the input (it
3525 isplugged as a front-end to the I/O module) for that entity. It
3526 capturesand converts on-the-fly the document to be parsed to UTF-8. The
3527 parseritself just does UTF-8 checking of this input and process
3528 ittransparently. The only difference is that the encoding information
3529 hasbeen added to the parsing context (more precisely to the
3530 inputcorresponding to this entity).</li>
3531 <li>The result (when using DOM) is an internal form completely in UTF-8with
3532 just an encoding information on the document node.</li>
Daniel Veillardb8cfbd12001-10-25 10:53:28 +00003533</ol>
3534
Daniel Veillard69839ba2006-06-06 13:27:03 +00003535<p>Ok then what happens when saving the document (assuming youcollected/built
3536an xmlDoc DOM like structure) ? It depends on the functioncalled,
3537xmlSaveFile() will just try to save in the original encoding,
3538whilexmlSaveFileTo() and xmlSaveFileEnc() can optionally save to a
3539givenencoding:</p>
Daniel Veillardb8cfbd12001-10-25 10:53:28 +00003540<ol>
Daniel Veillard69839ba2006-06-06 13:27:03 +00003541 <li>if no encoding is given, libxml2 will look for an encoding
3542 valueassociated to the document and if it exists will try to save to
3543 thatencoding,
Daniel Veillardb8cfbd12001-10-25 10:53:28 +00003544 <p>otherwise everything is written in the internal form, i.e. UTF-8</p>
3545 </li>
Daniel Veillard69839ba2006-06-06 13:27:03 +00003546 <li>so if an encoding was specified, either at the API level or on
3547 thedocument, libxml2 will again canonicalize the encoding name, lookup
3548 for aconverter in the registered set or through iconv. If not found
3549 thefunction will return an error code</li>
3550 <li>the converter is placed before the I/O buffer layer, as another kind
3551 ofbuffer, then libxml2 will simply push the UTF-8 serialization to
3552 throughthat buffer, which will then progressively be converted and pushed
3553 ontothe I/O layer.</li>
3554 <li>It is possible that the converter code fails on some input, for
3555 exampletrying to push an UTF-8 encoded Chinese character through the
3556 UTF-8 toISO-8859-1 converter won't work. Since the encoders are
3557 progressive theywill just report the error and the number of bytes
3558 converted, at thatpoint libxml2 will decode the offending character,
3559 remove it from thebuffer and replace it with the associated charRef
3560 encoding &amp;#123; andresume the conversion. This guarantees that any
3561 document will be savedwithout losses (except for markup names where this
3562 is not legal, this isa problem in the current version, in practice avoid
3563 using non-asciicharacters for tag or attribute names). A special "ascii"
3564 encoding nameis used to save documents to a pure ascii form can be used
3565 whenportability is really crucial</li>
Daniel Veillardb8cfbd12001-10-25 10:53:28 +00003566</ol>
3567
Daniel Veillardabfca612004-01-07 23:38:02 +00003568<p>Here are a few examples based on the same test document:</p>
Daniel Veillardb8cfbd12001-10-25 10:53:28 +00003569<pre>~/XML -&gt; ./xmllint isolat1
3570&lt;?xml version="1.0" encoding="ISO-8859-1"?&gt;
3571&lt;très&gt;là&lt;/très&gt;
3572~/XML -&gt; ./xmllint --encode UTF-8 isolat1
3573&lt;?xml version="1.0" encoding="UTF-8"?&gt;
Daniel Veillard69839ba2006-06-06 13:27:03 +00003574&lt;très&gt;là  &lt;/très&gt;
Daniel Veillardb8cfbd12001-10-25 10:53:28 +00003575~/XML -&gt; </pre>
3576
Daniel Veillard69839ba2006-06-06 13:27:03 +00003577<p>The same processing is applied (and reuse most of the code) for HTML
3578I18Nprocessing. Looking up and modifying the content encoding is a bit
3579moredifficult since it is located in a &lt;meta&gt; tag under the
3580&lt;head&gt;,so a couple of functions htmlGetMetaEncoding() and
3581htmlSetMetaEncoding() havebeen provided. The parser also attempts to switch
3582encoding on the fly whendetecting such a tag on input. Except for that the
3583processing is the same(and again reuses the same code).</p>
Daniel Veillardb8cfbd12001-10-25 10:53:28 +00003584
3585<h3><a name="Default">Default supported encodings</a></h3>
3586
Daniel Veillard69839ba2006-06-06 13:27:03 +00003587<p>libxml2 has a set of default converters for the following
3588encodings(located in encoding.c):</p>
Daniel Veillardb8cfbd12001-10-25 10:53:28 +00003589<ol>
3590 <li>UTF-8 is supported by default (null handlers)</li>
3591 <li>UTF-16, both little and big endian</li>
3592 <li>ISO-Latin-1 (ISO-8859-1) covering most western languages</li>
3593 <li>ASCII, useful mostly for saving</li>
Daniel Veillard69839ba2006-06-06 13:27:03 +00003594 <li>HTML, a specific handler for the conversion of UTF-8 to ASCII with
3595 HTMLpredefined entities like &amp;copy; for the Copyright sign.</li>
Daniel Veillardb8cfbd12001-10-25 10:53:28 +00003596</ol>
3597
Daniel Veillard69839ba2006-06-06 13:27:03 +00003598<p>More over when compiled on an Unix platform with iconv support the fullset
3599of encodings supported by iconv can be instantly be used by libxml. On alinux
3600machine with glibc-2.1 the list of supported encodings and aliases fill3 full
3601pages, and include UCS-4, the full set of ISO-Latin encodings, and thevarious
3602Japanese ones.</p>
Daniel Veillard67952602006-01-05 15:29:44 +00003603
Daniel Veillard69839ba2006-06-06 13:27:03 +00003604<p>To convert from the UTF-8 values returned from the API to another
3605encodingthen it is possible to use the function provided from <a
3606href="html/libxml-encoding.html">the encoding module</a>like <a
3607href="html/libxml-encoding.html#UTF8Toisolat1">UTF8Toisolat1</a>, or use
3608thePOSIX <a
3609href="http://www.opengroup.org/onlinepubs/009695399/functions/iconv.html">iconv()</a>API
3610directly.</p>
Daniel Veillardb8cfbd12001-10-25 10:53:28 +00003611
3612<h4>Encoding aliases</h4>
3613
Daniel Veillard69839ba2006-06-06 13:27:03 +00003614<p>From 2.2.3, libxml2 has support to register encoding names aliases.
3615Thegoal is to be able to parse document whose encoding is supported but
3616wherethe name differs (for example from the default set of names accepted
3617byiconv). The following functions allow to register and handle new aliases
3618forexisting encodings. Once registered libxml2 will automatically lookup
3619thealiases when handling a document:</p>
Daniel Veillardb8cfbd12001-10-25 10:53:28 +00003620<ul>
3621 <li>int xmlAddEncodingAlias(const char *name, const char *alias);</li>
3622 <li>int xmlDelEncodingAlias(const char *alias);</li>
3623 <li>const char * xmlGetEncodingAlias(const char *alias);</li>
3624 <li>void xmlCleanupEncodingAliases(void);</li>
3625</ul>
3626
3627<h3><a name="extend">How to extend the existing support</a></h3>
3628
Daniel Veillard69839ba2006-06-06 13:27:03 +00003629<p>Well adding support for new encoding, or overriding one of the
3630encoders(assuming it is buggy) should not be hard, just write input and
3631outputconversion routines to/from UTF-8, and register them
3632usingxmlNewCharEncodingHandler(name, xxxToUTF8, UTF8Toxxx), and they will
3633becalled automatically if the parser(s) encounter such an encoding
3634name(register it uppercase, this will help). The description of the
3635encoders,their arguments and expected return values are described in the
3636encoding.hheader.</p>
Daniel Veillardb8cfbd12001-10-25 10:53:28 +00003637
Daniel Veillardb8cfbd12001-10-25 10:53:28 +00003638<h2><a name="IO">I/O Interfaces</a></h2>
3639
3640<p>Table of Content:</p>
3641<ol>
3642 <li><a href="#General1">General overview</a></li>
3643 <li><a href="#basic">The basic buffer type</a></li>
3644 <li><a href="#Input">Input I/O handlers</a></li>
3645 <li><a href="#Output">Output I/O handlers</a></li>
3646 <li><a href="#entities">The entities loader</a></li>
3647 <li><a href="#Example2">Example of customized I/O</a></li>
3648</ol>
3649
3650<h3><a name="General1">General overview</a></h3>
3651
3652<p>The module <code><a
Daniel Veillard69839ba2006-06-06 13:27:03 +00003653href="http://xmlsoft.org/html/libxml-xmlio.html">xmlIO.h</a></code>providesthe
3654interfaces to the libxml2 I/O system. This consists of 4 main parts:</p>
Daniel Veillardb8cfbd12001-10-25 10:53:28 +00003655<ul>
Daniel Veillard69839ba2006-06-06 13:27:03 +00003656 <li>Entities loader, this is a routine which tries to fetch the
3657 entities(files) based on their PUBLIC and SYSTEM identifiers. The default
3658 loaderdon't look at the public identifier since libxml2 do not maintain
3659 acatalog. You can redefine you own entity loader by
3660 using<code>xmlGetExternalEntityLoader()</code>and<code>xmlSetExternalEntityLoader()</code>.
3661 <a href="#entities">Check theexample</a>.</li>
3662 <li>Input I/O buffers which are a commodity structure used by the
3663 parser(s)input layer to handle fetching the informations to feed the
3664 parser. Thisprovides buffering and is also a placeholder where the
3665 encodingconverters to UTF8 are piggy-backed.</li>
3666 <li>Output I/O buffers are similar to the Input ones and fulfill
3667 similartask but when generating a serialization from a tree.</li>
3668 <li>A mechanism to register sets of I/O callbacks and associate them
3669 withspecific naming schemes like the protocol part of the URIs.
3670 <p>This affect the default I/O operations and allows to use specific
3671 I/Ohandlers for certain names.</p>
Daniel Veillardb8cfbd12001-10-25 10:53:28 +00003672 </li>
3673</ul>
3674
Daniel Veillard69839ba2006-06-06 13:27:03 +00003675<p>The general mechanism used when loading http://rpmfind.net/xml.html
3676forexample in the HTML parser is the following:</p>
Daniel Veillardb8cfbd12001-10-25 10:53:28 +00003677<ol>
Daniel Veillard69839ba2006-06-06 13:27:03 +00003678 <li>The default entity loader calls
3679 <code>xmlNewInputFromFile()</code>withthe parsing context and the URI
3680 string.</li>
3681 <li>the URI string is checked against the existing registered handlersusing
3682 their match() callback function, if the HTTP module was compiledin, it is
3683 registered and its match() function will succeeds</li>
3684 <li>the open() function of the handler is called and if successful
3685 willreturn an I/O Input buffer</li>
3686 <li>the parser will the start reading from this buffer and
3687 progressivelyfetch information from the resource, calling the read()
3688 function of thehandler until the resource is exhausted</li>
3689 <li>if an encoding change is detected it will be installed on the
3690 inputbuffer, providing buffering and efficient use of the
3691 conversionroutines</li>
3692 <li>once the parser has finished, the close() function of the handler
3693 iscalled once and the Input buffer and associated resources
3694 aredeallocated.</li>
Daniel Veillardb8cfbd12001-10-25 10:53:28 +00003695</ol>
3696
Daniel Veillard69839ba2006-06-06 13:27:03 +00003697<p>The user defined callbacks are checked first to allow overriding of
3698thedefault libxml2 I/O routines.</p>
Daniel Veillardb8cfbd12001-10-25 10:53:28 +00003699
3700<h3><a name="basic">The basic buffer type</a></h3>
3701
Daniel Veillard69839ba2006-06-06 13:27:03 +00003702<p>All the buffer manipulation handling is done using
3703the<code>xmlBuffer</code>type define in <code><a
3704href="http://xmlsoft.org/html/libxml-tree.html">tree.h</a></code>which is
3705aresizable memory buffer. The buffer allocation strategy can be selected to
3706beeither best-fit or use an exponential doubling one (CPU vs. memory
3707usetrade-off). The values are
3708<code>XML_BUFFER_ALLOC_EXACT</code>and<code>XML_BUFFER_ALLOC_DOUBLEIT</code>,
3709and can be set individually or on asystem wide basis using
3710<code>xmlBufferSetAllocationScheme()</code>. A numberof functions allows to
3711manipulate buffers with names starting with
3712the<code>xmlBuffer...</code>prefix.</p>
Daniel Veillardb8cfbd12001-10-25 10:53:28 +00003713
3714<h3><a name="Input">Input I/O handlers</a></h3>
3715
Daniel Veillard69839ba2006-06-06 13:27:03 +00003716<p>An Input I/O handler is a simple
3717structure<code>xmlParserInputBuffer</code>containing a context associated to
3718theresource (file descriptor, or pointer to a protocol handler), the read()
3719andclose() callbacks to use and an xmlBuffer. And extra xmlBuffer and a
3720charsetencoding handler are also present to support charset conversion
3721whenneeded.</p>
Daniel Veillardb8cfbd12001-10-25 10:53:28 +00003722
3723<h3><a name="Output">Output I/O handlers</a></h3>
3724
Daniel Veillard69839ba2006-06-06 13:27:03 +00003725<p>An Output handler <code>xmlOutputBuffer</code>is completely similar to
3726anInput one except the callbacks are write() and close().</p>
Daniel Veillardb8cfbd12001-10-25 10:53:28 +00003727
3728<h3><a name="entities">The entities loader</a></h3>
3729
Daniel Veillard69839ba2006-06-06 13:27:03 +00003730<p>The entity loader resolves requests for new entities and create inputs
3731forthe parser. Creating an input from a filename or an URI string is
3732donethrough the xmlNewInputFromFile() routine. The default entity loader do
3733nothandle the PUBLIC identifier associated with an entity (if any). So it
3734justcalls xmlNewInputFromFile() with the SYSTEM identifier (which is
3735mandatory inXML).</p>
Daniel Veillardb8cfbd12001-10-25 10:53:28 +00003736
Daniel Veillard69839ba2006-06-06 13:27:03 +00003737<p>If you want to hook up a catalog mechanism then you simply need tooverride
3738the default entity loader, here is an example:</p>
Daniel Veillardb8cfbd12001-10-25 10:53:28 +00003739<pre>#include &lt;libxml/xmlIO.h&gt;
3740
3741xmlExternalEntityLoader defaultLoader = NULL;
3742
3743xmlParserInputPtr
3744xmlMyExternalEntityLoader(const char *URL, const char *ID,
3745 xmlParserCtxtPtr ctxt) {
3746 xmlParserInputPtr ret;
3747 const char *fileID = NULL;
3748 /* lookup for the fileID depending on ID */
3749
3750 ret = xmlNewInputFromFile(ctxt, fileID);
3751 if (ret != NULL)
3752 return(ret);
3753 if (defaultLoader != NULL)
3754 ret = defaultLoader(URL, ID, ctxt);
3755 return(ret);
3756}
3757
3758int main(..) {
3759 ...
3760
3761 /*
3762 * Install our own entity loader
3763 */
3764 defaultLoader = xmlGetExternalEntityLoader();
3765 xmlSetExternalEntityLoader(xmlMyExternalEntityLoader);
3766
3767 ...
3768}</pre>
3769
3770<h3><a name="Example2">Example of customized I/O</a></h3>
3771
Daniel Veillard69839ba2006-06-06 13:27:03 +00003772<p>This example come from <a
3773href="http://xmlsoft.org/messages/0708.html">areal use case</a>,
3774xmlDocDump() closes the FILE * passed by the applicationand this was a
3775problem. The <a href="http://xmlsoft.org/messages/0711.html">solution</a>was
3776to redefine anew output handler with the closing call deactivated:</p>
Daniel Veillardb8cfbd12001-10-25 10:53:28 +00003777<ol>
Daniel Veillard69839ba2006-06-06 13:27:03 +00003778 <li>First define a new I/O output allocator where the output don't closethe
3779 file:
Daniel Veillardb8cfbd12001-10-25 10:53:28 +00003780 <pre>xmlOutputBufferPtr
3781xmlOutputBufferCreateOwn(FILE *file, xmlCharEncodingHandlerPtr encoder) {
Daniel Veillard69839ba2006-06-06 13:27:03 +00003782    xmlOutputBufferPtr ret;
3783    
3784    if (xmlOutputCallbackInitialized == 0)
3785        xmlRegisterDefaultOutputCallbacks();
Daniel Veillardb8cfbd12001-10-25 10:53:28 +00003786
Daniel Veillard69839ba2006-06-06 13:27:03 +00003787    if (file == NULL) return(NULL);
3788    ret = xmlAllocOutputBuffer(encoder);
3789    if (ret != NULL) {
3790        ret-&gt;context = file;
3791        ret-&gt;writecallback = xmlFileWrite;
3792        ret-&gt;closecallback = NULL; /* No close callback */
3793    }
3794    return(ret);
Daniel Veillardb8cfbd12001-10-25 10:53:28 +00003795} </pre>
3796 </li>
3797 <li>And then use it to save the document:
3798 <pre>FILE *f;
3799xmlOutputBufferPtr output;
3800xmlDocPtr doc;
3801int res;
3802
3803f = ...
3804doc = ....
3805
3806output = xmlOutputBufferCreateOwn(f, NULL);
3807res = xmlSaveFileTo(output, doc, NULL);
3808 </pre>
3809 </li>
3810</ol>
3811
3812<h2><a name="Catalog">Catalog support</a></h2>
3813
3814<p>Table of Content:</p>
3815<ol>
3816 <li><a href="General2">General overview</a></li>
3817 <li><a href="#definition">The definition</a></li>
3818 <li><a href="#Simple">Using catalogs</a></li>
3819 <li><a href="#Some">Some examples</a></li>
3820 <li><a href="#reference">How to tune catalog usage</a></li>
3821 <li><a href="#validate">How to debug catalog processing</a></li>
3822 <li><a href="#Declaring">How to create and maintain catalogs</a></li>
Daniel Veillard69839ba2006-06-06 13:27:03 +00003823 <li><a href="#implemento">The implementor corner quick review of
3824 theAPI</a></li>
Daniel Veillardb8cfbd12001-10-25 10:53:28 +00003825 <li><a href="#Other">Other resources</a></li>
3826</ol>
3827
3828<h3><a name="General2">General overview</a></h3>
3829
Daniel Veillard69839ba2006-06-06 13:27:03 +00003830<p>What is a catalog? Basically it's a lookup mechanism used when an entity(a
3831file or a remote resource) references another entity. The catalog lookupis
3832inserted between the moment the reference is recognized by the software(XML
3833parser, stylesheet processing, or even images referenced for inclusionin a
3834rendering) and the time where loading that resource is actuallystarted.</p>
Daniel Veillardb8cfbd12001-10-25 10:53:28 +00003835
3836<p>It is basically used for 3 things:</p>
3837<ul>
Daniel Veillard69839ba2006-06-06 13:27:03 +00003838 <li>mapping from "logical" names, the public identifiers and a moreconcrete
3839 name usable for download (and URI). For example it can associatethe
3840 logical name
Daniel Veillardb8cfbd12001-10-25 10:53:28 +00003841 <p>"-//OASIS//DTD DocBook XML V4.1.2//EN"</p>
Daniel Veillard69839ba2006-06-06 13:27:03 +00003842 <p>of the DocBook 4.1.2 XML DTD with the actual URL where it can
3843 bedownloaded</p>
Daniel Veillardb8cfbd12001-10-25 10:53:28 +00003844 <p>http://www.oasis-open.org/docbook/xml/4.1.2/docbookx.dtd</p>
3845 </li>
Daniel Veillard69839ba2006-06-06 13:27:03 +00003846 <li>remapping from a given URL to another one, like an HTTP
3847 indirectionsaying that
Daniel Veillardb8cfbd12001-10-25 10:53:28 +00003848 <p>"http://www.oasis-open.org/committes/tr.xsl"</p>
3849 <p>should really be looked at</p>
3850 <p>"http://www.oasis-open.org/committes/entity/stylesheets/base/tr.xsl"</p>
3851 </li>
Daniel Veillard69839ba2006-06-06 13:27:03 +00003852 <li>providing a local cache mechanism allowing to load the
3853 entitiesassociated to public identifiers or remote resources, this is a
3854 reallyimportant feature for any significant deployment of XML or SGML
3855 since itallows to avoid the aleas and delays associated to fetching
3856 remoteresources.</li>
Daniel Veillardb8cfbd12001-10-25 10:53:28 +00003857</ul>
3858
3859<h3><a name="definition">The definitions</a></h3>
3860
3861<p>Libxml, as of 2.4.3 implements 2 kind of catalogs:</p>
3862<ul>
Daniel Veillard69839ba2006-06-06 13:27:03 +00003863 <li>the older SGML catalogs, the official spec is SGML Open
3864 TechnicalResolution TR9401:1997, but is better understood by reading <a
3865 href="http://www.jclark.com/sp/catalog.htm">the SP Catalog
3866 page</a>fromJames Clark. This is relatively old and not the preferred
3867 mode ofoperation of libxml.</li>
3868 <li><a
3869 href="http://www.oasis-open.org/committees/entity/spec.html">XMLCatalogs</a>is
3870 far more flexible, more recent, uses an XML syntax andshould scale quite
3871 better. This is the default option of libxml.</li>
Daniel Veillardb8cfbd12001-10-25 10:53:28 +00003872</ul>
3873
3874<p></p>
3875
3876<h3><a name="Simple">Using catalog</a></h3>
3877
Daniel Veillard69839ba2006-06-06 13:27:03 +00003878<p>In a normal environment libxml2 will by default check the presence of
3879acatalog in /etc/xml/catalog, and assuming it has been correctly
3880populated,the processing is completely transparent to the document user. To
3881take aconcrete example, suppose you are authoring a DocBook document, this
3882onestarts with the following DOCTYPE definition:</p>
Daniel Veillardb8cfbd12001-10-25 10:53:28 +00003883<pre>&lt;?xml version='1.0'?&gt;
3884&lt;!DOCTYPE book PUBLIC "-//Norman Walsh//DTD DocBk XML V3.1.4//EN"
3885 "http://nwalsh.com/docbook/xml/3.1.4/db3xml.dtd"&gt;</pre>
3886
Daniel Veillard69839ba2006-06-06 13:27:03 +00003887<p>When validating the document with libxml, the catalog will beautomatically
3888consulted to lookup the public identifier "-//Norman Walsh//DTDDocBk XML
3889V3.1.4//EN" and the system
3890identifier"http://nwalsh.com/docbook/xml/3.1.4/db3xml.dtd", and if these
3891entities havebeen installed on your system and the catalogs actually point to
3892them, libxmlwill fetch them from the local disk.</p>
Daniel Veillardb8cfbd12001-10-25 10:53:28 +00003893
Daniel Veillard69839ba2006-06-06 13:27:03 +00003894<p style="font-size: 10pt"><strong>Note</strong>: Really don't use
3895thisDOCTYPE example it's a really old version, but is fine as an example.</p>
Daniel Veillardb8cfbd12001-10-25 10:53:28 +00003896
Daniel Veillard69839ba2006-06-06 13:27:03 +00003897<p>Libxml2 will check the catalog each time that it is requested to load
3898anentity, this includes DTD, external parsed entities, stylesheets, etc ...
3899Ifyour system is correctly configured all the authoring phase and
3900processingshould use only local files, even if your document stays portable
3901because ituses the canonical public and system ID, referencing the remote
3902document.</p>
Daniel Veillardb8cfbd12001-10-25 10:53:28 +00003903
3904<h3><a name="Some">Some examples:</a></h3>
3905
Daniel Veillard69839ba2006-06-06 13:27:03 +00003906<p>Here is a couple of fragments from XML Catalogs used in libxml2
3907earlyregression tests in <code>test/catalogs</code>:</p>
Daniel Veillardb8cfbd12001-10-25 10:53:28 +00003908<pre>&lt;?xml version="1.0"?&gt;
3909&lt;!DOCTYPE catalog PUBLIC
3910 "-//OASIS//DTD Entity Resolution XML Catalog V1.0//EN"
3911 "http://www.oasis-open.org/committees/entity/release/1.0/catalog.dtd"&gt;
3912&lt;catalog xmlns="urn:oasis:names:tc:entity:xmlns:xml:catalog"&gt;
3913 &lt;public publicId="-//OASIS//DTD DocBook XML V4.1.2//EN"
3914 uri="http://www.oasis-open.org/docbook/xml/4.1.2/docbookx.dtd"/&gt;
3915...</pre>
3916
Daniel Veillard69839ba2006-06-06 13:27:03 +00003917<p>This is the beginning of a catalog for DocBook 4.1.2, XML Catalogs
3918arewritten in XML, there is a specific namespace for catalog
3919elements"urn:oasis:names:tc:entity:xmlns:xml:catalog". The first entry in
3920thiscatalog is a <code>public</code>mapping it allows to associate a
3921PublicIdentifier with an URI.</p>
Daniel Veillardb8cfbd12001-10-25 10:53:28 +00003922<pre>...
3923 &lt;rewriteSystem systemIdStartString="http://www.oasis-open.org/docbook/"
3924 rewritePrefix="file:///usr/share/xml/docbook/"/&gt;
3925...</pre>
3926
Daniel Veillard69839ba2006-06-06 13:27:03 +00003927<p>A <code>rewriteSystem</code>is a very powerful instruction, it says
3928thatany URI starting with a given prefix should be looked at another
3929URIconstructed by replacing the prefix with an new one. In effect this acts
3930likea cache system for a full area of the Web. In practice it is extremely
3931usefulwith a file prefix if you have installed a copy of those resources on
3932yourlocal system.</p>
Daniel Veillardb8cfbd12001-10-25 10:53:28 +00003933<pre>...
3934&lt;delegatePublic publicIdStartString="-//OASIS//DTD XML Catalog //"
3935 catalog="file:///usr/share/xml/docbook.xml"/&gt;
3936&lt;delegatePublic publicIdStartString="-//OASIS//ENTITIES DocBook XML"
3937 catalog="file:///usr/share/xml/docbook.xml"/&gt;
3938&lt;delegatePublic publicIdStartString="-//OASIS//DTD DocBook XML"
3939 catalog="file:///usr/share/xml/docbook.xml"/&gt;
3940&lt;delegateSystem systemIdStartString="http://www.oasis-open.org/docbook/"
3941 catalog="file:///usr/share/xml/docbook.xml"/&gt;
3942&lt;delegateURI uriStartString="http://www.oasis-open.org/docbook/"
3943 catalog="file:///usr/share/xml/docbook.xml"/&gt;
3944...</pre>
3945
Daniel Veillard69839ba2006-06-06 13:27:03 +00003946<p>Delegation is the core features which allows to build a tree of
3947catalogs,easier to maintain than a single catalog, based on Public
3948Identifier, SystemIdentifier or URI prefixes it instructs the catalog
3949software to look upentries in another resource. This feature allow to build
3950hierarchies ofcatalogs, the set of entries presented should be sufficient to
3951redirect theresolution of all DocBook references to the specific catalog
3952in<code>/usr/share/xml/docbook.xml</code>this one in turn could delegate
3953allreferences for DocBook 4.2.1 to a specific catalog installed at the same
3954timeas the DocBook resources on the local machine.</p>
Daniel Veillardb8cfbd12001-10-25 10:53:28 +00003955
3956<h3><a name="reference">How to tune catalog usage:</a></h3>
3957
Daniel Veillard69839ba2006-06-06 13:27:03 +00003958<p>The user can change the default catalog behaviour by redirecting queriesto
3959its own set of catalogs, this can be done by setting
3960the<code>XML_CATALOG_FILES</code>environment variable to a list of catalogs,
3961anempty one should deactivate loading the default
3962<code>/etc/xml/catalog</code>default catalog</p>
Daniel Veillardb8cfbd12001-10-25 10:53:28 +00003963
3964<h3><a name="validate">How to debug catalog processing:</a></h3>
3965
Daniel Veillard69839ba2006-06-06 13:27:03 +00003966<p>Setting up the <code>XML_DEBUG_CATALOG</code>environment variable willmake
3967libxml2 output debugging informations for each catalog operations,
3968forexample:</p>
Daniel Veillardb8cfbd12001-10-25 10:53:28 +00003969<pre>orchis:~/XML -&gt; xmllint --memory --noout test/ent2
3970warning: failed to load external entity "title.xml"
3971orchis:~/XML -&gt; export XML_DEBUG_CATALOG=
3972orchis:~/XML -&gt; xmllint --memory --noout test/ent2
3973Failed to parse catalog /etc/xml/catalog
3974Failed to parse catalog /etc/xml/catalog
3975warning: failed to load external entity "title.xml"
3976Catalogs cleanup
3977orchis:~/XML -&gt; </pre>
3978
Daniel Veillard69839ba2006-06-06 13:27:03 +00003979<p>The test/ent2 references an entity, running the parser from memory
3980makesthe base URI unavailable and the the "title.xml" entity cannot be
3981loaded.Setting up the debug environment variable allows to detect that an
3982attempt ismade to load the <code>/etc/xml/catalog</code>but since it's not
3983present theresolution fails.</p>
Daniel Veillardb8cfbd12001-10-25 10:53:28 +00003984
Daniel Veillard69839ba2006-06-06 13:27:03 +00003985<p>But the most advanced way to debug XML catalog processing is to use
3986the<strong>xmlcatalog</strong>command shipped with libxml2, it allows to
3987loadcatalogs and make resolution queries to see what is going on. This is
3988alsoused for the regression tests:</p>
Daniel Veillardb8cfbd12001-10-25 10:53:28 +00003989<pre>orchis:~/XML -&gt; ./xmlcatalog test/catalogs/docbook.xml \
3990 "-//OASIS//DTD DocBook XML V4.1.2//EN"
3991http://www.oasis-open.org/docbook/xml/4.1.2/docbookx.dtd
3992orchis:~/XML -&gt; </pre>
3993
Daniel Veillard69839ba2006-06-06 13:27:03 +00003994<p>For debugging what is going on, adding one -v flags increase the
3995verbositylevel to indicate the processing done (adding a second flag also
3996indicatewhat elements are recognized at parsing):</p>
Daniel Veillardb8cfbd12001-10-25 10:53:28 +00003997<pre>orchis:~/XML -&gt; ./xmlcatalog -v test/catalogs/docbook.xml \
3998 "-//OASIS//DTD DocBook XML V4.1.2//EN"
3999Parsing catalog test/catalogs/docbook.xml's content
4000Found public match -//OASIS//DTD DocBook XML V4.1.2//EN
4001http://www.oasis-open.org/docbook/xml/4.1.2/docbookx.dtd
4002Catalogs cleanup
4003orchis:~/XML -&gt; </pre>
4004
Daniel Veillard69839ba2006-06-06 13:27:03 +00004005<p>A shell interface is also available to debug and process multiple
4006queries(and for regression tests):</p>
Daniel Veillardb8cfbd12001-10-25 10:53:28 +00004007<pre>orchis:~/XML -&gt; ./xmlcatalog -shell test/catalogs/docbook.xml \
4008 "-//OASIS//DTD DocBook XML V4.1.2//EN"
4009&gt; help
4010Commands available:
4011public PublicID: make a PUBLIC identifier lookup
4012system SystemID: make a SYSTEM identifier lookup
4013resolve PublicID SystemID: do a full resolver lookup
4014add 'type' 'orig' 'replace' : add an entry
4015del 'values' : remove values
4016dump: print the current catalog state
4017debug: increase the verbosity level
4018quiet: decrease the verbosity level
4019exit: quit the shell
4020&gt; public "-//OASIS//DTD DocBook XML V4.1.2//EN"
4021http://www.oasis-open.org/docbook/xml/4.1.2/docbookx.dtd
4022&gt; quit
4023orchis:~/XML -&gt; </pre>
4024
Daniel Veillard69839ba2006-06-06 13:27:03 +00004025<p>This should be sufficient for most debugging purpose, this was
4026actuallyused heavily to debug the XML Catalog implementation itself.</p>
Daniel Veillardb8cfbd12001-10-25 10:53:28 +00004027
Daniel Veillard69839ba2006-06-06 13:27:03 +00004028<h3><a name="Declaring">How to create and maintain</a>catalogs:</h3>
Daniel Veillardb8cfbd12001-10-25 10:53:28 +00004029
Daniel Veillard69839ba2006-06-06 13:27:03 +00004030<p>Basically XML Catalogs are XML files, you can either use XML tools
4031tomanage them or use <strong>xmlcatalog</strong>for this. The basic step
4032isto create a catalog the -create option provide this facility:</p>
Daniel Veillardb8cfbd12001-10-25 10:53:28 +00004033<pre>orchis:~/XML -&gt; ./xmlcatalog --create tst.xml
4034&lt;?xml version="1.0"?&gt;
4035&lt;!DOCTYPE catalog PUBLIC "-//OASIS//DTD Entity Resolution XML Catalog V1.0//EN"
4036 "http://www.oasis-open.org/committees/entity/release/1.0/catalog.dtd"&gt;
4037&lt;catalog xmlns="urn:oasis:names:tc:entity:xmlns:xml:catalog"/&gt;
4038orchis:~/XML -&gt; </pre>
4039
Daniel Veillard69839ba2006-06-06 13:27:03 +00004040<p>By default xmlcatalog does not overwrite the original catalog and save
4041theresult on the standard output, this can be overridden using the
4042-nooutoption. The <code>-add</code>command allows to add entries in
4043thecatalog:</p>
Daniel Veillardb8cfbd12001-10-25 10:53:28 +00004044<pre>orchis:~/XML -&gt; ./xmlcatalog --noout --create --add "public" \
4045 "-//OASIS//DTD DocBook XML V4.1.2//EN" \
4046 http://www.oasis-open.org/docbook/xml/4.1.2/docbookx.dtd tst.xml
4047orchis:~/XML -&gt; cat tst.xml
4048&lt;?xml version="1.0"?&gt;
4049&lt;!DOCTYPE catalog PUBLIC "-//OASIS//DTD Entity Resolution XML Catalog V1.0//EN" \
4050 "http://www.oasis-open.org/committees/entity/release/1.0/catalog.dtd"&gt;
4051&lt;catalog xmlns="urn:oasis:names:tc:entity:xmlns:xml:catalog"&gt;
4052&lt;public publicId="-//OASIS//DTD DocBook XML V4.1.2//EN"
4053 uri="http://www.oasis-open.org/docbook/xml/4.1.2/docbookx.dtd"/&gt;
4054&lt;/catalog&gt;
4055orchis:~/XML -&gt; </pre>
4056
Daniel Veillard69839ba2006-06-06 13:27:03 +00004057<p>The <code>-add</code>option will always take 3 parameters even if some
4058ofthe XML Catalog constructs (like nextCatalog) will have only a
4059singleargument, just pass a third empty string, it will be ignored.</p>
Daniel Veillardb8cfbd12001-10-25 10:53:28 +00004060
Daniel Veillard69839ba2006-06-06 13:27:03 +00004061<p>Similarly the <code>-del</code>option remove matching entries from
4062thecatalog:</p>
Daniel Veillardb8cfbd12001-10-25 10:53:28 +00004063<pre>orchis:~/XML -&gt; ./xmlcatalog --del \
4064 "http://www.oasis-open.org/docbook/xml/4.1.2/docbookx.dtd" tst.xml
4065&lt;?xml version="1.0"?&gt;
4066&lt;!DOCTYPE catalog PUBLIC "-//OASIS//DTD Entity Resolution XML Catalog V1.0//EN"
4067 "http://www.oasis-open.org/committees/entity/release/1.0/catalog.dtd"&gt;
4068&lt;catalog xmlns="urn:oasis:names:tc:entity:xmlns:xml:catalog"/&gt;
4069orchis:~/XML -&gt; </pre>
4070
Daniel Veillard69839ba2006-06-06 13:27:03 +00004071<p>The catalog is now empty. Note that the matching of
4072<code>-del</code>isexact and would have worked in a similar fashion with the
4073Public IDstring.</p>
Daniel Veillardb8cfbd12001-10-25 10:53:28 +00004074
Daniel Veillard69839ba2006-06-06 13:27:03 +00004075<p>This is rudimentary but should be sufficient to manage a not too
4076complexcatalog tree of resources.</p>
Daniel Veillardb8cfbd12001-10-25 10:53:28 +00004077
Daniel Veillard69839ba2006-06-06 13:27:03 +00004078<h3><a name="implemento">The implementor corner quick review of
4079theAPI:</a></h3>
Daniel Veillardb8cfbd12001-10-25 10:53:28 +00004080
Daniel Veillard69839ba2006-06-06 13:27:03 +00004081<p>First, and like for every other module of libxml, there is anautomatically
4082generated <a href="html/libxml-catalog.html">API page forcatalog
4083support</a>.</p>
Daniel Veillardb8cfbd12001-10-25 10:53:28 +00004084
4085<p>The header for the catalog interfaces should be included as:</p>
4086<pre>#include &lt;libxml/catalog.h&gt;</pre>
4087
Daniel Veillard69839ba2006-06-06 13:27:03 +00004088<p>The API is voluntarily kept very simple. First it is not obvious
4089thatapplications really need access to it since it is the default behaviour
4090oflibxml2 (Note: it is possible to completely override libxml2 default
4091catalogby using <a
4092href="html/libxml-parser.html">xmlSetExternalEntityLoader</a>toplug an
4093application specific resolver).</p>
Daniel Veillardb8cfbd12001-10-25 10:53:28 +00004094
Daniel Veillard8a469172003-06-12 16:05:07 +00004095<p>Basically libxml2 support 2 catalog lists:</p>
Daniel Veillardb8cfbd12001-10-25 10:53:28 +00004096<ul>
4097 <li>the default one, global shared by all the application</li>
Daniel Veillard69839ba2006-06-06 13:27:03 +00004098 <li>a per-document catalog, this one is built if the document uses
4099 the<code>oasis-xml-catalog</code>PIs to specify its own catalog list, it
4100 isassociated to the parser context and destroyed when the parsing
4101 contextis destroyed.</li>
Daniel Veillardb8cfbd12001-10-25 10:53:28 +00004102</ul>
4103
4104<p>the document one will be used first if it exists.</p>
4105
4106<h4>Initialization routines:</h4>
4107
Daniel Veillard69839ba2006-06-06 13:27:03 +00004108<p>xmlInitializeCatalog(), xmlLoadCatalog() and xmlLoadCatalogs() should
4109beused at startup to initialize the catalog, if the catalog should
4110beinitialized with specific values xmlLoadCatalog() or
4111xmlLoadCatalogs()should be called before xmlInitializeCatalog() which would
4112otherwise do adefault initialization first.</p>
Daniel Veillardb8cfbd12001-10-25 10:53:28 +00004113
Daniel Veillard69839ba2006-06-06 13:27:03 +00004114<p>The xmlCatalogAddLocal() call is used by the parser to grow the
4115documentown catalog list if needed.</p>
Daniel Veillardb8cfbd12001-10-25 10:53:28 +00004116
4117<h4>Preferences setup:</h4>
4118
Daniel Veillard69839ba2006-06-06 13:27:03 +00004119<p>The XML Catalog spec requires the possibility to select defaultpreferences
4120between public and system delegation,xmlCatalogSetDefaultPrefer() allows
4121this, xmlCatalogSetDefaults() andxmlCatalogGetDefaults() allow to control if
4122XML Catalogs resolution shouldbe forbidden, allowed for global catalog, for
4123document catalog or both, thedefault is to allow both.</p>
Daniel Veillardb8cfbd12001-10-25 10:53:28 +00004124
Daniel Veillard69839ba2006-06-06 13:27:03 +00004125<p>And of course xmlCatalogSetDebug() allows to generate debug
4126messages(through the xmlGenericError() mechanism).</p>
Daniel Veillardb8cfbd12001-10-25 10:53:28 +00004127
4128<h4>Querying routines:</h4>
4129
Daniel Veillard69839ba2006-06-06 13:27:03 +00004130<p>xmlCatalogResolve(), xmlCatalogResolveSystem(),
4131xmlCatalogResolvePublic()and xmlCatalogResolveURI() are relatively explicit
4132if you read the XMLCatalog specification they correspond to section 7
4133algorithms, they shouldalso work if you have loaded an SGML catalog with a
4134simplified semantic.</p>
Daniel Veillardb8cfbd12001-10-25 10:53:28 +00004135
Daniel Veillard69839ba2006-06-06 13:27:03 +00004136<p>xmlCatalogLocalResolve() and xmlCatalogLocalResolveURI() are the same
4137butoperate on the document catalog list</p>
Daniel Veillardb8cfbd12001-10-25 10:53:28 +00004138
4139<h4>Cleanup and Miscellaneous:</h4>
4140
Daniel Veillard69839ba2006-06-06 13:27:03 +00004141<p>xmlCatalogCleanup() free-up the global catalog, xmlCatalogFreeLocal()
4142isthe per-document equivalent.</p>
Daniel Veillardb8cfbd12001-10-25 10:53:28 +00004143
Daniel Veillard69839ba2006-06-06 13:27:03 +00004144<p>xmlCatalogAdd() and xmlCatalogRemove() are used to dynamically modify
4145thefirst catalog in the global list, and xmlCatalogDump() allows to dump
4146acatalog state, those routines are primarily designed for xmlcatalog, I'm
4147notsure that exposing more complex interfaces (like navigation ones) would
4148bereally useful.</p>
Daniel Veillardb8cfbd12001-10-25 10:53:28 +00004149
Daniel Veillard69839ba2006-06-06 13:27:03 +00004150<p>The xmlParseCatalogFile() is a function used to load XML Catalog
4151files,it's similar as xmlParseFile() except it bypass all catalog lookups,
4152it'sprovided because this functionality may be useful for client tools.</p>
Daniel Veillardb8cfbd12001-10-25 10:53:28 +00004153
4154<h4>threaded environments:</h4>
4155
Daniel Veillard69839ba2006-06-06 13:27:03 +00004156<p>Since the catalog tree is built progressively, some care has been taken
4157totry to avoid troubles in multithreaded environments. The code is now
4158threadsafe assuming that the libxml2 library has been compiled with
4159threadssupport.</p>
Daniel Veillardb8cfbd12001-10-25 10:53:28 +00004160
4161<p></p>
4162
4163<h3><a name="Other">Other resources</a></h3>
4164
Daniel Veillard69839ba2006-06-06 13:27:03 +00004165<p>The XML Catalog specification is relatively recent so there isn't
4166muchliterature to point at:</p>
Daniel Veillardb8cfbd12001-10-25 10:53:28 +00004167<ul>
Daniel Veillard63d83142002-05-20 06:51:05 +00004168 <li>You can find a good rant from Norm Walsh about <a
Daniel Veillard69839ba2006-06-06 13:27:03 +00004169 href="http://www.arbortext.com/Think_Tank/XML_Resources/Issue_Three/issue_three.html">theneed
4170 for catalogs</a>, it provides a lot of context informations even ifI
4171 don't agree with everything presented. Norm also wrote a more
4172 recentarticle <a
4173 href="http://wwws.sun.com/software/xml/developers/resolver/article/">XMLentities
4174 and URI resolvers</a>describing them.</li>
4175 <li>An <a href="http://home.ccil.org/~cowan/XML/XCatalog.html">old
4176 XMLcatalog proposal</a>from John Cowan</li>
4177 <li>The <a href="http://www.rddl.org/">Resource Directory
4178 DescriptionLanguage</a>(RDDL) another catalog system but more oriented
4179 towardproviding metadata for XML namespaces.</li>
Daniel Veillardb8cfbd12001-10-25 10:53:28 +00004180 <li>the page from the OASIS Technical <a
Daniel Veillard69839ba2006-06-06 13:27:03 +00004181 href="http://www.oasis-open.org/committees/entity/">Committee on
4182 EntityResolution</a>who maintains XML Catalog, you will find pointers to
4183 thespecification update, some background and pointers to others
4184 toolsproviding XML Catalog support</li>
4185 <li>There is a <a href="buildDocBookCatalog">shell script</a>to generateXML
4186 Catalogs for DocBook 4.1.2 . If it can write to the /etc/xml/directory,
4187 it will set-up /etc/xml/catalog and /etc/xml/docbook based onthe
4188 resources found on the system. Otherwise it will just create~/xmlcatalog
4189 and ~/dbkxmlcatalog and doing:
Daniel Veillard8594de92003-04-25 10:08:44 +00004190 <p><code>export XML_CATALOG_FILES=$HOME/xmlcatalog</code></p>
Daniel Veillard69839ba2006-06-06 13:27:03 +00004191 <p>should allow to process DocBook documentations without
4192 requiringnetwork accesses for the DTD or stylesheets</p>
Daniel Veillard35e937a2002-01-19 22:21:54 +00004193 </li>
Daniel Veillard69839ba2006-06-06 13:27:03 +00004194 <li>I have uploaded <a
4195 href="ftp://xmlsoft.org/libxml2/test/dbk412catalog.tar.gz">asmall
4196 tarball</a>containing XML Catalogs for DocBook 4.1.2 which seemsto work
4197 fine for me too</li>
4198 <li>The <a
4199 href="http://www.xmlsoft.org/xmlcatalog_man.html">xmlcatalogmanual
4200 page</a></li>
Daniel Veillardb8cfbd12001-10-25 10:53:28 +00004201</ul>
4202
Daniel Veillard69839ba2006-06-06 13:27:03 +00004203<p>If you have suggestions for corrections or additions, simply contactme:</p>
Daniel Veillardb8cfbd12001-10-25 10:53:28 +00004204
4205<h2><a name="library">The parser interfaces</a></h2>
Daniel Veillardb05deb71999-08-10 19:04:08 +00004206
Daniel Veillard69839ba2006-06-06 13:27:03 +00004207<p>This section is directly intended to help programmers getting
4208bootstrappedusing the XML tollkit from the C language. It is not intended to
4209beextensive. I hope the automatically generated documents will provide
4210thecompleteness required, but as a separate set of documents. The interfaces
4211ofthe XML parser are by principle low level, Those interested in a higher
4212levelAPI should <a href="#DOM">look at DOM</a>.</p>
Daniel Veillardccb09631998-10-27 06:21:04 +00004213
Daniel Veillard69839ba2006-06-06 13:27:03 +00004214<p>The <a href="html/libxml-parser.html">parser interfaces for
4215XML</a>areseparated from the <a href="html/libxml-htmlparser.html">HTML
4216parserinterfaces</a>. Let's have a look at how the XML parser can be
4217called:</p>
Daniel Veillard0142b842000-01-14 14:45:24 +00004218
Daniel Veillard88f00ae2000-03-02 00:15:55 +00004219<h3><a name="Invoking">Invoking the parser : the pull method</a></h3>
Daniel Veillardb05deb71999-08-10 19:04:08 +00004220
Daniel Veillard69839ba2006-06-06 13:27:03 +00004221<p>Usually, the first thing to do is to read an XML input. The parser
4222acceptsdocuments either from in-memory strings or from files. The functions
4223aredefined in "parser.h":</p>
Daniel Veillard10c6a8f1998-10-28 01:00:12 +00004224<dl>
Daniel Veillardb05deb71999-08-10 19:04:08 +00004225 <dt><code>xmlDocPtr xmlParseMemory(char *buffer, int size);</code></dt>
Daniel Veillard88f00ae2000-03-02 00:15:55 +00004226 <dd><p>Parse a null-terminated string containing the document.</p>
Daniel Veillardb05deb71999-08-10 19:04:08 +00004227 </dd>
Daniel Veillard10c6a8f1998-10-28 01:00:12 +00004228</dl>
4229<dl>
Daniel Veillardb05deb71999-08-10 19:04:08 +00004230 <dt><code>xmlDocPtr xmlParseFile(const char *filename);</code></dt>
Daniel Veillard69839ba2006-06-06 13:27:03 +00004231 <dd><p>Parse an XML document contained in a (possibly compressed)file.</p>
Daniel Veillardb05deb71999-08-10 19:04:08 +00004232 </dd>
Daniel Veillard10c6a8f1998-10-28 01:00:12 +00004233</dl>
Daniel Veillardb05deb71999-08-10 19:04:08 +00004234
Daniel Veillard69839ba2006-06-06 13:27:03 +00004235<p>The parser returns a pointer to the document structure (or NULL in case
4236offailure).</p>
Daniel Veillardb05deb71999-08-10 19:04:08 +00004237
Daniel Veillard88f00ae2000-03-02 00:15:55 +00004238<h3 id="Invoking1">Invoking the parser: the push method</h3>
Daniel Veillard0142b842000-01-14 14:45:24 +00004239
Daniel Veillard69839ba2006-06-06 13:27:03 +00004240<p>In order for the application to keep the control when the document isbeing
4241fetched (which is common for GUI based programs) libxml2 provides apush
4242interface, too, as of version 1.8.3. Here are the interfacefunctions:</p>
Daniel Veillard0142b842000-01-14 14:45:24 +00004243<pre>xmlParserCtxtPtr xmlCreatePushParserCtxt(xmlSAXHandlerPtr sax,
4244 void *user_data,
4245 const char *chunk,
4246 int size,
4247 const char *filename);
4248int xmlParseChunk (xmlParserCtxtPtr ctxt,
4249 const char *chunk,
4250 int size,
4251 int terminate);</pre>
4252
Daniel Veillard88f00ae2000-03-02 00:15:55 +00004253<p>and here is a simple example showing how to use the interface:</p>
Daniel Veillard0142b842000-01-14 14:45:24 +00004254<pre> FILE *f;
4255
4256 f = fopen(filename, "r");
4257 if (f != NULL) {
4258 int res, size = 1024;
4259 char chars[1024];
4260 xmlParserCtxtPtr ctxt;
4261
4262 res = fread(chars, 1, 4, f);
Daniel Veillard60979bd2000-07-10 12:17:33 +00004263 if (res &gt; 0) {
Daniel Veillard0142b842000-01-14 14:45:24 +00004264 ctxt = xmlCreatePushParserCtxt(NULL, NULL,
4265 chars, res, filename);
Daniel Veillard60979bd2000-07-10 12:17:33 +00004266 while ((res = fread(chars, 1, size, f)) &gt; 0) {
Daniel Veillard0142b842000-01-14 14:45:24 +00004267 xmlParseChunk(ctxt, chars, res, 0);
4268 }
4269 xmlParseChunk(ctxt, chars, 0, 1);
Daniel Veillard60979bd2000-07-10 12:17:33 +00004270 doc = ctxt-&gt;myDoc;
Daniel Veillard0142b842000-01-14 14:45:24 +00004271 xmlFreeParserCtxt(ctxt);
4272 }
4273 }</pre>
4274
Daniel Veillard69839ba2006-06-06 13:27:03 +00004275<p>The HTML parser embedded into libxml2 also has a push interface;
4276thefunctions are just prefixed by "html" rather than "xml".</p>
Daniel Veillard0142b842000-01-14 14:45:24 +00004277
4278<h3 id="Invoking2">Invoking the parser: the SAX interface</h3>
4279
Daniel Veillard69839ba2006-06-06 13:27:03 +00004280<p>The tree-building interface makes the parser memory-hungry, first
4281loadingthe document in memory and then building the tree itself. Reading a
4282documentwithout building the tree is possible using the SAX interfaces (see
4283SAX.h and<a
4284href="http://www.daa.com.au/~james/gnome/xml-sax/xml-sax.html">JamesHenstridge's
4285documentation</a>). Note also that the push interface can belimited to SAX:
4286just use the two first arguments of<code>xmlCreatePushParserCtxt()</code>.</p>
Daniel Veillardccb09631998-10-27 06:21:04 +00004287
Daniel Veillard2f4dfc41999-09-24 14:03:48 +00004288<h3><a name="Building">Building a tree from scratch</a></h3>
Daniel Veillardb05deb71999-08-10 19:04:08 +00004289
Daniel Veillard69839ba2006-06-06 13:27:03 +00004290<p>The other way to get an XML tree in memory is by building it.
4291Basicallythere is a set of functions dedicated to building new elements.
4292(These arealso described in &lt;libxml/tree.h&gt;.) For example, here is a
4293piece ofcode that produces the XML document used in the previous examples:</p>
Daniel Veillard60979bd2000-07-10 12:17:33 +00004294<pre> #include &lt;libxml/tree.h&gt;
Daniel Veillard361d8452000-04-03 19:48:13 +00004295 xmlDocPtr doc;
Daniel Veillard25940b71998-10-29 05:51:30 +00004296 xmlNodePtr tree, subtree;
4297
4298 doc = xmlNewDoc("1.0");
Daniel Veillard60979bd2000-07-10 12:17:33 +00004299 doc-&gt;children = xmlNewDocNode(doc, NULL, "EXAMPLE", NULL);
4300 xmlSetProp(doc-&gt;children, "prop1", "gnome is great");
4301 xmlSetProp(doc-&gt;children, "prop2", "&amp; linux too");
4302 tree = xmlNewChild(doc-&gt;children, NULL, "head", NULL);
Daniel Veillard25940b71998-10-29 05:51:30 +00004303 subtree = xmlNewChild(tree, NULL, "title", "Welcome to Gnome");
Daniel Veillard60979bd2000-07-10 12:17:33 +00004304 tree = xmlNewChild(doc-&gt;children, NULL, "chapter", NULL);
Daniel Veillard25940b71998-10-29 05:51:30 +00004305 subtree = xmlNewChild(tree, NULL, "title", "The Linux adventure");
4306 subtree = xmlNewChild(tree, NULL, "p", "bla bla bla ...");
4307 subtree = xmlNewChild(tree, NULL, "image", NULL);
4308 xmlSetProp(subtree, "href", "linus.gif");</pre>
Daniel Veillardb05deb71999-08-10 19:04:08 +00004309
4310<p>Not really rocket science ...</p>
Daniel Veillard25940b71998-10-29 05:51:30 +00004311
Daniel Veillard2f4dfc41999-09-24 14:03:48 +00004312<h3><a name="Traversing">Traversing the tree</a></h3>
Daniel Veillardb05deb71999-08-10 19:04:08 +00004313
Daniel Veillard69839ba2006-06-06 13:27:03 +00004314<p>Basically by <a href="html/libxml-tree.html">including
4315"tree.h"</a>yourcode has access to the internal structure of all the elements
4316of the tree.The names should be somewhat simple like
4317<strong>parent</strong>,<strong>children</strong>, <strong>next</strong>,
4318<strong>prev</strong>,<strong>properties</strong>, etc... For example, still
4319with the previousexample:</p>
Daniel Veillard60979bd2000-07-10 12:17:33 +00004320<pre><code>doc-&gt;children-&gt;children-&gt;children</code></pre>
Daniel Veillardb05deb71999-08-10 19:04:08 +00004321
4322<p>points to the title element,</p>
Daniel Veillard91e9d582001-02-26 07:31:12 +00004323<pre>doc-&gt;children-&gt;children-&gt;next-&gt;children-&gt;children</pre>
Daniel Veillardb05deb71999-08-10 19:04:08 +00004324
Daniel Veillard69839ba2006-06-06 13:27:03 +00004325<p>points to the text node containing the chapter title "The
4326Linuxadventure".</p>
Daniel Veillard10c6a8f1998-10-28 01:00:12 +00004327
Daniel Veillard69839ba2006-06-06 13:27:03 +00004328<p><strong>NOTE</strong>: XML allows <em>PI</em>s and <em>comments</em>to
4329bepresent before the document root, so <code>doc-&gt;children</code>may
4330pointto an element which is not the document Root Element; a
4331function<code>xmlDocGetRootElement()</code>was added for this purpose.</p>
Daniel Veillardb24054a1999-12-18 15:32:46 +00004332
Daniel Veillard2f4dfc41999-09-24 14:03:48 +00004333<h3><a name="Modifying">Modifying the tree</a></h3>
Daniel Veillardb05deb71999-08-10 19:04:08 +00004334
Daniel Veillard69839ba2006-06-06 13:27:03 +00004335<p>Functions are provided for reading and writing the document content.
4336Hereis an excerpt from the <a href="html/libxml-tree.html">tree API</a>:</p>
Daniel Veillard25940b71998-10-29 05:51:30 +00004337<dl>
Daniel Veillard69839ba2006-06-06 13:27:03 +00004338 <dt><code>xmlAttrPtr xmlSetProp(xmlNodePtr node, const xmlChar *name,
4339 constxmlChar *value);</code></dt>
4340 <dd><p>This sets (or changes) an attribute carried by an ELEMENT node.The
4341 value can be NULL.</p>
Daniel Veillardb05deb71999-08-10 19:04:08 +00004342 </dd>
Daniel Veillard25940b71998-10-29 05:51:30 +00004343</dl>
4344<dl>
Daniel Veillard69839ba2006-06-06 13:27:03 +00004345 <dt><code>const xmlChar *xmlGetProp(xmlNodePtr node, const
4346 xmlChar*name);</code></dt>
4347 <dd><p>This function returns a pointer to new copy of the
4348 propertycontent. Note that the user must deallocate the result.</p>
Daniel Veillardb05deb71999-08-10 19:04:08 +00004349 </dd>
Daniel Veillard25940b71998-10-29 05:51:30 +00004350</dl>
Daniel Veillardb05deb71999-08-10 19:04:08 +00004351
Daniel Veillard69839ba2006-06-06 13:27:03 +00004352<p>Two functions are provided for reading and writing the text associatedwith
4353elements:</p>
Daniel Veillard25940b71998-10-29 05:51:30 +00004354<dl>
Daniel Veillard69839ba2006-06-06 13:27:03 +00004355 <dt><code>xmlNodePtr xmlStringGetNodeList(xmlDocPtr doc, const
4356 xmlChar*value);</code></dt>
4357 <dd><p>This function takes an "external" string and converts it to
4358 onetext node or possibly to a list of entity and text nodes.
4359 Allnon-predefined entity references like &amp;Gnome; will be
4360 storedinternally as entity nodes, hence the result of the function may
4361 not bea single node.</p>
Daniel Veillardb05deb71999-08-10 19:04:08 +00004362 </dd>
Daniel Veillard25940b71998-10-29 05:51:30 +00004363</dl>
4364<dl>
Daniel Veillard69839ba2006-06-06 13:27:03 +00004365 <dt><code>xmlChar *xmlNodeListGetString(xmlDocPtr doc, xmlNodePtr list,
4366 intinLine);</code></dt>
4367 <dd><p>This function is the inverse
4368 of<code>xmlStringGetNodeList()</code>. It generates a new
4369 stringcontaining the content of the text and entity nodes. Note the
4370 extraargument inLine. If this argument is set to 1, the function will
4371 expandentity references. For example, instead of returning the
4372 &amp;Gnome;XML encoding in the string, it will substitute it with its
4373 value (say,"GNU Network Object Model Environment").</p>
Daniel Veillardb05deb71999-08-10 19:04:08 +00004374 </dd>
Daniel Veillard25940b71998-10-29 05:51:30 +00004375</dl>
Daniel Veillard10c6a8f1998-10-28 01:00:12 +00004376
Daniel Veillard2f4dfc41999-09-24 14:03:48 +00004377<h3><a name="Saving">Saving a tree</a></h3>
Daniel Veillardb05deb71999-08-10 19:04:08 +00004378
4379<p>Basically 3 options are possible:</p>
Daniel Veillard25940b71998-10-29 05:51:30 +00004380<dl>
Daniel Veillard69839ba2006-06-06 13:27:03 +00004381 <dt><code>void xmlDocDumpMemory(xmlDocPtr cur, xmlChar**mem,
4382 int*size);</code></dt>
Daniel Veillard88f00ae2000-03-02 00:15:55 +00004383 <dd><p>Returns a buffer into which the document has been saved.</p>
Daniel Veillardb05deb71999-08-10 19:04:08 +00004384 </dd>
Daniel Veillard25940b71998-10-29 05:51:30 +00004385</dl>
4386<dl>
Daniel Veillardb05deb71999-08-10 19:04:08 +00004387 <dt><code>extern void xmlDocDump(FILE *f, xmlDocPtr doc);</code></dt>
Daniel Veillard88f00ae2000-03-02 00:15:55 +00004388 <dd><p>Dumps a document to an open file descriptor.</p>
Daniel Veillardb05deb71999-08-10 19:04:08 +00004389 </dd>
Daniel Veillard25940b71998-10-29 05:51:30 +00004390</dl>
4391<dl>
Daniel Veillardb05deb71999-08-10 19:04:08 +00004392 <dt><code>int xmlSaveFile(const char *filename, xmlDocPtr cur);</code></dt>
Daniel Veillard69839ba2006-06-06 13:27:03 +00004393 <dd><p>Saves the document to a file. In this case, the
4394 compressioninterface is triggered if it has been turned on.</p>
Daniel Veillardb05deb71999-08-10 19:04:08 +00004395 </dd>
Daniel Veillard25940b71998-10-29 05:51:30 +00004396</dl>
Daniel Veillard10c6a8f1998-10-28 01:00:12 +00004397
Daniel Veillard2f4dfc41999-09-24 14:03:48 +00004398<h3><a name="Compressio">Compression</a></h3>
Daniel Veillardb05deb71999-08-10 19:04:08 +00004399
Daniel Veillard69839ba2006-06-06 13:27:03 +00004400<p>The library transparently handles compression when doing
4401file-basedaccesses. The level of compression on saves can be turned on either
4402globallyor individually for one file:</p>
Daniel Veillard25940b71998-10-29 05:51:30 +00004403<dl>
Daniel Veillardb05deb71999-08-10 19:04:08 +00004404 <dt><code>int xmlGetDocCompressMode (xmlDocPtr doc);</code></dt>
Daniel Veillard88f00ae2000-03-02 00:15:55 +00004405 <dd><p>Gets the document compression ratio (0-9).</p>
Daniel Veillardb05deb71999-08-10 19:04:08 +00004406 </dd>
Daniel Veillard25940b71998-10-29 05:51:30 +00004407</dl>
4408<dl>
Daniel Veillardb05deb71999-08-10 19:04:08 +00004409 <dt><code>void xmlSetDocCompressMode (xmlDocPtr doc, int mode);</code></dt>
Daniel Veillard88f00ae2000-03-02 00:15:55 +00004410 <dd><p>Sets the document compression ratio.</p>
Daniel Veillardb05deb71999-08-10 19:04:08 +00004411 </dd>
Daniel Veillard25940b71998-10-29 05:51:30 +00004412</dl>
4413<dl>
Daniel Veillardb05deb71999-08-10 19:04:08 +00004414 <dt><code>int xmlGetCompressMode(void);</code></dt>
Daniel Veillard88f00ae2000-03-02 00:15:55 +00004415 <dd><p>Gets the default compression ratio.</p>
Daniel Veillardb05deb71999-08-10 19:04:08 +00004416 </dd>
Daniel Veillard25940b71998-10-29 05:51:30 +00004417</dl>
4418<dl>
Daniel Veillardb05deb71999-08-10 19:04:08 +00004419 <dt><code>void xmlSetCompressMode(int mode);</code></dt>
Daniel Veillard88f00ae2000-03-02 00:15:55 +00004420 <dd><p>Sets the default compression ratio.</p>
Daniel Veillardb05deb71999-08-10 19:04:08 +00004421 </dd>
Daniel Veillard25940b71998-10-29 05:51:30 +00004422</dl>
4423
Daniel Veillard2f4dfc41999-09-24 14:03:48 +00004424<h2><a name="Entities">Entities or no entities</a></h2>
Daniel Veillardc8eab3a1999-09-04 18:27:23 +00004425
Daniel Veillard69839ba2006-06-06 13:27:03 +00004426<p>Entities in principle are similar to simple C macros. An entity defines
4427anabbreviation for a given string that you can reuse many times throughout
4428thecontent of your document. Entities are especially useful when a given
4429stringmay occur frequently within a document, or to confine the change needed
4430to adocument to a restricted area in the internal subset of the document (at
4431thebeginning). Example:</p>
Daniel Veillard60979bd2000-07-10 12:17:33 +00004432<pre>1 &lt;?xml version="1.0"?&gt;
Daniel Veillardc8eab3a1999-09-04 18:27:23 +000044332 &lt;!DOCTYPE EXAMPLE SYSTEM "example.dtd" [
Daniel Veillard60979bd2000-07-10 12:17:33 +000044343 &lt;!ENTITY xml "Extensible Markup Language"&gt;
44354 ]&gt;
44365 &lt;EXAMPLE&gt;
Daniel Veillardc8eab3a1999-09-04 18:27:23 +000044376 &amp;xml;
Daniel Veillard60979bd2000-07-10 12:17:33 +000044387 &lt;/EXAMPLE&gt;</pre>
Daniel Veillardc8eab3a1999-09-04 18:27:23 +00004439
Daniel Veillard69839ba2006-06-06 13:27:03 +00004440<p>Line 3 declares the xml entity. Line 6 uses the xml entity, by
4441prefixingits name with '&amp;' and following it by ';' without any spaces
4442added. Thereare 5 predefined entities in libxml2 allowing you to escape
4443characters withpredefined meaning in some parts of the xml document
4444content:<strong>&amp;lt;</strong>for the character '&lt;',
4445<strong>&amp;gt;</strong>for the character '&gt;',
4446<strong>&amp;apos;</strong>for the character
4447''',<strong>&amp;quot;</strong>for the character '"',
4448and<strong>&amp;amp;</strong>for the character '&amp;'.</p>
Daniel Veillardc8eab3a1999-09-04 18:27:23 +00004449
Daniel Veillard69839ba2006-06-06 13:27:03 +00004450<p>One of the problems related to entities is that you may want the parser
4451tosubstitute an entity's content so that you can see the replacement text
4452inyour application. Or you may prefer to keep entity references as such in
4453thecontent to be able to save the document back without losing this
4454usuallyprecious information (if the user went through the pain of
4455explicitlydefining entities, he may have a a rather negative attitude if you
4456blindlysubstitute them as saving time). The <a
4457href="html/libxml-parser.html#xmlSubstituteEntitiesDefault">xmlSubstituteEntitiesDefault()</a>function
4458allows you to check and change the behaviour, which is to notsubstitute
4459entities by default.</p>
Daniel Veillardc8eab3a1999-09-04 18:27:23 +00004460
Daniel Veillard69839ba2006-06-06 13:27:03 +00004461<p>Here is the DOM tree built by libxml2 for the previous document in
4462thedefault case:</p>
Daniel Veillard60979bd2000-07-10 12:17:33 +00004463<pre>/gnome/src/gnome-xml -&gt; ./xmllint --debug test/ent1
Daniel Veillardc8eab3a1999-09-04 18:27:23 +00004464DOCUMENT
4465version=1.0
4466 ELEMENT EXAMPLE
4467 TEXT
4468 content=
4469 ENTITY_REF
4470 INTERNAL_GENERAL_ENTITY xml
4471 content=Extensible Markup Language
4472 TEXT
4473 content=</pre>
4474
4475<p>And here is the result when substituting entities:</p>
Daniel Veillard60979bd2000-07-10 12:17:33 +00004476<pre>/gnome/src/gnome-xml -&gt; ./tester --debug --noent test/ent1
Daniel Veillardc8eab3a1999-09-04 18:27:23 +00004477DOCUMENT
4478version=1.0
4479 ELEMENT EXAMPLE
4480 TEXT
4481 content= Extensible Markup Language</pre>
4482
Daniel Veillard69839ba2006-06-06 13:27:03 +00004483<p>So, entities or no entities? Basically, it depends on your use case.
4484Isuggest that you keep the non-substituting default behaviour and avoid
4485usingentities in your XML document or data if you are not willing to handle
4486theentity references elements in the DOM tree.</p>
Daniel Veillardc8eab3a1999-09-04 18:27:23 +00004487
Daniel Veillard69839ba2006-06-06 13:27:03 +00004488<p>Note that at save time libxml2 enforces the conversion of the
4489predefinedentities where necessary to prevent well-formedness problems, and
4490will alsotransparently replace those with chars (i.e. it will not generate
4491entityreference elements in the DOM tree or call the reference() SAX callback
4492whenfinding them in the input).</p>
Daniel Veillardc8eab3a1999-09-04 18:27:23 +00004493
Daniel Veillard69839ba2006-06-06 13:27:03 +00004494<p><span style="background-color: #FF0000">WARNING</span>: handling
4495entitieson top of the libxml2 SAX interface is difficult!!! If you plan to
4496usenon-predefined entities in your documents, then the learning curve to
4497handlethen using the SAX API may be long. If you plan to use complex
4498documents, Istrongly suggest you consider using the DOM interface instead and
4499let libxmldeal with the complexity rather than trying to do it yourself.</p>
Daniel Veillard7b9c4b72000-08-25 16:26:50 +00004500
Daniel Veillard2f4dfc41999-09-24 14:03:48 +00004501<h2><a name="Namespaces">Namespaces</a></h2>
Daniel Veillardc8eab3a1999-09-04 18:27:23 +00004502
Daniel Veillard8a469172003-06-12 16:05:07 +00004503<p>The libxml2 library implements <a
Daniel Veillard69839ba2006-06-06 13:27:03 +00004504href="http://www.w3.org/TR/REC-xml-names/">XML namespaces</a>support
4505byrecognizing namespace constructs in the input, and does namespace
4506lookupautomatically when building the DOM tree. A namespace declaration
4507isassociated with an in-memory structure and all elements or attributes
4508withinthat namespace point to it. Hence testing the namespace is a simple and
4509fastequality operation at the user level.</p>
Daniel Veillardc8eab3a1999-09-04 18:27:23 +00004510
Daniel Veillard69839ba2006-06-06 13:27:03 +00004511<p>I suggest that people using libxml2 use a namespace, and declare it in
4512theroot element of their document as the default namespace. Then they don't
4513needto use the prefix in the content but we will have a basis for future
4514semanticrefinement and merging of data from different sources. This doesn't
4515increasethe size of the XML output significantly, but significantly increases
4516itsvalue in the long-term. Example:</p>
Daniel Veillard60979bd2000-07-10 12:17:33 +00004517<pre>&lt;mydoc xmlns="http://mydoc.example.org/schemas/"&gt;
4518 &lt;elem1&gt;...&lt;/elem1&gt;
4519 &lt;elem2&gt;...&lt;/elem2&gt;
4520&lt;/mydoc&gt;</pre>
Daniel Veillardc8eab3a1999-09-04 18:27:23 +00004521
Daniel Veillard69839ba2006-06-06 13:27:03 +00004522<p>The namespace value has to be an absolute URL, but the URL doesn't have
4523topoint to any existing resource on the Web. It will bind all the element
4524andattributes with that URL. I suggest to use an URL within a domain
4525youcontrol, and that the URL should contain some kind of version information
4526ifpossible. For example, <code>"http://www.gnome.org/gnumeric/1.0/"</code>is
4527agood namespace scheme.</p>
Daniel Veillardec303412000-03-24 13:41:54 +00004528
Daniel Veillard69839ba2006-06-06 13:27:03 +00004529<p>Then when you load a file, make sure that a namespace carrying
4530theversion-independent prefix is installed on the root element of your
4531document,and if the version information don't match something you know, warn
4532the userand be liberal in what you accept as the input. Also do *not* try to
4533basenamespace checking on the prefix value. &lt;foo:text&gt; may be exactly
4534thesame as &lt;bar:text&gt; in another document. What really matters is the
4535URIassociated with the element or the attribute, not the prefix string (which
4536isjust a shortcut for the full URI). In libxml, element and attributes have
4537an<code>ns</code>field pointing to an xmlNs structure detailing the
4538namespaceprefix and its URI.</p>
Daniel Veillardc8eab3a1999-09-04 18:27:23 +00004539
4540<p>@@Interfaces@@</p>
Daniel Veillard3e35f8e2003-10-21 00:05:38 +00004541<pre>xmlNodePtr node;
Daniel Veillardfc8dc352003-10-18 09:07:46 +00004542if(!strncmp(node-&gt;name,"mytag",5)
4543 &amp;&amp; node-&gt;ns
4544 &amp;&amp; !strcmp(node-&gt;ns-&gt;href,"http://www.mysite.com/myns/1.0")) {
4545 ...
Daniel Veillard3e35f8e2003-10-21 00:05:38 +00004546}</pre>
Daniel Veillardc8eab3a1999-09-04 18:27:23 +00004547
Daniel Veillard69839ba2006-06-06 13:27:03 +00004548<p>Usually people object to using namespaces together with validity
4549checking.I will try to make sure that using namespaces won't break validity
4550checking,so even if you plan to use or currently are using validation I
4551stronglysuggest adding namespaces to your document. A default namespace
4552scheme<code>xmlns="http://...."</code>should not break validity even on
4553lessflexible parsers. Using namespaces to mix and differentiate content
4554comingfrom multiple DTDs will certainly break current validation schemes. To
4555checksuch documents one needs to use schema-validation, which is supported
4556inlibxml2 as well. See <a href="http://www.relaxng.org/">relagx-ng</a>and <a
Daniel Veillard3e35f8e2003-10-21 00:05:38 +00004557href="http://www.w3c.org/XML/Schema">w3c-schema</a>.</p>
Daniel Veillardc8eab3a1999-09-04 18:27:23 +00004558
Daniel Veillardb8cfbd12001-10-25 10:53:28 +00004559<h2><a name="Upgrading">Upgrading 1.x code</a></h2>
Daniel Veillardc8eab3a1999-09-04 18:27:23 +00004560
Daniel Veillardb8cfbd12001-10-25 10:53:28 +00004561<p>Incompatible changes:</p>
Daniel Veillardc8eab3a1999-09-04 18:27:23 +00004562
Daniel Veillard69839ba2006-06-06 13:27:03 +00004563<p>Version 2 of libxml2 is the first version introducing serious
4564backwardincompatible changes. The main goals were:</p>
Daniel Veillardb8cfbd12001-10-25 10:53:28 +00004565<ul>
Daniel Veillard69839ba2006-06-06 13:27:03 +00004566 <li>a general cleanup. A number of mistakes inherited from the very
4567 earlyversions couldn't be changed due to compatibility constraints.
4568 Examplethe "childs" element in the nodes.</li>
4569 <li>Uniformization of the various nodes, at least for their header and
4570 linkparts (doc, parent, children, prev, next), the goal is a
4571 simplerprogramming model and simplifying the task of the DOM
4572 implementors.</li>
4573 <li>better conformances to the XML specification, for example version
4574 1.xhad an heuristic to try to detect ignorable white spaces. As a result
4575 theSAX event generated were ignorableWhitespace() while the spec
4576 requirescharacter() in that case. This also mean that a number of DOM
4577 nodecontaining blank text may populate the DOM tree which were not
4578 presentbefore.</li>
Daniel Veillardb8cfbd12001-10-25 10:53:28 +00004579</ul>
Daniel Veillardc8eab3a1999-09-04 18:27:23 +00004580
Daniel Veillardb8cfbd12001-10-25 10:53:28 +00004581<h3>How to fix libxml-1.x code:</h3>
Daniel Veillardc8eab3a1999-09-04 18:27:23 +00004582
Daniel Veillard69839ba2006-06-06 13:27:03 +00004583<p>So client code of libxml designed to run with version 1.x may have to
4584bechanged to compile against version 2.x of libxml. Here is a list of
4585changesthat I have collected, they may not be sufficient, so in case you find
4586otherchange which are required, <a href="mailto:Daniel.Veillard@w3.org">drop
4587me amail</a>:</p>
Daniel Veillardb8cfbd12001-10-25 10:53:28 +00004588<ol>
Daniel Veillard69839ba2006-06-06 13:27:03 +00004589 <li>The package name have changed from libxml to libxml2, the library
4590 nameis now -lxml2 . There is a new xml2-config script which should be
4591 used toselect the right parameters libxml2</li>
4592 <li>Node <strong>childs</strong>field has been
4593 renamed<strong>children</strong>so s/childs/children/g should be
4594 applied(probability of having "childs" anywhere else is close to 0+</li>
4595 <li>The document don't have anymore a <strong>root</strong>element it
4596 hasbeen replaced by <strong>children</strong>and usually you will get
4597 alist of element here. For example a Dtd element for the internal
4598 subsetand it's declaration may be found in that list, as well as
4599 processinginstructions or comments found before or after the document
4600 root element.Use <strong>xmlDocGetRootElement(doc)</strong>to get the
4601 root element ofa document. Alternatively if you are sure to not reference
4602 DTDs nor havePIs or comments before or after the root
4603 elements/-&gt;root/-&gt;children/g will probably do it.</li>
4604 <li>The white space issue, this one is more complex, unless special case
4605 ofvalidating parsing, the line breaks and spaces usually used for
4606 indentingand formatting the document content becomes significant. So they
4607 arereported by SAX and if your using the DOM tree, corresponding nodes
4608 aregenerated. Too approach can be taken:
Daniel Veillardb8cfbd12001-10-25 10:53:28 +00004609 <ol>
Daniel Veillard69839ba2006-06-06 13:27:03 +00004610 <li>lazy one, use the compatibility
4611 call<strong>xmlKeepBlanksDefault(0)</strong>but be aware that you
4612 arerelying on a special (and possibly broken) set of heuristics
4613 oflibxml to detect ignorable blanks. Don't complain if it breaks
4614 ormake your application not 100% clean w.r.t. to it's input.</li>
4615 <li>the Right Way: change you code to accept possibly
4616 insignificantblanks characters, or have your tree populated with
4617 weird blank textnodes. You can spot them using the commodity
4618 function<strong>xmlIsBlankNode(node)</strong>returning 1 for such
4619 blanknodes.</li>
Daniel Veillardb8cfbd12001-10-25 10:53:28 +00004620 </ol>
Daniel Veillard69839ba2006-06-06 13:27:03 +00004621 <p>Note also that with the new default the output functions don't add
4622 anyextra indentation when saving a tree in order to be able to round
4623 trip(read and save) without inflating the document with extra
4624 formattingchars.</p>
Daniel Veillardb8cfbd12001-10-25 10:53:28 +00004625 </li>
Daniel Veillard69839ba2006-06-06 13:27:03 +00004626 <li>The include path has changed to $prefix/libxml/ and the
4627 includesthemselves uses this new prefix in includes instructions... If
4628 you areusing (as expected) the
Daniel Veillardb8cfbd12001-10-25 10:53:28 +00004629 <pre>xml2-config --cflags</pre>
Daniel Veillard69839ba2006-06-06 13:27:03 +00004630 <p>output to generate you compile commands this will probably work out
4631 ofthe box</p>
Daniel Veillardb8cfbd12001-10-25 10:53:28 +00004632 </li>
Daniel Veillard69839ba2006-06-06 13:27:03 +00004633 <li>xmlDetectCharEncoding takes an extra argument indicating the length
4634 inbyte of the head of the document available for character detection.</li>
Daniel Veillardb8cfbd12001-10-25 10:53:28 +00004635</ol>
Daniel Veillardc8eab3a1999-09-04 18:27:23 +00004636
Daniel Veillardb8cfbd12001-10-25 10:53:28 +00004637<h3>Ensuring both libxml-1.x and libxml-2.x compatibility</h3>
Daniel Veillardc8eab3a1999-09-04 18:27:23 +00004638
Daniel Veillard69839ba2006-06-06 13:27:03 +00004639<p>Two new version of libxml (1.8.11) and libxml2 (2.3.4) have been
4640releasedto allow smooth upgrade of existing libxml v1code while
4641retainingcompatibility. They offers the following:</p>
Daniel Veillardb8cfbd12001-10-25 10:53:28 +00004642<ol>
Daniel Veillard69839ba2006-06-06 13:27:03 +00004643 <li>similar include naming, one should
4644 use<strong>#include&lt;libxml/...&gt;</strong>in both cases.</li>
4645 <li>similar identifiers defined via macros for the child and root
4646 fields:respectively
4647 <strong>xmlChildrenNode</strong>and<strong>xmlRootNode</strong></li>
4648 <li>a new macro <strong>LIBXML_TEST_VERSION</strong>which should beinserted
4649 once in the client code</li>
Daniel Veillardb8cfbd12001-10-25 10:53:28 +00004650</ol>
Daniel Veillardc8eab3a1999-09-04 18:27:23 +00004651
Daniel Veillard69839ba2006-06-06 13:27:03 +00004652<p>So the roadmap to upgrade your existing libxml applications is
4653thefollowing:</p>
Daniel Veillardb8cfbd12001-10-25 10:53:28 +00004654<ol>
4655 <li>install the libxml-1.8.8 (and libxml-devel-1.8.8) packages</li>
Daniel Veillard69839ba2006-06-06 13:27:03 +00004656 <li>find all occurrences where the xmlDoc <strong>root</strong>field isused
4657 and change it to <strong>xmlRootNode</strong></li>
4658 <li>similarly find all occurrences where the
4659 xmlNode<strong>childs</strong>field is used and change it
4660 to<strong>xmlChildrenNode</strong></li>
4661 <li>add a <strong>LIBXML_TEST_VERSION</strong>macro somewhere in
4662 your<strong>main()</strong>or in the library init entry point</li>
Daniel Veillardb8cfbd12001-10-25 10:53:28 +00004663 <li>Recompile, check compatibility, it should still work</li>
Daniel Veillard69839ba2006-06-06 13:27:03 +00004664 <li>Change your configure script to look first for xml2-config and fallback
4665 using xml-config . Use the --cflags and --libs output of the commandas
4666 the Include and Linking parameters needed to use libxml.</li>
4667 <li>install libxml2-2.3.x and libxml2-devel-2.3.x (libxml-1.8.y
4668 andlibxml-devel-1.8.y can be kept simultaneously)</li>
4669 <li>remove your config.cache, relaunch your configuration mechanism,
4670 andrecompile, if steps 2 and 3 were done right it should compile
4671 as-is</li>
4672 <li>Test that your application is still running correctly, if not this
4673 maybe due to extra empty nodes due to formating spaces being kept in
4674 libxml2contrary to libxml1, in that case insert xmlKeepBlanksDefault(1)
4675 in yourcode before calling the parser (next
4676 to<strong>LIBXML_TEST_VERSION</strong>is a fine place).</li>
Daniel Veillardb8cfbd12001-10-25 10:53:28 +00004677</ol>
Daniel Veillardc8eab3a1999-09-04 18:27:23 +00004678
Daniel Veillardb8cfbd12001-10-25 10:53:28 +00004679<p>Following those steps should work. It worked for some of my own code.</p>
Daniel Veillardc8eab3a1999-09-04 18:27:23 +00004680
Daniel Veillard69839ba2006-06-06 13:27:03 +00004681<p>Let me put some emphasis on the fact that there is far more changes
4682fromlibxml 1.x to 2.x than the ones you may have to patch for. The overall
4683codehas been considerably cleaned up and the conformance to the XML
4684specificationhas been drastically improved too. Don't take those changes as
4685an excuse tonot upgrade, it may cost a lot on the long term ...</p>
Daniel Veillardc8eab3a1999-09-04 18:27:23 +00004686
Daniel Veillard52dcab32001-10-30 12:51:17 +00004687<h2><a name="Thread">Thread safety</a></h2>
4688
Daniel Veillard69839ba2006-06-06 13:27:03 +00004689<p>Starting with 2.4.7, libxml2 makes provisions to ensure that
4690concurrentthreads can safely work in parallel parsing different documents.
4691There ishowever a couple of things to do to ensure it:</p>
Daniel Veillard52dcab32001-10-30 12:51:17 +00004692<ul>
4693 <li>configure the library accordingly using the --with-threads options</li>
Daniel Veillard69839ba2006-06-06 13:27:03 +00004694 <li>call xmlInitParser() in the "main" thread before using any of
4695 thelibxml2 API (except possibly selecting a different memory
4696 allocator)</li>
Daniel Veillard52dcab32001-10-30 12:51:17 +00004697</ul>
4698
Daniel Veillard69839ba2006-06-06 13:27:03 +00004699<p>Note that the thread safety cannot be ensured for multiple threads
4700sharingthe same document, the locking must be done at the application level,
4701libxmlexports a basic mutex and reentrant mutexes API in
4702&lt;libxml/threads.h&gt;.The parts of the library checked for thread safety
4703are:</p>
Daniel Veillard52dcab32001-10-30 12:51:17 +00004704<ul>
4705 <li>concurrent loading</li>
4706 <li>file access resolution</li>
4707 <li>catalog access</li>
4708 <li>catalog building</li>
4709 <li>entities lookup/accesses</li>
4710 <li>validation</li>
4711 <li>global variables per-thread override</li>
4712 <li>memory handling</li>
4713</ul>
4714
Daniel Veillard69839ba2006-06-06 13:27:03 +00004715<p>XPath is supposed to be thread safe now, but this wasn't
4716testedseriously.</p>
Daniel Veillard52dcab32001-10-30 12:51:17 +00004717
Daniel Veillard35008381999-10-25 13:15:52 +00004718<h2><a name="DOM"></a><a name="Principles">DOM Principles</a></h2>
Daniel Veillardb05deb71999-08-10 19:04:08 +00004719
Daniel Veillard69839ba2006-06-06 13:27:03 +00004720<p><a href="http://www.w3.org/DOM/">DOM</a>stands for the <em>DocumentObject
4721Model</em>; this is an API for accessing XML or HTML structureddocuments.
4722Native support for DOM in Gnome is on the way (module gnome-dom),and will be
4723based on gnome-xml. This will be a far cleaner interface tomanipulate XML
4724files within Gnome since it won't expose the internalstructure.</p>
Daniel Veillard14fff061999-06-22 21:49:07 +00004725
Daniel Veillard8a469172003-06-12 16:05:07 +00004726<p>The current DOM implementation on top of libxml2 is the <a
Daniel Veillard69839ba2006-06-06 13:27:03 +00004727href="http://cvs.gnome.org/lxr/source/gdome2/">gdome2 Gnome module</a>,
4728thisis a full DOM interface, thanks to Paolo Casarini, check the <a
4729href="http://www.cs.unibo.it/~casarini/gdome2/">Gdome2 homepage</a>for
4730moreinformations.</p>
Daniel Veillardc8eab3a1999-09-04 18:27:23 +00004731
Daniel Veillard35008381999-10-25 13:15:52 +00004732<h2><a name="Example"></a><a name="real">A real example</a></h2>
Daniel Veillardb05deb71999-08-10 19:04:08 +00004733
Daniel Veillard69839ba2006-06-06 13:27:03 +00004734<p>Here is a real size example, where the actual content of the
4735applicationdata is not kept in the DOM tree but uses internal structures. It
4736is based ona proposal to keep a database of jobs related to Gnome, with an
4737XML basedstorage structure. Here is an <a href="gjobs.xml">XML encoded
4738jobsbase</a>:</p>
Daniel Veillard60979bd2000-07-10 12:17:33 +00004739<pre>&lt;?xml version="1.0"?&gt;
4740&lt;gjob:Helping xmlns:gjob="http://www.gnome.org/some-location"&gt;
4741 &lt;gjob:Jobs&gt;
Daniel Veillard14fff061999-06-22 21:49:07 +00004742
Daniel Veillard60979bd2000-07-10 12:17:33 +00004743 &lt;gjob:Job&gt;
4744 &lt;gjob:Project ID="3"/&gt;
4745 &lt;gjob:Application&gt;GBackup&lt;/gjob:Application&gt;
4746 &lt;gjob:Category&gt;Development&lt;/gjob:Category&gt;
Daniel Veillard14fff061999-06-22 21:49:07 +00004747
Daniel Veillard60979bd2000-07-10 12:17:33 +00004748 &lt;gjob:Update&gt;
4749 &lt;gjob:Status&gt;Open&lt;/gjob:Status&gt;
4750 &lt;gjob:Modified&gt;Mon, 07 Jun 1999 20:27:45 -0400 MET DST&lt;/gjob:Modified&gt;
4751 &lt;gjob:Salary&gt;USD 0.00&lt;/gjob:Salary&gt;
4752 &lt;/gjob:Update&gt;
Daniel Veillard14fff061999-06-22 21:49:07 +00004753
Daniel Veillard60979bd2000-07-10 12:17:33 +00004754 &lt;gjob:Developers&gt;
4755 &lt;gjob:Developer&gt;
4756 &lt;/gjob:Developer&gt;
4757 &lt;/gjob:Developers&gt;
Daniel Veillard14fff061999-06-22 21:49:07 +00004758
Daniel Veillard60979bd2000-07-10 12:17:33 +00004759 &lt;gjob:Contact&gt;
4760 &lt;gjob:Person&gt;Nathan Clemons&lt;/gjob:Person&gt;
4761 &lt;gjob:Email&gt;nathan@windsofstorm.net&lt;/gjob:Email&gt;
4762 &lt;gjob:Company&gt;
4763 &lt;/gjob:Company&gt;
4764 &lt;gjob:Organisation&gt;
4765 &lt;/gjob:Organisation&gt;
4766 &lt;gjob:Webpage&gt;
4767 &lt;/gjob:Webpage&gt;
4768 &lt;gjob:Snailmail&gt;
4769 &lt;/gjob:Snailmail&gt;
4770 &lt;gjob:Phone&gt;
4771 &lt;/gjob:Phone&gt;
4772 &lt;/gjob:Contact&gt;
Daniel Veillard14fff061999-06-22 21:49:07 +00004773
Daniel Veillard60979bd2000-07-10 12:17:33 +00004774 &lt;gjob:Requirements&gt;
Daniel Veillard14fff061999-06-22 21:49:07 +00004775 The program should be released as free software, under the GPL.
Daniel Veillard60979bd2000-07-10 12:17:33 +00004776 &lt;/gjob:Requirements&gt;
Daniel Veillard14fff061999-06-22 21:49:07 +00004777
Daniel Veillard60979bd2000-07-10 12:17:33 +00004778 &lt;gjob:Skills&gt;
4779 &lt;/gjob:Skills&gt;
Daniel Veillard14fff061999-06-22 21:49:07 +00004780
Daniel Veillard60979bd2000-07-10 12:17:33 +00004781 &lt;gjob:Details&gt;
Daniel Veillard14fff061999-06-22 21:49:07 +00004782 A GNOME based system that will allow a superuser to configure
4783 compressed and uncompressed files and/or file systems to be backed
4784 up with a supported media in the system. This should be able to
4785 perform via find commands generating a list of files that are passed
4786 to tar, dd, cpio, cp, gzip, etc., to be directed to the tape machine
4787 or via operations performed on the filesystem itself. Email
4788 notification and GUI status display very important.
Daniel Veillard60979bd2000-07-10 12:17:33 +00004789 &lt;/gjob:Details&gt;
Daniel Veillard14fff061999-06-22 21:49:07 +00004790
Daniel Veillard60979bd2000-07-10 12:17:33 +00004791 &lt;/gjob:Job&gt;
Daniel Veillard14fff061999-06-22 21:49:07 +00004792
Daniel Veillard60979bd2000-07-10 12:17:33 +00004793 &lt;/gjob:Jobs&gt;
4794&lt;/gjob:Helping&gt;</pre>
Daniel Veillardb05deb71999-08-10 19:04:08 +00004795
Daniel Veillard69839ba2006-06-06 13:27:03 +00004796<p>While loading the XML file into an internal DOM tree is a matter ofcalling
4797only a couple of functions, browsing the tree to gather the data andgenerate
4798the internal structures is harder, and more error prone.</p>
Daniel Veillardb05deb71999-08-10 19:04:08 +00004799
Daniel Veillard69839ba2006-06-06 13:27:03 +00004800<p>The suggested principle is to be tolerant with respect to the
4801inputstructure. For example, the ordering of the attributes is not
4802significant,the XML specification is clear about it. It's also usually a good
4803idea not todepend on the order of the children of a given node, unless it
4804really makesthings harder. Here is some code to parse the information for a
4805person:</p>
Daniel Veillardb05deb71999-08-10 19:04:08 +00004806<pre>/*
Daniel Veillard14fff061999-06-22 21:49:07 +00004807 * A person record
4808 */
4809typedef struct person {
4810 char *name;
4811 char *email;
4812 char *company;
4813 char *organisation;
4814 char *smail;
4815 char *webPage;
4816 char *phone;
4817} person, *personPtr;
4818
4819/*
4820 * And the code needed to parse it
4821 */
4822personPtr parsePerson(xmlDocPtr doc, xmlNsPtr ns, xmlNodePtr cur) {
4823 personPtr ret = NULL;
4824
4825DEBUG("parsePerson\n");
4826 /*
4827 * allocate the struct
4828 */
4829 ret = (personPtr) malloc(sizeof(person));
4830 if (ret == NULL) {
4831 fprintf(stderr,"out of memory\n");
Daniel Veillardb05deb71999-08-10 19:04:08 +00004832 return(NULL);
Daniel Veillard14fff061999-06-22 21:49:07 +00004833 }
4834 memset(ret, 0, sizeof(person));
4835
4836 /* We don't care what the top level element name is */
Daniel Veillard60979bd2000-07-10 12:17:33 +00004837 cur = cur-&gt;xmlChildrenNode;
Daniel Veillard14fff061999-06-22 21:49:07 +00004838 while (cur != NULL) {
Daniel Veillard60979bd2000-07-10 12:17:33 +00004839 if ((!strcmp(cur-&gt;name, "Person")) &amp;&amp; (cur-&gt;ns == ns))
4840 ret-&gt;name = xmlNodeListGetString(doc, cur-&gt;xmlChildrenNode, 1);
4841 if ((!strcmp(cur-&gt;name, "Email")) &amp;&amp; (cur-&gt;ns == ns))
4842 ret-&gt;email = xmlNodeListGetString(doc, cur-&gt;xmlChildrenNode, 1);
4843 cur = cur-&gt;next;
Daniel Veillard14fff061999-06-22 21:49:07 +00004844 }
4845
4846 return(ret);
Daniel Veillardb05deb71999-08-10 19:04:08 +00004847}</pre>
4848
Daniel Veillard91e9d582001-02-26 07:31:12 +00004849<p>Here are a couple of things to notice:</p>
Daniel Veillard14fff061999-06-22 21:49:07 +00004850<ul>
Daniel Veillard69839ba2006-06-06 13:27:03 +00004851 <li>Usually a recursive parsing style is the more convenient one: XML
4852 datais by nature subject to repetitive constructs and usually exhibits
4853 highlystructured patterns.</li>
4854 <li>The two arguments of type <em>xmlDocPtr</em>and <em>xmlNsPtr</em>,i.e.
4855 the pointer to the global XML document and the namespace reserved tothe
4856 application. Document wide information are needed for example todecode
4857 entities and it's a good coding practice to define a namespace foryour
4858 application set of data and test that the element and attributesyou're
4859 analyzing actually pertains to your application space. This isdone by a
4860 simple equality test (cur-&gt;ns == ns).</li>
4861 <li>To retrieve text and attributes value, you can use the
4862 function<em>xmlNodeListGetString</em>to gather all the text and entity
4863 referencenodes generated by the DOM output and produce an single text
4864 string.</li>
Daniel Veillard14fff061999-06-22 21:49:07 +00004865</ul>
Daniel Veillardb05deb71999-08-10 19:04:08 +00004866
Daniel Veillard69839ba2006-06-06 13:27:03 +00004867<p>Here is another piece of code used to parse another level of
4868thestructure:</p>
Daniel Veillard60979bd2000-07-10 12:17:33 +00004869<pre>#include &lt;libxml/tree.h&gt;
Daniel Veillard361d8452000-04-03 19:48:13 +00004870/*
Daniel Veillard14fff061999-06-22 21:49:07 +00004871 * a Description for a Job
4872 */
4873typedef struct job {
4874 char *projectID;
4875 char *application;
4876 char *category;
4877 personPtr contact;
4878 int nbDevelopers;
4879 personPtr developers[100]; /* using dynamic alloc is left as an exercise */
4880} job, *jobPtr;
4881
4882/*
4883 * And the code needed to parse it
4884 */
4885jobPtr parseJob(xmlDocPtr doc, xmlNsPtr ns, xmlNodePtr cur) {
4886 jobPtr ret = NULL;
4887
4888DEBUG("parseJob\n");
4889 /*
4890 * allocate the struct
4891 */
4892 ret = (jobPtr) malloc(sizeof(job));
4893 if (ret == NULL) {
4894 fprintf(stderr,"out of memory\n");
Daniel Veillardb05deb71999-08-10 19:04:08 +00004895 return(NULL);
Daniel Veillard14fff061999-06-22 21:49:07 +00004896 }
4897 memset(ret, 0, sizeof(job));
4898
4899 /* We don't care what the top level element name is */
Daniel Veillard60979bd2000-07-10 12:17:33 +00004900 cur = cur-&gt;xmlChildrenNode;
Daniel Veillard14fff061999-06-22 21:49:07 +00004901 while (cur != NULL) {
4902
Daniel Veillard60979bd2000-07-10 12:17:33 +00004903 if ((!strcmp(cur-&gt;name, "Project")) &amp;&amp; (cur-&gt;ns == ns)) {
4904 ret-&gt;projectID = xmlGetProp(cur, "ID");
4905 if (ret-&gt;projectID == NULL) {
Daniel Veillardb05deb71999-08-10 19:04:08 +00004906 fprintf(stderr, "Project has no ID\n");
4907 }
4908 }
Daniel Veillard60979bd2000-07-10 12:17:33 +00004909 if ((!strcmp(cur-&gt;name, "Application")) &amp;&amp; (cur-&gt;ns == ns))
4910 ret-&gt;application = xmlNodeListGetString(doc, cur-&gt;xmlChildrenNode, 1);
4911 if ((!strcmp(cur-&gt;name, "Category")) &amp;&amp; (cur-&gt;ns == ns))
4912 ret-&gt;category = xmlNodeListGetString(doc, cur-&gt;xmlChildrenNode, 1);
4913 if ((!strcmp(cur-&gt;name, "Contact")) &amp;&amp; (cur-&gt;ns == ns))
4914 ret-&gt;contact = parsePerson(doc, ns, cur);
4915 cur = cur-&gt;next;
Daniel Veillard14fff061999-06-22 21:49:07 +00004916 }
4917
4918 return(ret);
Daniel Veillardb05deb71999-08-10 19:04:08 +00004919}</pre>
Daniel Veillard14fff061999-06-22 21:49:07 +00004920
Daniel Veillard69839ba2006-06-06 13:27:03 +00004921<p>Once you are used to it, writing this kind of code is quite simple,
4922butboring. Ultimately, it could be possible to write stubbers taking either
4923Cdata structure definitions, a set of XML examples or an XML DTD and
4924producethe code needed to import and export the content between C data and
4925XMLstorage. This is left as an exercise to the reader :-)</p>
Daniel Veillardb05deb71999-08-10 19:04:08 +00004926
Daniel Veillard69839ba2006-06-06 13:27:03 +00004927<p>Feel free to use <a href="example/gjobread.c">the code for the full
4928Cparsing example</a>as a template, it is also available with Makefile in
4929theGnome CVS base under gnome-xml/example</p>
Daniel Veillardb05deb71999-08-10 19:04:08 +00004930
Daniel Veillardc310d562000-06-23 18:32:15 +00004931<h2><a name="Contributi">Contributions</a></h2>
4932<ul>
Daniel Veillard69839ba2006-06-06 13:27:03 +00004933 <li>Bjorn Reese, William Brack and Thomas Broyer have provided a number
4934 ofpatches, Gary Pennington worked on the validation API, threading
4935 supportand Solaris port.</li>
Daniel Veillardb8cfbd12001-10-25 10:53:28 +00004936 <li>John Fleck helps maintaining the documentation and man pages.</li>
Daniel Veillard69839ba2006-06-06 13:27:03 +00004937 <li><a href="mailto:igor@zlatkovic.com">Igor Zlatkovic</a>is now
4938 themaintainer of the Windows port, <a
4939 href="http://www.zlatkovic.com/projects/libxml/index.html">he
4940 providesbinaries</a></li>
4941 <li><a href="mailto:Gary.Pennington@sun.com">Gary Pennington</a>provides<a
4942 href="http://garypennington.net/libxml2/">Solaris binaries</a></li>
Daniel Veillarde356c282001-03-10 12:32:04 +00004943 <li><a
Daniel Veillard69839ba2006-06-06 13:27:03 +00004944 href="http://mail.gnome.org/archives/xml/2001-March/msg00014.html">MattSergeant</a>developed
4945 <a href="http://axkit.org/download/">XML::LibXSLT</a>, a Perl wrapper
4946 forlibxml2/libxslt as part of the <a href="http://axkit.com/">AxKit
4947 XMLapplication server</a></li>
4948 <li><a href="mailto:fnatter@gmx.net">Felix Natter</a>and <a
4949 href="mailto:geertk@ai.rug.nl">Geert Kloosterman</a>provide <a
4950 href="libxml-doc.el">an emacs module</a>to lookup libxml(2)
4951 functionsdocumentation</li>
4952 <li><a href="mailto:sherwin@nlm.nih.gov">Ziying Sherwin</a>provided <a
Daniel Veillardaf43f632002-03-08 15:05:20 +00004953 href="http://xmlsoft.org/messages/0488.html">man pages</a></li>
Daniel Veillard5168dbf2001-07-07 00:18:23 +00004954 <li>there is a module for <a
Daniel Veillard69839ba2006-06-06 13:27:03 +00004955 href="http://acs-misc.sourceforge.net/nsxml.html">libxml/libxslt
4956 supportin OpenNSD/AOLServer</a></li>
4957 <li><a href="mailto:dkuhlman@cutter.rexx.com">Dave Kuhlman</a>provided
4958 thefirst version of libxml/libxslt <a
Daniel Veillard2d347fa2002-03-17 10:34:11 +00004959 href="http://www.rexx.com/~dkuhlman">wrappers for Python</a></li>
Daniel Veillard1aadc442001-11-28 13:10:32 +00004960 <li>Petr Kozelka provides <a
Daniel Veillard69839ba2006-06-06 13:27:03 +00004961 href="http://sourceforge.net/projects/libxml2-pas">Pascal units to
4962 gluelibxml2</a>with Kylix and Delphi and other Pascal compilers</li>
4963 <li><a href="mailto:aleksey@aleksey.com">Aleksey Sanin</a>implemented the<a
4964 href="http://www.w3.org/Signature/">XML Canonicalization and XMLDigital
4965 Signature</a><a href="http://www.aleksey.com/xmlsec/">implementations for
4966 libxml2</a></li>
4967 <li><a href="mailto:Steve.Ball@explain.com.au">Steve
4968 Ball</a>andcontributors maintain <a
4969 href="http://tclxml.sourceforge.net/">tclbindings for libxml2 and
4970 libxslt</a>, as well as <a
4971 href="http://tclxml.sf.net/tkxmllint.html">tkxmllint</a>a GUI forxmllint
4972 and <a href="http://tclxml.sf.net/tkxsltproc.html">tkxsltproc</a>a GUI
4973 for xsltproc.</li>
Daniel Veillardc310d562000-06-23 18:32:15 +00004974</ul>
4975
Daniel Veillardc8eab3a1999-09-04 18:27:23 +00004976<p></p>
Daniel Veillardccb09631998-10-27 06:21:04 +00004977</body>
4978</html>