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 |
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="http://www.w3.org/1999/XSL/Transform" xmlns:xs="http://www.w3.org/2001/XMLSchema" exclude-result-prefixes="#all" version="3.0">
<xsl:mode name="rev-change" on-no-match="shallow-copy" streamable="yes"/>
<xsl:output indent="yes"/> <xsl:strip-space elements="*"/>
<xsl:template match="topic"> <xsl:copy> <xsl:apply-templates select="@*"/> <xsl:iterate select="*"> <xsl:param name="rev-change" as="xs:boolean" select="false()"/> <xsl:apply-templates select="." mode="rev-change"> <xsl:with-param name="rev-change" select="$rev-change" tunnel="yes"/> </xsl:apply-templates> <xsl:next-iteration> <xsl:with-param name="rev-change" select="if (self::revst) then true() else if (self::revend) then false() else $rev-change"/> </xsl:next-iteration> </xsl:iterate> </xsl:copy> </xsl:template>
<xsl:template mode="rev-change" match="topic/*"> <xsl:param name="rev-change" tunnel="yes"/> <xsl:copy> <xsl:if test="$rev-change"> <xsl:attribute name="rev">changed</xsl:attribute> </xsl:if> <xsl:apply-templates select="@*" mode="#current"/> <xsl:apply-templates mode="#current"/> </xsl:copy> </xsl:template>
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: [xsl] Is this a grouping task?, Martin Honnen martin | Thread | Re: [xsl] Is this a grouping task?, Martin Honnen martin |
Re: [xsl] Is this a grouping task?, Martin Honnen martin | Date | Re: [xsl] Is this a grouping task?, Martin Honnen martin |
Month |