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

Re: Always use complexType/simpleContent/restriction?

From: Eddie Robertsson <eddie@allette.com.au>
Date: Thu, 30 Aug 2001 10:13:54 +1000
Message-ID: <3B8D8542.F50AF13@allette.com.au>
To: "Lemmin, Harald" <Harald.Lemmin@softwareag.com>
CC: xmlschema-dev@w3.org
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. The
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) without
> named types?

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

Received on Wednesday, 29 August 2001 20:15:05 UTC

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