title: Merging data from an XML node to another node using XSLT
body: <p>Using XSLT, I am trying to figure out how to merge/update the data in a set of nodes with data from another set of nodes. The nodes have the same schema, but different parents. The data needs to be merged based on a shared parent attribute. In the example below, data is being copied from Principal to Driver. Can anyone help me out here?</p>
  
  <p>Input File:</p>
  
  <pre><code>&lt;Info&gt;
    &lt;Principal id="Insured"&gt;
      &lt;PersonName&gt;
        &lt;GivenName&gt;Jane&lt;/GivenName&gt;
        &lt;OtherGivenName&gt;A&lt;/OtherGivenName&gt;
        &lt;Surname&gt;Doe&lt;/Surname&gt;
      &lt;/PersonName&gt;
      &lt;PersonInfo&gt;
        &lt;BirthDate&gt;01-01-1980&lt;/BirthDate&gt;
        &lt;MaritalStatus&gt;M&lt;/MaritalStatus&gt;
      &lt;/PersonInfo&gt;
      &lt;PrincipalInfo&gt;&lt;/PrincipalInfo&gt;
    &lt;/Principal&gt;
    &lt;Policy&gt;
      &lt;Driver id="Insured"&gt;
        &lt;PersonName&gt;
          &lt;GivenName&gt;Jane&lt;/GivenName&gt;
          &lt;Surname&gt;Smith&lt;/Surname&gt;
        &lt;/PersonName&gt;
        &lt;PersonInfo&gt;
          &lt;BirthDate&gt;01-01-1980&lt;/BirthDate&gt;
          &lt;MaritalStatus&gt;S&lt;/MaritalStatus&gt;
          &lt;Occupation&gt;Manager&lt;/Occupation&gt;
        &lt;/PersonInfo&gt;
      &lt;/Driver&gt;
      &lt;PolicyInfo&gt;&lt;/PolicyInfo&gt;
    &lt;/Policy&gt;
  &lt;/Info&gt;
  </code></pre>
  
  <p>Desired Result:</p>
  
  <pre><code>&lt;Info&gt;
    &lt;Principal id="Insured"&gt;
      &lt;PersonName&gt;
        &lt;GivenName&gt;Jane&lt;/GivenName&gt;
        &lt;OtherGivenName&gt;A&lt;/OtherGivenName&gt;
        &lt;Surname&gt;Doe&lt;/Surname&gt;
      &lt;/PersonName&gt;
      &lt;PersonInfo&gt;
        &lt;BirthDate&gt;01-01-1980&lt;/BirthDate&gt;
        &lt;MaritalStatus&gt;M&lt;/MaritalStatus&gt;
      &lt;/PersonInfo&gt;
      &lt;PrincipalInfo&gt;&lt;/PrincipalInfo&gt;
    &lt;/Principal&gt;
    &lt;Policy&gt;
      &lt;Driver id="Insured"&gt;
        &lt;PersonName&gt;
          &lt;GivenName&gt;Jane&lt;/GivenName&gt;
          &lt;OtherGivenName&gt;A&lt;/OtherGivenName&gt;
          &lt;Surname&gt;Doe&lt;/Surname&gt;
        &lt;/PersonName&gt;
        &lt;PersonInfo&gt;
          &lt;BirthDate&gt;01-01-1980&lt;/BirthDate&gt;
          &lt;MaritalStatus&gt;M&lt;/MaritalStatus&gt;
          &lt;Occupation&gt;Manager&lt;/Occupation&gt;
        &lt;/PersonInfo&gt;
      &lt;/Driver&gt;
      &lt;PolicyInfo&gt;&lt;/PolicyInfo&gt;
    &lt;/Policy&gt;
  &lt;/Info&gt;
  </code></pre>