Re: namespaces and schemaLocation

The issue of local vs global scope ( sub elements in 'no namespace' vs sub
elements in explicit namespace ) is an interesting one. It may help to look
at attributes and draw parallels.

<person xmlns='http://example.org/people' unit='commando'>
  <name>Martin</name>
  <weight unit='zurgs'>999</weight>
  <height unit='cubits'>5</height>
</person>

In the above example the elements are in the http://example.org/people
namespace, that is at the Infoset level if you look at the namespace string
for any of the elements you will get "http://example.org/people".

Conversely the attributes are in 'no namespace', that is at the Infoset
level if you look at the namespace string for any of the attributes you will
get "". This means that the attributes are 'locally scoped'. The practical
implication of this is that the only way to correctly interpret a 'unit'
attribute is to look at the containing element.

So for the first 'unit' attribute I look at the containing element 'person'
and know that this tells me what kind of military unit the person belongs
to. Looking at the second 'unit' attribute and the containing 'weight'
element I know that it's telling me the units of weight and in my
application I have some way of knowing how much a 'zurg' weighs in pounds
and ounces. And so on. In other words if I get given an unqualified
attribute in isolation, I have no way of ( deterministically ) knowing how
to interpret it.

The same is true of local elements.

<t:team xmlns:t='http://example.org/teams'>
  <name>Schema Working Group</name>
  <person>
    <name>Martin</name>
  </person>
  <person>#
    <name>Dan</name>
  </person>
</t:team>

With the above XML document given a 'name' element in isolation I don't know
whether it is the name of a team or the name of a person, the namespace
string for both is "". I have to look at the immediate ancestor to figure it
out. So let's say I put all the elements of the above instance into the same
namespace...

<team xmlns='http://example.org/teams'>
  <name>Schema Working Group</name>
  <person>
    <name>Martin</name>
  </person>
  <person>#
    <name>Dan</name>
  </person>
</team>

Now given a 'name' element in isolation I still don't know what whether it
is the name of a team or the name of a person, the namespace string for both
is "http://example.org/teams". I've not gained anything and I've confused
the issue by saying that the two names are the same even when they're not.
At least in the case when the namespace string was "" I knew they were
locally scoped and the only way to figure out what I had was to look at the
parent element.

Namespaces allow us to group names into scopes. Things that are in no
namespace are saying 'Hey, I'm scoped by my parent not by my namespace
string'

Hope this helps

Martin Gudgin
DevelopMentor


----- Original Message -----
From: "Liz Castro" <lcastro@cookwood.com>
To: <www-xml-schema-comments@w3.org>
Sent: Thursday, August 10, 2000 4:27 PM
Subject: Re: namespaces and schemaLocation


<SNIP>
> And I don't think I understand yet the advantages or disadvantages of
having
> all the elements in an instance in the same namespace or not (the only
> advantage I see is that you could have a default namespace and then have
to
> type less prefixes). Mostly I want to understand how to make it one way or
> another so that when I do understand _why_ I'd want to do it, I'll be able
to
> do it.
>
> Thanks,
> Liz
>
> Liz Castro
> Cookwood Press
> http://www.cookwood.com

Received on Thursday, 10 August 2000 16:06:23 UTC