|
Subject: Re: [xsl] Is this a grouping task? From: "Martin Honnen martin.honnen@xxxxxx" <xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx> Date: Tue, 22 Oct 2019 19:09:59 -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":
Thinking about it again, it seems in XSLT 3 simply using an accumulator makes it even more easy and compact:
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:xs="http://www.w3.org/2001/XMLSchema" exclude-result-prefixes="#all" version="3.0">
<xsl:mode on-no-match="shallow-copy" streamable="yes" use-accumulators="rev-change"/>
<xsl:accumulator name="rev-change" as="xs:boolean"
initial-value="false()" streamable="yes">
<xsl:accumulator-rule match="topic" select="false()"/>
<xsl:accumulator-rule match="topic/revst" select="true()"/>
<xsl:accumulator-rule match="topic/revend" select="false()"/>
</xsl:accumulator> <xsl:template match="topic/*[accumulator-before('rev-change')]">
<xsl:copy>
<xsl:attribute name="rev">changed</xsl:attribute>
<xsl:apply-templates select="@*"/>
<xsl:apply-templates/>
</xsl:copy>
</xsl:template>Saxon EE however doesn't like it for streaming and crashes, works fine however with HE or with EE and streaming turned off.
| Current Thread |
|---|
|
| <- Previous | Index | Next -> |
|---|---|---|
| Re: [xsl] Is this a grouping task?, Martin Honnen martin | Thread | Re: [xsl] Is this a grouping task?, Dimitre Novatchev dn |
| Re: [xsl] Is this a grouping task?, Martin Honnen martin | Date | Re: [xsl] Is this a grouping task?, Dimitre Novatchev dn |
| Month |