Re: XHTML attributes and namespace, clarification needed

Robin Berjon wrote:
>> Where exactly is that stated in http://www.w3.org/TR/REC-xml-names/ ? 
>> I searched for it in both the XML and Namespaces in XML documents, but 
>> did not find it. That is why people specify sources when they quote.
> 
> I used the latest version of the spec. There's little point complaining 
> that superseded versions are unclear.

The W3C lists the 1.0 document first, with "W3C Recommendation" in bold.
The XML specs refer to the 1.0 document. Do you think it's strange?

Additionally I don't see the Namespaces for 1.1 specification mentioning
anywhere that it supersedes the 1.0 specification. And this is not
obvious, as XHTML 2.0 for example doesn't supersede 1.0 either, nor does
(afaik) XML 1.1 supersede 1.0. I have learned to take care with
assumptions about specs superseding eachother or not.


>> All I needed was an actual quote from the spec, not Latin, thank you.
> 
> Well no offense but if you had actually read the spec before commenting 
> at length on it you would've needed neither.

I read the spec about Namespaces both XML 1.0 and XML 1.1 referred to,
which isn't that weird given the things I mentioned above. Its errata
didn't improve the clarity in this respect either. Which I find pretty
odd, as there are 5 whole years between the 1.0 and 1.1 recommendations,
I would have expected this confusion to be cleared up sooner.


>> Anyways, wasn't there some kind of ban on XML 1.1 because it 
>> introduced all kinds of incompatibilities with XML 1.0? Is quoting 
>> from that spec a good idea?
> 
> How is that relevant? Namespaces 1.1 applies to XML 1.0 and XML 1.1 
> equally. All it did was allow IRIs and a mechanism for undeclaration. As 
> far as I've heard, it's been pretty much well received.

It may just be me, but I read the document title as Namespaces for "XML
1.1". I thought they were released as a couple (they certainly were
released at the same date), and the document was specifically aimed at
XML 1.1, not superseding the document for XML 1.0. And as I have heard
some horror stories (well...) about XML 1.1, I don't automatically jump
to the spec with the highest number.


> Besides, there's no ban on XML 1.1. Some people, mostly Microsoft, don't 
> like it. I wouldn't believe everything that they say.

I definitely haven't heard those 'horror stories' from anything
Microsoft-related. Naturally I have a built-in alarm bell which starts
to ring loudly whenever Microsoft makes a statement ;p.


>> Actually, I read the following sentence in the Errata for the 
>> Namespaces in XML 1.0 document:
>>
>> "Namespace Scoping
>> Change the first paragraph of section 5.1 to read:
>>     A namespace declaration is considered to apply to the element 
>> where it is specified and its attributes, and to all elements and 
>> their attributes within the content of that element, unless overridden 
>> by another namespace declaration with the same NSAttName part."
>>
>> ... note in particular the use of 'and its attributes'.
>>
>> So it seems that's not just all there is to it.
> 
> *sigh* It's a spec, not a bunch of tea leaves. All the above says is 
> that namespaces declared on an element are in scope for the element 
> itself and its attributes. You're again trying to see things in the spec 
> that simply aren't there. I tell you, that's the number one reason why 
> people think namespaces are hard. I'd love to know why that is though.

Bah, don't sigh me. You can hardly blame me for the confusion. Really.

But, you're right here...

Anyways, let's summarize. The Namespaces 1.0 specification is unclear
with respect to the namespace unprefixed attributes live in. In fact its
formulation suggests that it is taken indirectly from its element (and
if I may, this is also what common sense would do):
"Note that default namespaces do not apply directly to attributes."

However the Namespaces 1.1 spec says:
"Default namespace declarations do not apply directly to attribute
names; the interpretation of unprefixed attributes is determined by the
element on which they appear.", and
"The namespace name for an unprefixed attribute name always has no value."

I guess that's clear enough.

More generally spoken, I think this is quite a weird turn the XML spec
takes. It just makes much more sense if the attributes live in the same
namespace as their elements (e.g. the classes example). That is probably
why so many people apparantly 'don't get it right'.

I can't help but shake the feeling that they might have intended this
default attribute namespace thing to work differently in the original
spec. This feeling is strengthened by that single sentence about the
matter in the 1.0 spec (even after 12 errata), which uses the term
'directly' which would not apply at all and be totally unnecessary to
mention if attributes without prefix have no namespace. Now if there
were other statements about this matter in the spec, I could discard it
as an error, but as that's the only sentence saying anything at all
about the namespace for attributes without prefix, I'd say it carries
some importance...

Why they would have changed that then, 5 years later, I can not fathom.
Perhaps because there were already major implementations implementing it
with a null namespace. Certainly the editors of the documents are the
same, so a different perspective by different authors couldn't be the
reason. But that's probably just my (conspiracy theory ;p) feelings.

In any case, I strongly hope this will change by XML 2.0. But I guess
this is the wrong list to express that hope :).


~Grauw

p.s. if I do a getAttributeNS('', 'class') in JavaScript, both in
Mozilla and the Opera 7.6 beta it returns the attribute value. When I do
getAttributeNS('http://www.w3.org/1999/xhtml', 'class') in Mozilla, it
does not return anything, but in Opera it also returns the attribute
value. With anything else Opera doesn't return anything either, so it
doesn't just ignore the namespace.

It seems that if you specify an empty namespace, Opera ignores the
namespace altogether as if getAttribute() was called. This is obviously
a bug in Opera (I hope they read this)... Nevertheless, it seems Mozilla
implements the behavior explicitly defined in XML 1.1, while Opera
implements the behavior as I thought XML 1.0 defined. So if even browser
implementors can read a different meaning in the same spec, surely it is
not weird for me to :).

-- 
Ushiko-san! Kimi wa doushite, Ushiko-san!!

Received on Wednesday, 15 December 2004 17:28:30 UTC