Subject: Re: [xsl] xsl:accumulator and temporary trees From: "Martin Honnen martin.honnen@xxxxxx" <xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx> Date: Wed, 12 Feb 2020 14:08:17 -0000 |
Hello,phase="end"/>
I use an accumulator to calculate height of block elements in a page.
My accumulator is defined like this :
B <xsl:accumulator name="height.counter" as="xs:double" initial-value="0.0"> B B B <xsl:accumulator-rule match="page" select="2.3"/> B B B <xsl:accumulator-rule match="li1" select="$value + 1.9"
B B B <xsl:accumulator-rule match="li2" select="$value + 1.8"phase="end"/>
B B B <xsl:accumulator-rule match="li3" select="$value + 1.34" phase="end"/> B B B <xsl:accumulator-rule match="private:block" select="$value + xs:double(./@height)" phase="end"/> B </xsl:accumulator>
Modes are defined like this :
B <xsl:mode name="private:acc" on-no-match="shallow-skip" use-accumulators="#all"/> B <xsl:mode use-accumulators="#all"/>
For a special element, I calculate the block height, and I proceed like this :
B B B <xsl:variable name="block" as="element(private:block)"> B B B B B <private:block height="{$height}"/> B B B </xsl:variable> B B B <xsl:apply-templates mode="private:acc" select="$block"/>
li1, li2 and li3, which are in source tree and processed in default mode do modify accumulator value. But my accumulator is never incremented when a private:block is processed.
Any suggestion will be much appreciated.
Accumulators, like keys, work on a tree, if you have some nodes in one tree and the temporarily created element that is obviously in a different tree then the accumulators of the temporarily created tree are computed independently of the input tree.
I think you need to push the input through a mode that adds the private:block elements and then you need to push that complete, temporarily created tree through a new mode where you want to use the accumulator.
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
[xsl] xsl:accumulator and temporary, Christophe Marchand | Thread | Re: [xsl] xsl:accumulator and tempo, Christophe Marchand |
[xsl] xsl:accumulator and temporary, Christophe Marchand | Date | [xsl] xsl:for-each in Corresp Tag, Byomokesh Sahoo saho |
Month |