W3C home > Mailing lists > Public > xmlschema-dev@w3.org > November 2000

Re: Unprefixed attributes (was: Re: <attribute ref="thisNamespace:foo"/> not working?)

From: Martin Gudgin <marting@develop.com>
Date: Mon, 20 Nov 2000 08:41:37 -0000
Message-ID: <001901c052cd$b6d06d60$c24efea9@greyarea>
To: <xmlschema-dev@w3.org>

----- Original Message -----
From: "Robert Braddock" <stormwarden@bigfoot.com>
To: <xmlschema-dev@w3.org>
Sent: Monday, November 20, 2000 12:54 AM
Subject: Unprefixed attributes (was: Re: <attribute
ref="thisNamespace:foo"/> not working?)


<SNIP>
> Thus, if the element uses the default namespace, it's
> unprefixed attributes are in the default namespace.

<mjg>
I think it comes down to what you can expect to see at the Infoset level.
Consider the following XML document;

  <root name='martin' xmlns='http://example.org/2000/11/mjg' />

If I walk up to the Element Information Item for 'root' and ask it what its
namespace URI is it will tell me 'http://example.org/2000/11/mjg'. If I walk
up to the Attribute Information Item for 'name' and ask it for its namespace
URI it will tell me '' ( the empty string ).

Q.    What does this tell me about the 'name' attribute?
A.    That the only way to interpret it is to look at the element it belongs
to.

Which I think is the conclusion you come to. The confusion only arises, I
think, because both the element and the attribute are unprefixed so at first
glance it *looks* like the namespace URI for 'name' will be the same as the
namespace URI for 'root'.

It's also interesting to look at the following case

  <r:root xmlns='http://example.org/2000/11/mjg' >
    <name>martin</name>
  </r:root>

because in essence it is exactly the same; the 'name' element has a
namespace URI of '' ( the empty string ) and the 'root' element has a
namespaceURI of 'http://example.org/2000/11/mjg'.

Q.    What does this tell me about the 'name' element?
A.    That the only way to interpret it is to look at its parent element.

Of course this second case above does not cause as much confusion because it
is more obvious that 'root' and 'name' do not have the same value for their
respective namespace URI properties.

To describe the attribute case using XML Schema you could write;

<schema xmlns='http://www.w3.org/2000/10/XMLSchema'
targetNamespace='http://example.org/2000/11/mjg'>

  <element name='root'>
    <complexType>
      <attribute name='name' type='string' />
    </complexType>
  </element>

</schema>

While the second case could be described thus;

<schema xmlns='http://www.w3.org/2000/10/XMLSchema'
targetNamespace='http://example.org/2000/11/mjg'>

  <element name='root'>
    <complexType>
      <element name='name' type='string' />
    </complexType>
  </element>

</schema>

Note that the only difference between the two is that one contains a local
attribute declaration while the other contains a local element declaration.

Hope this helps,

Martin Gudgin
DevelopMentor
Received on Monday, 20 November 2000 03:43:04 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Tuesday, 11 January 2011 00:14:18 GMT