Subject: RE: [xsl] Announcement: Dexter - XSL Transform Generation Tool|
From: "Chaudhary, Harsh" <HCHAUDHA@xxxxxxxxx>
Date: Thu, 17 Jan 2008 13:07:48 -0600
Hi, I am writing a table using XSLT 1.0. The sort key to the table is the "Zone". A table can have multiple zones. There are also a couple of columns as show below. The requirement is to first sort the table by Zone and then by Territory. The value in the Number row will appear for only the last row for any give zone. So a table will look something like: Zone Territory Number 1 1 1 2 1 3 25 2 1 12 3 1 7 4 1 4 2 50 I am using the Meunichian method to group all rows by Zone and then on the inner for-each for the meunichian code, I am sorting by Territory. So far so good. My question is, how do I detect the last row for each zone? Input XML: <root> <row> <zone code='1' territory='1' number='25'> <zone code='1' territory='2' number='25'> <zone code='1' territory='3' number='25'> <zone code='2' territory='1' number='12'> <zone code='3' territory='1' number='7'> <zone code='4' territory='1' number='50'> <zone code='4' territory='2' number='50'> </row> </root> <xsl:for-each select="//competitor[generate-id() = generate-id(key('someKey', @zone))]"> <xsl:sort select="@zone"/> <xsl:for-each select="key('someKey', @zone)"> <xsl:sort select="@competitorTerritory"/> //Some code //How do I detect the last row for each Zone? </xsl:for-each> </xsl:for-each> Would appreciate your help. If I left some information out, please let me know. Thanks, HC.