Re: complexType : extension of a sequence by a choice ?

Bruno Chatel a écrit :

>Hi,
>
>I have some questions about extension of complexTypes (and do not found the answer
>in the specifications) :
>
>Is extension of a complexType composed of sequence, by using choise is allowed ?
>Is extension of a complexType composed of choice, by using sequence is allowed ?
>
>  
>
Nothing forbids it, and if you look at "3.4.2 XML Representation of 
Complex Type Definitions", the content type of the complex type 
definition is defined as:

----
[...]
2 If the <extension> alternative is chosen, then [Definition:]  let the 
explicit content be empty if any of the sub-clauses of clause 1.1 above 
applies, otherwise the particle corresponding to the <all>, <choice>, 
<group> or <sequence> among the [children], and then take the 
appropriate case among the following:

2.1 If the ·explicit content· is empty, then the {content type} of the 
type definition ·resolved· to by the ·actual value· of the base [attribute]

2.2 If the type definition ·resolved· to by the ·actual value· of the 
base [attribute] has a {content type} of empty, then a pair of mixed or 
elementOnly (determined as per clause 1.2.1 above) and the ·explicit 
content· itself;

2.3 otherwise a pair of mixed or elementOnly (determined as per clause 
1.2.1 above) and a particle whose properties are as follows:

{min occurs}
    1
{max occurs}
    1
{term}
    A model group whose {compositor} is sequence and whose {particles} 
are the particle of the {content type} of the type definition ·resolved· 
to by the ·actual value· of the base [attribute] followed by the 
·explicit content·.
----

>Are these derivations allowed ?
>
><xs:complexType name="tseq">
>    <xs:sequence>
>        <xs:element name="t1"/>
>        <xs:element name="t2"/>
>    </xs:sequence>
></xs:complexType>
>
><xs:complexType name="tchoi">
>    <xs:sequence>
>        <xs:element name="t3"/>
>        <xs:element name="t4"/>
>    </xs:sequence>
></xs:complexType>
>
><xs:complexType name="tseq-ext-choi">
>    <xs:complexContent>
>        <xs:extension base="tseq">
>            <xs:choice>
>                <xs:element name="t3"/>
>            </xs:choice>
>        </xs:extension>
>    </xs:complexContent>
></xs:complexType>
>
><xs:complexType name="tchoi-ext-seq">
>    <xs:complexContent>
>        <xs:extension base="tchoi">
>            <xs:sequence>
>                <xs:element name="t1"/>
>            </xs:sequence>
>        </xs:extension>
>    </xs:complexContent>
></xs:complexType>
>
>
>If yes, what is the effective content model for these ?
>
>  
>
For example, the term in the content type of tseq-ext-choi is equivalent to:

<xs:sequence>
  <xs:sequence>
    <xs:element name="t1"/>
    <xs:element name="t2"/>
  </xs:sequence>
  <xs:choice>
    <xs:element name="t3"/>
  </xs:choice>
</xs:sequence>

Michael

Received on Thursday, 5 February 2004 08:32:31 UTC