Map Module
Contents
map:collation
Signatures | map:collation($map as map(*)) as xs:string |
Summary | Returns the URI of the supplied map's collation. |
Rules | The function map:collation returns the collation URI of the <emph>map</emph> supplied as $input .
|
map:contains
Signatures | map:contains($map as map(*), $key as item()) as xs:boolean |
Summary | Tests whether a supplied map contains an entry for a given key. |
Rules | The function map:contains returns true if the map supplied as $map contains an entry with a key equal to the supplied value of $key ; 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 $key .
If the supplied key is let $week := map{0:="Sonntag", 1:="Montag", 2:="Dienstag", 3:="Mittwoch", 4:="Donnerstag", 5:"Freitag", 6:"Samstag"} |
Examples |
The expression |
map:entry
Signatures | map:entry($key as item(), $value as item()*) as map(*) |
Summary | The function |
Rules | If the supplied key is xs:untypedAtomic , it is converted to xs:string . If the supplied key is the xs:float or xs:double value NaN , the supplied $map is returned unchanged.
The function map:new(( map:entry("Su", "Sunday"), map:entry("Mo", "Monday"), map:entry("Tu", "Tuesday"), map:entry("We", "Wednesday"), map:entry("Th", "Thursday"), map:entry("Fr", "Friday"), map:entry("Sa", "Saturday") )) Unlike the map:new(for $b in //book return map:entry($b/isbn, $b)) |
Examples | The expression map:entry("M", "Monday") returns map{"M":="Monday"} .
|
map:get
Signatures | map:get($map as map(*), $key as item()) as item()* |
Summary | Returns the value associated with a supplied key in a given map. |
Rules | The function map:get attempts to find an entry within the map supplied as $input that has a key equal to the supplied value of $key . 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 $key . If the supplied key is xs:untypedAtomic , it is converted to xs:string . If the supplied key is the xs:float or xs:double value NaN , the function returns an empty sequence.
A return value of let $week := map{0:="Sonntag", 1:="Montag", 2:="Dienstag", 3:="Mittwoch", 4:="Donnerstag", 5:"Freitag", 6:"Samstag"} |
Examples |
The expression |
map:keys
Signatures | map:keys($map as map(*)) as xs:anyAtomicType* |
Summary | Returns a sequence containing all the key values present in a map. |
Rules | The function map:keys takes any <emph>map</emph> as its $input argument and returns the keys that are present in the map as a sequence of atomic values, in implementation-dependent order.
|
Examples | The expression map:keys(map{1:="yes", 2:="no"}) returns some permutation of (1,2) . (The result is in implementation-dependent order.). |
map:new
Signatures | map:new() as map(*) map:new($maps as map(*)*) as map(*) map:new($maps as map(*)*, $coll as xs:string) as map(*) |
Summary | Creates a new map: either an empty map, or a map that combines entries from a number of existing maps. |
Rules | The function map:new 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
There is no requirement that the supplied input maps should have the same or compatible types. The type of a map (for example let $week := map{0:="Sonntag", 1:="Montag", 2:="Dienstag", 3:="Mittwoch", 4:="Donnerstag", 5:"Freitag", 6:"Samstag"} |
Examples |
The expression |
map:remove
Signatures | map:remove($map as map(*), $key as item()) as map(*) |
Summary | Constructs a new map by removing an entry from an existing map. |
Rules | The function map:remove returns a new map. The collation of the new map is the same as the collation of the map supplied as $map . The entries in the new map correspond to the entries of $map , excluding any entry whose key is equal to $key .
No failure occurs if the input map contains no entry with the supplied key; the input map is returned unchanged let $week := map{0:="Sonntag", 1:="Montag", 2:="Dienstag", 3:="Mittwoch", 4:="Donnerstag", 5:"Freitag", 6:"Samstag"} |
Examples | The expression map:remove($week, 4) returns map{0:="Sonntag", 1:="Montag", 2:="Dienstag", 3:="Mittwoch", 5:"Freitag", 6:"Samstag"} .The expression |
map:size
Signatures | map:size($map as map(*)) as xs:integer |
Summary | Returns a the number of entries in the supplied map. |
Rules | The function map:size takes any map as its $input argument and returns the number of entries that are present in the map.
|
Examples | The expression map:size(map:new()) returns 0 .The expression map:size(map{"true":=1, "false":0}) returns 2 . |