title: Variables in XSLT how to declare , assign value and use that variable in a different location in the same XSLT
body: <p>Please consider my "A/B" xPath expression returns the following node</p>
  
  <pre><code>  &lt;Q ID="12345"&gt;
    ----
    ----
    &lt;/Q&gt;
  </code></pre>
  
  <p>This is my variable
     </p>
  
  <p>This is how I’m trying to assign a value to my tempVariable variable</p>
  
  <pre><code>  &lt;xsl:for-each select="A/B"&gt;
    &lt;xsl:variable name="tempVariable"&gt;&lt;xsl:value-of select="@ID"/&gt;&lt;/xsl:variable&gt;
    &lt;/xsl:for-each&gt;
  </code></pre>
  
  <p>And after all I’m trying to use this variable </p>
  
  <pre><code>  &lt;xsl:if test="$tempVariable='12345'"&gt;
    ....
    ....
    &lt;/xsl:if&gt;
  </code></pre>
  
  <p>but here as I understand I’m getting $tempVariable ="" which is not correct.</p>
  
  <p>Can someone please tell me where I’m doing wrong or how can I do this in proper way.
  Thank you.</p>