[XSL-LIST Mailing List Archive Home]
[By Thread]
[By Date]
[Recent Entries]
[Reply To This Message]
Re: Is this a grouping task?
Am 22.10.2019 um 21:10 schrieb Martin Honnen martin.honnen@xxxxxx:
On 22.10.2019 20:41, Martin Honnen martin.honnen@xxxxxx wrote:
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.
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>
<xsl:template match="revst | revend" priority="2"/>
</xsl:stylesheet>
Saxon EE however doesn't like it for streaming and crashes
Michael Kay has already identified the problem with streaming in above
code, using
<xsl:template
match="topic/*[boolean(accumulator-before('rev-change'))]">
fixes it.
|
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
RSS 2.0 |
|
Atom 0.3 |
|
|