Re: [xsl] Converting Strict XHTML + CSS with XSLT

Subject: Re: [xsl] Converting Strict XHTML + CSS with XSLT
From: Jeni Tennison <jeni@xxxxxxxxxxxxxxxx>
Date: Wed, 10 Jul 2002 10:12:26 +0100
Hi Patrick,

> Most introductory texts to XSLT show how nice and easy it is to
> convert from shapeless XML to HTML + CSS. I would like to do the
> opposite and convert from strict XHTML + CSS to some other format
> using XSLT.In order to do so, interpreting the stylesheet
> information during this transformation is essential. Has anyone
> experience with this ?

I suspect that the developers of IE, Netscape and Opera do ;) I think
that you will find this very hard to do using XSLT, mainly because
parsing CSS (or any text-based format) is not particularly easy. If I
were you, I'd have two steps: one to create an XML version of the CSS
and the other to do the actual interpretation of the XHTML against the
CSS. The hard thing then will be working out how to match a particular
XHTML element against the CSS selectors, particularly doing so quickly
and efficiently.

> Two additional questions (not directly linked to XSLT) :
>     1) I have never heard of an XML representation of the CSS stylesheet
> information. Is there such an initiative ? Corolary : Why are CSS not
> represented using XML  ? Wouldn't this make their processing easier and
> allow, for instance, selectors to be XPaths ?

CSS was around way before XML came into existence: CSS1 reached
Recommendation in December 1996, while XML reached Recommendation in
February 1998. So it's not really surprising that CSS didn't use XML
syntax.

> 2) What is the advantage of using strict XHTML as compared to
> transitional XHTML, apart from imposing stylesheets ?

Transitional XHTML includes a lot of elements that are deprecated in
XHTML 1.1. Deprecated elements tend to disappear in later versions of
a standard, so if you use transitional XHTML you'll find it harder to
upgrade your XHTML to version 2.0 or whatever... At least in theory --
in practice deprecated HTML elements have tended to hang around anyway
because, in the end, browsers recognise and accept them.

Cheers,

Jeni

---
Jeni Tennison
http://www.jenitennison.com/


 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


Current Thread