[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

sort order elements

Subject: sort order elements
From: 04083259@xxxxxxxxxxxxx
Date: Wed, 30 Mar 2005 17:23:41 +0100 (BST)
order elements
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

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.