xsl-list
[Top] [All Lists]

sort order elements

2005-03-30 09:30:50
sorry was some mising elements in the priviouse message :


hi
from the following xml database i am trying to output elements in revers
order :



<car>
<AA><x>40</x><y>360</y><AA>
<BB><x>40</x><y>360</y><x>120</x><y>280</y><BB>
<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>
<BB><x>120</x><y>280</y>    <x>40</x><y>360</y><BB>
<AA><x>40</x><y>360</y><AA>
</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>
<AA><x>10</x><y>3</y><AA>
<BB><x>120</x><y>280</y>    <x>40</x><y>360</y><BB>
<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




--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--



<Prev in Thread] Current Thread [Next in Thread>