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

Re: Question on streaming and grouping with nested key

Subject: Re: Question on streaming and grouping with nested keys
From: "David Rudel fwqhgads@xxxxxxxxx" <xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx>
Date: Fri, 14 Jul 2017 08:06:07 -0000
Re:  Question on streaming and grouping with nested key
I'm sure someone with more savvy can tell you how to do this with
accumulators, but it seems that there is a straightforward way to do this
with streaming iterate.

Use burst-mode streaming to iterate through each <TRANSACTION> element.

This <xsl:iterate> instruction should have two parameters, each one a map:

<xsl:param name="item_count_map" select="map:new()"/>
<xsl:param name="sum_map" select="map:new()"/>

The first one will keep track of the number of <ITEM1> elements with a
given grouping key. The second map will sum up the values in the
<SUBITEM2.1> elements.

Each round of the iteration, you will make new maps by updating the current
map.

For each transaction, check whether the grouping key is a key of the map.
If so, the new maps (the one for the next iteration of the <xsl:iterate>
instruciton) will have that key updated. If the grouping-key is not a key
of the map, add it to each map.







On Fri, Jul 14, 2017 at 12:09 AM, Felix Sasaki felix@xxxxxxxxxxxxxx <
xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx> wrote:

> I want to analyse a list of transactions in XSLT 3.0 streaming mode.
> Transactions should be grouped by a key which is nested inside each
> transaction (see SUBITEM2.2/GROUPING-KEY below). For the grouped
> transactions, there are items to count or items with numeric values to some
> up, see ITEM1 and ITEM2/SUBITEM2.1.
>
>
> <TRANSACTION-LIST>
>   <TRANSACTION>
>     <ITEM1> something to count </ITEM1>
>     <ITEM2>
>       <SUBITEM2.1> something to sum up</SUBITEM2.1>
>       <SUBITEM2.2> ...
>         <GROUPING-KEY>some-key</GROUPING-KEY>
>       </SUBITEM2.2>
>     </ITEM2>
>   </TRANSACTION> ...
> </TRANSACTION-LIST>
>
>   The output should be a list as follows:
> - Transaction following grouping key value 1:
>     Numbers of ITEM1
>     Sum of ITEM 2
> - Transactions following grouping key value 2, 3, ...n: the same list with
> other values.
>
> I am wondering if this is possible with XSLT 3.0 streaming, since then the
> XSLT processor "sees" the TRANSACTION element, it does not yet see the
> nested grouping key.
>
> - Felix
>
> XSL-List info and archive <http://www.mulberrytech.com/xsl/xsl-list>
> EasyUnsubscribe <-list/1312897> (by
> email <>)
>



-- 

"A false conclusion, once arrived at and widely accepted is not dislodged
easily, and the less it is understood, the more tenaciously it is held." -
Cantor's Law of Preservation of Ignorance.

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.