title: XSLT access different tag outside the for-each
body: <p>I want to output a different tag(active ) value by a condition inside a for loop.but cant do from this approach.any suggestions??</p>
  
  <p>Data:</p>
  
  <pre><code>    &lt;ss&gt;
      &lt;identifier&gt;
          &lt;system&gt;
              &lt;value value="10" /&gt;
          &lt;/system&gt;
          &lt;system&gt;
              &lt;value value="15"/&gt;
          &lt;/system&gt;
          &lt;system&gt;
              &lt;value value="789"/&gt;
          &lt;/system&gt;
      &lt;/identifier&gt;
      &lt;active value="123" /&gt;
  &lt;/ss&gt;
  </code></pre>
  
  <p>Xslt: </p>
  
  <pre><code>&lt;xsl:stylesheet version="1.0"
      xmlns:xsl="http://www.w3.org/1999/XSL /Transform"&gt;
      &lt;xsl:output method="xml" indent="yes" /&gt;
      &lt;xsl:template match="ss"&gt;
          &lt;Patient
              xmlns="http://hl7.org/fhir"&gt;
              &lt;identifier&gt;
                  &lt;xsl:for-each select="identifier/system/value"&gt;
                      &lt;xsl:variable name="aa"&gt;
                          &lt;xsl:if test="@value='10'"&gt;
                              &lt;xsl:value-of select="active/@value" /&gt;
                          &lt;/xsl:if&gt;
                      &lt;/xsl:variable&gt;
                      &lt;gender value="{$aa}"/&gt;
                  &lt;/xsl:for-each&gt;
              &lt;/identifier&gt;
          &lt;/Patient&gt;
      &lt;/xsl:template&gt;
  &lt;/xsl:stylesheet&gt;
  </code></pre>
  
  <p>Output:
  output that I expect from above code</p>
  
  <pre><code>&lt;?xml version="1.0"?&gt;
  &lt;Patient
      xmlns="http://hl7.org/fhir"&gt;
      &lt;identifier&gt;
          &lt;gender value="123"/&gt;
          &lt;gender value=""/&gt;
          &lt;gender value=""/&gt;
      &lt;/identifier&gt;
  &lt;/Patient&gt;
  </code></pre>