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

Re: How is fold-left useful to XSLT streaming?

Subject: Re: How is fold-left useful to XSLT streaming?
From: Michael Kay <mike@xxxxxxxxxxxx>
Date: Tue, 10 Dec 2013 10:51:34 +0000
Re:  How is fold-left useful to XSLT streaming?
Suppose you have data which gives the increase in prices in any given year

<year n="1692" inflation="1.02"/>
<year n="1693" inflation="1.03"/>

and you want to calculate the increase over the entire period, by multiplying
the values of all the @inflation values in the sequence.

fold-left(year[@n ge 1692 and @n le 2013]/@inflation, 1, function($z as
xs:double, $this as xs:double) {$z * $this})

This will be streamable in the next XSLT 3.0 draft. Note that it depends on
the function being defined to operate on atomic values, to make sure that it
doesn't navigate away from the attribute node to other places in the streamed

The same calculation can also be achieved using xsl:iterate.

Michael Kay

On 10 Dec 2013, at 10:29, Costello, Roger L. <costello@xxxxxxxxx> wrote:

> On Friday, November 22, 2013 Michael Kay wrote:
>> There are plenty of techniques still available for
>> streamed processing: accumulators, xsl:iterator,
>> fold-left, xsl:fork.
> I understand the usefulness of accumulators, xsl:iterator, and xsl:fork to
> I am unclear on the usefulness of fold-left to streaming.
> Would you (Michael or anyone) provide an example to illustrate the
usefulness of fold-left to streaming please?
> /Roger

Current Thread


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.
First Name
Last Name
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.