Subject: Re: [xsl] Question on streaming and grouping with nested keys From: "Felix Sasaki felix@xxxxxxxxxxxxxx" <xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx> Date: Fri, 14 Jul 2017 12:04:54 -0000 |
Thank you for your feedback, Martin and David. I tried the example from Martin with <xsl:template match="TRANSACTION-LIST"> <xsl:copy> <xsl:for-each-group select="copy-of(TRANSACTION)" group-by="ITEM2/SUBITEM2/GROUPING-KEY"> <xsl:copy> <item1-sum><xsl:value-of select="sum(current-group()/ITEM2/SUBITEM2.1)"/></item1-count> ... It gives me an of memory error. The input file is 160MB, but the individual transactions are rather small (around 20+ elements). The error also appears if I remove "<xsl:copy>". I have a working solution using an accumulator and maps, see below, but here I did not manage to use streaming. If I set the accumulator to streamable="yes", Saxon EE tells me "The xsl:accumulator-rule/@select expression for a streaming accumulator must be motionless" Although I am using xsl-copy() as in Martin's example. <xsl:accumulator name="gather-values" as="map(xs:anyAtomicType, node())" initial-value="map{}"> <xsl:accumulator-rule match="TRANSACTION"> <xsl:variable name="current" select="copy-of()"/> <xsl:variable name="currentKey" select="$current/ITEM2/SUBITEM2/GROUPING-KEY"/> <xsl:choose> <xsl:when test="map:contains($value, $currentKey)"> <xsl:variable name="amount"> <amount> <xsl:value-of select="map:get($value, $currentKey)/amount + xs:decimal($current/ITEM2/SUBITEM2.1)" /> </amount> </xsl:variable> <xsl:sequence select=" map:put($value, $currentKey, $amount)"/> </xsl:when> <xsl:otherwise> <xsl:variable name="amount"> <amount> <xsl:value-of select="xs:decimal($current/ITEM2/SUBITEM2.1)"/> </amount> </xsl:variable> <xsl:sequence select="map:put($value, $currentKey, $amount)"/> </xsl:otherwise> </xsl:choose> </xsl:accumulator-rule> </xsl:accumulator> - Felix 2017-07-14 10:17 GMT+02:00 Martin Honnen martin.honnen@xxxxxx < xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx>: > > > Am 14.07.2017 um 09:09 schrieb Felix Sasaki felix@xxxxxxxxxxxxxx: > > 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. > > See also https://stackoverflow.com/questions/44287959/xslt-3-0- > streaming-with-grouping-and-sum-accumulator/44291127#44291127 for a > similar problem and some worked out code samples trying to tackle the > problem. > XSL-List info and archive <http://www.mulberrytech.com/xsl/xsl-list> > EasyUnsubscribe <-list/3033841> (by > email <>)
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: [xsl] Question on streaming and, Martin Honnen martin | Thread | Re: [xsl] Question on streaming and, Martin Honnen martin |
[xsl] HTML tables to CALS tables co, Love Kumar Sharma lu | Date | Re: [xsl] Question on streaming and, Martin Honnen martin |
Month |