[xsd-users] abstract and substitutionGroup

Boris Kolpackov boris at codesynthesis.com
Thu May 6 14:08:06 EDT 2010


Hi Ray,

Ray Lischner <rlischner at proteuseng.com> writes:

>   <xsd:complexType name="Base" abstract="true"/>
>   <xsd:complexType name="Der1">
>     <xsd:complexContent>
>       <xsd:extension base="msg:Base">
>         <xsd:sequence>
>           <xsd:element name="i" type="xsd:int"/>
>         </xsd:sequence>
>       </xsd:extension>
>     </xsd:complexContent>
>   </xsd:complexType>
>   <xsd:complexType name="Der2">
>     <xsd:complexContent>
>       <xsd:extension base="msg:Der1">
>         <xsd:sequence>
>           <xsd:element name="s" type="xsd:string"/>
>         </xsd:sequence>
>       </xsd:extension>
>     </xsd:complexContent>
>   </xsd:complexType>
>   <xsd:complexType name="Msg">
>     <xsd:sequence>
>       <xsd:element ref="msg:base"/>
>     </xsd:sequence>
>   </xsd:complexType>
>   <xsd:element name="message" type="msg:Msg"/>
>   <xsd:element name="base1" type="msg:Base"/>
                       ^^^^^
I assume you mean "base" here.


>   <xsd:element name="der1" type="msg:Der1" substitutionGroup="msg:base"/>
>
> [...]
>
> The resulting document is:
> 
> <message xmlns="msg">
>   <base xsi:type="Der2">
>     <i>1</i>
>     <s>str</s>
>   </base>
> </message>
> 
> The author of the schema claims that the abstract property should 
> prevent the use of <base>, and therefore force the use of <der1>:
> 
> <message xmlns="msg">
>   <der1 xsi:type="Der2">
>     <i>1</i>
>     <s>str</s>
>   </der1>
> </message>

No, either <base xsi:type="Der2"> or <der1 xsi:type="Der2"> are valid
forms since they both specify the actual type of the element which is
not abstract. However, if the the base element itself were declared
abstract:

<xsd:element name="base1" type="msg:Base" abstract="true"/>

Then it is possible (thought I am not 100% sure) that the first version
would have been invalid.

Boris



More information about the xsd-users mailing list