title: Attribute/element co-occurrence constraint in XML Schema
body: <p>Is it possible to create an XML Schema which imposes a co-occurrence constraint to an attribute/element pair?</p>
  
  <pre><code>&lt;primitive-list&gt;
      &lt;primitive name="P1"&gt;
          &lt;definition&gt;&lt;!-- primitive specification --&gt;&lt;/definition&gt;
      &lt;/primitive&gt;
      &lt;primitive name="P2"&gt;
          &lt;definition&gt;&lt;!-- primitive specification --&gt;&lt;/definition&gt;
      &lt;/primitive&gt;
  
      &lt;!-- other common primitives are specified here--&gt;
  
  &lt;primitive-list&gt;
  
  &lt;composite-list&gt;
      &lt;composite name="C1"&gt;
          &lt;primitive ref="P1" /&gt;
          &lt;primitive ref="P2" /&gt;
          &lt;primitive&gt;
              &lt;definition&gt;&lt;!-- inline primitive specification --&gt;&lt;/definition&gt;
          &lt;/primitive&gt;        
      &lt;/composite&gt;
  
      &lt;!-- Other compisites are specified here--&gt;
  
  &lt;/composite-list&gt;
  </code></pre>
  
  <p>The schema should imply that:</p>
  
  <ul>
  <li>If a <b>primitive</b> element is specified inside a <b>primitive-list</b> element, then it should contain the <b>name</b> attribute and the embedded <b>definition</b> element, but not the <b>ref</b> attribute.</li>
  <li>If a <b>primitive</b> element is specified in the <b>composite</b> element, then it should contain either the <b>ref</b> attribute or the <b>definition</b> element. The <b>name</b> is allowed in neither cases.</li>
  </ul>
  
  <p>I am pretty sure that it is possible since the <b>element</b> element in XML Schema itself behaves just like that. So anybody who is in possession of that sacred knowledge please share :-)</p>
  
  <p>Thank you in advance.</p>