<p>I would have thought this would be an easy one to Google, but I've been unsucessful.</p>

<p>I want to assign a variable the value out of an attribute (easy so far) then use that variable to select another node based on the value of that attribute.</p>

<p>Example:</p>

<pre><code>&lt;xsl:variable name="myId" select="@id" /&gt;
&lt;xsl value-of select="//Root/Some/Other/Path/Where[@id='{@myId}']/@Name /&gt;
</code></pre>

<p>That does not work.  If I replace the {@myId} with the value that is in the variable then it does find the right node, but doign it this way produces nothing.  I'm sure I'm missing something, or perhaps there is a different way to do it.</p>

<p>The context is that there is related data under different top-level nodes that share the same id value so I need to get the related nodes in my template.</p>

[{'answer_id': 5469, 'author': 'palehorse', 'author_id': 312, 'author_profile': 'https://Stackoverflow.com/users/312', 'pm_score': 5, 'selected': True, 'text': '<p>Ok, I finally figured it out.  Silly problem really, I simply needed to leave out the quotes and the braces.  One of those times when I <em>thought</em> that I\'d already tried that.  :D  Oh, and I mistyped @myId in the first example, the code was actually $myId.</p>\n\n<pre><code>&lt;xsl:variable name="myId" select="@id" /&gt;\n&lt;xsl value-of select="//Root/Some/Other/Path/Where[@id=$myId]/@Name" /&gt;\n</code></pre>\n'}, {'answer_id': 16386, 'author': 'samjudson', 'author_id': 1908, 'author_profile': 'https://Stackoverflow.com/users/1908', 'pm_score': 3, 'selected': False, 'text': '<p>You seem to have got confused with use of a variable (which is just $variable) and Attribute Value Templates, which allow you to put any XPath expression in some attributes, e.g. </p>\n\n<pre><code>&lt;newElement Id="{@Id}"/&gt;\n</code></pre>\n\n<p>They can obviously be combined, so you can include a variable in an Attribute Value Template, such as:</p>\n\n<pre><code>&lt;newElement Id="{$myId}"/&gt;\n</code></pre>\n'}]
['https://Stackoverflow.com/questions/5374', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/312/']