title: How to join two node sets based on unique element?
body: <p>I have one big xml file with different node sets that I need to combine using xsl based on a unique element value that both nodes contain. </p>
  
  <p>Here's a sample of the xml file that needs to be transformed: </p>
  
  <pre><code>&lt;root&gt;
    &lt;node1&gt;
      &lt;funds&gt;
        &lt;fund&gt;
          &lt;FundId&gt;a&lt;/FundId&gt;
          &lt;FundName&gt;fund a&lt;/FundName&gt;
          &lt;SomeInfo&gt;some info&lt;/SomeInfo&gt;
        &lt;/fund&gt;
        &lt;fund&gt;
          &lt;FundId&gt;b&lt;/FundId&gt;
          &lt;FundName&gt;fund b&lt;/FundName&gt;
          &lt;SomeInfo&gt;some info&lt;/SomeInfo&gt;
        &lt;/fund&gt;
        &lt;fund&gt;
          &lt;FundId&gt;c&lt;/FundId&gt;
          &lt;FundName&gt;fund c&lt;/FundName&gt;
          &lt;SomeInfo&gt;some info&lt;/SomeInfo&gt;
        &lt;/fund&gt;
      &lt;/funds&gt;
    &lt;/node1&gt;
    &lt;node2&gt;
      &lt;funds&gt;
        &lt;fund&gt;
          &lt;FundId&gt;a&lt;/FundId&gt;
          &lt;MaxInvestmentAmount&gt;200&lt;/MaxInvestmentAmount&gt;
          &lt;MinInvestmentAmount&gt;1&lt;/MinInvestmentAmount&gt;
        &lt;/fund&gt;
        &lt;fund&gt;
          &lt;FundId&gt;b&lt;/FundId&gt;
          &lt;MaxInvestmentAmount&gt;100&lt;/MaxInvestmentAmount&gt;
          &lt;MinInvestmentAmount&gt;5&lt;/MinInvestmentAmount&gt;
        &lt;/fund&gt;
        &lt;fund&gt;
          &lt;FundId&gt;c&lt;/FundId&gt;
          &lt;MaxInvestmentAmount&gt;50&lt;/MaxInvestmentAmount&gt;
          &lt;MinInvestmentAmount&gt;20&lt;/MinInvestmentAmount&gt;
        &lt;/fund&gt;
      &lt;/funds&gt;
    &lt;/node2&gt;
  &lt;/root&gt;
  </code></pre>
  
  <p>And here's the desired output: </p>
  
  <pre><code>&lt;node&gt;
      &lt;funds&gt;
          &lt;fund&gt;
              &lt;FundId&gt;a&lt;FundId/&gt;
              &lt;FundName&gt;fund a&lt;/FundName&gt;
              &lt;SomeInfo&gt;some info&lt;/SomeInfo&gt;
              &lt;MaxInvestmentAmount&gt;200&lt;/MaxInvestmentAmount&gt;
              &lt;MinInvestmentAmount&gt;1&lt;/MinInvestmentAmount&gt;
          &lt;/fund&gt;
          &lt;fund&gt;
              &lt;FundId&gt;b&lt;FundId/&gt;
              &lt;FundName&gt;fund b&lt;/FundName&gt;
              &lt;SomeInfo&gt;some info&lt;/SomeInfo&gt;
              &lt;MaxInvestmentAmount&gt;100&lt;/MaxInvestmentAmount&gt;
              &lt;MinInvestmentAmount&gt;5&lt;/MinInvestmentAmount&gt;
          &lt;/fund&gt;
          &lt;fund&gt;
              &lt;FundId&gt;c&lt;FundId/&gt;
              &lt;FundName&gt;fund c&lt;/FundName&gt;
              &lt;SomeInfo&gt;some info&lt;/SomeInfo&gt;
              &lt;MaxInvestmentAmount&gt;50&lt;/MaxInvestmentAmount&gt;
              &lt;MinInvestmentAmount&gt;20&lt;/MinInvestmentAmount&gt;
          &lt;/fund&gt;
      &lt;/funds&gt;
  &lt;/node&gt;
  </code></pre>
  
  <p>I've tried template matching but this doesn't seem to work the way I have tried it since both nodes have the same inner node names so they keep overriding each other. </p>