Preferred tool for folding XML into HTML

Laurent Szyster laurent.szyster at q-survey.be
Wed Jan 9 10:31:16 EST 2002


Peter Hansen wrote:
> 
> Laurent Szyster wrote:
> >
> > By the way, I advise you to pick wathever XSLT engine available
> > on your platform and pipe the XML into it from Python. An XSLT
> > engine written in Python is a non-sense. Providing Python binding
> > to an XSLT library is *The Right Thing* to do.
> 
> Why ever would you say this?  Surely, except _possibly_ for reasons
> of performance, there is no logic in the above statement.

Bbecause I wrote one "XSLT-like" engine with Python ;-)

Actually it is more an XSLT-stylesheet-to-Python-module compiler
than an engine. I thought (three years ago) that waiting for a free
C library with Python binding would be too long. Also, the project
needed custom FO elements.

The main problem is the DOM: creating all these nodes takes time.
Actually, even with Greg Stein minimalistic DOM builder, more than
90% of the time it takes to instanciate a DOM from an XML stream
is gobbled by object creation. Python _is_ slow at instanciation.

About 10 times slower than Java, 100 times slower than C.

> And if performance is thought to be the issue, wouldn't one need to
> have actual minimum performance requirements in mind, and to measure
> the performance of a Python solution and determine that it is
> inadequate, before one could say using Python is nonsense?

As Cameron pointed out, a difference of two orders of magnitude does
matter, whatever the requirements.

The only balanced approach would be to add the simplest possible
DOM in a C module (I would suggest Greg Stein's one) using
kjbuckets for fast graph and sets algebra (that's a nice way to
index and query a DOM) and a Python XSLT compiler that produces
python modules using this XPATH-enabled DOM module.

Now that stable, cross-platform Python binding exists for libxslt
and Xalan, I'm not sure there's still a need for a specific Python
solution (unless you want to write your own language for XML
transformation, of course *~).


Laurent



More information about the Python-list mailing list