Re: XML-based CSS

On Wed, Oct 29, 2008 at 9:14 PM, RFID Consulting <>wrote:

> Hello,
> Can somebody tell me why don't w3c provide us with xml-based css format?

Many stylesheet languages were proposed early on, including several that
were precursors to XML (at the time that CSS was created, XML as such didn't
exist, but there were several proposals based on SGML).  They failed for
various reasons, mostly unrelated to their syntax.  At this point, there's
simply no reason to provide an xml format; CSS is simple to read and parse,
and while XML would likely be even simpler to parse, it's not clear that
this is an important enough benefit to override the clear downside that it
will simply be more difficult to write.

> It may be optional, but it would be easy to parse css using simple xml
> parsers (we have such for every modern programming language).

CSS is already a simple language to parse.  It could be made simpler to
parse, but then it would almost certainly be more difficult to write.

> Xml-based css will simplify development if:
> - we need to generate css dynamically in php,asp,,perl, etc...
> (converting style other document format, quering it from database or any
> other source)

*Producing* CSS programmatically is easy as pie.  I'd say it's *simpler*
than XML would be.  If you're storing the information in a CSS-like
structure, you just output it directly, throwing in the occasional
curly-brace, colon, or semicolon.  If you're *not* storing it in a CSS-like
structure, XML won't solve your problem.

> - we have CMS and wonts to add css editor to it,
> - we wont parse css to print, convert or render document,

In both of these, the "parse CSS" part is trivial compared to the
"successfully use CSS in the application" part.  XML won't help at all with

> - we wont to store pictures (dackgrounds, etc...) inside stylesheet (xml
> provides us such ability opposed to css),

Hmm?  Why would you need an image inside a stylesheet?  Do you mean like a
binary encoding of an image, stored literally inside the stylesheet code?
If this is absolutely necessary, the data: protocol can be used for this

> Example:
> <stylesheet>
>   <style tag="body">
>     <background><color>FFFFFF</color></background>
>     <border><style>none</style></border>
>     <color>797A7A</color>
>     <font><family>Verdana,Arial,Helvetica,sans-serif</family><size>12px</
> size></font>
>     <text-align>center</text-align>
>     <margin>0</margin>
>     <padding>0</padding>
>   </style>
>   <style tag="a">
>      <color>797A7A</color>
>      <outline-style>none</outline-style>
>    </style>
>   <style class=".myclass">
>      <color>BBBBBB</color>
>   </style>
> </stylesheet>

Similar proposals have been put forth before, and they have failed too.  For
this specific example syntax, it seems that you have no way of doing the
full contextual selectors that CSS benefits from.  This is the sort of
selection that was common in the early proposals, ten years ago or more, but
it's unacceptable in today's world.

Go ahead and read Hakon's thesis that Jens linked to.  It provides a very
nice history of style-sheet proposals for the web.


Received on Thursday, 30 October 2008 15:38:23 UTC