xsl-list
[Top] [All Lists]

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

2019-05-31 01:36:34
Am 30.05.2019 um 23:46 schrieb Costello, Roger L. costello(_at_)mitre(_dot_)org:

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

        <xsl:variable name="groups" as="array(element(row))*">
            <xsl:for-each-group select="$rows" composite="yes"
group-by="ARPT__IDENT, TRM__IDENT">
                <xsl:sequence select="array { current-group() }"/>
            </xsl:for-each-group>
        </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).
--~----------------------------------------------------------------
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
EasyUnsubscribe: http://lists.mulberrytech.com/unsub/xsl-list/1167547
or by email: xsl-list-unsub(_at_)lists(_dot_)mulberrytech(_dot_)com
--~--

<Prev in Thread] Current Thread [Next in Thread>