W3C home > Mailing lists > Public > xmlschema-dev@w3.org > August 2001

RE: Always use complexType/simpleContent/restriction?

From: Lemmin, Harald <Harald.Lemmin@softwareag.com>
Date: Thu, 30 Aug 2001 12:28:10 +0200
Message-ID: <DFF2AC9E3583D511A21F0008C7E62106172E20@softwareag.com>
To: "'xmlschema-dev@w3.org'" <xmlschema-dev@w3.org>
Hello Eddi,

thanks for your reply. 
I understand now that from a base type you cannot "add" an attribute by
restriction, because the base type does not has this attribute before. 
And you cannot restrict a base type with a facet by complexType, because the
result is not a complex, but a simple type and thus simpleType has to be

So the solution is named types.

Kind regards,

-----Original Message-----
From: Eddie Robertsson [mailto:eddie@allette.com.au]
Sent: Thursday, August 30, 2001 2:14 AM
To: Lemmin, Harald
Cc: xmlschema-dev@w3.org
Subject: Re: Always use complexType/simpleContent/restriction?

Hi Harald,

> I automatically generate schemata and can use only simple types, but no
> named types.
> I want to model:
> (a) an element (simple type) with an attribute.

 <xs:element name="a">
    <xs:extension base="xs:string">
     <xs:attribute name="a" type="xs:string"/>

> (b) an element (simple type) with a facette.

 <xs:element name="b">
   <xs:restriction base="xs:string">
    <xs:length value="10"/>

> (c) an element (simple type) with an attribute and a facette.
> (c) can be modelled only with complexType/simpleContent/restriction:
>         <element name="e" type="xs:string">
>           <complexType>
>             <simpleContent>
>               <restriction>
>                 <length value="10"/>
>                 <attribute name="a" type="xs:string">
>                 </attribute>
>               </restriction>
>             </simpleContent>
>           </complexType>
>         </element>

I don't think you can do c) without using named type but I'm not 100% sure.
example you give above is not valid because 1) you can't use both the type
attribute and the child element <complexType>, 2) If you want to add an
attribute to a simpleContent model you have to use <extension> and not

> My questions are:
> (I) Which solution to use in case (a) and (b)? Can I always use
> complexType/simpleContent/restriction, like (c)??

See solution above.

> (II) Is it ok to "restrict" an element (simple type) by an attribute, like
> done in (c) [shouldn't it be an extension]? If not, how to model (c)
> named types?

No, you have to use extension and I can't see how you can model (c) without
named types.

Received on Thursday, 30 August 2001 06:28:34 UTC

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