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

accumulators

Subject: accumulators
From: Jakub Malý <jakub@xxxxxxx>
Date: Fri, 19 Apr 2013 23:04:51 +0200
 accumulators
Hi, 
I am fiddling with XSLT accumulators in the new version of Saxon. 
I first looked at the examples in the spec and thought that this might work
(and output 01210), but it doesn't:

<?xml version="1.0" encoding="UTF-8"?>

<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
	xmlns:f="myf"	version="3.0">

	<xsl:accumulator name="f:my-var" as="xs:integer" initial-value="0" >
		<xsl:accumulator-rule match="f:inc" new-value="$value + 1"/>
		<xsl:accumulator-rule match="f:dec" new-value="$value - 1"/>
	</xsl:accumulator>
	
	<xsl:variable name="f:control-inc" as="element()*">
		<f:inc/>
	</xsl:variable>
	<xsl:variable name="f:control-dec" as="element()*">
		<f:dec/>
	</xsl:variable>
	
	<xsl:template match="/">
		<xsl:value-of select="f:my-var()" />
		<xsl:apply-templates select="$f:control-inc"/>
		<xsl:value-of select="f:my-var()" />
		<xsl:apply-templates select="$f:control-inc"/>
		<xsl:value-of select="f:my-var()" />
		<xsl:apply-templates select="$f:control-dec"/>
		<xsl:value-of select="f:my-var()" />
		<xsl:apply-templates select="$f:control-dec"/>
		<xsl:value-of select="f:my-var()" />
	</xsl:template>
</xsl:stylesheet>

So I read the spec and I guess I understand why. 
Accumulator rule is not triggered by calling apply-templates, it does not
matter how many times the same node is processed, the value for the
accumulator will be the same. 

Do accumulators work only for the nodes from the source document or also for
nodes from documents loaded using doc() or document()?  

Jakub.

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.