[lxml-dev] Request for help on testing new libxml2 feature

Stefan Behnel behnel_ml at gkec.informatik.tu-darmstadt.de
Thu Feb 2 16:30:54 CET 2006



Kasimier Buchcik wrote:
> On Wed, 2006-02-01 at 20:55 +0100, Andreas Pakulat wrote:
>> regarding the remove-redundant-namespaces issue there are news:
>>
>> kbuchcik implemented the xmlDOMWrapReconcileNamespaces in tree.c of
>> libxml2 so it should remove redundant NS decl. However neither do I have
>> any experience with libxml2 nor do I have the time to dig into it so
>> that I can build a test program for this.
>>
>> Thus I ask you guys here, who surely are libxml2 experts, if you could
>> help me out here. Either some "hack" for lxml that allows me to test
>> this or a small programm that takes an xml file and applies this
>> function to it's DOM tree (and outputs the result) would be really
>> great.
> 
> Note that removal of redundant ns-decls in 
> xmlDOMWrapReconcileNamespaces() was committed to CVS just
> yesterday and I fixed some bugs today; I peformed only rudimental
> tests, so more testing would be appreciated.
> 
> Andreas' bug-entry:
> http://bugzilla.gnome.org/show_bug.cgi?id=329347

Ok, I think we cannot easily depend on CVS versions of libxml2 in lxml, so
this rather experimental feature will not be supported in lxml for a while.

As a work around this kind of problems with libxml2 versions, we *could*
support something like conditional *compilation* in lxml, depending on the
libxml2 version. It's not beautiful, but I could imagine something like this,
related to the new I/O API and Geert's/Patrick's patches:

class XMLFormatter:
    def __init__(..., xhtml=False, ...):
        if xhtml:
            if LIBXML_VERSION < 20623:
                 raise VersionError, \
                       "Libxml version >= 2.6.23 needed for XHTML formatting"
            else:
                 ...

This would allow us to keep a consistent API, while supporting different
versions of libxml2 and their diverging features. This obviously only works
for libxml2 versions that provide all API functions used by the lxml code,
since they must be available at compile time.

I actually haven't tested this, but it may even work. Anyway, for now, this is
only an idea. So far, we do not even have code that needs this. But is may
make the change to Geert's output features simpler and may also allow us to
support experimental features of libxml2.

Stefan


More information about the lxml-dev mailing list