[XML-SIG] Python / XML / XSLT vs. Cocoon for website server side

A.M. Kuchling amk at amk.ca
Fri Aug 15 08:02:36 EDT 2003

On Friday, August 15, 2003, at 02:27  AM, Richard Johannesson wrote:
>  Quixote? [seemed like to choice, but prefer standard markup like XSLT]

It would be straightforward to use XSLT templates in Quixote; there's 
no requirement to use PTL.  Let's say you have a bunch of data items as 
XML documents:

DATA = {'key1': '<?xml ...',

You would write a class that wraps a single data item:

class XSLTDataUI:
     XSLT_TEMPLATE = "/www/sites/xslt/data.xslt"

     def __init__ (self, key):
         self.data = DATA[key]

     # In the _q_index method, use some existing XSLT support
     def _q_index (self, request):
         output = XSLTProcess(self.XSLT_TEMPLATE, self.data)
         return output

To publish the data set, you would then write a _q_lookup() function 
that created instances of the UI class:

def _q_lookup (request, component):
     return XSLTDataUI(component)

You could subclass XSLTDataUI and override XSLT_TEMPLATE to use a 
different template, or override the __init__() to get data from an 
RDBMS, the filesystem, or whatever;
add a _q_lookup() method to the class and you can support a hierarchy 
of data documents; and so forth.


More information about the XML-SIG mailing list