Subject: [xsl] [Accumulators] Another stupid question From: "Christophe Marchand cmarchand@xxxxxxxxxx" <xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx> Date: Tue, 6 Oct 2020 20:57:41 -0000 |
<?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: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>
Thanks in advance, Christophe
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
[xsl] XSL-List Guidelines, B Tommie Usdin btusd | Thread | Re: [xsl] [Accumulators] Another st, B Tommie Usdin btusd |
[xsl] XSL-List Guidelines, B Tommie Usdin btusd | Date | Re: [xsl] [Accumulators] Another st, B Tommie Usdin btusd |
Month |