title: Need to match elements from different nodes
body: <p>Below is a snippet of the XML.</p>
  
  <pre><code>&lt;wd:Report_Data xmlns:wd="urn:com.workday.report/CRINT-Outbound"&gt;
      &lt;wd:Report_Entry&gt;
          &lt;wd:Worker&gt;
              &lt;wd:Employee_ID&gt;TestId1&lt;/wd:Employee_ID&gt;
              &lt;wd:Full_Legal_Name&gt;Test Name1&lt;/wd:Full_Legal_Name&gt;
          &lt;/wd:Worker&gt;
          &lt;wd:Deduction-Code&gt;TestCode1&lt;/wd:Deduction-Code&gt;
          &lt;wd:Result_Line_Amount&gt;100&lt;/wd:Result_Line_Amount&gt;
      &lt;/wd:Report_Entry&gt;
      &lt;wd:Report_Entry&gt;
          &lt;wd:Worker&gt;
              &lt;wd:Employee_ID&gt;TestId1&lt;/wd:Employee_ID&gt;
              &lt;wd:Full_Legal_Name&gt;Test Name1&lt;/wd:Full_Legal_Name&gt;
          &lt;/wd:Worker&gt;
          &lt;wd:Earning_Code&gt;TestCode1&lt;/wd:Earning_Code&gt;
          &lt;wd:Result_Line_Amount&gt;200&lt;/wd:Result_Line_Amount&gt;
      &lt;/wd:Report_Entry&gt;
  &lt;/wd:Report_Data&gt;
  </code></pre>
  
  <p>Below is a snippet of my XSLT.</p>
  
  <pre><code>    &lt;xsl:variable name="employeeId"&gt;
          &lt;xsl:value-of select="wd:Worker/wd:Employee_ID"/&gt;
      &lt;/xsl:variable&gt;
  
      &lt;xsl:variable name="deductionCode"&gt;
          &lt;xsl:value-of select="wd:Earning_Code"/&gt;
      &lt;/xsl:variable&gt;
  
      &lt;OffsetAmount&gt;
          &lt;xsl:variable name="offsetCode" select="$deductionCode"/&gt;
  
          &lt;xsl:apply-templates select="/wd:Report_Data/wd:Report_Entry[wd:Deduction-Code]"&gt;
              &lt;xsl:with-param name="idParam" select="$employeeId"&gt;&lt;/xsl:with-param&gt;
              &lt;xsl:with-param name="deductionParam" select="$offsetCode"&gt;&lt;/xsl:with-param&gt;
          &lt;/xsl:apply-templates&gt;
  
      &lt;/OffsetAmount&gt;
  
  &lt;/xsl:template&gt;
  
  &lt;xsl:template match="/wd:Report_Data/wd:Report_Entry[wd:Deduction-Code]"&gt;
      &lt;xsl:param name="idParam"/&gt;
      &lt;xsl:param name="deductionParam"/&gt;
      &lt;xsl:value-of select="/wd:Report_Data/wd:Report_Entry[wd:Worker/wd:Employee_ID = $idParam and wd:Deduction-Code = $deductionParam]/wd:Result_Line_Amount"/&gt;
  &lt;/xsl:template&gt;
  
  &lt;/xsl:stylesheet&gt;
  </code></pre>
  
  <p>I need to match the wd:Deduction-Code from one node to the matching wd:Earning_Code from another node so I can include the corresponding amounts for earning and deduction in the output like below.</p>
  
  <pre><code>TestId1, Test Name1, TestCode1, 100, 200
  </code></pre>
  
  <p>But with my code, I am able to get TestId1, Test Name1, TestCode1, 100 but not 200.</p>
  
  <pre><code>TestId1, Test Name1, TestCode1, 100, 
  </code></pre>
  
  <p>Any suggestion would be most welcome. Thanks!</p>