title: XSLT using variable in for-each select
body: <p>I am trying to supply a dynamic name to a for-each select and cannot seem to get it to work.</p>
  
  <p>My template is intended to allow a specific tag name to be passed in and then those nodes are selected from the xml and used for processing.</p>
  
  <pre><code>&lt;xsl:param name="tagName" select="'DefaultTag'" /&gt;
  
  &lt;xsl:variable name="DataSource" select="document('../xml/datasource.xml')"/&gt;
  
  &lt;xsl:template name="ProcessData"&gt;
      &lt;xsl:for-each select="$DataSource//$tagName/DataValue" &gt;
  
          ... Data operations here ...
  
      &lt;/xsl:for-each&gt;
  &lt;/xsl:template&gt;
  </code></pre>
  
  <p>If I replace the $tagName in the for-each select with a hard-coded value then it works (for that value).</p>
  
  <p>How do I get the variable substitution to happen using the param value?</p>
  
  <p>Thanks,
  -Dennis</p>