A ''map'' is a function that associates a set of keys with values, resulting in a collection of key/value pairs. Each key/value pair in a map is called an entry. A key is an arbitrary atomic value, and the associated value is an arbitrary sequence. Within a map, no two entries have the same key, when compared using the {{Code|eq}} operator. It is not necessary that all the keys should be mutually comparable (for example, they can include a mixture of integers and strings).
Maps have the following syntaxcan be constructed as follows:
<pre class="brush:xquery">
map { },
(: map with two entries :)
map { 'key': true(), 1984: (<a/>, <b/>) },(: map with ten entries :)map:merge( for $i in 1 to 10 return map { $i: 'value' || $i })
</pre>
An ''array'' is a function that associates a set of positions, represented as positive integer keys, with values. The first position in an array is associated with the integer {{Code|1}}. The values of an array are called its members. In the type hierarchy, array has a distinct type, which is derived from function.
Arrays can be constructed in two ways. With the square bracket notation, the comma serves as delimiter:
<pre class="brush:xquery">
(: empty array :)
[],
(: array with a sequence as single member :)
[ (1, 2) ]
(: array with two members :)
[ 1 to 2, 3 ] ≙ [ (1, 2), 3 ]
</pre>
With the {{Code|array}} keyword and curly brackets, a comma is evaluated in the usual way:
<pre class="brush:xquery">
(: empty array :)
array { } ≙ array { () }
(: array with three members :)
array { (1, 2) } ≙ array { 1, 2 }
(: array with three members :)
array { 1 to 2, 3 } ≙ array { 1, 2, 3 }
</pre>
The function corresponding to the array has the signature {{Code|function($index as xs:integer) as item()*}}. The expression {{Code|$array($index)}} returns the associated member. The fact that an array is a function item allows it to be passed as an argument to higher-order functions that expect a function item as one of their arguments.