W3C home > Mailing lists > Public > xmlschema-dev@w3.org > January 2009

Re: restriction against base type (choice - elt)

From: George Cristian Bina <george@oxygenxml.com>
Date: Wed, 28 Jan 2009 09:00:53 +0200
Message-ID: <498002A5.502@oxygenxml.com>
To: Bharath Kumar Reddy T <bharathkr@huawei.com>
Cc: xmlschema-dev@w3.org, ashutosh_p@huawei.com, ranjit@huawei.com

Hi,

If you take your initial sample and remove the substitution group you 
will get exactly to that situation:

<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">

<xs:element name="head"/>
<xs:element name="m1"/>
<xs:element name="m2"/>

<xs:complexType name="base">
  <xs:sequence>
   <xs:element ref="head"/>
  </xs:sequence>
</xs:complexType>

<xs:complexType name="derived">
  <xs:complexContent>
   <xs:restriction base="base">
    <xs:sequence>
           <xs:choice>
              <xs:element ref="m1"/>
              <xs:element ref="m2"/>
           </xs:choice>
    </xs:sequence>
   </xs:restriction>
  </xs:complexContent>
</xs:complexType>

</xs:schema>

Best Regards,
George
-- 
George Cristian Bina
<oXygen/> XML Editor, Schema Editor and XSLT Editor/Debugger
http://www.oxygenxml.com

Bharath Kumar Reddy T wrote:
> 
> 
> Hi..
> 
> In the table which is in the link 
> http://www.w3.org/TR/xmlschema-1/#cos-particle-restrict it is given that 
> the case
> 
> Choice(derived) and elt(base) is forbidden.
> 
> Can you please tell me the meaning of this??
> 
> Thanks and Regards,
> Bharath.
> 
> 
> -----Original Message-----
> From: George Cristian Bina [mailto:george@oxygenxml.com]
> Sent: Tuesday, January 27, 2009 12:35 PM
> To: Bharath Kumar Reddy T
> Cc: xmlschema-dev@w3.org; ashutosh_p@huawei.com; ranjit@huawei.com
> Subject: Re: restriction against base type (choice - elt)
> 
> Hi Bharath,
> 
> It looks valid to me because the head from the base is treated as a 
> choice of head, m1 and m2, see
> 
> http://www.w3.org/TR/xmlschema-1/#cos-particle-restrict
> 
> 2.1 Any top-level element declaration particle (in R or B) which is the 
> {substitution group affiliation} of one or more other element 
> declarations and whose Ěsubstitution groupĚ contains at least one 
> element declaration other than itself is treated as if it were a choice 
> group whose {min occurs} and {max occurs} are those of the particle, and 
> whose {particles} consists of one particle with {min occurs} and {max 
> occurs} of 1 for each of the declarations in its Ěsubstitution groupĚ.
> 
> Best Regards,
> George
> --
> George Cristian Bina
> <oXygen/> XML Editor, Schema Editor and XSLT Editor/Debugger 
> http://www.oxygenxml.com
> 
> Bharath Kumar Reddy T wrote:
>  > Hi..
>  > 
>  > According to specification the following schema is invalid since
>  > according to the table in
>  > http://www.w3.org/TR/xmlschema-1/#cos-particle-restrict
>  > it is given that the case "choice (Derived particle) to element(Base
>  > Particle) is Forbidden"
>  > 
>  > 
>  > 
>  > <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
>  > 
>  > <xs:element name="head"/>
>  > <xs:element name="m1" substitutionGroup="head"/> <xs:element name="m2"
>  > substitutionGroup="head"/>
>  > 
>  > <xs:complexType name="base">
>  >  <xs:sequence>
>  >   <xs:element ref="head"/>
>  >  </xs:sequence>
>  > </xs:complexType>
>  > 
>  > <xs:complexType name="derived">
>  >  <xs:complexContent>
>  >   <xs:restriction base="base">
>  >    <xs:sequence>
>  >           <xs:choice>
>  >              <xs:element ref="m1"/>
>  >              <xs:element ref="m2"/>
>  >           </xs:choice>
>  >    </xs:sequence>
>  >   </xs:restriction>
>  >  </xs:complexContent>
>  > </xs:complexType>
>  > 
>  > </xs:schema>
>  > 
>  > Can anybody please tell me whether the above schema is valid or
>  > invalid against the schema spec.
>  > 
>  > Thanks and Regards,
>  > Bharath.
>  > 
> 
Received on Wednesday, 28 January 2009 07:01:14 UTC

This archive was generated by hypermail 2.4.0 : Friday, 17 January 2020 23:15:50 UTC