Subject:error in xsd Author:Adriaan Vanderende Date:12 Sep 2002 10:17 AM
Hi,
I get errors on attached xsd. As in other xml editors is does not give me an error.
Validating Untitled1.xsd...
Untitled1.xsd:26,42: The type 'xsd:string' is a simple type. It cannot be used in a derivation by RESTRICTION for a complexType
Untitled1.xsd:36,42: The type 'xsd:string' is a simple type. It cannot be used in a derivation by RESTRICTION for a complexType
Untitled1.xsd:13,45: The type 'xsd:string' is a simple type. It cannot be used in a derivation by RESTRICTION for a complexType
Subject:Re: error in xsd Author:(Deleted User) Date:12 Sep 2002 10:45 AM
At 10.32 12/09/2002 -0400, you wrote:
>From: "Adriaan Vanderende"
>
>Hi,
>
>I get errors on attached xsd. As in other xml editors is does not give me
>an error.
>
>Validating Untitled1.xsd...
>Untitled1.xsd:26,42: The type 'xsd:string' is a simple type. It cannot be
>used in a derivation by RESTRICTION for a complexType
>Untitled1.xsd:36,42: The type 'xsd:string' is a simple type. It cannot be
>used in a derivation by RESTRICTION for a complexType
>Untitled1.xsd:13,45: The type 'xsd:string' is a simple type. It cannot be
>used in a derivation by RESTRICTION for a complexType
Adrian, the schema makes use of this definition (replace { with < and }
with >):
{xsd:element name = "f1"}
{xsd:complexType}
{xsd:simpleContent}
{xsd:restriction base = "xsd:string"}
{xsd:length value = "6"/}
{xsd:attribute name = "attrib2"
type = "xsd:string"/}
{/xsd:restriction}
{/xsd:simpleContent}
{/xsd:complexType}
{/xsd:element}
and this, according to the section 2.2.1.3 (Complex Type Definition) is
illegal.
"Each complex type definition is either
- a restriction of a complex base type definition
or
- an extension of a simple or complex base type definition
or
- a restriction of the ur-type definition.
"
The correct schema would be
{xsd:simpleType name="sizcharstring"}
{xsd:restriction base="xsd:string"}
{xsd:length value="6"/}
{/xsd:restriction}
{/xsd:simpleType}
{xsd:element name = "f1"}
{xsd:complexType}
{xsd:simpleContent}
{xsd:extension base = "sizcharstring"}
{xsd:attribute name = "attrib2"
type = "xsd:string"/}
{/xsd:extension}
{/xsd:simpleContent}
{/xsd:complexType}
{/xsd:element}
where you first define a new simple type derived by restriction from
xsd:string, then you extend it to add the attribute to define the complex
type for f1.