[Home] [By Thread] [By Date] [Recent Entries]
Hello !
I have another question with accumulators. I use accumulators to calculate block height, and then to calculate block locations (y). I have this XSL for a repro... <?xml version="1.0" encoding="UTF-8"?> <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" B xmlns:xs="http://www.w3.org/2001/XMLSchema" B xmlns:private="top:marchand" B exclude-result-prefixes="#all" B version="3.0"> B <xsl:output method="xml" indent="true"/> B <xsl:mode on-no-match="shallow-copy" use-accumulators="#all"/> B <xsl:accumulator name="blockHeight" as="xs:double" initial-value="0.0">
B B B <xsl:accumulator-rule match="page">
B B B B B <xsl:message>Reset block height to 3.2</xsl:message>
B B B B B <xsl:sequence select="3.2"/>
B B B </xsl:accumulator-rule>
B B B <xsl:accumulator-rule match="private:block">
B B B B B <xsl:message>Adding block height {@id} : {@height}</xsl:message>
B B B B B <xsl:sequence select="$value + xs:double(@height)"/>
B B B </xsl:accumulator-rule>
B </xsl:accumulator>B <xsl:template match="block">
B B B <xsl:variable name="height" as="xs:double" select="3.5"/>
B B B <!-- produce some output -->
B B B <xsl:variable name="TempTree" as="element(private:block)">
B B B B B <private:block height="{$height}"/>
B B B </xsl:variable>
B B B <xsl:apply-templates select="$TempTree"/>
B B B <xsl:copy>
B B B B B <xsl:attribute name="y" select="accumulator-after('blockHeight')"/>
B B B B B <xsl:apply-templates select="node() | @*"/>
B B B </xsl:copy>
B </xsl:template>B <xsl:template match="private:block"> B B B <xsl:message>private:block matched</xsl:message> B </xsl:template> B <xsl:template name="xsl:initial-template"> B B B <xsl:variable name="content" as="document-node()"> B B B B B <xsl:document> B B B B B B B <doc> B B B B B B B B B <page id="p1"> B B B B B B B B B B B <block id="b1"> B B B B B B B B B B B B B <!-- arbitrary content --> B B B B B B B B B B B </block> B B B B B B B B B B B <block id="b2"> B B B B B B B B B B B B B <!-- another arbitrary content --> B B B B B B B B B B B </block> B B B B B B B B B </page> B B B B B B B B B <page id="p2"> B B B B B B B B B B B <block id="b3"> B B B B B B B B B B B B B <!-- arbitrary content --> B B B B B B B B B B B </block> B B B B B B B B B B B <block id="b4"> B B B B B B B B B B B B B <!-- another arbitrary content --> B B B B B B B B B B B </block> B B B B B B B B B </page> B B B B B B B </doc> B B B B B </xsl:document> B B B </xsl:variable> B B B <xsl:apply-templates select="$content"/> B </xsl:template> </xsl:stylesheet> When I run this XSL on the sample XML, I have messages displayed : "Reset block height to 3.2", "private:block matched", but never the "Adding block height..." According to specification [1], I expect private:block matches accumulator rule, and accumulator value being augmented by block/@height. What am I doing wrong ? Thanks in advance, Christophe [1] : 18.2.2 https://www.w3.org/TR/xslt-30/#applicability-of-accumulators list item 1
|

Cart



