0

I'm making an xsd and i was wondering, can i let the fact that a specific element is mandatory be based on a the value of a different element? For example, i have the following:

<xs:element name="Type" minOccurs="1">
    <xs:simpleType>
      <xs:restriction base="xs:string">
          <xs:enumeration value="01"/>
          <xs:enumeration value="02"/>
          <xs:enumeration value="03"/>
      </xs:restriction>
    </xs:simpleType>
</xs:element>
<xs:element name="Value01" type="xs:string" minOccurs="?"/>
<xs:element name="Value02" type="xs:string" minOccurs="?"/>

So if the value of Type is 01, Value01 is mandatory, Value02 is forbidden, If value of type is 02, Value02 is mandatory, Value01 is forbidden And if type is 03, both are forbidden.

Is this possible in a not to complicated way?

Thanks in advance, Thomas

1 Answers1

0

It can be done in XSD 1.1 (using xsd:assert) but not in XSD 1.0.

Michael Kay
  • 156,231
  • 11
  • 92
  • 164