[mod_python] XSLT and mod_python

Richard Lewis richardlewis at fastmail.co.uk
Wed May 23 12:16:04 EDT 2007

On Wednesday 23 May 2007 16:50:59 Martijn Moeling wrote:
> Hi,
> I am currently looking into XSLT and to build support for it in my
> mod_python based Browser OS/Desktop, I prefer to use standards and I
> prefer Native compiled/compilable stuff.
> Suit4 is not my idea of a solution.
> I came across mod_xslt2 for apache has anyone used this in conjunction
> with MP?
I've used libxslt with mod_python.

There are raw Python bindings[1] for libxslt/libxml but they have a few 
drawbacks: bad API; and memory leaks.

Therefore I use lxml[2] which implements Fredrik Lundh[3]'s ElementTree[4] 
interface (which is now part of the Python standard library, as of 2.5[5]) as 
a wrapper around libxml/libxslt. Its a very nice way to work with XML/XSLT in 
Python as its /very/ fast and it creates nice Pythonic data structures as a 
result of your XSLT transformations which you can then go on to manipulate in 
code (or just write to a string or file-like object). The only problem I've 
had with it is, I /think/, that its causing crashing of the mod_python's 
Python interpreter when you use <xsl:import />. As I said, I /think/ this is 
what's causing these crashes, but I'm not sure yet.

I used to work on a Cocoon[6]-like project[7] using mod_python and lxml. My 
co-developer has now taken the reigns of this project as is working with 
WSGI[8] rather than specifically mod_python. </shameless-plug> ;-)


[1] http://xmlsoft.org/python.html
[2] http://codespeak.net/lxml/
[3] http://effbot.org/zone/about.htm
[4] http://effbot.org/zone/element-index.htm
[5] http://docs.python.org/lib/module-xml.etree.ElementTree.html
[6] http://cocoon.apahce.org/
[7] http://code.google.com/p/pycoon
[8] http://www.python.org/dev/peps/pep-0333/
Richard Lewis
JID: ironchicken at jabber.earth.li

More information about the Mod_python mailing list