Re: [xsl] Is this a grouping task?

Subject: Re: [xsl] Is this a grouping task?
From: "Martin Honnen martin.honnen@xxxxxx" <xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx>
Date: Tue, 22 Oct 2019 18:41:44 -0000
On 22.10.2019 20:07, Rick Quatro rick@xxxxxxxxxxxxxx wrote:

I am using XSLT 2 and think this may require a for-each-group solution.
Any advice would be appreciated. Thank you very much.

As an alternative, if you can move to XSLT 3, then I think it is also easy with "xsl:iterate":

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="";

<xsl:mode on-no-match="shallow-copy" streamable="yes"/>

    <xsl:mode name="rev-change" on-no-match="shallow-copy"

    <xsl:output indent="yes"/>
    <xsl:strip-space elements="*"/>

    <xsl:template match="topic">
            <xsl:apply-templates select="@*"/>
            <xsl:iterate select="*">
                <xsl:param name="rev-change" as="xs:boolean"
                <xsl:apply-templates select="." mode="rev-change">
                    <xsl:with-param name="rev-change"
select="$rev-change" tunnel="yes"/>
                    <xsl:with-param name="rev-change"
                        select="if (self::revst) then true()
                        else if (self::revend) then false()
                        else $rev-change"/>

    <xsl:template mode="rev-change" match="topic/*">
        <xsl:param name="rev-change" tunnel="yes"/>
            <xsl:if test="$rev-change">
                <xsl:attribute name="rev">changed</xsl:attribute>
            <xsl:apply-templates select="@*" mode="#current"/>
            <xsl:apply-templates mode="#current"/>

<xsl:template mode="rev-change" match="revst | revend" priority="2"/>


Even works with streaming if you use Saxon 9.8 or 9.9 EE.

Current Thread