Re: conditional schemas

>In this case, wouldn't I have to duplicate everything that is inside the
"actions" element? 'Cause that's quite a lot...
>Regards, Lieve

Ok, here goes...

<xs:complexType name="outer">
  <xs:choice>
    <xs:element name="action" type="actionsWithAccess"/>
    <xs:element name="action" type="actionsWithSettings"/>
  </xs:choice>
</xs:complexType>

<xs:complexType name="action">
  <xs:sequence>
    <xs:element name="whatevercontent"/>
    <xs:element name="whatevercontent2"/>
  </xs:sequence>
</xs:complexType>

<xs:complexType name="actionsWithSettings">
  <xs:complexContent>
    <xs:extension base="action">
      <xs:attribute name="name" use="required" fixed="settings"/>
    </xs:extension>
  </xs:complexContent>
</xs:complexType>

<xs:complexType name="actionsWithAccess">
  <xs:complexContent>
    <xs:extension base="action">
      <xs:sequence>
        <xs:element name="tag"/>
      </xs:sequence>
      <xs:attribute name="name" use="required" fixed="access"/>
    </xs:extension>
  </xs:complexContent>
</xs:complexType>

First <xs:complexType name="outer"> is the whole that combines the other
parts. It contains a choice between two elements of type actionsWithSettings
and actionsWithAccess. <xs:complexType name="action"> is the base action
type that <xs:element name="actionsWithSettings"> and <xs:element
name="actionsWithAccess"> extends. This way you have a common base for both
elements. Perhaps not the easiest solution, but it works, and can be used as
common framework for this type of problems.

I'd like some expertise input to this solution though, since I've never
tried this it before, and am a bit uncertain about extensions.

Best regards

Erik Beijnoff
Systems development

erik.beijnoff@addsystems.com
erik@beijnoff.com

Received on Wednesday, 28 November 2001 10:20:17 UTC