Re: [xsl] Grouping: XHTML inline, block and flow

Subject: Re: [xsl] Grouping: XHTML inline, block and flow
From: "Andrew Welch" <andrew.j.welch@xxxxxxxxx>
Date: Thu, 27 Mar 2008 10:46:24 +0000
On 27/03/2008, Raka Gator <plogbil@xxxxxxxxx> wrote:
>  <td>This is a <strong>wonderful</strong> table <p>but evil</p></td>
>
>  I'd like that transformed into something like this (omitting lots of attributes
>  for clarity):
>
>  <table:table-cell>
>   <text:p>This is a <text:span text:style-name="bold">wonderful
>  </text:span> table</text:p>
>   <text:p>but evil</text:p>
>  </table:table-cell>

This is one for "group-adjacent":

<xsl:for-each-group select="node()" group-adjacent="not(self::p)">
  <xsl:choose>
    <xsl:when test="current-grouping-key()">
      <text:p><xsl:apply-templates select="current-group()"/></text:p>
    </xsl:when>
    <xsl:otherwise>
      <xsl:apply-templates select="current-group()"/>
    </xsl:otherwise>
  </xsl:choose>
</xsl:for-each-group>

...which is a slightly modified version of the last example from here:

http://www.w3.org/TR/xslt20/#grouping-examples


cheers
-- 
Andrew Welch
http://andrewjwelch.com
Kernow: http://kernowforsaxon.sf.net/

Current Thread