Re: [xsl] Re: XPath expression that yields the same resultasxsl:for-each-group?

Subject: Re: [xsl] Re: XPath expression that yields the same resultasxsl:for-each-group?
From: "Martin Honnen martin.honnen@xxxxxx" <xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx>
Date: Fri, 31 May 2019 06:36:28 -0000
Am 30.05.2019 um 23:46 schrieb Costello, Roger L. costello@xxxxxxxxx:

Group the rows using the composite key ARPT__IDENT | TRM__IDENT and store
the groups in an XSLT variable:



<xsl:variable name="groups" as="array(element(row))*" select="


let $keys :=

distinct-values($rows/concat(ARPT__IDENT, '|', TRM__IDENT))

return

for $i in $keys

return

array {$rows[$i = concat(ARPT__IDENT, '|', TRM__IDENT)] }

Note that you can also create such a sequence of arrays where each array contains the items belonging to a group with

B B B B B B B  <xsl:variable name="groups" as="array(element(row))*">
B B B B B B B B B B B  <xsl:for-each-group select="$rows" composite="yes"
group-by="ARPT__IDENT, TRM__IDENT">
B B B B B B B B B B B B B B B  <xsl:sequence select="array { current-group()
}"/>
B B B B B B B B B B B  </xsl:for-each-group>
B B B B B B B  </xsl:variable>


https://xsltfiddle.liberty-development.net/jyRYYiQ/1


That will probably perform better than the pure XPath expression based
grouping (that does nothing more than apply the old XQuery 1.0
"grouping" technique to collect distinct-values first as a means to
select items of each group).

Current Thread