W3C home > Mailing lists > Public > www-dom@w3.org > October to December 2000

Re: xmlns attribute namespace

From: Garret Wilson <garret@globalmentor.com>
Date: Thu, 21 Dec 2000 10:09:56 -0800
Message-ID: <00d501c06b79$3a282c20$7245a640@pacbell.net>
To: "Gareth Reakes" <gareth@decisionsoft.com>, <rayw@xmission.com>
Cc: "www-dom list" <www-dom@w3.org>
Thanks, Gareth and Ray, for helping clarify the namespace issue. There still
seem to be a couple of things I'm not clear on.

Gareth mentioned:

> Default namespaces do not apply to attribute names.

This would seem to match what the "Namespaces in XML" document says, namely:

<namespaces10>
However, each of the following is legal, the second because the default
namespace does not apply to attribute names:

<!-- http://www.w3.org is bound to n1 and is the default -->
<x xmlns:n1="http://www.w3.org"
   xmlns="http://www.w3.org" >
  <good a="1"     b="2" />
  <good a="1"     n1:a="2" />
</x>
</namespaces10>

In this instance, the second <good> has an attribute of "n1:a", which gets
the namespace URI http://www.w3.org , and the attribute "a" doesn't get the
default namespace (giving it a DOM Level 2 null namespace), even though
<good> itself does get the default namespace of http://www.w3.org .

That almost seems straightfoward, until one reads the first example of
"Namespaces in XML", "A.3 Expanded Element Types and Attribute Names":

<!-- 1 --> <section xmlns='urn:com:books-r-us'>
<!-- 2 -->   <title>Book-Signing Event</title>
<!-- 3 -->   <signing>
<!-- 4 -->     <author title="Mr" name="Vikram Seth" />
<!-- 5 -->     <book title="A Suitable Boy" price="$22.95" />
             </signing>
           </section>

The document claims that the names would expand so that:

5 title <ExpAName name='title' eltype="book" elns="urn:com:books-r-us" />

This seems to be saying that the <book> "title" attribute takes on the
default namespace of "book".

The first example in the "XML Schema Part 0: Primer" document seems to
uphold this notion:

<xsd:schema xmlns:xsd="http://www.w3.org/2000/08/XMLSchema">
[cut]
 <xsd:element name="purchaseOrder" type="PurchaseOrderType"/>

If attributes do not take default namespaces, then how can the "name"
attribute of <xsd:element> be validated to the definition of the schema for
namespace http://www.w3.org/2000/08/XMLSchema ? Is the example incorrect,
and each attribute should be prefixed by "xsd:"?

I imagine I'm missing something simple here.

Thanks,

Garret
Received on Thursday, 21 December 2000 13:10:39 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Friday, 22 June 2012 06:13:48 GMT