[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

[Accumulators] Another stupid question

Subject: [Accumulators] Another stupid question
From: "Christophe Marchand cmarchand@xxxxxxxxxx" <xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx>
Date: Tue, 6 Oct 2020 20:57:41 -0000
 [Accumulators] Another stupid question
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

Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.