W3C home > Mailing lists > Public > xmlschema-dev@w3.org > January 2002

Re: complexType's typedef

From: Jeni Tennison <jeni@jenitennison.com>
Date: Fri, 25 Jan 2002 18:42:56 +0000
Message-ID: <4732019281.20020125184256@jenitennison.com>
To: wu.liu@verizon.com
CC: xmlschema-dev@w3.org
Hi Wu,

> The corresponding datatype for MyStructType in schema is:
> =====================================================================
> <complexType name="MyStructType">
>       <sequence>
>             <element name="first" type=string"/>
>             <element name="second" type="string"/>
>       </sequence>
> </complexType>
> =====================================================================
> But how to treat typedef? The following definition gives me error:
> =====================================================================
> <complexType name="MyTypedefType">
>       <restriction base="MyStructType "/>
> </complexType>
> =====================================================================

The error is probably arising from a namespace conflict. In:

  <restriction base="MyStructType" />

the value of the base attribute is interpreted as a qualified name - a
local name in a particular namespace. Since you don't have a prefix
for that qualified name, the schema validator uses the default
namespace. However, from the looks of your XML Schema elements, you've
declared the XML Schema namespace as being the default namespace, so
the schema validator tries to look for a MyStructType type in the
namespace http://www.w3.org/2001/XMLSchema.

I guess that you're not using a namespace for your schema? If so, if
you don't have a target namespace, then you must declare the XML
Schema namespace with a prefix, so you have, for example:

<xs:complexType name="MyStructType">
    <xs:element name="first" type=string"/>
    <xs:element name="second" type="string"/>

<xs:complexType name="MyTypedefType">
  <xs:restriction base="MyStructType "/>

Alternatively, you could add a target namespace to your schema (using
the targetNamespace attribute on the schema element) and declare that
namespace with a prefix. Then whenever you have a reference (e.g. the
base attribute of the restriction element) then you need to use that
prefix. So you'd get:

  <restriction base="my:MyStructType" />

for example.



Jeni Tennison
Received on Friday, 25 January 2002 13:42:58 UTC

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