Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
BOOK: XSLT 2.0 and XPath 2.0 Programmer's Reference, 4th Edition ISBN: 978-0-470-19274-0
This is the forum to discuss the Wrox book XSLT 2.0 and XPath 2.0 Programmer's Reference, 4th Edition by Michael Kay; ISBN: 9780470192740
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: XSLT 2.0 and XPath 2.0 Programmer's Reference, 4th Edition ISBN: 978-0-470-19274-0 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 Display Modes
  #1 (permalink)  
Old June 17th, 2014, 01:36 PM
Registered User
Points: 10, Level: 1
Points: 10, Level: 1 Points: 10, Level: 1 Points: 10, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Aug 2011
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default Finding position within group

Hello:

Given the following XML:

<code>
<root>
<item @type="a">blah, blah, blah</item>
<item @type="b">blah, blah, blah</item>
<item @type="c">blah, blah, blah</item>
<item @type="a">blah, blah, blah</item>
<item @type="b">blah, blah, blah</item>
<item @type="c">blah, blah, blah</item>
<item @type="b">blah, blah, blah</item>
<item @type="c">blah, blah, blah</item>
</root>
</code>

I'm using for-each-group to get one <item> with type="a" followed by any number of <item>s with type="b" or type="c". The example above would represent two groups. The first 3 items would be a group, and the rest would be another group. I've got that part working using the following:
<code>
<xsl:for-each-group select="item" group-starting-with="*[@type="a"]">
</code>

However, I want to be able to identify the nth occurence of each type within the group. I want to know if it's the first type="b" or the 2nd and so on.

Trying to count using preceding-sibling isn't working, as it looks outside my current-group(). Is it possible to count occurrences within the group without disturbing the order? Thank you.
Reply With Quote
Reply


Thread Tools
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
for-each-group, group-adjacent confusion CanOfBees XSLT 2 June 28th, 2013 02:50 PM
bunches of nodes, how to group them to different group using the business rules JohnKiller XSLT 9 March 7th, 2012 01:42 PM
Restart new group number in Group Footer sukarso Crystal Reports 2 October 13th, 2006 12:11 PM
Group by , Sub Group by and Sum mateenmohd SQL Server 2000 1 March 29th, 2005 08:51 AM



All times are GMT -4. The time now is 08:37 PM.


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