[xsl] sort order elements

Subject: [xsl] sort order elements
From: 04083259@xxxxxxxxxxxxx
Date: Wed, 30 Mar 2005 17:23:41 +0100 (BST)
hi
from the following xml database i am trying to output elements in revers
order :



<car>
<A><x>40</x><y>360</y></A>
<B><x>40</x><y>360</y><x>120</x><y>280</y></B>
<C> <x>120</x><y>280</y></C>
<D><x>40</x><y>360</y><x>120</x><y>280</y></D>
<E><x>10</x><y>3</y></E>
</car>



i used the following template xslt1.0:


<xsl:template match="car">
<xsl:copy>
   <xsl:for-each select="*">
     <xsl:sort select="position()" data-type="number"      
order="descending" />

<xsl:copy>
      <xsl:for-each select="x">
        <xsl:sort select="position()" data-type="number"      
order="descending" />
        <xsl:copy-of select=". | following-sibling::y[1]" />
      </xsl:for-each>
 </xsl:copy>
  </xsl:for-each>
  </xsl:copy>
</xsl:template>
</xsl:stylesheet>




then the result was as following :

<car>
<E><x>10</x><y>3</y></E>
<D><x>120</x><y>280</y>	<x>40</x><y>360</y></D>
<C><x>120</x><y>280</y>	</C>
<B><x>120</x><y>280</y>	<x>40</x><y>360</y></B>
<A><x>40</x><y>360</y>	</A>
</car>

that is exactly was i wanted except that i want the elements (A,B,C,D,E)
to be in its original place such the following :


<car>
<A><x>10</x><y>3</y></A>
<B><x>120</x><y>280</y>	<x>40</x><y>360</y></B>
<C><x>120</x><y>280</y>	</C>
<D><x>120</x><y>280</y>	<x>40</x><y>360</y></D>
<E><x>40</x><y>360</y>	</E>
</car>


thanks

Current Thread