2) I fail to see how I can repeatedly group some children, when in
between are some children that are not to be grouped. Do I need to apply
recursion when working my way through the children?
not in xslt2, no just use for-each-group
It's so much easier if you provide an example, failing that I'll provide
one:-)
If I understand you correctly you want to take
<x>
<abc>1</abc>
<foo>bbb</foo>
<abc>b</abc>
<xyz>b</xyz>
<xyz>c</xyz>
<foo>bbb</foo>
<zzz/>
<hhh/>
<xyz>d</xyz>
</x>
and group adjacent runs of abc and xyz to produce
$ saxon8 wrap.xml wrap.xsl
<?xml version="1.0" encoding="UTF-8"?>
<x>
<wrap>
<abc>1</abc>
</wrap>
<foo>bbb</foo>
<wrap>
<abc>b</abc>
<xyz>b</xyz>
<xyz>c</xyz>
</wrap>
<foo>bbb</foo>
<zzz/>
<hhh/>
<wrap>
<xyz>d</xyz>
</wrap>
</x>
(using copy-of rather than apply-templates for simplicity)
<xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output indent="yes"/>
<xsl:template match="x">
<x>
<xsl:for-each-group select="*"
group-adjacent="exists(self::xyz|self::abc)">
<xsl:choose>
<xsl:when test="current-grouping-key()">
<wrap>
<xsl:copy-of select="current-group()"/>
</wrap>
</xsl:when>
<xsl:otherwise>
<xsl:copy-of select="current-group()"/>
</xsl:otherwise>
</xsl:choose>
</xsl:for-each-group>
</x>
</xsl:template>
</xsl:stylesheet>
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>
--~--