Good XML tools?

Alan Kennedy alanmk at hotmail.com
Wed Jul 31 06:05:51 EDT 2002


Laurent Szyster wrote:
> In many case (if not most) XML processing is far easier with a
> dedicated language like XSLT. Use Python to generate XML and/or
> XSLT, but don't use it to transform XML: XSLT is far better at it.

I strongly disagree.

Have you looked at Zope Page Templates at all? ZPT is a way of
controlling the generation of (X|HT)ML from python.

It is my own opinion that ZPT and Python is far superior to XSLT, for
the following reasons.

1. ZPT allows you to design your *ML page using GUI design tools. XSLT
makes this next to impossible.

2. ZPT allows you to validate the structure of your page templates
*before* transform. You can only validate the *output* of XSLT
templates.

3. ZPT is *much* simpler to learn than XSLT.

4. ZPT provides a full object-oriented language in which to write
code:python. Writing everything functionally with XSLT can be real
pain.

5. (To me this is the most important one): ZPT breaks the stricture
that only allows XSLT to use one XML document to control the
generation of another.

Consider the following

sourceDocument * template -> outputDocument

In XSLT, the sourceDocument can only be an XML document (unless you
use Xpath extension functions, in which case you're no longer writing
XSLT).

In ZPT, the sourceDocument can be anything you can fit into python
data structures, i.e. anything you like: database data, xml documents,
live feeds, calculation results, etc, etc, etc.

Admittedly, the concept of ZPT doesn't require Python. It could also
be implemented with, for example, Javascript. But Guido invented it,
and implemented it in Python, so it's definitely "Pythonic".

i-used-to-love-xslt-too-until-zpt-opened-my-eyes-ly-yrs

Alan Kennedy.



More information about the Python-list mailing list