xsl-list
[Top] [All Lists]

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

2013-12-10 04:51:47
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"/>

etc,
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 
document.

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

Michael Kay
Saxonica 


On 10 Dec 2013, at 10:29, Costello, Roger L. <costello(_at_)mitre(_dot_)org> 
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 
streaming.

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

--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: 
<mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--



--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--


<Prev in Thread] Current Thread [Next in Thread>