RE: [xml] Delphi bindings for libxml2
- From: <Eric Zurcher csiro au>
- To: <xml gnome org>
- Cc: igor zlatkovic com
- Subject: RE: [xml] Delphi bindings for libxml2
- Date: Fri, 4 Feb 2005 12:40:47 +1100
-----Original Message-----
From: Igor Zlatkovic [mailto:igor zlatkovic com]
Sent: Friday, 4 February 2005 4:49 AM
To: Zurcher, Eric (LI, Black Mountain)
Subject: Re: [xml] Delphi bindings for libxml2
On 03.02.2005 00:05, Eric Zurcher csiro au wrote:
Hello all,
It is now almost exactly 2 years since the last update of Petr
Kozelka's Pascal units for accessing libxml2 and
libxslt(available at
http://sourceforge.net/projects/libxml2-pas). Those units
corresponded to release 2.5.10 of libxml2. Since then, there have
been a number of significant additions to the libxml2 API, such as
the addition of the SAX2 parser.
I make extensive use of libxml2 in several of my Delphi
applications,
and wanted to be able to make use of the faster SAX2 code, so I
thought I'd try updating the bindings on my own. I first tried using
h2pas, but found that it didn't work as well as I had hoped (perhaps
a result of my inexperience in its use). As an alternative, I put
together an XSLT transformation to generate the bindings from
libxml2-api.xml (and its libxslt counterparts), rather than from the
*.h files. This approach seems to have worked well, with the output
of the transformation requiring only a tiny bit of manual editing.
I have tried several times to contact Petr to see whether he would
like to incorporate my binding into his libxml2-pas project on
sourceforge, but I have received no response from him. I am writing
now to see whether anyone else is interested this code, or in
providing a "home" for it so that it can be distributed (preferably
under the terms of the MIT license) to any who wish to use it.
I can put the code on zlatkovic.com together with the Windows binaries.
It will be automatically mirrored on xmlsoft.org. I can give you a shell
account on zlatkovic.com so you can update the package(s).
Ciao,
Igor
Thanks, Igor. I think I'll take up your offer. At this stage, I am only
able to test these bindings using Delphi on a Windows platform, so it
makes sense to keep them associated with the Windows distribution,
rather than with gnome. Can we discuss the details off-list, then make
a posting when all is ready?
In repsonse to Kasimier's queries:
This is good to hear! Will the bindings be Kylix compatible as well?
The bindings ought to work with Kylix, but I have tested them using only a
very simple example. I do not intend to support Pascal compilers other than
Delphi/Kylix, but if someone else wishes to take up that challenge, they
are of course welcome to do so, with my blessing.
Will it follow the namings used in Libxml2-pas? E.g. the "PxmlChar"?
There are some differences, but these could be changed fairly readily
if compatibility is important. The differences include: (1) Use of
enumerated types with assigned ordinal values, rather that the use of
constant integers, for "enum" values. (2) Use of the libxml2 convention of
naming pointer types by appending "Ptr" (e.g., xmlCharPtr), rather than the
Delphi convention of prepending a "P" (e.g., PxmlChar). Exceptions are
those types pre-defined by Delphi (e.g. PPChar, PDouble).
By the way, we realized that mapping the memory functions to use the
Delphi memory-manager in the initialization part of the libxml2.pas
unit is not adviseable, since if using DLLs every DLLs will overwrite
the previous mapping, resulting in the function pointers being invalid
for all DLLs when the last DLL which mapped is unloaded.
Yes, that is not a good approach when using DLLs, and I don't use it.
Instead, I use a bit of indirection to make use of the xmlMalloc, xmlFree,
etc., exported by the libxml2 DLL.
I should mention that there are a few quirks relating to imported variables,
since Object Pascal does not formally support importing of variables from
shared libraries. However, it is possible to use addresses obtained from
GetProcAddress to gain access to these variables.
Cheers,
Eric Zurcher
CSIRO Livestock Industries
Canberra, Australia
Eric Zurcher csiro au
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]