This is a discussion on Re: XML+Logs to Latex. XSLT? - Python ; 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, ...
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
XSLT is definitely a language (it's turing complete, after all), but
that there are of course several Python bindings to XSLT libraries;
> - 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:
If the log files are really large, use the iterparse API:
> Do you think this approach is the best? Fastest, clearest, more
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 ;-)