Database Reference
In-Depth Information
<GroupedItems>
<Group
key=
"A"
>
<item>
Apples
</item>
<item>
Apricots
</item>
</Group>
<Group
key=
"B"
>
<item>
Bananas
</item>
<item>
Brambles
</item>
</Group>
<Group
key=
"P"
>
<item>
Pears
</item>
</Group>
</GroupedItems>
Other XQuery Extras
Beside eXist's support for XQuery 1.0 and the majority of XQuery 3.0, it also has a
few interesting features which are currently specific to its XQuery implementation.
The map data type proposed for XQuery 3.1
The
map
data type in eXist is essentially a key/value lookup table. Keys must be
atomic values (e.g.,
xs:string
,
xs:integer
,
xs:date
, etc.). Values can be anything
from a simple numbers to complete XML documents. Here is a basic example of cre‐
ating and using a map:
let
$
map1
:=
map
{
"a"
:=
1
,
"b"
:=
<XML>
this is
<i>
cool
</i></XML>
}
return
(
$
map1
(
"a"
),
$
map1
(
"b"
))
This will return:
1
<XML>this is <i>cool</i></XML>
Working programmatically with maps is possible through the
map
extension module.
This module allows you to do everything from checking for the existence of keys up
to constructing maps on the fly. Please refer to the
online function documentation
for more information.
Maps are immutable, like any other XQuery variables. So, changing
a map using the functions from the
map
extension module (e.g.,
calling
map:remove
) will create a
new
map.
There is also an article about maps on the
eXist wiki
.
Search WWH ::
Custom Search