[mod_python] Outgoing apache handler

Lee Brown administrator at leebrown.org
Thu May 12 09:16:42 EDT 2005


A filter might (or might not) be the best place to do this.  XSLT transform
engines like Xalan want to have the whole source document available in one
chunk, but a filter object has no way of knowing that it has the whole
source stream available to it when called.  (It might, it might not; you'd
have to run some test cases to be sure.)

A "brute force" way to implement the transform as a filter would be to use
something like Saxon, which can handle piecewise data input, but the
downside to that is that you'd end up writing your own transform engine in

Doing the transform in the content phase, however, allows you to fetch the
entire source document and feed it to the transform engine.  Another
advantage of doing it in the content phase is that it gives you a chance to
"tweak" the result tree.

In the application I'm currently working on, I have a mixture of both static
and dynamic content to be served.  I use XSLT to build up the static content
from XML data and then I inject computed content by manipulating the result
tree DOM.  This works pretty well, though using PyXML to manipulate the DOM
is a lot slower that using Pyana to do straight transforms.  My next
development step is to figure out a way to pre-process the dynamic content
into an XML stream so that I can build the content all in one shot through
the XSLT engine.

Best Regards,
Lee E. Brown
(administrator at leebrown.org)

-----Original Message-----
From: mod_python-bounces at modpython.org
[mailto:mod_python-bounces at modpython.org] On Behalf Of Nicolas Lehuen
Sent: Monday, May 09, 2005 5:05 AM
To: Simon Wittber
Cc: mod_python at modpython.org
Subject: Re: [mod_python] Outgoing apache handler

I have done nothing similar, but I think the way to go would be to implement
a filter. See :




2005/5/9, Simon Wittber <simonwittber at gmail.com>:
> Hello chaps.
> I want to write a handler which will process outgoing xml files.
> It will check for an xsl stylesheet declaration, and transform the xml 
> server side before sending the content to the browser.
> My question is, which apache phase should I add this handler to, and 
> has anyone else done something similar?
> Sw.
> _______________________________________________
> Mod_python mailing list
> Mod_python at modpython.org
> http://mailman.modpython.org/mailman/listinfo/mod_python

Mod_python mailing list
Mod_python at modpython.org

More information about the Mod_python mailing list