[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.python

Re: XML+Logs to Latex. XSLT?

Fredrik Lundh

1/10/2008 9:33:00 PM

Florencio Cano wrote:

> Yes. For sure. I though XSLT was something like XML not other
> "language" and that Python will have any library that uses XSLT to do
> transformation...

XSLT is definitely a language (it's turing complete, after all), but
that there are of course several Python bindings to XSLT libraries;
here's one:

http://codespeak...

> - First process the XML document with Python (sax?) and do the first
> Latex document.
> - Second process each log with Python and insert the information in
> the Latex document created in first step.

You can do it in several steps, or you could generate the Latex file in
one step, by first loading the XML structure into a Python data
structure, and then loading (and possibly writing out the formatted
version of) one log file after another.

But please don't use SAX if you can avoid it; it's hard to work with,
and not very efficient. I'd recommend ElementTree, which is a light-
weight DOM library, that's part of the standard library:

http://effbot.org/zone/element...

If the log files are really large, use the iterparse API:

http://effbot.org/zone/element-iterparse.htm#increment...

> Do you think this approach is the best? Fastest, clearest, more
> maintenable?

Depends on who's going to maintain it, of course. I suspect a Haskell
programmer would prefer if it was written in Haskell...

> Is this the way you will do it?

As the author of ElementTree, I'm a bit biased, but I'd definitely do it
in Python ;-)

</F>