title: XSD validate element depending on parent node
body: <p><code>&lt;a&gt;</code> can have text and <code>&lt;i&gt;</code> tag, <code>&lt;i&gt;</code> can have text and <code>&lt;a&gt;</code> tag inside.</p>
  
  <pre><code>&lt;a&gt;lol&lt;i&gt;so rad&lt;/i&gt;&lt;/a&gt; - valid
  &lt;i&gt;so sweet &lt;a&gt;lolz&lt;/a&gt;&lt;/i&gt; - valid
  </code></pre>
  
  <p>My current solution has a serious flaw, next one is "valid", cos inner <code>&lt;a&gt;</code> wrapped in <code>&lt;i&gt;</code>.</p>
  
  <pre><code>&lt;a&gt;so what now &lt;i&gt;so sweet &lt;a&gt;lolz&lt;/a&gt;&lt;/i&gt;&lt;/a&gt;
  </code></pre>
  
  <p>I want to test <code>&lt;i&gt;</code> element parent, so i can forbid <code>&lt;a&gt;</code> child elements if it is inside <code>&lt;a&gt;</code> tag.</p>
  
  <p>Current XSD:</p>
  
  <pre><code>&lt;xs:element name="a"&gt;
    &lt;xs:complexType&gt;
       &lt;xs:complexContent&gt;
          &lt;xs:extension base="bodyMixed"&gt;
            &lt;xs:attribute name="href" type="xs:anyURI" use="required" /&gt;
            &lt;xs:attribute name="target" type="xs:string" /&gt;
          &lt;/xs:extension&gt;
        &lt;/xs:complexContent&gt;
       &lt;/xs:complexType&gt;
  &lt;/xs:element&gt;
  
  &lt;xs:complexType name="bodyMixed" mixed="true"&gt;
      &lt;xs:group ref="fontStyle" minOccurs="0" maxOccurs="unbounded"/&gt;
  &lt;/xs:complexType&gt;
  
  &lt;xs:complexType name="basic" mixed="true"&gt;
     &lt;xs:sequence&gt;
        &lt;xs:element ref="a" minOccurs="0" maxOccurs="unbounded"/&gt;
     &lt;/xs:sequence&gt;
  &lt;/xs:complexType&gt;
  
  &lt;xs:group name="fontStyle"&gt;
      &lt;xs:choice&gt;
         &lt;xs:element name="i" type="basic"/&gt;
      &lt;/xs:choice&gt;
  &lt;/xs:group&gt;
  </code></pre>