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

Speaking for myself, and not formally for the Schemas WG:

the decision in Schemas to treat elements and attributes asymmetrically 
reflects a related asymmetry in namespaces itself.  You'll note that per 
XML Namespaces [1], default namespace bindings to not apply to attributes. 
 You can see this because per the namespaces recommendation, the following 
example does NOT have a duplicate attibute (it's actually not important 
that I've used two elements here, it's just easier to separate the 
namespace bindings from the attributes:


        <!-- prefix p and the default are bound to the same namespace URI 
-_>
        <outer xmlns="http://example.org/ns" 
xmlns:p="http://example.org/ns">
          <-- no duplicate attribute error in the following -->
          <inner a="1" p:a="2"/>
          <-- the following has the same element tag as the one above -->
          <p:inner />
        </outer>

Reading between the lines, the Namespaces recommendation takes the view 
that attributes tend to be scoped to the elements on which they appear. 
Also, it's quite common in colloquial XML usage, to find unqualified 
attributes on qualified elements.  Finally, while the connection is 
indirect, DTDs do treat attributes as local to the element;  you can tell 
this because you can declare different default values for attribute "A" on 
element "E1" vs. element "A" on "E2".  For all of these reasons, Schemas 
defaults to a model in which attributes are unqualified, even if a 
targetNamespace is declared for a schema document.

Noah

[1] http://www.w3.org/TR/REC-xml-names/#uniqAttrs


--------------------------------------
Noah Mendelsohn 
IBM Corporation
One Rogers Street
Cambridge, MA 02142
1-617-693-4036
--------------------------------------








Nanda Kol <nandakol@hotmail.com>
Sent by: xmlschema-dev-request@w3.org
08/16/2007 11:32 AM
 
        To:     <xmlschema-dev@w3.org>
        cc:     (bcc: Noah Mendelsohn/Cambridge/IBM)
        Subject:        Why does the default namespace not apply to 
attributes?


All,
 
The following question is about the rationale for the difference in 
approach between elements and attributes with regard to namespaces.
 
In order to promote reuse of XML artifacts within our organization, a set 
of recommendations has been specified for XML Schema documents design. One 
of the recommendations is that every XML Schema document should have a 
target namespace. However, after some experiments and investigation we 
learnt that this namespace does not apply to attributes, which means that 
the use of a target namespace results in attributes and elements being in 
different conceptual spaces, which seems counter-intuitive. 
 
We have been wondering what could be the rationale behind this, but 
couldn’t find the answer. Hopefully, you can provide it or you know where 
to search for it.
 
Moreover, if you can provide us any directions on the best approach  (i.e. 
set attributeFormDefault to “qualified”, use global attribute 
declarations, or else) with respect to reusability, this would be more 
than welcome.
 
Thanks in advance,
Nanda

Play free games, earn tickets, get cool prizes! Join Live Search Club.   
Join Live Search Club!

Received on Thursday, 16 August 2007 18:27:12 UTC