[xsl] How to sort a $variable and store that into another $variable ?

Subject: [xsl] How to sort a $variable and store that into another $variable ?
From: "Jean-Philippe Martin" <jeanph01@xxxxxxxxx>
Date: Wed, 10 Dec 2008 13:15:04 -0500
I'm trying to sort a <xsl:variable> containing 22 nodes and store this
sorted list into another xsl:variable.

Is this possible ?

Here's the best I could do :

<xsl:variable name="sortedList">
    <xsl:call-template name="sortThis">
        <xsl:with-param name="unsortedList" select="$unsortedList"/>

  <xsl:template name="sortThis">
    <xsl:param name="unsortedList"/>

    <xsl:for-each select="$unsortedList">
      <xsl:sort select="."/>
      <xsl:copy-of select="."/>

I have also tried it this way but with the same result :

<xsl:variable name="sortedList">
    <xsl:apply-templates mode="sort" select="$unsortedList">
        <xsl:sort select="."/>

  <xsl:template match="node()" mode="sort">
     <xsl:copy-of select="@*"/>

What I get is a single node containing all the values sorted
concatenated in a single string.

Is there a way to do this ?

Ps: this is xsl 1.0.

Thank you very much.

Current Thread