Hi,
Given an input document containing amongst other things a
recurring element I
would like to create a container element in the output
document. To my mind
this was a case of output an opening container tag prior to the first
occurrent of the recurrent element and a closing tag after the last
occurrence.
See <http://jenitennison.com/xslt/grouping/>.
You want something like
<xsl:template match="bar[not(preceding-sibling::*[1][self::bar])]">
<container>
<xsl:apply-templates select="." mode="walk"/>
</container>
</xsl:template>
<xsl:template match="bar" />
<xsl:template match="bar" mode="walk">
<foobar>
<xsl:copy-of select="@id"/>
<xsl:apply-templates/>
</foobar>
<xsl:apply-templates select="following-sibling::*[1][self::bar]"
mode="walk"/>
</xsl:template>
For bar in mixed content you need to tweak the expressions and patterns.
Cheers,
Jarno