XSD choice inside all

xsd

Solution

Check this link: http://www.w3.org/wiki/Needs_choice_inside_all

I summarize for you the solutions proposed:

One solution is to wrap the element that can change inside another:

  <xsd:all>
   <xsd:element minOccurs="0" maxOccurs="1" ref="sending" />
   <xsd:element minOccurs="0" maxOccurs="1" ref="logging"/>
   <xsd:element minOccurs="0" maxOccurs="1" ref ="usetype"/>
  </xsd:all>

 <xsd:element name="usetype">
  <xsd:complexType>
   <xsd:choice>
    <xsd:element ref="useonly"/>
    <xsd:element ref="notuseonly"/>
   </xsd:choice>
  </xsd:complexType>
 </xsd:element>

The other one is to use a substitution group:

  <xsd:all>
   <xsd:element ref="sending"/>
   <xsd:element ref="logging"/>
   <xsd:element ref="usetype"/>
  </xsd:all>
 </xsd:complexType>
 <xsd:element name="usetype" abstract="true"/>
 <xsd:element name="useonly" substitutionGroup="usetype"> ... </xsd:element>
 <xsd:element name="notuseonly" substitutionGroup="usetype"> ... </xsd:element>

Problem

You can't put choice tag inside the all tag. So, is there any workaround to get this functionallity? For example, I have`<settings>` tag like: ``` <settings> <logging /> <sending /> <useonly /> </settings> ``` Or something like ``` <settings> <logging /> <notuseonly /> <sending /> </settings> ``` So I want to prevent `<useonly>` and `<notuseonly>` showing up together, while the order is not important. And if allowed, in XSD it would look like: ``` <xs:all> <xs:element minOccurs="0" maxOccurs="1" ref="sending" /> <xs:element minOccurs="0" maxOccurs="1" ref="logging" /> <xs:choice> <xs:element minOccurs="0" maxOccurs="1" ref ="useonly" /> <xs:element minOccurs="0" maxOccurs="1" ref ="notuseonly" /> </xs:choice> </xs:all> ``` Any thoughts?

Original source