<p>Given the following XML:</p>

<pre><code>&lt;current&gt;
  &lt;login_name&gt;jd&lt;/login_name&gt;
&lt;/current&gt;
&lt;people&gt;
  &lt;person&gt;
    &lt;first&gt;John&lt;/first&gt;
    &lt;last&gt;Doe&lt;/last&gt;
    &lt;login_name&gt;jd&lt;/login_name&gt;
  &lt;/preson&gt;
  &lt;person&gt;
    &lt;first&gt;Pierre&lt;/first&gt;
    &lt;last&gt;Spring&lt;/last&gt;
    &lt;login_name&gt;ps&lt;/login_name&gt;
  &lt;/preson&gt;
&lt;/people&gt;
</code></pre>

<p>How can I get "John Doe" from within the current/login matcher?</p>

<p>I tried the following:</p>

<pre><code>&lt;xsl:template match="current/login_name"&gt;
  &lt;xsl:value-of select="../people/first[login_name = .]"/&gt;
  &lt;xsl:text&gt; &lt;/xsl:text&gt;
  &lt;xsl:value-of select="../people/last[login_name = .]"/&gt;
&lt;/xsl:template&gt;
</code></pre>

I think what he actually wanted was the replacement in the match for the "current" node, not a match in the person node:
```
```
<xsl:variable name="login" select="//current/login_name/text()"/>

<xsl:template match="current/login_name">
<xsl:value-of select='concat(../../people/person[login_name=$login]/first," ", ../../people/person[login_name=$login]/last)'/>

</xsl:template>
```
```