Re: conditional schemas

Hi Erik,


> Wouldn't it be possible to express this with something on the form:
>
> <xs:element name="testelement">
>   <xs:complexType>
>     <xs:choice>
>
>       <xs:element name="actions">
>         <xs:complexType>
>           <xs:sequence>
>             <xs:element name="tag"/>
>           </xs:sequence>
>             <xs:attribute name="name" use="required" fixed="access"/>
>         </xs:complexType>
>       </xs:element>
>
>       <xs:element name="actions">
>         <xs:complexType>
>           <xs:attribute name="name" use="required" fixed="settings"/>
>         </xs:complexType>
>       </xs:element>
>
>     </xs:choice>
>   </xs:complexType>
> </xs:element>

No, as Erik (van der Vlist) already pointed out, this would brake the
unique particle rule in W3C XML Schema. In this case it's because you
define two global elements with the same name but with different types.
Eric also pointed out that you can solve this by using the xsi:type
construct in the instance document but to use this appraoch would in
this case require some preprocessing that checks if the attribute value
really is access and in that case add the xsi:type attribute with the
correct datatype specified.

Cheers,
/Eddie

Received on Wednesday, 28 November 2001 17:31:29 UTC