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 November 19th, 2007, 07:09 PM
Authorized User
 
Join Date: May 2007
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>
 
Old November 19th, 2007, 07:40 PM
mhkay's Avatar
Wrox Author
 
Join Date: Apr 2004
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





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





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