| Returns true if the <em>map</em> supplied as <code>$map</code> contains an entry with a key equal to the supplied value of <code>$key</code>; otherwise it returns false. The equality comparison uses the map's collation; no error occurs if the map contains keys that are not comparable with the supplied <code>$key</code>.
If the supplied key is <code>xs:untypedAtomic</code>, it is converted to <code>xs:string</code>. If the supplied key is the <code>xs:float</code> or <code>xs:double</code> value <code>NaN</code>, the function returns false.
<pre class="brush:xquery">let $week := map{0:="Sonntag", 1:="Montag", 2:="Dienstag", 3:="Mittwoch", 4:="Donnerstag", 5:="Freitag", 6:="Samstag"}</pre>
|-
| valign='top' | '''Examples'''
The expression <code>map:contains($week, 9)</code> returns <code>false()</code>.<br/>
The expression <code>map:contains(map{}, "xyz")</code> returns <code>false()</code>.<br/>
The expression <code>map:contains(map{"xyz":=23}, "xyz")</code> returns <code>true()</code>.<br/>
|}
|-
| valign='top' | '''Summary'''
| Returns Creates a new <em>map</em> containing a single entry. The collation of the new map is the default collation from the static context. The key of the entry in the new map is <code>$key</code>, and its associated value is <code>$value</code>. If the supplied key is <code>xs:untypedAtomic</code>, it is converted to <code>xs:string</code>. If the supplied key is the <code>xs:float</code> or <code>xs:double</code> value <code>NaN</code>, the supplied <code>$map</code> is returned unchanged.
The function <code>map:entry</code> is intended primarily for use in conjunction with the function <code>[[#map:new|map:new]]</code>. For example, a map containing seven entries may be constructed like this:
</pre>
Unlike the <code>map{...}</code> expression, this technique can be used to construct a map with a variable number of entries, for example:
<pre class="brush:xquery">map:new(for $b in //book return map:entry($b/isbn, $b))</pre>
|-
| valign='top' | '''Examples'''
| The expression <code>map:entry("M", "Monday")</code> returns creates a map <code>map{"M":="Monday"}</code>with a single entry.
|}
A return value of <code>()</code> from <code>map:get</code> could indicate that the key is present in the map with an associated value of <code>()</code>, or it could indicate that the key is not present in the map. The two cases can be distinguished by calling <code>map:contains</code>.
Invoking the <em>map</em> as a function item has the same effect as calling <code>get</code>: that is, when <code>$map</code> is a map, the expression <code>$map($K)</code> is equivalent to <code>get($map, $K)</code>. Similarly, the expression <code>get(get(get($map, 'employee'), 'name'), 'first')</code> can be written as <code>$map('employee')('name')('first')</code>.
<pre class="brush:xquery">let $week := map{0:="Sonntag", 1:="Montag", 2:="Dienstag", 3:="Mittwoch", 4:="Donnerstag", 5:="Freitag", 6:="Samstag"}</pre>
|-
| valign='top' | '''Examples'''
|-
| valign='top' | '''Examples'''
| The expression <code>map:keys(map{1:="yes", 2:="no"})</code> returns some permutation of <code>(1,2)</code>. <em>(The the result is in implementation-dependent order.).</em><br/>
|}
</ol>
There is no requirement that the supplied input maps should have the same or compatible types. The type of a map (for example <code>map(xs:integer, xs:string)</code>) is descriptive of the entries it currently contains, but is not a constraint on how the map may be combined with other maps.
<pre class="brush:xquery">let $week := map{0:="Sonntag", 1:="Montag", 2:="Dienstag", 3:="Mittwoch", 4:="Donnerstag", 5:="Freitag", 6:="Samstag"}</pre>
|-
| valign='top' | '''Examples'''
|
The expression <code>map:new()</code> returns <code>creates an empty map{}</code>.<br/>The expression <code>map:new(())</code> returns <code>creates an empty map{}</code>.<br/>The expression <code>map:new(map:entry(0, "no"), map:entry(1, "yes"))</code> returns creates a map with the values <code>map{0:="no", 1:="yes"}</code>.<br/>The expression <code>map:new(map:entry(0, "no"), map:entry(1, "yes"))</code> returns creates a map with the values <code>map{0:="no", 1:="yes"}</code>.<br/>The expression <code>map:new(($week, map{7:="Unbekannt"}))</code> returns creates a map with the values <code>map{0:="Sonntag", 1:="Montag", 2:="Dienstag", 3:="Mittwoch", 4:="Donnerstag", 5:="Freitag", 6:="Samstag", 7:="Unbekannt"}</code>.<br/>The expression <code>map:new(($week, map{6:="Sonnabend"}))</code> returns creates a map with the values <code>map{0:="Sonntag", 1:="Montag", 2:="Dienstag", 3:="Mittwoch", 4:="Donnerstag", 5:="Freitag", 6:="Sonnabend"}</code>.<br/>
|}
| Constructs a new map by removing an entry from an existing map. The collation of the new map is the same as the collation of the map supplied as <code>$map</code>. The entries in the new map correspond to the entries of <code>$map</code>, excluding any entry whose key is equal to <code>$key</code>.
No failure occurs if the input map contains no entry with the supplied key; the input map is returned unchanged
<pre class="brush:xquery">let $week := map{0:="Sonntag", 1:="Montag", 2:="Dienstag", 3:="Mittwoch", 4:="Donnerstag", 5:="Freitag", 6:="Samstag"}</pre>
|-
| valign='top' | '''Examples'''
| The expression <code>map:remove($week, 4)</code> returns creates a map with the values <code>map{0:="Sonntag", 1:="Montag", 2:="Dienstag", 3:="Mittwoch", 5:="Freitag", 6:="Samstag"}</code>.<br/>The expression <code>map:remove($week, 23)</code> returns creates a map with the values <code>map{0:="Sonntag", 1:="Montag", 2:="Dienstag", 3:="Mittwoch", 4:="Donnerstag", 5:="Freitag", 6:="Samstag"}</code>.<br/>
|}
|-
| valign='top' | '''Examples'''
| The expression <code>map:size(map:new())</code> returns <code>0</code>.<br/> The expression <code>map:size(map{"true":=1, "false":=0})</code> returns <code>2</code>.<br/>
|}