Domanda

How to connect the (all) element with the above (sequence) element ? or it is already connected together ? we have done them separately because it's invalid to put (sequence) and (all) together in same element(caseif).

Here is the schema :

<xs:element name="caseif">   
<xs:complexType>
<xs:sequence>
<xs:element ref="condition" minOccurs="1" /> 
</xs:sequence>
</xs:complexType>
</xs:element>

<xs:complexType>
<xs:all>
<xs:element ref="send"/>
<xs:element ref="call"/>
<xs:element ref="variable"/>
<xs:element ref="input"/>
<xs:element ref="output"/>
<xs:element ref="file"/>
<xs:element ref="comment"/>
<xs:element ref="loop"/>
<xs:element ref="case"/>
<xs:element ref="assignment"/>
</xs:all>
</xs:complexType>
È stato utile?

Soluzione

The simplest design here is to put the send, call, etc. elements into a wrapper. Then the declarations can take the form

<complexType name="caseif">
  <sequence>
    <element ref="tns:condition"/>
    <element ref="tns:then"/>
  </sequence>
</complexType>
<complexType name="wrapper">
  <all>
    <element ref="send" minOccurs="1"/>
    <element ref="call" minOccurs="1"/>
    <element ref="variable" minOccurs="1"/>
    ...
    <element ref="assignment" minOccurs="1"/>
  </all>
</complexType>
<element name="caseif" type="tns:caseif"/>
<element name="condition" type="tns:..."/>
<element name="then" type="tns:wrapper"/>

An alternative is to fix a sequence for send, call, etc. If the order in which they appear conveys information, fixing an order is impossible. If it doesn't, fixing an order helps ensure no one thinks it does convey any information.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top