title: XSD type validation according to one attribute value
body: <p>As I remember, some time ago I had similar piece of XML:</p>
  
  <pre><code>&lt;item type="Person" name="Pawel" Surname="Wu" /&gt;
  &lt;item type="Address" city="Sample town" address="Sample street etc." /&gt;
  </code></pre>
  
  <p>and I wantetd to validate it with XSD. However, last time I did it (about 2 years ago I had such a task) it was impossible to specify element type according to attribute value (<strong>type</strong> in this example). So I was forced to redesign XML structure into something like this:</p>
  
  <pre><code>&lt;person name=..... /&gt;
  &lt;address city=..... /&gt;
  </code></pre>
  
  <p>and writing XSD was piece of cake.</p>
  
  <p>Today, I have similar issue. As an input I get XML document with generic <strong>item</strong> elements that have <strong>type</strong> attriibute, and latter, depending on this attribute value, another attributes are allowed/required or not. Documents in that shape are still created in system manually, so I would like to have an XSD document that will reduce/eliminate errors (it's easy to forget that element <strong>item</strong> with <strong>type="personalDetails"</strong> must have a particular collection of attributes set).</p>
  
  <p>Is it possible to write a XSD schema to validate such a documents now?</p>
  
  <p>Thanks,Pawel</p>