Am 13.05.2022 um 13:47 schrieb Markus Elfring:
How do you think about to extend an XQuery sccript variant like the following for the desired transformation?
declare option output:method "csv"; declare option output:csv "header=yes"; for $x in (["f", [1, 2, 3]], ["g", [4, 5]]) return
<csv> <record> <key>{$x(1)}</key> <values>{$x(2)}</values> </record> </csv>
Test result: key,values f,1 2 3 g,4 5
Your result asked for in the original question, if it also was meant to indicate some CSV representation, could be achieved using
declare option output:method "csv"; declare option output:csv "header=yes";
<csv> { (["f", [1, 2, 3]], ["g", [4, 5]]) ! (let $key := ?1, $values := ?2?* return $values! <record> <key>{$key}</key> <value>{.}</value> </record> ) } </csv>