|
Subject: Re: [xsl] Question on streaming and grouping with nested keys From: "Martin Honnen martin.honnen@xxxxxx" <xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx> Date: Fri, 14 Jul 2017 08:05:46 -0000 |
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.
>
> 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.
>
As the grouping key is in a descendant element, you would need to use
copy-of first e.g.
<xsl:template match="TRANSACTION-LIST">
<xsl:copy>
<xsl:for-each-group select="copy-of(TRANSACTION)"
group-by="ITEM2/SUBITEM2/GROUPING-KEY">
<xsl:copy>
<item1-count><xsl:value-of
select="count(current-group()/ITEM1)"/></item1-count>
Basically with copy-of the nodes are pulled into memory and you depend
on the pipelining explained in
https://www.w3.org/TR/xslt-30/#grounded-consuming-constructs.
| Current Thread |
|---|
|
| <- Previous | Index | Next -> |
|---|---|---|
| [xsl] Question on streaming and gro, Felix Sasaki felix@x | Thread | Re: [xsl] Question on streaming and, David Rudel fwqhgads |
| [xsl] Question on streaming and gro, Felix Sasaki felix@x | Date | Re: [xsl] Question on streaming and, David Rudel fwqhgads |
| Month |