Thank you very much for both suggestions. So if I understand right I
either have to resort to something which looks to me like "recursion
into groups", applying xsl:for-each-group to the result of all previous
groupings, or I have to set up a kind of table of grouping keys on which
to branch.
A third approach came to my mind. When the order of elements in the flat
sequence is fixed, the series of xsl:apply-templates instructions that
process the remaining elements may be interrupted by the necessary
xsl:for-each-group instructions, which then can immediately select the
elements they have to group. Like this:
<xsl:stylesheet version="2.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output indent="yes"/>
<xsl:template match="root">
<xsl:copy>
<xsl:apply-templates/>
</xsl:copy>
</xsl:template>
<xsl:template match="flatsequence">
<hierarchy>
<xsl:apply-templates select="a"/>
<xsl:for-each-group
select="b|c" group-adjacent="1">
<container1>
<xsl:copy-of select="current-group()"/>
</container1>
</xsl:for-each-group>
<xsl:apply-templates select="d|e|f"/>
<xsl:for-each-group
select="g|h|i" group-adjacent="1">
<container2>
<xsl:copy-of select="current-group()"/>
</container2>
</xsl:for-each-group>
<xsl:apply-templates select="j"/>
</hierarchy>
</xsl:template>
<xsl:template match="a|d|e|f|g|h|i|j">
<xsl:copy>
<xsl:apply-templates/>
</xsl:copy>
</xsl:template>
</xsl:stylesheet>
That seems to work, but perhaps I am missing something?
(If it's OK as it is: any idea how to specify the grouping criterion,
which just has to evaluate as permanently true, more elegantly than
using 'group-adjacent="1"'?)
Yves
--~------------------------------------------------------------------
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>
--~--