title: XSL store node-set in variable
body: <p>(XSLT 1.0.)
  Given a variable called Rows which contains the following (example):</p>
  
  <p><strong>Input</strong></p>
  
  <pre><code>&lt;AllResults&gt;
      &lt;Result&gt;
        &lt;subject&gt;can be filtered by filter 1&lt;/subject&gt;
        &lt;type&gt;can be filtered by filter 2&lt;/type&gt;
        &lt;date&gt;can be filtered by filter 3&lt;/date&gt;
      &lt;/Result&gt;
      &lt;Result&gt; ...
      &lt;/Result&gt;
  &lt;/AllResults&gt;
  </code></pre>
  
  <p>I have 3 filter variables. For each filter, I'd like to apply the filter to the input shown above if the filter variable is not empty. I'd like to store the filtered result, the  items that match the filters, into a new variable. I tried the following, but I got an error message about it (filterResult) being a "result tree instead of a node-set". The Rows variable is a node-set, as I have determined by using a debugger.</p>
  
  <p><strong>Part of the XSL</strong></p>
  
  <pre><code>&lt;xsl:variable name="filterResult"&gt;
      &lt;xsl:choose&gt;
          &lt;xsl:when test="$filter1 != '' and $filter2 != '' and $filter3 != ''"&gt;
              &lt;xsl:copy-of select="$Rows[date=$filter1 and type=$filter2 and subject=$filter3]" /&gt;
          &lt;/xsl:when&gt;
          &lt;xsl:when test="$filter1 != '' and $filter2 != ''"&gt;
              &lt;xsl:copy-of select="$Rows[date=$filter1 and type=$filter2]" /&gt;
          &lt;/xsl:when&gt;
          &lt;xsl:when test="$filter1 != '' and $filter3 != ''"&gt;
              &lt;xsl:copy-of select="$Rows[date=$filter1 and subject=$filter3]" /&gt;
          &lt;/xsl:when&gt;
          &lt;xsl:when test="$filter3 != '' and $filter2 != ''"&gt;
              &lt;xsl:copy-of select="$Rows[type=$filter2 and subject=$filter3]" /&gt;
          &lt;/xsl:when&gt;
          &lt;xsl:when test="$filter1 != ''"&gt;
              &lt;xsl:copy-of select="$Rows[date=$filter1]" /&gt;
          &lt;/xsl:when&gt;
          &lt;xsl:when test="$filter3 != ''"&gt;
              &lt;xsl:copy-of select="$Rows[subject=$filter3]" /&gt;
          &lt;/xsl:when&gt;
          &lt;xsl:when test="$filter2 != ''"&gt;
              &lt;xsl:copy-of select="$Rows[type=$filter2]" /&gt;
          &lt;/xsl:when&gt;
          &lt;xsl:otherwise&gt; 
              &lt;xsl:copy-of select="$Rows" /&gt;
          &lt;/xsl:otherwise&gt;
      &lt;/xsl:choose&gt;
  &lt;/xsl:variable&gt;
  </code></pre>
  
  <p>I realize that copy-of produces a result tree and not a node-set, but I am not sure HOW to produce a node set given my 3 filters requirement that I described above. </p>
  
  <p><strong>Additional Info</strong></p>
  
  <p>I do know that I could do something like <code>&lt;xsl:variable name="me" select="/set/node"/&gt;</code> which would create a variable containing a node set but I don't see how that helps me, since I have a lot of possible conditions (given the three filters). </p>