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.
|