title: How do I access elements from the outer loop from within nested loops?
body: <p>I have nested xsl:for loops:</p>
  
  <pre><code>&lt;xsl:for-each select="/Root/A"&gt;
      &lt;xsl:for-each select="/Root/B"&gt;
          &lt;!-- Code --&gt;
      &lt;/xsl:for&gt;
  &lt;/xsl:for&gt;
  </code></pre>
  
  <p><strong>From within the inner loop, how can I access attributes from the current node in the outer loop?</strong></p>
  
  <p>I keep finding myself writing code like this:</p>
  
  <pre><code>&lt;xsl:for-each select="/Root/A"&gt;
      &lt;xsl:variable name="someattribute" select="@SomeAttribute"/&gt;
      &lt;xsl:for-each select="/Root/B"&gt;
          &lt;!-- Now can use $someattribute to access data from 'A' --&gt;
      &lt;/xsl:for&gt;
  &lt;/xsl:for&gt;
  </code></pre>
  
  <p>This doesn't scale very well, as sometimes I need to access several pieces of information and end up creating one variable for each piece.  Is there an easier way?</p>