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

Re: Schemas, namespaces, local, global, in no namespace

From: Martin Gudgin <marting@develop.com>
Date: Mon, 14 Aug 2000 15:15:16 +0100
Message-ID: <001d01c005fa$7402d740$0100a8c0@arbitrary>
To: <www-xml-schema-comments@w3.org>

----- Original Message -----
From: "Liz Castro" <lcastro@cookwood.com>
To: <www-xml-schema-comments@w3.org>
Sent: Monday, August 14, 2000 2:28 PM
Subject: Re: Schemas, namespaces, local, global, in no namespace


<SNIP>
> OK, that does help. I guess what I don't get is if name and town (and bar
and item) are all not associated
> with the 'something' namespace that I'm using to schema validate my xml
docs, how does XSV (or any
> validator) know how to validate them?
>
> Imagine that I dutifly qualify the something namespace in the xml document
with "red" and I add a new
> element (zip) of type integer (and deliberately give it bad content.
> http://www.cookwood.com/xmltests/martin3.xml:
>
> <?xml version="1.0" encoding="UTF-8"?>
> <red:baz xmlns:red="http://www.example.org/something"
> xmlns:xsi="http://www.w3.org/1999/XMLSchema-instance"
xsi:schemaLocation="http://www.example.org/something
>
> F:\schemas\martin2.xsd">
>  <bar>this is a string</bar>
>  <item>
>   <name>pen knife</name>
>   <town>nyc</town>
>   <zip>not a number!</zip>
>  </item>
> </red:baz>
>
> I add a definition for the zip element in the new schema
(http://www.cookwood.com/xmltests/martin3.xsd):
>
> <?xml version="1.0" encoding="UTF-8"?>
> <schema xmlns="http://www.w3.org/1999/XMLSchema"
xmlns:tns="http://www.example.org/something"
> targetNamespace="http://www.example.org/something">
>  <complexType name="foo">
>   <element name="bar" type="string"/>
>   <element name="item">
>    <complexType>
>     <element name="name" type="string"/>
>     <element name="town" type="string"/>
>     <element name="zip" type="integer"/>
>    </complexType>
>   </element>
>  </complexType>
>  <element name="baz" type="tns:foo"/>
> </schema>
>
> XSV properly tells me that the zip element has bad content. But how does
it know that if zip isn't in the
> target namespace that is defined with the schema?

[MJG]
A validator knows how to validate zip ( and name and town ( and item and
bar )) because the schema says:

'When you find something of type foo in the http://www.example.org/something
namespace it will contain an unqualified bar element of type string followed
by an unqualified item element. Furthermore the item element will contain
unqualified name and town elements in that order, both of type string
followed by an unqualified zip element of type integer'

Hope this helps,

Martin Gudgin
Received on Monday, 14 August 2000 10:20:19 UTC

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