title: XML schema on type substitution
body: <p>i have an XML file like below and wanted to create an XML schema using type substitution method so that it can validate the below XML file. But the schema that i created is totally wrong.please show me how to code the schema to validate the file XML below.</p>
  
  <p>Details:</p>
  
  <ul>
  <li>there are only two types of animals being stored one is bird and one is fish.</li>
  <li>for both type, name and origin element is required</li>
  <li>for type:bird, additional color element can be optionally stored.</li>
  <li><p>for type:fish, additional size element is required to be store</p>
  
  <pre><code>&lt;animals&gt;
   &lt;animal animalID="b-1" xsi:type="bird"&gt;
       &lt;name&gt;Humming Bird&lt;/name&gt;
       &lt;origin&gt;Asia&lt;/origin&gt;
       &lt;color&gt;Blue&lt;/color&gt;
   &lt;/animal&gt; 
   &lt;animal animalID="b-2" xsi:type="bird"&gt;
       &lt;name&gt;Horn Bill&lt;/name&gt;
       &lt;origin&gt;Asia&lt;/origin&gt;
   &lt;/animal&gt;
   &lt;animal animalID="f-2" xsi:type="fish"&gt;
       &lt;name&gt;Whale&lt;/name&gt;
       &lt;origin&gt;Europe&lt;/origin&gt;
       &lt;size&gt;Large&lt;/size&gt;
   &lt;/animal&gt;
   &lt;animal animalID="b-5" xsi:type="bird"&gt;
       &lt;name&gt;Parrot&lt;/name&gt;
       &lt;origin&gt;Europe&lt;/origin&gt;
   &lt;/animal&gt;
  </code></pre>
  
  <p></p></li>
  </ul>
  
  <p>i have come out with the below schema and i think its totally wrong.</p>
  
  <pre><code> &lt;xsd:element name="bird" substitutionGroup="animals" 
           type="birdType"/&gt;
   &lt;xsd:element name="fish" substitutionGroup="animals" 
           type="fishType"/&gt;
   &lt;xsd:element name="animals"&gt;
  &lt;xsd:complexType&gt;
      &lt;xsd:sequence&gt;
          &lt;xsd:element name="animal" maxOccurs="unbounded"/&gt;
      &lt;/xsd:sequence&gt;
  &lt;/xsd:complexType&gt;
  &lt;/xsd:element&gt;
  
   &lt;xsd:element name="animal"&gt;
  &lt;xsd:complexType&gt;
      &lt;xsd:sequence&gt;
          &lt;xsd:element ref="bird" maxOccurs="unbounded"/&gt;
      &lt;/xsd:sequence&gt;
  &lt;/xsd:complexType&gt;
  &lt;/xsd:element&gt;
  </code></pre>