Andrey Bushman
Andrey Bushman

Reputation: 12516

OR logic in XSD file

Fragment of my XSD file:

  <!--ru-RU: Группа настроек-->
  <!--en-US: Settings group-->
  <xs:complexType name="settingsGroup" >    
    <xs:sequence>
      <xs:element name="string" type="stringValue" minOccurs="0" maxOccurs="unbounded"/>
      <xs:element name="bool" type="boolValue" minOccurs="0" maxOccurs="unbounded"/>
      <xs:element name="date" type="dateValue" minOccurs="0" maxOccurs="unbounded"/>
      <xs:element name="dateTime" type="dateTimeValue" minOccurs="0" maxOccurs="unbounded"/>
      <xs:element name="int" type="intValue" minOccurs="0" maxOccurs="unbounded"/>
      <xs:element name="double" type="doubleValue" minOccurs="0" maxOccurs="unbounded"/>
      <xs:element name="day" type="dayValue" minOccurs="0" maxOccurs="unbounded"/>
      <xs:element name="month" type="monthValue" minOccurs="0" maxOccurs="unbounded"/>
      <xs:element name="year" type="yearValue" minOccurs="0" maxOccurs="unbounded"/>
      <xs:element name="localization" type="languageValue" minOccurs="0" maxOccurs="unbounded"/>     
    </xs:sequence>
    <xs:attribute name="nameId" type="xs:ID" use="required"/>
  </xs:complexType>

I need to change the 'settingsGroup' type so that it can get or a collection of the 'settingsGroup' types, or what is specified by me in the scheme above... How can I write it OR logic in XSD file?

Something like this:

  <!--ru-RU: Группа настроек-->
  <!--en-US: Settings group-->
  <xs:complexType name="settingsGroup" >
    <!--en-US: Something like it:-->
    <xs:or>
        <xs:sequence>
            <xs:element name="group" type="settingsGroup" minOccurs="0" maxOccurs="unbounded"/>
        </xs:sequence>
        <xs:sequence>
          <xs:element name="string" type="stringValue" minOccurs="0" maxOccurs="unbounded"/>
          <xs:element name="bool" type="boolValue" minOccurs="0" maxOccurs="unbounded"/>
          <xs:element name="date" type="dateValue" minOccurs="0" maxOccurs="unbounded"/>
          <xs:element name="dateTime" type="dateTimeValue" minOccurs="0" maxOccurs="unbounded"/>
          <xs:element name="int" type="intValue" minOccurs="0" maxOccurs="unbounded"/>
          <xs:element name="double" type="doubleValue" minOccurs="0" maxOccurs="unbounded"/>
          <xs:element name="day" type="dayValue" minOccurs="0" maxOccurs="unbounded"/>
          <xs:element name="month" type="monthValue" minOccurs="0" maxOccurs="unbounded"/>
          <xs:element name="year" type="yearValue" minOccurs="0" maxOccurs="unbounded"/>
          <xs:element name="localization" type="languageValue" minOccurs="0" maxOccurs="unbounded"/>     
        </xs:sequence>
    </xs:or>
    <xs:attribute name="nameId" type="xs:ID" use="required"/>
  </xs:complexType>

Upvotes: 0

Views: 410

Answers (1)

Rookie Programmer Aravind
Rookie Programmer Aravind

Reputation: 12154

Its <xs:choice> .. use it in place of <xs:or>

Upvotes: 1

Related Questions