[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Re: Is this a grouping task?
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.
<?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 on-no-match="shallow-copy" streamable="yes"/> <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> <xsl:template mode="rev-change" match="revst | revend" priority="2"/> </xsl:stylesheet> Even works with streaming if you use Saxon 9.8 or 9.9 EE.
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|