<!-- how to match g, h and i as well within the same
"for-each-group"? -->
Two ways.
I used a grouping key of exists(self::b|self::c) so it only has two
states to group or not to group so like that you can only group one
thing at a time, but that's OK as you can have more than one pass.
<xsl:template match="flatsequence">
<hierarchy>
<xsl:variable name="p1">
<xsl:for-each-group
select="*" group-adjacent="exists(self::b|self::c)"> ...
</xsl:variable>
<xsl:for-each-group
select="$p1/*"
group-adjacent="exists(self::h|self::h|self::i)"> ...
</xsl:for-each-group>
</hierarchy>
</xsl:template>
Or you do it in one pass with a grouping key that has three states (and
an xsl:choose with three branches.
<xsl:template match="flatsequence">
<hierarchy>
<xsl:for-each-group
select="*" group-adjacent="if (exists(self::b|self::c)) then 1
if (exists(self::h|self::i|self::i)) then 2
else 0">
<xsl:choose>
<xsl:when test="current-grouping-key()=1">
<group1><xsl:copy-of select="current-group()"/>...
<xsl:when test="current-grouping-key()=2">
<group2><xsl:copy-of select="current-group()"/>...
<xsl:otherwise>
<xsl:copy-of select="current-group()"/>..
David
--~------------------------------------------------------------------
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>
--~--