Hi all,
I have a XSL grouping problem that I am having difficulty with and for which I
couldn't find a previous post about in the archives. I also noticed that there
hadn't been a grouping question in a day or so I thought I would do my part to
help out :-).
I'm using XSLT 2.0 as implemented by Saxon 8.8 (congrats to Michael on this
latest version). The XML I'm working with looks like this:
<feature>
<id>BACR48K23</id>
<pub>
<id>0105495</id>
</pub>
</feature>
...
This can sometimes be repeated over again with a new feature/id and the same
pub/id, a new pub/id and the same feature/id, or both ids being completely new.
Each feature chunk is adjacent to the others but they are in random order. A
completely flat view of this would look like this for example
featureid1 pubid1
featureid1 pubid2
featureid2 pubid1
featureid3 pubid1
featureid3 pubid2
The grouping I would like to do is first group by featureid to produce this
list.
featureid1 pubid1, pubid2
featureid2 pubid1
featureid3 pubid1, pubid2
This is no problem using something along the lines of
<xsl:for-each-group select="feature" group-by="id">
<xsl:value-of select="current-grouping-key()" />
<xsl:value-of select="current-group()/pub/id" separator=", " />
</xsl:for-each-group>
The problem comes in to play because I need to do another round of grouping.
This time on items from the second list grouped by those with a common set of
pubid's. Doing this on the above list would produce this:
featureid1, featureid3 pubid1, pubid2
featureid2 pubid1
I've not been able to wrap my head around the best way to achieve this. Anyone
have suggestions?
Thanks,
Josh Goodman
--~------------------------------------------------------------------
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--