Re: Why does the default namespace not apply to attributes?

Here's my stab at answering this...

The main component of an XML file is an element.  And the main part of an 
element is the text part (e.g. as in <myElement>Text</MyElement>, although 
the text can obviously contain additional mark-up).  The text part is in 
effect an anonymous, and hence namespace-less, parameter of the element. 
The attributes are adjective-like annotations, often specifying how the 
element, and in particular the text part, should be interpreted or rendered 
etc.  As they are specific to the element/text part of the element, it makes 
sense that they are locally scoped and hence don't need namespaces.  The 
elements on the other hand could, in theory, be mixed and matched in any 
order, possibly from a number of vocabularies.  Hence namespaces are helpful 
on elements to tell <a:name/> from <b:name> etc.

> One could argue this is inconsistent - but if there were no differences
> between elements and attributes then there would be no point in XML
> providing both.

Arguably not the best justification I've seen for attributes :-)  (Although 
possibly mine is no better!)

HTH,

Pete.
--
=============================================
Pete Cordell
Codalogic
for XML Schema to C++ data binding visit
 http://www.codalogic.com/lmx/
=============================================

----- Original Message ----- 
From: "Michael Kay" <mike@saxonica.com>
To: "'Nanda Kol'" <nandakol@hotmail.com>; <noah_mendelsohn@us.ibm.com>
Cc: <xmlschema-dev@w3.org>
Sent: Monday, August 20, 2007 1:31 PM
Subject: RE: Why does the default namespace not apply to attributes?


> > Please, don't misunderstand my question; it is absolutely not my
> intention to suggest changes to the XML spec, rather my aim is to to find
> out what is the rationale for the difference between elements and 
> attributes
> with regard to the default namespace.
>
> The rationale, I think, is that attributes normally have meanings and
> definitions that are local to the element in which they appear; when that 
> is
> the case, putting them in a namespace serves no useful purpose.
>
> Of course it's also sometimes true that child elements have meanings and
> definitions that are local to the parent element in which they appear; and 
> I
> think that's why the XML Schema spec allows the option
> elementFormDefault="unqualified". In practice though I think this option 
> is
> rarely used and certainly is rarely recommended. The most common practice 
> is
> to put child elements in the same namespace as their parents.
>
> One could argue this is inconsistent - but if there were no differences
> between elements and attributes then there would be no point in XML
> providing both.
>
> Michael Kay
> http://www.saxonica.com/
>
> 

Received on Monday, 20 August 2007 17:33:23 UTC