title: trouble with xsl:for-each selection using xsl:variable
body: <p><strong>Problem:</strong>  </p>
  
  <p>I am having trouble generating an xpath expression that selects a node in a different section of the XML document by position.  I am using xsl:variable to create the expression, but when I use a xsl:for-each with the value of the xsl:variable as my select statement I get an error.</p>
  
  <pre><code>&lt;xsl:variable name="input_params_query"&gt;
    &lt;xsl:text disable-output-escaping="yes"&gt;/example/inputs/dataset[&lt;/xsl:text&gt;
    &lt;xsl:number value="position()" format="1" /&gt;
    &lt;xsl:text disable-output-escaping="yes"&gt;]/parameter&lt;/xsl:text&gt;
  &lt;/xsl:variable&gt;
  
  &lt;xsl:for-each select="$input_params_query"&gt;
    &lt;input rdf:resource="#{@name}"/&gt;
  &lt;/xsl:for-each&gt;
  </code></pre>
  
  <p>Results in the error:</p>
  
  <pre><code>The 'select' expression does not evaluate to a node set.
  </code></pre>
  
  <p>When I print out the value of the xsl:variable I am using I get:</p>
  
  <pre><code>/example/inputs/dataset[1]/parameter
  </code></pre>
  
  <p>which is a valid and correct Xpath expression for the nodes I am trying to select in the for-each call.</p>
  
  <p>Is my usage of the xsl:variable as xsl:for-each select attribute incorrect? </p>
  
  <p><strong>Background and Full Explanation:</strong></p>
  
  <p>I am using XSLT to generate a RDF/XML representation of information available in the following XML structure.</p>
  
  <p>
      
       
         
           
           
         
         
           
          
       
       
        
         
         
        
       
      </p>
  
  <p>In this case what the XML really means is that a process was run twice; the first time generating output file "a" and the second time generation output file "b". The parameters "p1" and "p2" were inputs for the execution that generated file "a" and the parameter "p3" was an input to the execution that generated file "b".</p>
  
  <p>For each output of 'process' I am generating a RDF individual and defining the inputs and outputs for that process execution.  Basically, I want to define all values from /example/inputs/dataset[n]/parameters as inputs to the process which generates the output /example/process/outputs/file[n].</p>
  
  <pre><code>&lt;xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
   xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
   version="1.0"&gt;
   &lt;xsl:output method="xml" version="1.0" encoding="UTF-8" indent="yes"/&gt;
   &lt;xsl:template match="//process"&gt;
    &lt;xsl:for-each select="outputs/*"&gt;
  
    &lt;!-- declare rdf resource of type Process, define Process outputs --&gt;
    &lt;!-- ... this I already have working so I have withheld for brevity --&gt;
  
    &lt;!-- define input parameters --&gt;
  
     &lt;xsl:variable name="input_params_query"&gt;
      &lt;xsl:text disable-output-escaping="yes"&gt;/example/inputs/dataset[&lt;/xsl:text&gt;
      &lt;xsl:number value="position()" format="1" /&gt;
      &lt;xsl:text disable-output-escaping="yes"&gt;]/parameter&lt;/xsl:text&gt;
     &lt;/xsl:variable&gt;
  
     &lt;xsl:for-each select="$input_params_query"&gt;
      &lt;input rdf:resource="#{@name}"/&gt;
     &lt;/xsl:for-each&gt;
  
    &lt;/xsl:for-each&gt;
   &lt;/xsl:template&gt;
  &lt;/xsl:stylesheet&gt;
  </code></pre>