title: XML class description to C++ class description: a design pattern?
body: <p>I was wondering whether there are any specific design patterns (maybe targeted at C++) for this situation.</p>
  
  <p>I have an XML file containing data in this format:</p>
  
  <pre><code>&lt;STH_XML&gt;
  &lt;tag1&gt;
      &lt;tag2 id="myId1"&gt;
          &lt;tag3 name="type" value="myVal1"/&gt;
          &lt;tag4 name="device" value="myVal2"/&gt;
          &lt;tag5 name="instances" value="myVal3"/&gt;
          &lt;tag6&gt;
              &lt;tag7 id="myId2"&gt;
                  &lt;specs name="type" value="myVal4"/&gt;
                  &lt;specs name="frequency" value="myVal5" unit="MHz"/&gt;
              &lt;/tag7&gt;
          &lt;/tag6&gt;
      &lt;/tag2&gt;
  &lt;/tag1&gt;
  </code></pre>
  
  <p></p>
  
  <p>Unfortunately, the XSD/DTD of this XML is subject to frequent changes.</p>
  
  <p>I need to automatically convert the XSD/DTD into a series of C++ structures or classes like this:</p>
  
  <pre><code>struct tag7
  {
     std::string id;
     std::string type;
     std::string frequency;
  }
  
  struct tag6
  {
     std::set&lt;tag7*&gt; tag6s;
  }
  
  struct tag2
  {
     std::string id;
     std::string type;
     std::string device;
     std::string instances;
     tag6 elem6; // because I know there is only one from the XSD analysis
  }
  
  struct tag1
  {
     std::set&lt;tag2&gt; tag2s;
  }
  </code></pre>
  
  <p><strong>What design pattern is best suited to realize this functionality?</strong></p>