Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > XML > XSLT
Password Reminder
Register
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
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 tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old November 19th, 2007, 07:09 PM
Authorized User
 
Join Date: May 2007
Location: , , .
Posts: 79
Thanks: 0
Thanked 0 Times in 0 Posts
Default Iterate count within for-each-group

I am working with four groups and need to add capture a unique numeric value for each group. Is there any way to access the group position?

<xsl:for-each-group select="p" group-by="group">
  <div>
    <xsl:attribute name="id">

    </xsl:attribute>
    <xsl:for-each select="current-group()">

    </xsl:for-each>
  </div>
</xsl:for-each-group>

XML:
<p>
  <text></text>
  <group>introduction</group>
</p>
<p>
  <text></text>
  <group>body</group>
</p>
<p>
  <text></text>
  <group>body</group>
</p>
<p>
  <text></text>
  <group>body</group>
</p>
<p>
  <text></text>
  <group>conclusion</group>
</p>
<p>
  <text></text>
  <group>conclusion</group>
</p>
<p>
  <text></text>
  <group>footnote</group>
</p>
Reply With Quote
  #2 (permalink)  
Old November 19th, 2007, 07:40 PM
mhkay's Avatar
Wrox Author
Points: 18,487, Level: 59
Points: 18,487, Level: 59 Points: 18,487, Level: 59 Points: 18,487, Level: 59
Activity: 100%
Activity: 100% Activity: 100% Activity: 100%
 
Join Date: Apr 2004
Location: Reading, Berks, United Kingdom.
Posts: 4,962
Thanks: 0
Thanked 292 Times in 287 Posts
Default

Within for-each-group(), calling position() will give you values 1,2,3.... as you iterate over the groups. I would think that meets your need.

Michael Kay
http://www.saxonica.com/
Author, XSLT Programmer's Reference and XPath 2.0 Programmer's Reference
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Problem with Count() function 4 group of records Odeh Naber Access 0 July 24th, 2007 03:28 AM
Group by Count * >1? Raith SQL Language 7 May 24th, 2007 03:50 PM
To iterate the FOR loop variable garg.ashish15 Oracle 0 November 10th, 2006 09:31 AM
Group By query with count problem ptaylor SQL Language 2 May 12th, 2004 09:27 AM
Help! - How do i count and group this gfowajuh SQL Server 2000 4 August 19th, 2003 05:13 AM



All times are GMT -4. The time now is 01:35 PM.


Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.