title: XSLT 'value-of select' on multiple attribute check at different level
body: <p>This is a simplifed Xml example for the problem I am facing.I have to set attribute <code>Class</code> value in output xml by matching on <code>NameID</code> &amp; <code>SRNo</code> in <code>&lt;Info&gt;</code> and <code>&lt;/Address&gt;</code> .   Note: Attributes are at different level.   </p>
  
  <pre><code>&lt;Detail   DetailKey="11119612" DetailNo="123456" DetailType="A"&gt;
      &lt;Infos&gt;
          &lt;Info InfoKey="11111599613" SRNo="1" Class="C"&gt;
              &lt;NameID NameID="121212" /&gt;
          &lt;/Info&gt;
          &lt;Info InfoKey="11111599612" SRNo="2" Class="A" &gt;
              &lt;NameID NameID="121213" /&gt;
          &lt;/Info&gt;     
      &lt;/Infos&gt;
      &lt;Addresss&gt;
          &lt;Address AddressKey="11111591234" SRNo="1" &gt;
              &lt;NameID NameID="121212" /&gt;
          &lt;/Address&gt;
          &lt;Address AddressKey="11111593243" SRNo="2" &gt;
              &lt;NameID NameID="121213" /&gt;
          &lt;/Address&gt;      
      &lt;/Addresss&gt;
  &lt;/Detail&gt;
  </code></pre>
  
  <p>What I have tried.  </p>
  
  <pre><code>&lt;xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"&gt;
     &lt;xsl:output method="xml" indent="yes" /&gt;
     &lt;xsl:template match="/"&gt;
        &lt;Detail&gt;
           &lt;Infos&gt;
              &lt;xsl:for-each select="Detail/Addresss/Address"&gt;
                 &lt;Info&gt;
                    &lt;xsl:attribute name="AddressKey"&gt;
                       &lt;xsl:value-of select="@AddressKey" /&gt;
                    &lt;/xsl:attribute&gt;
                    &lt;xsl:variable name="vSRNo" select="@SRNo" /&gt;
                    &lt;xsl:variable name="vNameID" select="NameID/@NameID" /&gt;
                    &lt;xsl:attribute name="Class"&gt;
                       &lt;xsl:value-of select="../../Infos/Info[@SRNo=$vSRNo]/Name[@NameID=$vNameID]/../@Class" /&gt;
                    &lt;/xsl:attribute&gt;
                 &lt;/Info&gt;
              &lt;/xsl:for-each&gt;
           &lt;/Infos&gt;
        &lt;/Detail&gt;
     &lt;/xsl:template&gt;
  &lt;/xsl:stylesheet&gt;
  </code></pre>