Hi Markus,
although I do not quite understand your description (why should I care for the representation of the map I construct?), it may be that one piece of information is useful to you, as it is not obvious from the spec: it's about how to construct a map dynamically, that is,
(1) when the keys are not known beforehand,
(2) and/or when the entry values are assigned in "iterations" of a FLWOR expression
(Especially (2) might be what puzzles you.)
(1) and (2) can't be accomplished when using the map constructor expression, like this: basex "map{'x':1, 'y': false()}"
The trick consists of using a combination of the functions map:merge() [1] and map:entry() [2].
So summarize, the code constructing the map entries is the argument of function map:merge().This code may for example be (most often is) a FLWOR expression. In this code, each entry is constructed by a call of function map:entry(). For a tiny example see below.
Kind regards,
Hans-Jürgen
PS: Tiny example demonstrating the construction of maps via map:merge() & map:entry().
(: Creates a map with one entry for each element name
encountered in the input document. The entry value
is the number of elements with that name. As the
map keys are not known in advance, map:merge() is
used.
:)
map:merge(
for $elem in //*
group by $name := $elem/local-name(.)
return map:entry($name, count($elem))
)