View Single Post
  #1 (permalink)  
Old June 17th, 2014, 01:36 PM
tkuzzy tkuzzy is offline
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