Another possibility:
declare namespace map = "http://www.w3.org/2005/xpath-functions/map";
let $map := map { "a": 1, "b": 2, "c": 3 }
let $entries := map:for-each($map, function($k, $v){ [$k, $v] })
return (array{$entries!?1}, array{$entries!?2})
>
> Here is yet another alternative that can be efficient (but it’s not
> the most compact one):
>
> let $map := map { "a": 1, "b": 2, "c": 3 }
> return (
> array { map:keys($map) },
> array { map:for-each($map, function($key, $value) { $value }) }
> )
>
A disadvantage with this, and some other proposed solutions, is that the spec
offers no guarantee that map:keys() and map:for-each() will iterate the entries
of the map in the same order.
Note also that map:for-each($map, function($key, $value) { $value }) can be
written $map?*
Michael Kay
Saxonica
_______________________________________________
[email protected]
http://x-query.com/mailman/listinfo/talk