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

RE: Recursive XSD with targetNamespace

From: Michael Kay <mike@saxonica.com>
Date: Fri, 14 Nov 2008 21:42:35 -0000
To: "'Todd Moon'" <tmrfcm@gmail.com>
Cc: <xmlschema-dev@w3.org>
Message-ID: <0C8B6EAB7BE44623A09AFA9FCB9D948B@Sealion>
Very little that's in XSD makes intuitive sense - get used to it.
The basic rule is that when you are defining a component (such as an element
declaration), the "name" attribute gives the local name, and it is
implicitly qualified by the targetNamespace. When you are referencing a
component, you use a QName in the "ref" attribute, and if the QName is
unprefixed, it refers to a name in the default namespace - not the target
Michael Kay


From: Todd Moon [mailto:tmrfcm@gmail.com] 
Sent: 14 November 2008 21:14
To: Michael Kay
Cc: xmlschema-dev@w3.org
Subject: Re: Recursive XSD with targetNamespace

This worked, but it doesn't make a lot of intuitive sense to me. The
namespace specified in the targetNamespace is the namespace of the document
to be validated. The Item type is defined in the schema. Why should I have
to use the target namespace when referencing a type defined and used within
the schema? 

Do all types defined in the schema automatically share the namespace
specified in targetSchema?


- Todd Moon

On Fri, Nov 14, 2008 at 4:01 PM, Michael Kay <mike@saxonica.com> wrote:

Whenever you refer to a component in a namespace, you need to use a
qualified name. So it should be
having declared
xmlns:foo=" <http://foo/> http://foo"
Michael Kay


From: xmlschema-dev-request@w3.org [mailto:xmlschema-dev-request@w3.org] On
Behalf Of Todd Moon
Sent: 14 November 2008 20:24
To: xmlschema-dev@w3.org
Subject: Recursive XSD with targetNamespace

Hello everyone.

I have a recursively defined type called "Item" and the schema works fine at
first. However, if I specify a targetNamespace in the XSD, Visual Studio
gives me an error claiming that "Item" is not defined (when it's used within
the definition of Item itself.)

Here's a greatly simplified schema that still exposes the problem:

<?xml version="1.0" encoding="utf-8" ?>
   <xsd:complexType name="Item">
           <xsd:element name="SerialNumber" />
               <xsd:element name="Item" type="Item" />

If I remove the targetNamespace attribute this works fine. Why is this
causing a problem?


- Todd Moon
Received on Friday, 14 November 2008 21:43:14 UTC

This archive was generated by hypermail 2.4.0 : Friday, 17 January 2020 23:15:48 UTC