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

RE: XSLT - How to find the last element in a group of

Subject: RE: XSLT - How to find the last element in a group of nodes inside of a for loop
From: "Wei, Alice J." <ajwei@xxxxxxxxxxx>
Date: Thu, 17 Jan 2008 14:26:02 -0500
 RE: XSLT - How to find the last element in a group of
Hi,

  Referring to your question, have you tried using <xsl:value-of
select="@zone[last()]">?

   I have to point out that if you have no actual value, what you are doing
here is merely extracting the result from what is displayed in the attribute.
Is that what you want?

  As for your code, I am not sure what you want to select in the
<xsl:for-each>
  if there is is no attribute that say competitorTerritory in your input.

I hope this helps.

======================================================
Alice Wei
MIS 2008
School of Library and Information Science
Indiana University Bloomington
ajwei@xxxxxxxxxxx
________________________________________
From: Chaudhary, Harsh [HCHAUDHA@xxxxxxxxx]
Sent: Thursday, January 17, 2008 2:10 PM
To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
Subject:  XSLT - How to find the last element in a group of nodes inside
of a for loop

This is a duplicate of my previous email. I accidently sent out the
wrong Subject. Sorry about that.

-----Original Message-----
From: Chaudhary, Harsh
Sent: Thursday, January 17, 2008 1:08 PM
To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
Subject: RE:  Announcement: Dexter - XSL Transform Generation Tool


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.

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.