Re: [xsl] for-each-group

Subject: Re: [xsl] for-each-group
From: "Martin Honnen martin.honnen@xxxxxx" <xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx>
Date: Wed, 28 Mar 2018 16:00:55 -0000
On 28.03.2018 17:53, Rick Quatro rick@xxxxxxxxxxxxxx wrote:

I have a <step> element that looks something like this:



<para>Intro stuff</para>

<para>More intro stuff</para>



<para>Conclusion stuff</para>

<para>More conclusion stuff</para>



I want 4 separate groups:

1) First two <para> elements.

2) First <figure>

3) Second <figure>

4) Last two <para> elements.

Can you explain the rules for that result, do you want to group any adjacent "para" element into one group but keep each "figure" element in its own group?

In that case you can use

  <xsl:for-each-group select="*" group-adjacent="boolean(self::para)">
       <xsl:when test="current-grouping-key()">
            <xsl:apply-templates select="current-group()"/>
        <xsl:for-each select="current-group()">
              <xsl:apply-templates select="."/>

Current Thread