W3C home > Mailing lists > Public > www-style@w3.org > January 2006

Re: [Selectors], XSLT, and a browser's internal view of an xml document

From: Noah Scales <noahjscales@yahoo.com>
Date: Tue, 31 Jan 2006 00:16:24 -0800 (PST)
Message-ID: <20060131081624.77559.qmail@web50401.mail.yahoo.com>
To: www-style@w3.org

Hello, Mr. Zbarsky.

The result of applying a CSS 3.0 stylesheet to an XML
document, if it were serialized, may have different
elements and attributes than the original XML
document. Because CSS doesn't have it's own namespace
(yes, that's been true all along!), only a few
languages (for example, XHTML, SVG) could even in
principle be serialized that way. No one thinks about
it like that unless, like me, they don't appreciate
that the W3C CSS Working Group does not consider the
result of applying a CSS stylesheet to an XML document
to be worth serializing, perhaps because encoding the
transformation required would use XSLT, and result in
less than performance-critical rendering of CSS
styles.

You wrote:

"Your logic is basically the following: "XML documents
may only consist of Unicode characters, so Unicode
should actually be called 'XML Unicode'.
That's clearly false, no?  What you're saying is
equivalent."

Well, other character encodings of XML are possible.
For example, 'ISO-8859-1 XML'. So your argument may be
the following:

"It's inane/pointless/fruitless/unhelpful for you to
distinguish Unicode XML from other character encodings
when you are refering to XML in general. So it's
inane/pointless/fruitless/unhelpful for you to
distinguish CSS Selectors from XPATH Selectors when
you are refering to Selectors in general."

But the CSS Selector specification only discusses the
one selector language CSS uses. So your argument is
not cogent.

If you want to fry up some pancakes and you go into a
kitchenware store looking for a pancake spatula, you
don't ask for "spatulas". After all, you might get any
old spatula. Instead, you ask for a pancake spatula,
even though people can also use pancake spatulas for
flipping sausages, cheese sandwiches, and chow mein.
So if you want to specify some CSS rules using CSS
selectors, you ask about CSS selectors. Even though
people use CSS selectors for other purposes quite
well. 


You wrote:

"You claim this repeatedly, but this is simply not
true.  If you feel that it's true for some reason, I'd
love to hear your reason."

If I interpret you correctly, you want my reasons to
claim that an arbitrary xml document modified by
embedded CSS can't be reserialized without including
CSS Selectors in the document or in an external
stylesheet. I think a counterexample better
demonstrates the impossibility. Here's my
counterexample.

<?xml version="1.0"?>
<page 
    xmlns="http://www.awebsite.org/2006"
    xmlns:xlink="http://www.w3.org/1999/xlink"
    xmlns:css="http://www.w3.org/2006/css">
<css:style>
mylink {
       hover-background:yellow;
       color:rgb(255,0,0);
       text-decoration:underline;
   }   
</css:style>
<mylink xlink:type="simple"
xlink:href="somepage.xml">some page</mylink>.
</page>

----------
after transformation by XSLT...
----------

<?xml version="1.0"?>
<page 
    xmlns="http://www.mywebsite.net/2006"
    xmlns:xlink="http://www.w3.org/1999/xlink"
    xmlns:css="http://www.w3.org/2006/css">
<mylink xlink:type="simple" xlink:href="somepage.xml"
css:style="hover-background:yellow;color:rgb(255,0,0);"
css:style="hover-text-decoration:underline;">some
page</mylink>.
</page>

You can visualize an output XHTML file as a DOM tree,
complete with style-named attribute nodes whose value
is css att:val pairs, and an input XHTML file as a DOM
tree, with a single style element containing
selectors. But whatever data is created by applying
CSS to an input XML document can't be output in XML at
all, unless CSS Selectors are present in the output as
well. The XML code counterexample demonstrates one way
that's false. The other, trivial, counterexample is if
XPATH selectors are substituted for CSS selectors in a
source XML file containing an xml-stylesheet
instruction that points to an embedded CSS stylesheet.
You asked what reason I have to say that. Well, can
you add inline CSS to arbitrary XML elements and have
a browser render it properly? 

For a discussion of the advantages of modularizing the
namespace of css stylesheets, take a look at the
technical report on modularizing XHTML. Visit:

./xhtml-modularization/introduction.html#s_intro_xhtml_mods

You wrote:

"XSLT creates a different DOM, by definition (see XSLT
specification).  CSS does not, also by definition (see
the CSS specification). Your offer quoted above makes
me strongly suspect some fundamental misunderstandings
on your part about how CSS and XSLT work..."

OK, perhaps you're right. So you mean that you can't
use CSS to create an output file different from an
input file, even though you use CSS to do the
following:
 - create sequence numbers.
 - copy attribute values from one element to before or
after another.
 - insert text and images before and after elements.
 - show and hide elements.
 - do arithmetic (using "calc()"). 

So you can't get an xml serialization that reflects
how CSS modified your XML file, because CSS, by
definition, doesn't modify the input DOM tree created
from your input XML file. It's for XSLT to transform
and serialize the input tree created from an XML file.
Is my understanding improved?

That's the understanding that HÃ¥kon Lie and Bert Bos
had when they coauthored the W3C "Using XML and CSS
Together" technical report. That's available at:

./TR/NOTE-XSL-and-CSS

-Noah Scales

__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 
Received on Tuesday, 31 January 2006 08:16:32 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Monday, 27 April 2009 13:54:42 GMT