title: Xslt loop through different nodes and combine in BizTalk map
body: <p>I want to compare two records in a single xml file and fetch the matching records. (Note: I will not be able to change the InputSchema)</p>
  
  <blockquote>
    <p>The InputRequest1 contains Identifiers (ID and IDScheme) and which I
    want to compare with InputRequest2 which contains multiple Products
    and corresponding Identifiers (ID and IDScheme) and Login detials (ID
    and IDScheme - Login). I should compare the InputRequest1 to the
    InputRequest2 nodes and extract the matching Product details to form
    the Output. The Output should contain the Login and ID details as
    shown in the example below.</p>
  </blockquote>
  
  <p>Sample XML:    </p>
  
  <pre><code>&lt;ns0:Root xmlns:ns0="http://schemas.microsoft.com/BizTalk/2003/aggschema"&gt;
    &lt;InputMessagePart_0&gt;
      &lt;ns1:InputRequest1 xmlns:ns1="http://myClient/schema/5.0.0/"&gt;
        &lt;ns1:Identifier&gt;
          &lt;ns1:ID&gt;123456&lt;/ns1:ID&gt;
          &lt;ns1:IDScheme&gt;ABC&lt;/ns1:IDScheme&gt;
        &lt;/ns1:Identifier&gt;
        &lt;ns1:Identifier&gt;
          &lt;ns1:ID&gt;654321&lt;/ns1:ID&gt;
          &lt;ns1:IDScheme&gt;CBA&lt;/ns1:IDScheme&gt;
        &lt;/ns1:Identifier&gt;
        &lt;ns1:Identifier&gt;
          &lt;ns1:ID&gt;2356152&lt;/ns1:ID&gt;
          &lt;ns1:IDScheme&gt;ZZZ&lt;/ns1:IDScheme&gt;
        &lt;/ns1:Identifier&gt;
      &lt;/ns1:InputRequest1&gt;
    &lt;/InputMessagePart_0&gt;
    &lt;InputMessagePart_1&gt;
      &lt;ns1:InputRequest2 xmlns:ns1="http://myClient/schema/5.0.0/"&gt;
        &lt;ns1:Products&gt;
          &lt;ns1:ProfileContext&gt;
            &lt;ns1:LoginID&gt;
              &lt;ns1:ID&gt;login123&lt;/ns1:ID&gt;
              &lt;ns1:IDScheme&gt;USERID&lt;/ns1:IDScheme&gt;
            &lt;/ns1:LoginID&gt;
          &lt;/ns1:ProfileContext&gt;
          &lt;ns1:ProductDetails&gt;
            &lt;ns1:ProductIdentifier&gt;
              &lt;ns1:ID&gt;123456&lt;/ns1:ID&gt;
              &lt;ns1:IDScheme&gt;ABC&lt;/ns1:IDScheme&gt;
            &lt;/ns1:ProductIdentifier&gt;
          &lt;/ns1:ProductDetails&gt;
        &lt;/ns1:Products&gt;
        &lt;ns1:Products&gt;
          &lt;ns1:ProfileContext&gt;
            &lt;ns1:MemberIdentifier&gt;
              &lt;ns1:ID&gt;login789&lt;/ns1:ID&gt;
              &lt;ns1:IDScheme&gt;USERTID&lt;/ns1:IDScheme&gt;
            &lt;/ns1:MemberIdentifier&gt;
          &lt;/ns1:ProfileContext&gt;
          &lt;ns1:ProductDetails&gt;
            &lt;ns1:ProductIdentifier&gt;
              &lt;ns1:ID&gt;9876543&lt;/ns1:ID&gt;
              &lt;ns1:IDScheme&gt;DEF&lt;/ns1:IDScheme&gt;
            &lt;/ns1:ProductIdentifier&gt;
          &lt;/ns1:ProductDetails&gt;
        &lt;/ns1:Products&gt;
        &lt;ns1:Products&gt;
          &lt;ns1:ProfileContext&gt;
            &lt;ns1:MemberIdentifier&gt;
              &lt;ns1:ID&gt;login456&lt;/ns1:ID&gt;
              &lt;ns1:IDScheme&gt;USERTID&lt;/ns1:IDScheme&gt;
            &lt;/ns1:MemberIdentifier&gt;
          &lt;/ns1:ProfileContext&gt;
          &lt;ns1:ProductDetails&gt;
            &lt;ns1:ProductIdentifier&gt;
              &lt;ns1:ID&gt;456789&lt;/ns1:ID&gt;
              &lt;ns1:IDScheme&gt;CBA&lt;/ns1:IDScheme&gt;
            &lt;/ns1:ProductIdentifier&gt;
          &lt;/ns1:ProductDetails&gt;
        &lt;/ns1:Products&gt;
      &lt;/ns1:InputRequest2&gt;
    &lt;/InputMessagePart_1&gt;
  &lt;/ns0:Root&gt;
  </code></pre>
  
  <p><strong>I want the output to be:</strong></p>
  
  <pre><code>&lt;ns1:OutputRequest xmlns:ns1="http://myClientOutput/schema/5.0.0/"&gt;
    &lt;ns1:Identifier&gt;
      &lt;ns1:ID&gt;login123&lt;/ns1:ID&gt;
      &lt;ns1:IDScheme&gt;USERID&lt;/ns1:IDScheme&gt;
    &lt;/ns1:Identifier&gt;
    &lt;ns1:Identifier&gt;
      &lt;ns1:ID&gt;123456&lt;/ns1:ID&gt;
      &lt;ns1:IDScheme&gt;ABC&lt;/ns1:IDScheme&gt;
    &lt;/ns1:Identifier&gt;
    &lt;ns1:Identifier&gt;
      &lt;ns1:ID&gt;login456&lt;/ns1:ID&gt;
      &lt;ns1:IDScheme&gt;USERID&lt;/ns1:IDScheme&gt;
    &lt;/ns1:Identifier&gt;
    &lt;ns1:Identifier&gt;
      &lt;ns1:ID&gt;654321&lt;/ns1:ID&gt;
      &lt;ns1:IDScheme&gt;CBA&lt;/ns1:IDScheme&gt;
    &lt;/ns1:Identifier&gt;
  &lt;/ns1:OutputRequest&gt;
  </code></pre>
  
  <p>Can you please help me in the xslt for this transformation? Thanks.</p>