deps/src/libxml2-2.9.1/doc/FAQ.html
| |
|
|
|
|
|
|
|
|
|
| Main Menu | |
|
| Related links | |
|
|
|
|
|
|
Table of Contents:
libxml2 is released under the MIT License; see the file Copyright in the distribution for the precise wording
Yes. The MIT License allows you to keep proprietary the changes you made to libxml, but it would be graceful to send-back bug fixes and improvements as patches for possible incorporation in the main development tree.
Do Not Use libxml1 , use libxml2
Where can I get libxml ?
The original distribution comes from xmlsoft.org or gnome.org
Most Linux and BSD distributions include libxml, this is probably the safer way for end-users to use libxml.
David Doolin provides precompiled Windows versions at http://www.ce.berkeley.edu/~doolin/code/libxmlwin32/
You probably have an old libxml0 package used to provide the shared library for libxml.so.0, you can probably safely remove it. The libxml packages provided on xmlsoft.org provide libxml.so.0
The most generic solution is to re-fetch the latest src.rpm , and rebuild it locally with
rpm --rebuild libxml(2)-xxx.src.rpm.
If everything goes well it will generate two binary rpm packages (one providing the shared libs and xmllint, and the other one, the -devel package, providing includes, static libraries and scripts needed to build applications with libxml(2)) that you can install locally.
As most UNIX libraries libxml2 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 a similar utility to update your list of installed shared libs.
Libxml2 does not require 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 libxml2 will detect and use the following libs:
Sometimes 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.
Sometimes (especially on Solaris) make checks fail due to limitations in make. Try using GNU-make instead.
The configure script (and other Makefiles) are generated. Use the autogen.sh script to regenerate the configure script and Makefiles, like:
./autogen.sh --prefix=/usr --disable-shared
It seems the initial release of gcc-3.0 has a problem with the optimizer which miscompiles the URI module. Please use another compiler.
Usually the problem comes from the fact that the compiler doesn't get the right compilation or linking flags. There is a small shell script xml2-config which is installed as part of libxml2 usual install process which provides those flags. Use
xml2-config --cflags
to get the compilation flags and
xml2-config --libs
to get the linker flags. Usually this is done directly from the Makefile as:
CFLAGS=xml2-config --cflags``
LIBS=xml2-config --libs``
There are many different ways to accomplish this. Here is one way to do this under Linux. Suppose your home directory is /home/user. Then:
myxml/home/user/myxml/libxml2 )--prefix" switch, specifying an installation subdirectory in /home/user/myxml, e.g../configure --prefix /home/user/myxml/xmlinst {other configuration options}
now run make followed by make install
/home/user/myxml/xmlinst/lib, /home/user/myxml/xmlinst/include and /home/user/myxml/xmlinst/bin
export PATH=/home/user/myxml/xmlinst/bin:$PATH
Now suppose you have a program test1.c that you would like to compile with your "private" library. Simply compile it using the command
gcc xml2-config --cflags --libs -o test test.c
Note that, because your PATH has been set with /home/user/myxml/xmlinst/bin at the beginning, the xml2-config program which you just installed will be used instead of the system default one, and this will automatically get the correct libraries linked with your program.
Libxml2 will not invent spaces in the content of a document since all spaces in the content of a document are significant. If you build a tree from the API and want indentation:
the correct way is to generate those yourself too.
the dangerous way is to ask libxml2 to add those blanks to your content modifying the content of your document in the process. The result may not be what you expect. There is NO way to guarantee that such a modification won't affect other parts of the content of your document. See xmlKeepBlanksDefault () and xmlSaveFormatFile ()
Extra nodes in the document:
For an XML file as below:
<?xml version="1.0"?>
<PLAN xmlns="http://www.argus.ca/autotest/1.0/">
<NODE CommFlag="0"/>
<NODE CommFlag="1"/>
</PLAN>
after parsing it with the function pxmlDoc=xmlParseFile(...);
I want to the get the content of the first node (node with the CommFlag="0")
so I did it as following;
xmlNodePtr pnode;
pnode=pxmlDoc->children->children;
but it does not work. If I change it to
pnode=pxmlDoc->children->children->next;
then it works. Can someone explain it to me.
In XML all characters in the content of the document are significant including blanks and formatting line breaks.
The extra nodes you are wondering about are just that, text nodes with the formatting spaces which are part of the document but that people tend to forget. There is a function xmlKeepBlanksDefault () to remove those at parse time, but that's an heuristic, and its use should be limited to cases where you are certain there is no mixed-content in the document.
You are compiling code developed for libxml version 1 and using a libxml2 development environment. Either switch back to libxml v1 devel or even better fix the code to compile with libxml2 (or both) by following the instructions.
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
Read and follow all advices on the thread safety page, and make 100% sure you never call xmlCleanupParser() while the library or an XML document might still be in use by another thread.
It's hard to maintain the documentation in sync with the code <grin/> ...
Check the previous points 1/ and 2/ raised before, and please send patches.
Ideally a libxml2 book would be nice. I have no such plan ... But you can:
libxml2 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 which may fulfill your needs:
It is possible to validate documents which had not been validated at initial parsing time or documents which 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);
It is a null terminated sequence of utf-8 characters. And only utf-8! You need to convert strings encoded in different ways to utf-8 before passing them to the API. This can be accomplished with the iconv library for instance.
|
|
|
|
|