# Libxml Frequently Asqued Questions

Location: http://xmlsoft.org/FAQ.html

Libxml home page: http://xmlsoft.org/

Mailing-list archive: http://xmlsoft.org/messages/

Version: $Revision: 1.4 $

Table of Content:

- Licence(s)
- Installation
- Compilation
- Developper corner

## Licence(s)

1. Licensing Terms for libxml

   libxml is released under 2 (compatible) licences:

   - the LGPL: GNU Library General Public License
   - the W3C IPR: very similar to the XWindow licence
2. Can I embed libxml in a proprietary application ?

   Yes. The W3C IPR allows you to also keep proprietary the changes you made to libxml, but it would be graceful to provide back bugfixes and improvements as patches for possible incorporation in the main developement tree

## Installation

1. Where can I get libxml ?

   The original distribution comes from rpmfind.net or gnome.org

   Most linux and Bsd distribution includes libxml, this is probably the safer way for end-users

   David Doolin provides precompiled Windows versions at http://www.ce.berkeley.edu/~doolin/code/libxmlwin32/

2. I see libxml and libxml2 releases, which one should I install ?
   - If you are not concerned by any existing backward compatibility with existing application, install libxml2 only
   - If you are not doing development, you can safely install both. usually the packages libxml and libxml2 are compatible (this is not the case for development packages)
   - If you are a developper and your system provides separate packaging for shared libraries and the development components, it is possible to install libxml and libxml2, and depending on your development needs have either libxml-devel or libxml2-devel too
   - If you are developping a new application, please develop against libxml2(-devel)
3. I can't install the libxml package it conflicts with libxml0

   You probably have an old libxml0 package used to provide the shared library for libxml.so.0, you can probably safely remove it. Anyway the libxml packages provided on rpmfind.net provides libxml.so.0

## Compilation

1. What is the process to compile libxml ?

   As most UNIX libraries libxml follows the "standard":

   `gunzip -c xxx.tar.gz | tar xvf -`

   `cd libxml-xxxx`

   `./configure --help`

   to see the options, then the compilation/installation proper

   `./configure [possible options]`

   `make`

   `make install`

   At that point you may have to rerun ldconfig or similar utility to update your list of installed shared libs.

2. What other libraries are needed to compile/install libxml ?

   Libxml does not requires any other library, the normal C ANSI API should be sufficient (please report any violation to this rule you may find).

   However if found at configuration time libxml will deect and use the following libs:

   - libz: a highly portable and available widely compression library
   - iconv: a powerful character encoding conversion library. It's included by default on recent glibc libraries, so it doesn't need to be installed specifically on linux. It seems it's now part of the official UNIX specification. Here is one implementation of the library which source can be found here.
3. The Makefile for the example gjobread is not generated

   This is due to a circular dependancy in automake. No solution found so far (if you know how to fix this the patch will be very welcome), that failure won't affect the actually building of the xml library. You can later go in and create the example Makefile by hand or reuse the following:

       CC=gcc
               CFLAGS=`xml-config --cflags`
               LDFLAGS=`xml-config --libs`

               all: gjobread

               clean:
               <TAB>@(rm -f gjobread gjobread.o)

               gjobread.o : gjobread.c
               <TAB>$(CC) $(CFLAGS) -c gjobread.c

               gjobread: gjobread.o
               <TAB>$(CC) -o gjobread gjobread.o $(LDFLAGS)

4. libxml does not compile with HP-UX's optional ANSI-C compiler

   this is due to macro limitations. Try to add " -Wp,-H16800 -Ae" to the CFLAGS

   you can also install and use gcc instead or use a precompiled version of libxml, both available from the HP-UX Porting and Archive Centre

5. make check fails on some platforms

   Sometime the regression tests results don't completely match the value produced by the parser, and the makefile uses diff to print the delta. On some platforms the diff return breaks the compilation process, if the diff is small this is probably not a serious problem

## Developper corner

1. I get compilation errors of existing code like when accessing root or childs fields of nodes

   You are compiling code developped for libxml version 1 and using a libxml2 developement environment. Either switch back to libxml v1 devel or even better fix the code to compile with libxml2 (or both) by following the instructions.

2. I get compilation errors about non existing xmlRootNode or xmlChildrenNode fields

   The source code you are using has been upgraded to be able to compile with both libxml and libxml2, but you need to install a more recent version: libxml(-devel) >= 1.8.8 or libxml2(-devel) >= 2.1.0

3. XPath implementation looks seriously broken

   True, it's incomplete and the version released in 2.0.0 was nearly unusable. A set of patches from Picdar Technology have been integrated in 2.1.0 fixing the most nasty bugs. But there is still bugs and its incomplete. Patches and bug reports are welcome. This will be worked out, XPath implementation is not abandonned, just a momentary lack of time.

4. The example provided in the web page does not compile

   It's hard to maintain the documentation in sync with the code <grin/> ...

   Check the previous points 1/ and 2/ raised before, and send patches.

5. Where can I get more examples and informations than in the web page

   Ideally a libxml book would be nice. I have no such plan ... But you can:

   - check more deeply the existing generated doc
   - looks for examples of use for libxml function using the Gnome code for example the following will query the full Gnome CVs base for the use of the xmlAddChild() function:

     http://cvs.gnome.org/lxr/search?string=xmlAddChild

     This may be slow, a large hardware donation to the gnome project could cure this :-)

   - Browse the libxml source, I try to write code as clean and documented as possible, so looking at it may be helpful
6. What about C++ ?

   libxml is written in pure C in order to allow easy reuse on a number of platforms, including embedded systems. I don't intend to convert to C++.

   There is however a C++ wrapper provided by Ari Johnson <ari@btigate.com> which may fullfill your needs:

   Website: http://lusis.org/~ari/xml++/

   Download: http://lusis.org/~ari/xml++/libxml++.tar.gz

7. How to validate a document a posteriori ?

   It is possible to validate documents which had not been validated at initial parsing time or documents who have been built from scratch using the API. Use the xmlValidateDtd() function. It is also possible to simply add a Dtd to an existing document:

       xmlDocPtr doc; /* your existing document */
               xmlDtdPtr dtd = xmlParseDTD(NULL, filename_of_dtd); /* parse the DTD */
               dtd->name = xmlStrDup((xmlChar*)"root_name"); /* use the given root */

               doc->intSubset = dtd;
               if (doc->children == NULL) xmlAddChild((xmlNodePtr)doc, (xmlNodePtr)dtd);
               else xmlAddPrevSibling(doc->children, (xmlNodePtr)dtd);

8. etc ...

Daniel Veillard

$Id: FAQ.html,v 1.4 2000/10/16 16:58:19 veillard Exp $