Changes

Jump to navigation Jump to search
19 bytes added ,  23:04, 22 April 2011
no edit summary
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'''
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'''
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(map:entry(0, "no"), map:entry(1, "yes"))</code> returns <code>map{0:="no", 1:="yes"}</code>. <em>(Returns a map with two entries; the collation of the map is the default collation from the static context).</em><br/>
The expression <code>map:new(map:entry(0, "no"), map:entry(1, "yes"))</code> returns <code>map{0:="no", 1:="yes"}</code>. <em>(Returns a map with two entries; the collation of the map is the default collation from the static context).</em><br/>
The expression <code>map:new(($week, map{7:="Unbekannt"}))</code> returns <code>map{0:="Sonntag", 1:="Montag", 2:="Dienstag", 3:="Mittwoch", 4:="Donnerstag", 5:="Freitag", 6:="Samstag", 7:="Unbekannt"}</code>. <em>(The value of the existing map is unchanged; a new map is created containing all the entries from <code>$week</code>, supplemented with a new entry.).</em><br/>The expression <code>map:new(($week, map{6:="Sonnabend"}))</code> returns <code>map{0:="Sonntag", 1:="Montag", 2:="Dienstag", 3:="Mittwoch", 4:="Donnerstag", 5:="Freitag", 6:="Sonnabend"}</code>. <em>(The value of the existing map is unchanged; a new map is created containing all the entries from <code>$week</code>, with one entry replaced by a new entry. Both input maps contain an entry with the key value <code>6</code>; the one used in the result is the one that comes last in the input sequence.).</em><br/>
The expression <code>map:new((map{"A":=1}, map{"a:=2"}), "http://collation.example.com/caseblind")</code> returns <code>map{"a":=2}</code>. <em>(Assuming that the keys of the two entries are equal under the rules of the chosen collation, only one of the entries can appear in the result; the one that is chosen is the one from the last map in the input sequence. If both entries were in the same map, it would be implementation-dependent which was chosen.).</em><br/>
|}
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 <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 <code>map{0:="Sonntag", 1:="Montag", 2:="Dienstag", 3:="Mittwoch", 4:="Donnerstag", 5:="Freitag", 6:="Samstag"}</code>.<br/>
|}
==map:size==
editor, reviewer
33

edits

Navigation menu