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:complexType>
   <xs:simpleContent>
    <xs:extension base="xs:string">
     <xs:attribute name="a" type="xs:string"/>
    </xs:extension>
   </xs:simpleContent>
  </xs:complexType>
 </xs:element>

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

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

> (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
restriction.

> 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.

Cheers,
/Eddie
Received on Wednesday, 29 August 2001 20:15:05 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Tuesday, 11 January 2011 00:14:23 GMT