W3C home > Mailing lists > Public > www-style@w3.org > December 2004

XHTML attributes and namespace, clarification needed

From: Daniel Glazman <daniel.glazman@disruptive-innovations.com>
Date: Tue, 14 Dec 2004 11:46:56 +0100
Message-ID: <41BEC4A0.1060902@disruptive-innovations.com>
To: www-html@w3.org
Cc: chris@w3.org, www-style@w3.org

Hi there,

(message cc'ed to www-style because the problem impacts CSS selectors
  and Chris Lilley for the TAG)

I have a serious problem regarding namespaces and XHTML attributes. First,
let's look at the specs:

1) according to XHTML 1.0 section 3.1.1 [1], strictly conforming documents
    must contain an xmlns declaration for the XHTML namespace
2) according to Namespaces in XML section 5.2 [2], the default namespace of a
    doc does not apply directly to attributes
3) according to Namespaces in XML section 5.3 [3], the following is ok:

      <x xmlns:n1="http://www.w3.org"
         xmlns="http://www.w3.org" >
        <good a="1"     n1:a="2" />
      </x>

4) the DOM 2 Core spec [4] states again that if an attribute is not explicitly
    given a namespace, it simply has no namespace.

So, the following is valid XML too, right ?

      <?xml version="1.0"?>
      <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
                     "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
      <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"
            xmlns:html="http://www.w3.org/1999/xhtml">
        <head>
          <title>Junk title</title>
          <style type="text/css">
           .foo { color : green }
           .bar { color : blue }
          </style>
        </head>
        <body>
          <p dir="rtl"   html:dir="ltr"
             class="foo" html:class="bar"
            this is a paragraph
          </p>
        </body>
      </html>

a) can someone tell me what is the direction of the paragraph above ?
b) XHTML 1.0 spec section C.13" [5] says "Within the XHTML namespace, user
    agents are expected to recognize the "class" attribute". But in
    <p class="foo">, [2] states that the class attribute has NO namespace...
    So can someone tell me what is the class of the paragraph above ?
c) if the answer is "it has two classes, one with no namespace and the
    other in the XHTML namespace", can someone explain me which one is
    used for the class selector in CSS ? And what is the text colour of the
    paragraph ? And which attribute editing tools should offer to handle ?
d) shouldn't **all** XHTML attributes declare the XHTML namespace ? I
    understand this would be a mess but isn't it what the specs quoted
    above seem to imply ?

As I see it, XHTML is clearly violating the specs, since the whole model
is based on the fact all attributes with no namespace carried by XHTML 1.0
elements *are* in the XHTML namespace. While the RDF validator requires
from RDF instances that RDF attributes are given the RDF namespace.

It seems to me that the "an attribute with no namespace declared has no
namespace" model is incompatible with XHTML where "an attribute with no
namespace declared has the namespace of the element node carrying that
attribute" is apparently the rule... Can someone clarify this for me
please ?

[1] http://www.w3.org/TR/xhtml1/#strict
[2] http://www.w3.org/TR/REC-xml-names/#defaulting
[3] http://www.w3.org/TR/REC-xml-names/#uniqAttrs
[4] http://www.w3.org/TR/2000/REC-DOM-Level-2-Core-20001113/core.html#ID-NodeNSname
[5] http://www.w3.org/TR/xhtml1/#C_13

</Daniel>
Received on Tuesday, 14 December 2004 10:47:05 GMT

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