[lxml-dev] XInclude does not support Resolvers?

Stefan Behnel behnel_ml at gkec.informatik.tu-darmstadt.de
Sat Dec 2 22:14:30 CET 2006


Hi,

Martijn Faassen wrote:
> I'm fine with supporting something Python-based in addition to the
> libxml2 version, but I think the XInclude implementation in libxml2 has
> the benefit in that it's probably fairly complete and besides, *they*'re
> maintaining it, not us. :) So, I'm fine with adding our own XInclude
> support, as long as it's in addition and not a replacement, along the
> same lines as the way we support ElementTree's 'find' together with our
> own 'xpath'.

I copied ET's ElementInclude module over to lxml (trunk) and modified it a
bit. The related tests in ET's selftest.py pass (with one minor exception),
although the serialisations can look a little different (so I had to fix the
doctests a little).

The implementation is adapted in that it uses Element.getiterator() to find
the XInclude elements. I also had to extend lxml's API in order to make the
original parser of a document available at the API level. There is now a
'parser' property on _ElementTree that is used by ElementInclude to provide
the same parser configuration (including resolvers) as for the source document.

It's not tested much, so I'd be glad if others could give it a try.

Hope it's useful,
Stefan


More information about the lxml-dev mailing list