[XML-SIG] Re: PyXML, 4suite, libxml2... what should I choose?

Uche Ogbuji Uche.Ogbuji at fourthought.com
Sun Dec 5 23:20:47 CET 2004


On Mon, 2004-11-29 at 22:06 +0100, Paul Boddie wrote:
> Frans Englich wrote:
> >
> > Currently, I pipe out my structures to libxml2/libxslt's xmllint/xsltproc
> > for doing validation, and XSLT processing. libxml2 is capable, but the
> > solution is ugly, and slow(de-serialization/serialization). In addition, I
> > lack XPath functionality. I have no intentions to skip Python's XML
> > structures, and use for example libxml2's.
> 
> Although it was written to meet my own simple needs, I suggest you take a look 
> at libxml2dom:
> 
> http://www.python.org/pypi?:action=display&name=libxml2dom
> 
> It should be possible to feed DOM nodes from libxml2dom into PyXML's XPath 
> implementation, although I suppose I ought to wrap the libxml2 XPath 
> functionality itself in order to be able to drop that particular dependency 
> on PyXML. I did hear something about 4Suite and XPath convenience methods on 
> nodes, and that did make me wonder if some kind of standard might emerge that 
> I could implement in libxml2dom.

It's no-brainer stuff.  On any node object:

node.xpath('path/to/desired/child[predicate-or-whatever]')

The node itself serves as the context node, the only item in the context
list, which is set to position() = 1.  Namespace bindings are extracted
from in-scope namespaces for that node.  Variable bindings can be passed
in as an optional second dictionary parameter.

You're welcome to emulate that API, of course.  If you have any
feedback, let us know.

> Anyway, I've been using libxml2dom with libxslt without unnecessary 
> serialisation, so this may be what you're looking for. If you and others want 
> to improve the software, I may establish a SourceForge project for it and let 
> development follow that course.

Building a smoother DOM interface to libxml2 is a very valuable service.
Perhaps, however, you want to pool your efforts with the lxml/vlibxml2
folks?  They seem to be more focused on rationalizing memory management,
which seems a useful complement to your focus.


-- 
Uche Ogbuji                                    Fourthought, Inc.
http://uche.ogbuji.net    http://4Suite.org    http://fourthought.com
Use CSS to display XML - http://www.ibm.com/developerworks/edu/x-dw-x-xmlcss-i.html
Location, Location, Location - http://www.xml.com/pub/a/2004/11/24/py-xml.html
The State of Python-XML in 2004 - http://www.xml.com/pub/a/2004/10/13/py-xml.html
Be humble, not imperial (in design) - http://www.adtmag.com/article.asp?id=10286
XMLOpen and more XML Hacks - http://www.ibm.com/developerworks/xml/library/x-think27.html
A survey of XML standards - http://www-106.ibm.com/developerworks/xml/library/x-stand4/



More information about the XML-SIG mailing list