title: How to make one of two optional tag dependent on the other?
body: <p>I have two tags in XSD:</p>
  
  <pre><code>&lt;xsd:element name="tag1" minOccurs="0"&gt;
  
  &lt;xsd:element name="tag2" minOccurs="0"&gt;
  </code></pre>
  
  <p>They are both optional and can be omitted. However I want to add a restriction that if tag2 is given, tag1 should also be given (as tag2 is dependent on tag1). How to achieve this by just XSD?</p>
  
  <hr>
  
  <p>Edit:</p>
  
  <p>There are mandatory tags between them. Thus a sequence will not work. e.g.</p>
  
  <pre><code>&lt;xsd:element name="tag1" minOccurs="0"&gt;
  &lt;xsd:element name="tag3" minOccurs="1"&gt;
  &lt;xsd:element name="tag4" minOccurs="1"&gt;
  &lt;xsd:element name="tag2" minOccurs="0"&gt;
  </code></pre>