libxmlの使用条件
libxmlは、MITライセンスの元にリリースされています。正確な表現は配布されている中にあるコピーライトに関するファイルを参照してください。
libxmlを私のアプリケーションの中に埋め込むことが出来ますか?
はい。MITライセンスは、libxmlに対して私的な変更を加える事も許可しています。しかし、バグフィックスやメインの開発作業に組み入れる事の可能な改良パッチなどを提供してくださると幸いです。
Where can I get libxml ?
The original distribution comes from rpmfind.net or gnome.org
Most Linux and BSD distributions include libxml, this is probably the safer way for end-users
David Doolin provides precompiled Windows versions at
I see libxml and libxml2 releases, which one should I install ?
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
I can't install the libxml(2) RPM package due to failed dependencies
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 (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.
どこでlibxmlを手に入れる事が出来ますか?
オリジナルの配布物はrpmfind.netかgnome.orgにあります。
ほとんどのLinuxとBSDのディストリビューションはおそらくエンドユーザに安全な方法でlibxmlを含める事が出来ます。
David Doolin氏がコンパイル前のWindows版を以下で提供しています。
http://www.ce.berkeley.edu/~doolin/code/libxmlwin32/(訳注:リンク切れ?)
libxmlとlibxml2どちらかをインストールすべきか?
libxml0と衝突して、libxmlパッケージをインストールすることが出来ません。
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
依存関係の失敗のためにlibxml(2)のRPMパッケージをインストールすることが出来ません。
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 (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.
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.
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 detect and use the following libs:
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.
Sometimes (especially on Solaris) make checks fails due to limitations in make. Try using GNU-make instead.
I use the CVS version and there is no configure script
The configure (and other Makefiles) are generated. Use the autogen.sh script to regenerate the configure and Makefiles, like:
./autogen.sh --prefix=/usr --disable-shared
I have troubles when running make tests with gcc-3.0
It seems the initial release of gcc-3.0 has a problem with the optimizer which miscompiles the URI module. Please use another compiler
libxmlのコンパイル手順は?
ほとんどのUNIXライブラリと同様、以下の"標準"に従います。
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.
libxmをコンパイル及びインストールするためには、他にどのようなライブラリが必要ですか?
Libxmlは他のどのようなライブラリも必要としません。 標準的なC ANSI APIで十分でしょう。(この規則違反を見つけたなら、ご報告ください。).
しかしながら、次のようなライブラリを設定時に見つけたならば、libxmlはこれらを使用します。
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.
Sometimes (especially on Solaris) make checks fails due to limitations in make. Try using GNU-make instead.
I use the CVS version and there is no configure script
The configure (and other Makefiles) are generated. Use the autogen.sh script to regenerate the configure and Makefiles, like:
./autogen.sh --prefix=/usr --disable-shared
I have troubles when running make tests with gcc-3.0
It seems the initial release of gcc-3.0 has a problem with the optimizer which miscompiles the URI module. Please use another compiler
xmlDocDump() generates output on one line
libxml 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:
Extra nodes in the document:
For a 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 case where you are sure there is no mixed-content in the document.
I get compilation errors of existing code like when accessing root or childs fields of nodes
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.
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
XPath implementation looks seriously broken
XPath implementation prior to 2.3.0 was really incomplete, upgrade to a recent version, there is no known bug in the current version.
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.
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:
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 :-)
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 few C++ wrappers which may fulfill your needs:
by Ari Johnson <ari@btigate.com>:
Website: http://lusis.org/~ari/xml++/
by Peter Jones <pjones@pmade.org>
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);
etc ...
xmlDocDump() generates output on one line
libxml 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:
Extra nodes in the document:
For a 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 case where you are sure there is no mixed-content in the document.
I get compilation errors of existing code like when accessing root or childs fields of nodes
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.
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
XPath implementation looks seriously broken
XPath implementation prior to 2.3.0 was really incomplete, upgrade to a recent version, there is no known bug in the current version.
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.
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:
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 :-)
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 few C++ wrappers which may fulfill your needs:
by Ari Johnson <ari@btigate.com>:
Website: http://lusis.org/~ari/xml++/
by Peter Jones <pjones@pmade.org>
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);
etc ...