Re: [xsl] Un-nesting elements in XSLT 2.0

Subject: Re: [xsl] Un-nesting elements in XSLT 2.0
From: David Carlisle <davidc@xxxxxxxxx>
Date: Sat, 11 Nov 2006 00:07:59 GMT
It's a grouping question, you want to group things into groups of adjacent
nodes that are either block level nodes (which you process directly)
or inline nodes (which you put in a <p>

<xsl:template match="para">
<xsl:for-each-group select="node()" group-adjacent="self::img or self::table">
<xsl:choose>
<xsl:when test="current-grouping-key()">
<xsl:apply-templates select="current-group()"/>
</xsl:when>
<xsl:otherwise>
<p>
<xsl:apply-templates select="current-group()"/>
</p>
</xsl:otherwis>
</xsl:choose>
</xsl:template>

David

Current Thread