Re: [xsl] XSLT splitting (grouping?) hierarchical structure

Subject: Re: [xsl] XSLT splitting (grouping?) hierarchical structure
From: "Martin Honnen martin.honnen@xxxxxx" <xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx>
Date: Thu, 10 Feb 2022 08:57:34 -0000
Am 10.02.2022 um 09:54 schrieb Martin Honnen martin.honnen@xxxxxx:

Am 10.02.2022 um 09:40 schrieb Imsieke, Gerrit, le-tex gerrit.imsieke@xxxxxxxxx:
Hi Matthieu,

At XML Prague 2019, I presented what I call the "upward projection
method" [1, 2]. It turned out that Wendell Piez had independently
developed his own upward projection approach [3, 4]. Both methods
group the leaf nodes, starting at the splitting points.

Gerrit

[1]

https://archive.xmlprague.cz/2019/files/xmlprague-2019-proceedings.pdf#page=3
47

[2]


https://subversion.le-tex.de/common/presentations/2019-02-09_xmlprague_xslt-u
pward-projection/slides/index.html



I think Gerrit's approach will help you although I think your set of
restricted-to nodes will be adapted slightly, instead of

B B current-group()/ancestor-or-self::node()

it seems you want to carry over the section/title from each section.


So somehow like this:


B <xsl:mode name="split" on-no-match="shallow-copy"/>


B  <xsl:template match="node()" mode="split">
B B B  <xsl:param name="nodes" tunnel="yes"/>
B B B  <xsl:if test=". intersect $nodes/ancestor-or-self::node()">
B B B B B  <xsl:next-match/>
B B B  </xsl:if>
B  </xsl:template>

B  <xsl:template match="section">
B B B  <xsl:variable name="section" select="."/>
B B B  <xsl:for-each-group select=".//node()" group-ending-with="split">
B B B B B  <section>
B B B B B B B  <xsl:apply-templates select="$section/node()" mode="split">
B B B B B B B B B  <xsl:with-param name="nodes"
select="current-group()[not(self::split)] |
$section/title/descendant-or-self::node()" tunnel="yes"/>
B B B B B B B  </xsl:apply-templates>
B B B B B  </section>
B B B B B  <xsl:copy-of select="current-group()[last()][self::split]"/>
B B B  </xsl:for-each-group>
B  </xsl:template>

Current Thread