Changes

Jump to navigation Jump to search
225 bytes removed ,  00:42, 26 May 2012
m
Text replace - "| valign='top' | " to "| "
|<code><strong>map:collation</strong>($map as map(*)) as xs:string</code>
|-
| valign='top' | '''Summary'''
| Returns the collation URI of the ''map'' supplied as <code>$map</code>.
|}
|<code><strong>map:contains</strong>($map as map(*), $key as item()) as xs:boolean</code>
|-
| valign='top' | '''Summary'''
| Returns true if the ''map'' 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.
|-
| valign='top' | '''Examples'''
|
* <code>map:contains($week, 2)</code> returns <code>true()</code>.
|<code><strong>map:entry</strong>($key as item(), $value as item()*) as map(*)</code>
|-
| valign='top' | '''Summary'''
| Creates a new ''map'' 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 class="brush:xquery">map:new(for $b in //book return map:entry($b/isbn, $b))</pre>
|-
| valign='top' | '''Examples'''
|
* <code>map:entry("M", "Monday")</code> creates a map with the values <code>{ "M":="Monday" }</code>.
|<code><strong>map:get</strong>($map as map(*), $key as item()) as item()*</code>
|-
| valign='top' | '''Summary'''
|Returns the value associated with a supplied key in a given map. This function attempts to find an entry within the ''map'' supplied as <code>$map</code> that has a key equal to the supplied value of <code>$key</code>. If there is such an entry, it returns the associated value; otherwise it returns an empty sequence. 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 an empty sequence.
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 ''map'' 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>.
|-
| valign='top' | '''Examples'''
|
* <code>map:get($week, 4)</code> returns <code>"Donnerstag"</code>.
|<code><strong>map:keys</strong>($map as map(*)) as xs:anyAtomicType*</code>
|-
| valign='top' | '''Summary'''
|Returns a sequence containing all the key values present in a map. The function takes any ''map'' as its <code>$map</code> argument and returns the keys that are present in the map as a sequence of atomic values, in implementation-dependent order.
|-
| valign='top' | '''Examples'''
|
* <code>map:keys(map{ 1:="yes", 2:="no" })</code> returns some permutation of <code>(1,2)</code> ''(the result is in implementation-dependent order).''
|<code><strong>map:new</strong>() as map(*)</code><br/><code><strong>map:new</strong>($maps as map(*)*) as map(*)</code><br/><code><strong>map:new</strong>($maps as map(*)*, $coll as xs:string) as map(*)</code>
|-
| valign='top' | '''Summary'''
| Constructs and returns a new map. The zero-argument form of the function returns an empty ''map'' whose collation is the default collation in the static context. It is equivalent to calling the one-argument form of the function with an empty sequence as the value of the first argument.
The one-argument form of the function returns a ''map'' that is formed by combining the contents of the maps supplied in the <code>$maps</code> argument. It is equivalent to calling the two-argument form of the function with the default collation from the static context as the second argument.
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.
|-
| valign='top' | '''Examples'''
|
* <code>map:new()</code> creates an empty map.
|<code><strong>map:remove</strong>($map as map(*), $key as item()) as map(*)</code><br/>
|-
| valign='top' | '''Summary'''
| 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
|-
| valign='top' | '''Examples'''
|
* <code>map:remove($week, 4)</code> creates a map with the values <code>{ 0:="Sonntag", 1:="Montag", 2:="Dienstag", 3:="Mittwoch", 5:="Freitag", 6:="Samstag" }</code>.
|<code><strong>map:size</strong>($map as map(*)) as xs:integer</code><br/>
|-
| valign='top' | '''Summary'''
| Returns a the number of entries in the supplied map. The function takes any ''map'' as its <code>$map</code> argument and returns the number of entries that are present in the map.
|-
| valign='top' | '''Examples'''
|
* <code>map:size(map:new())</code> returns <code>0</code>.
Bureaucrats, editor, reviewer, Administrators
13,554

edits

Navigation menu