title: Create XSD for hierarchical data
body: <p>I want to export objects to XML and create XSD. following are the base classes</p>
  
  <pre><code>class Owner
  {
      private int id;
      private string name;
      private List&lt;Car&gt; cars;
      private int age;
  }
  
  class CarTemplate
  {
      private int drive;
      private double engineCc;
  }
  
  class Car
  {
      private int id;
      private string name;
      private double cost;
      private CarTemplate template;
  }
  </code></pre>
  
  <p>Following is the modified structure that I want to export to XML and create XSD out of it</p>
  
  <pre><code>class ExportedOwner
  {
      private int id;
      private string name;
      private List&lt;Car&gt; cars;
  }
  
  class ExportedCar
  {
      private string name;
      private double cost;
      private CarTemplate template;
  }
  </code></pre>
  
  <p>The structure of XML should be in following format</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8" ?&gt;
  &lt;Owner&gt;
      &lt;id&gt;1&lt;/id&gt;
      &lt;Name&gt;John&lt;/Name&gt;
      &lt;Age&gt;49&lt;/Age&gt;
      &lt;Cars&gt;
          &lt;Car&gt;
              &lt;id&gt;1&lt;/id&gt;
              &lt;Name&gt;Merc Class C&lt;/Name&gt;
              &lt;CarTemplate&gt;
                  &lt;drive&gt;2&lt;/drive&gt;
                  &lt;engineCc&gt;2500&lt;/engineCc&gt;
              &lt;/CarTemplate&gt;
          &lt;/Car&gt;
          &lt;Car&gt;
              &lt;id&gt;2&lt;/id&gt;
              &lt;Name&gt;Merc Class M&lt;/Name&gt;
              &lt;CarTemplate&gt;
                  &lt;drive&gt;4&lt;/drive&gt;
                  &lt;engineCc&gt;2900&lt;/engineCc&gt;
              &lt;/CarTemplate&gt;
          &lt;/Car&gt;
      &lt;/Cars&gt;
  &lt;/Owner&gt;
  </code></pre>
  
  <p>How can I create XSD for the XML format. I want XSD for importing the XML file back into the appication.</p>