title: XSL: How best to store a node in a variable and then use it in future xpath expressions?
body: <p>I need to be able to store a node set in variable and then perform more filting/sorting on it afterward. All the examples I've seen of this involve either using XSL2 or extensions neither of which are really an option.</p>
  
  <p>I've a list of hotels in my XML doc that can be sorted/filtered and then paged through 5 at a time. I'm finding though I'm repeating alot of the logic as currently I've not found a good way to store node-sets in xsl variable and then use xpath on them for further filtering/sorting.</p>
  
  <p>This is the sort of thing I'm after (excuse the code written of the top of my head so might not be 100%):</p>
  
  <pre><code>&lt;xsl:variable name="hotels" select="/results/hotels[active='true']" /&gt;
  &lt;xsl:variable name="3_star_or_less" select="/results/hotels[number(rating) &lt;= 3]" /&gt;
  &lt;xsl:for-each select="3_star_or_less"&gt;
    &lt;xsl:sort select="rating" /&gt;
  &lt;/xsl:for-each&gt;
  </code></pre>
  
  <p>Has anyone got an example of how best to do this sort of thing?</p>