On 26/09/2026 21:43, rick@xxxxxxxxxxxxxx wrote:
However, I need content under a title to be wrapped in a conbody
element, like this:
I think you get that with the following adaption of the grouping function
B B <xsl:function name="cp:group" as="node()*">
B B B B <xsl:param name="elements" as="element()*"/>
B B B B <xsl:param name="level" as="xs:integer"/>
B B B B <!-- Make a variable for the heading name. -->
B B B B <xsl:variable name="heading" select="'h' || $level"/>
B B B B <xsl:variable name="heading-next" select="'h' || $level + 1"/>
B B B B <xsl:for-each-group select="$elements"
group-starting-with="*[local-name() = $heading]">
B B B B B B <xsl:choose>
B B B B B B B B <xsl:when test="self::*[local-name() = $heading]">
B B B B B B B B B B <concept id="{generate-id()}">
B B B B B B B B B B B B <title>
B B B B B B B B B B B B B B <xsl:apply-templates/>
B B B B B B B B B B B B </title>
B B B B B B B B B B B B <xsl:sequence
select="cp:group(current-group()
except ., $level + 1)"/>
B B B B B B B B B B </concept>
B B B B B B B B </xsl:when>
B B B B B B B B <xsl:otherwise>
B B B B B B B B B <xsl:where-populated>
B B B B B B B B B B <conbody>
B B B B B B B B B B B <xsl:apply-templates
select="current-group()"/>
B B B B B B B B B B </conbody>
B B B B B B B B B </xsl:where-populated>
B B B B B B B B </xsl:otherwise>
B B B B B B </xsl:choose>
B B B B </xsl:for-each-group>
B B </xsl:function>
|