Am 04.04.2022 um 15:27 schrieb Markus Elfring:
for $x in $results let $count := $x[1]
Perhaps you want
$x(1)
here to access the first item in the array $x?
Yes. ‒ Thanks that you pointed a typo out.
Thus I adjusted the member access specification. But I stumble on the message “[XPTY0004] Item expected, sequence found: (1, 1, 1)” from the query evaluation.
Which script fine-tuning will help then?
How about showing sample input and output data?
I would guess, that for the grouping you rather want
declare option output:csv "header=yes, separator=|"; let $results := for $x in //test_data/product return array { fn:count($x/contributor), $x/id/data() }
for $x in $results
group by $count := $x(1)