W3C home > Mailing lists > Public > www-xml-schema-comments@w3.org > July to September 2000

Schemas, namespaces, local, global, in no namespace

From: Liz Castro <lcastro@cookwood.com>
Date: Fri, 11 Aug 2000 17:47:23 -0400
Message-ID: <3994746C.2F65ADD@cookwood.com>
To: www-xml-schema-comments@w3.org
Well, I've got most of it, but there's still something that's not quite

In fact, what I don't understand now is why I'm not getting _enough_

I recreated Martin's example of the very simple schema creating a very
simple namespace:

<schema xmlns='http://www.w3.org/1999/XMLSchema'
        targetNamespace='http://example.org/something' >

<complexType name='foo'>
    <element name='bar' type='string' />

  <element name='baz' type='tns:foo' />


And I create a little instance:

<?xml version="1.0" encoding="UTF-8"?>
<baz xmlns="http://www.example.org/something"
 <bar>this is a string</bar>

(which XML Spy loves and thinks is completely valid). But XSV thinks
it's terrible--'bar' is not allowed here in the 'baz' element, 'baz'
can't end yet, 'bar' is not declared.

But then rereading Martin's post, I say, OK. In the schema, 'foo' and
'baz' are part of the target namespace but 'bar' is a local element in
no namespace, so in the instance, I should declare the 'something'
namespace with a prefix, and use that prefix with the baz element (which
belongs to the something namespace) but I won't use it for 'bar' since
bar is not in the something namespace. And that kind of makes sense. And
XSV likes it:

<?xml version="1.0" encoding="UTF-8"?>
<red:baz xmlns:red="http://www.example.org/something"
 <bar>this is a string</bar>

(This time XML Spy complains bitterly that "This file is not valid:
Mandatory element 'red:bar' expected in place of 'bar'.)

But I'm guessing that XSV knows better.

Now, I add a bunch of stuff to the schema

<?xml version="1.0" encoding="UTF-8"?>
<schema xmlns="http://www.w3.org/1999/XMLSchema"

 <complexType name="foo">
  <element name="bar" type="string"/>
  <element name="item" >
    <element name="name" type="string"/>
    <element name="town" type="string"/>

  <element name="baz" type="tns:foo"/>

because I'm curious what happens to elements inside of elements inside
of elements ('name' and 'town' here). And as long as I use <red:baz
xmlns:red="http://www.example.org/something"...> and don't qualify
anything else, everything is wonderful and XSV is happy (though again
XML Spy thinks I'm an idiot).

But just out of curiosity, I leave off the 'red' and try this instance

<?xml version="1.0" encoding="UTF-8"?>
<baz xmlns="http://www.example.org/something" >
 <bar>this is a string</bar>
 <item><name>pen knife</name>

As expected, XSV gives me errors (and XML Spy doesn't), but curiously,
XSV only complains about bar and item, but not about name and town. Why
isn't there a problem with all of them? If bar and item aren't part of
the 'something' namespace because they are local elements in the schema,
then name and town shouldn't be in any namespace either...and thus there
should be a problem when I declare 'something' as the default namespace
for the whole document (which is what happens when I get rid of the
'red' qualifier).

Why isn't there a problem with name and town?

I'm still missing something, right?


Liz Castro
Cookwood Press
Received on Friday, 11 August 2000 17:41:00 UTC

This archive was generated by hypermail 2.3.1 : Wednesday, 7 January 2015 14:49:53 UTC