Re: Who would learn enouh to tell better right methods!

Tim Bagot wrote:

> On Fri, 11 Jun 1999, Tapio Markula wrote:
> > IE allows to use this style:
> > <xdc:title style="font-family: sans-serif;">
> The style attribute has a special meaning in HTML, but not in XML
> documents in general. It may be that some software may choose to interpret
> this attribute as if it were in an HTML document, but such interpretation
> is certainly not guaranteed.

Any software that does would be incorrect to do so.
Until the time that XML defines such a behavior (if ever), "style" can only be
presumed to be *style* data on an element whose namespace defines it to work
that way (ie: HTML).

> > I tested
> > <!doctype html public "-//W3C//DTD XHTML 1.0 Transitional//EN"
> >  "">
> > <?xml version="1.0"?>
> > <?xml-stylesheet href="xml-sheet.css" type="text/css" ?>
> > <html xmlns=""
> >            xmlns:author="xml-dtd.dtd">
> >
> > DTD was defined all new elemets
> >
> > BODY
> > <author:container class="author2">
> > <author:nameclass="author">Tapio Markula</author:name></author:container>
> >
> > BUT in this case IE 5.0 can't find css to
> > this: <author:container class="author2"> from xml-sheet.css but it used
> > definition, which I made to
> >
> > <link rel="STYLESHEET" type="text/css" href="sivusto2.css">
> This is not the way to attach style sheets to XML documents; it has this
> functionality only in HTML. This suggests that IE does not provide a
> particularly good implementation of XML.
> > According to a worker of Mozilla this is illegal
> > <author:container class="author2">
> It isn't exactly illegal (assuming the class attribute exists in the
> relevant namespace), but it is unlikely to do what you expect.

Having the attribute is not illegal, treating it exactly like HTML's class
attribute certainly is.

> The class
> attribute is special for CSS only in HTML documents. In CSS2, you can use
> attribute matching selectors (e.g. container[class~=author2]).


> Alternatively, you can put the class attribute in the html namespace (e.g.
> <author:container html:class="author2">).

No that should not work either. A "class" attribute in the HTML namespace is
not the same as a "class" attribute on an element in the HTML namespace.
<html:p class="foo" html:class="bar">...</html:p>

That is perfectly valid XML. "html:class" is NOT the class attribute we know
and love. So only a ".foo" selector would match, not ".bar".

> This does raise an interesting point, though. AFAIAA, the interaction
> between XML Namespaces and CSS is not defined.

Actually, it is. A document from the CSS working group on this point is
forthcoming (real soon now).

> Clearly, elements with the
> same name but in different namespaces should be treated as distinct by the
> style sheet.


> Presumably, therefore, CSS element selectors should include
> namespaces in style sheets applied to documents using them, or else the
> style rules should apply only to elements in the document's default
> namespace, if it has one.

Actually, for backwards compatibility, if the CSS doesn't have a specified
namespace, the selectors should apply to elements in all namespaces.

> The former is difficult, since the colon is
> already used to delimit pseudo-elements and pseudo-classes.

Or simply use a different delimiter in CSS...

> Or is it
> (theoretically) possible to specify a namespace on the xml-stylesheet
> directive and have it do the Right Thing? I'm not sure that it is.
> I suspect that XSL is the better choice for XML documents, at least those
> using namespaces.

CSS3's namespace support will be able to make CSS apply to any XML file just
fine. For the record, Gecko (Mozilla 5.0) and at least one other browser vendor
(who shall remain nameless until they choose to speak up) already have
experimental implementations of this.

> Tim Bagot

Received on Monday, 14 June 1999 01:56:14 UTC