Wrox Programmer Forums
Go Back   Wrox Programmer Forums > XML > XSLT
XSLT General questions and answers about XSLT. For issues strictly specific to the book XSLT 1.1 Programmers Reference, please post to that forum instead.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the XSLT section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
Old June 4th, 2003, 07:20 PM
Registered User
Join Date: Jun 2003
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default document node order vs sort node order.

So I am grouping nodes by predicate on an attribute and sorted the nodes based on another attribute. I put these nodes into lines in a table. I want to have the lines in the table have alternating background colors. When I use xsl:number that returns the document order # of the node but what I want is the number of the node in the grouped & sorted order - otherwise the colors don't alternate they are just lumped together in pre-sorted/pre-grouped order.

How do I go about that?

Here is the grouping example,

<th>Method Stats</th>
<xsl:apply-templates select="Metric[Values/@per='method']">
     <xsl:sort select="Values/@total" data-type="number" order="descending"/>


Old June 5th, 2003, 09:33 AM
Friend of Wrox
Join Date: Jun 2003
Posts: 1,212
Thanks: 0
Thanked 1 Time in 1 Post

try the position() function instead, it reflects the sorted order. I assume you're trying to do something like this:
<xsl:element name="tr">
<xsl:if test="position() mod 2 = 0">
   <xsl:attribute name="class">even</xsl:attribute>

Old June 5th, 2003, 11:06 AM
Registered User
Join Date: Jun 2003
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts

Yeah that was exactly what I was doing. Thanks for the help.

Similar Threads
Thread Thread Starter Forum Replies Last Post
TreeView and SiteMap Node Order robzyc ASP.NET 1.0 and 1.1 Basics 0 May 19th, 2008 04:27 AM
Dynamic sort order or sort datatype kapy_kal XSLT 2 September 18th, 2007 02:10 PM
Order of node parsing freddy XSLT 2 January 18th, 2007 03:12 PM
sort recordset in different order pablohoney Classic ASP Databases 0 December 29th, 2005 08:32 PM
Sort order Question Tere Crystal Reports 1 February 14th, 2005 03:18 PM

Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.