 |
 |
 |
Hi,
Tempore 03:00:25, die 09/01/2005 AD, hinc in xsl-list@xxxxxxxxxxxxxxxxxxxxxx scripsit Philipp Kursawe <LukeSky77@xxxxxxx>:
I have run into a problem solving the following sophisticated (at least for
me) task:
There is a list of items each containing two nodes "row" and "col". First
the list has to be ordered ASCENDING by "rows". Next step is to sort the
list items of each "row" by its "col" node where the ordering direction
changes when the row is different to the previous.
I guess the easiest way is to group the 'item' elements by row and then alternate their sort order:
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="xml" indent="yes"/>
<xsl:key name="item" match="item" use="@row"/>
<xsl:template match="items">
<xsl:copy>
<xsl:for-each select="item[generate-id(key('item',@row))=generate-id()]">
<xsl:sort select="@row" data-type="number"/>
<xsl:variable name="order">
<xsl:choose>
<xsl:when test="position() mod 2=0">ascending</xsl:when>
<xsl:otherwise>descending</xsl:otherwise>
</xsl:choose>
</xsl:variable>
<xsl:comment><xsl:value-of select="$order"/></xsl:comment>
<xsl:for-each select="key('item',@row)">
<xsl:sort select="@col" order="{$order}" data-type="number"/>
<xsl:copy-of select="."/>
</xsl:for-each>
</xsl:for-each>
</xsl:copy>
</xsl:template>
</xsl:stylesheet>
regards,
--
Joris Gillis (http://users.telenet.be/root-jg/me.html)
B+There are only 10 types of people in this world. Those who understand binary, and those who don'tB;
|
 | 



|  |
These Archives are provided for informational purposes only and have been generated directly from the Altova mailing list archive system and are comprised of the lists set forth on www.altova.com/list/index.html. Therefore, Altova does not warrant or guarantee the accuracy, reliability, completeness, usefulness, non-infringement of intellectual property rights, or quality of any content on the Altova Mailing List Archive(s), regardless of who originates that content. You expressly understand and agree that you bear all risks associated with using or relying on that content. Altova will not be liable or responsible in any way for any content posted including, but not limited to, any errors or omissions in content, or for any losses or damage of any kind incurred as a result of the use of or reliance on any content. This disclaimer and limitation on liability is in addition to the disclaimers and limitations contained in the Website Terms of Use and elsewhere on the site.
|  |
| |
 |
 |
 |