title: How to access global variable value in multiple template tags
body: <p>I have created a global variable and its been used in two templates I am able to access i first template, not able to get the value in second template . Below are my workings</p>
  
  <pre><code> &lt;xsl:variable name="currentValue"&gt;&lt;/xsl:variable&gt; //global variable declaration
  
    &lt;xsl:template match="/"&gt;
    &lt;xsl:variable name="unique-accounts" select="/*/*/*/accountId/text()generate-id()=generate-id(key('account-by-id', .)[1])]"/&gt;
   &lt;xsl:for-each select="$unique-accounts"&gt;
        &lt;xsl:variable name="currentValue" select="current()"/&gt;
         &lt;xsl:value-of select="$currentValue"/&gt; //here value is printing
         &lt;xsl:apply-templates select="//secondTemplate"/&gt;
   &lt;/xsl:for-each&gt;
   &lt;/xsl:template&gt; //close od first template
  
  &lt;xsl:template match="secondTemplate"&gt; 
    &lt;xsl:value-of select="$currentValue"/&gt;  //here value is not printing
  &lt;/xsl:template&gt;
  </code></pre>