Quote:
quote:Originally posted by mhkay
group-adjacent defines the value that adjacent things have in common if they are to go in the same group. In your case, for the most part you are grouping elements that have the same name, that is:
group-adjacent="node-name(.)"
|
Thank you for youâre help. I didnât read youâre book to well⦠I was thinking that I could use the group-adjacent attribute as some sort selection of element names that make up a group. You put me in the right direction with the group-starting-with attribute. My stylesheet now looks like:
<?xml version="1.0"?>
<xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:strip-space elements="*"/>
<xsl:template match="root">
<xsl:element name="{name()}">
<xsl:apply-templates/>
</xsl:element>
</xsl:template>
<xsl:template match="heading1">
<xsl:element name="{name()}">
<xsl:for-each-group select="*" group-starting-with="plain[not(preceding-sibling::*[1][self::plain])] | jheader | jtext[not(preceding-sibling::*[1][self::jheader or self::jtext or self::btext])] | btext[not(preceding-sibling::*[1][self::jheader or self::jtext or self::btext])]">
<xsl:choose>
<xsl:when test="self::plain">
<plaingroup>
<xsl:copy-of select="current-group()"/>
</plaingroup>
</xsl:when>
<xsl:otherwise>
<jgroup>
<xsl:copy-of select="current-group()"/>
</jgroup>
</xsl:otherwise>
</xsl:choose>
</xsl:for-each-group>
</xsl:element>
</xsl:template>
</xsl:stylesheet>
and is working correctly.
Thanks again, Geurt Lagemaat