[XML-SIG] XML from scratch and transformation with XSLT

Peter Herndon tpherndon at gmail.com
Sat Apr 1 01:38:26 CEST 2006

On Mar 31, 2006, at 2:46 PM, Marc Garcia wrote:

> I want to make a simple program in python that get data from a  
> database
> (or other source), create a new xml document with it and then parse it
> with an existing xslt sheet.

Why would you do this?  That is, you are pulling data from a database  
into Python, then transforming it into XML, then running that XML  
through an XSLT transformation.  Why not pull the data into Python,  
manipulate them in Python, then output as the end-result XML?  That  
is, transcribe from Python directly to the desired final XML format?

I can think of a couple of reasons to do it your way -- the XSLT  
engine might well be faster than the Python transformation, it might  
be easier to output simple XML and then expand it via XSLT, etc. --  
but I'm wondering if you've considered the above simpler path?  It  
might make your life easier.

> Do somebody know what is the simplest way to achieve it? I'm having  
> some
> problems with all of it (encoding problems, installation bugs, more  
> than
> one library required...) and I need some expert tips to know what  
> way I
> have to work on.

I'm hardly an expert, and your email doesn't present enough data to  
make any specific recommendations, but I'd suggest using (c) 
ElementTree as your XML library, if it meets your requirements.  You  
could pull the data in, do your manipulations in Python, then create  
your XML using ElementTree.  And it will solve your installation  
issues if you can afford to wait long enough -- it will be in the  
standard library for Python 2.5.  Otherwise, ElementTree itself is  
pure Python, and is thus easily installed, though there is an  
optional C extension (cElementTree) that will improve performance.


More information about the XML-SIG mailing list