[lxml-dev] Targeted XSL transformations
Stefan Behnel
stefan_ml at behnel.de
Thu Jul 16 07:11:30 CEST 2009
Hi,
just a quick answer to the last bit (skipping over your mail somewhat).
Emanuele D'Arrigo wrote:
> 2009/7/14 Stefan Behnel wrote:
>> My preferred solution, however: if you can avoid putting any style
>> information into the (X)HTML document (or at least the style bits that
>> interfere in multiple XSL docs), and move it out into a CSS file, I think
>> you can get yourself out of a lot of hassle. Many of the decisions that you
>> would take in XSLT to put style information in the right places can be left
>> to the browser's CSS engine.
>
> I wish I could leave that to something indeed rather than having to
> implement it myself. Unfortunately, although my original post referred to
> xhtml, in practice I'm not dealing with a browser nor with xhtml. Instead
> I'm attempting to write a GUI system based on Mozilla's XUL.
How does that discourage CSS?
> I initially thought of using CSS but, I seem to understand, lxml only allows
> me to -select- elements in the tree via css. This is quite short from
> generating the cascade of css rules and transforming the tree accordingly.
I didn't say "generate" them - just write them down. There's also a package
called "cssutils" which you might (or might not) find useful for your needs.
http://cthedot.de/cssutils/
> For this reason I'm currently oriented toward XSLT: once a stylesheet is
> ready it's quite easy to create a transform object out of it and apply it to
> an xml object.
It's common to use both: XSLT for structural tree transformations, and CSS
for applying style information. That keeps the details of content structure
and visual representation somewhat separated, which tends to be a rather
big advantage.
Stefan
More information about the lxml-dev
mailing list