Re: [xsl] Question on streaming and grouping with nested keys

Subject: Re: [xsl] 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
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