actually it's surprisingly dificult in pure xslt 1 to sort and process
(or query) at the same time.
Almost all processors provide a node-set() extension function which
makes things much easier.
First sort:
<xsl:variable name="x">
<xsl:for-each select="question">
<xsl:sort...
<xsl:copy-of select="."/>
</xsl:for-each>
<xsl:variable>
Now $x is essentially your sorted list and in xslt2 (or xslt 1.1 draft)
you'd be able to apply templates to that, but in xslt1.0 it's a result tree
fragment that can be copied to the output but not queried.
But assuming you have x:node-set() in your processors extension
namespace
you can do
<xsl:apply-templates select="x:node-set($x)/question"/>
and then the previous question is just preceding-sibling::question[1] as
usual as your (new) input is sorted.
David
--
http://www.dcarlisle.demon.co.uk/matthew
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list