W3C home > Mailing lists > Public > xmlschema-dev@w3.org > March 2002

Restriction with substitution, can I do this???

From: Joey Coyle <joey@xcoyle.com>
Date: Mon, 11 Mar 2002 17:05:55 -0500 (EST)
Message-Id: <5.1.0.14.2.20020311143955.00a8d6b0@wheresmymailserver.com>
To: xmlschema-dev@w3.org
Is this valid, I basically have a type which contains a sequence of 
itself.   Then I define two restrictions,  Blue and Green, and then comes 
my question.... called MyQuestionBase, can I substitute the unbounded 
"item" element with just two subclasses Blue and Green.  This seems like 
substitution groups, but they are not global elements, they are global 
complex types that I am substituting for "item" in the restriction.   This 
validates OK, but I don't really trust if it is valid?????  Please help
joey coyle

<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" 
elementFormDefault="qualified" attributeFormDefault="unqualified">

         <xs:complexType name="Base">
                 <xs:sequence>
                         <xs:element name="item" type="Base" 
maxOccurs="unbounded"/>
                 </xs:sequence>
         </xs:complexType>


         <xs:complexType name="BlueBase">
                 <xs:complexContent>
                         <xs:restriction base="Base">
                                 <xs:sequence>
                                         <xs:element name="item" 
type="Base" maxOccurs="unbounded"/>
                                 </xs:sequence>
                         </xs:restriction>
                 </xs:complexContent>
         </xs:complexType>


         <xs:complexType name="GreenBase">
                 <xs:complexContent>
                         <xs:restriction base="Base">
                                 <xs:sequence>
                                         <xs:element name="item" 
type="Base" maxOccurs="unbounded"/>
                                 </xs:sequence>
                         </xs:restriction>
                 </xs:complexContent>
         </xs:complexType>



         <xs:complexType name="MyQuestionBase">
                 <xs:complexContent>
                         <xs:restriction base="Base">
                                 <xs:sequence>
                                         <xs:element name="blue" 
type="BlueBase"/>
                                         <xs:element name="green" 
type="GreenBase"/>
                                 </xs:sequence>
                         </xs:restriction>
                 </xs:complexContent>
         </xs:complexType>


</xs:schema>
Received on Tuesday, 12 March 2002 04:25:13 GMT

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