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

Re: restrictions of a complextype element

From: Henry S. Thompson <ht@cogsci.ed.ac.uk>
Date: 21 Jun 2001 10:36:10 +0100
To: vdv@dyomedea.com
Cc: xmlschema-dev@w3.org
Message-ID: <f5bpuby41kl.fsf@cogsci.ed.ac.uk>
Eric van der Vlist <vdv@dyomedea.com> writes:

> Eddie Robertsson wrote:
> > 
> > Not really. To achieve what you try to do you first need to create a global
> > simpleType for your base type like this:
> 
> You can do it like this, however, instead of extending a global
> simpleType that you have created, you can also restrict the xs:string
> like David was trying to do:
> 
> <?xml version="1.0" encoding="UTF-8"?>
> <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
> elementFormDefault="qualified">
>   <xs:element name="Test">
>     <xs:complexType>
>       <xs:simpleContent>
>         <xs:restriction base="xs:string">
>           <xs:enumeration value="hello world"/>
>           <xs:enumeration value="this is me"/>
>           <xs:attribute name="myAtt" type="xs:string" use="required"/>
>         </xs:restriction>
>       </xs:simpleContent>
>     </xs:complexType>
>   </xs:element>
> </xs:schema>
> 
> (the xs:attribute needs to be inside the xs:restrict and not outside
> xs:simpleContent as David had written).

Sorry, that's not allowed.  Within <simpleContent>, if the base is a
simple type, the derivation must be by extension, see [1]:

 "2 If the <simpleContent> alternative is chosen, the type definition
 ·resolved· to by the ·actual value· of the base [attribute] must be
 either a complex type definition whose {content type} is a simple
 type definition or, only if the <extension> alternative is also
 chosen, a simple type definition;"

ht

[1] http://www.w3.org/TR/xmlschema-1/#src-ct
-- 
  Henry S. Thompson, HCRC Language Technology Group, University of Edinburgh
          W3C Fellow 1999--2001, part-time member of W3C Team
     2 Buccleuch Place, Edinburgh EH8 9LW, SCOTLAND -- (44) 131 650-4440
	    Fax: (44) 131 650-4587, e-mail: ht@cogsci.ed.ac.uk
		     URL: http://www.ltg.ed.ac.uk/~ht/
Received on Thursday, 21 June 2001 05:36:12 GMT

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