Debian Codegraph @

test/syntax/source/code/xquery

raw
1 declare option output:method 'json';
2
3 (
4 let $map := map { 'R': 'red', 'G': 'green', 'B': 'blue' }
5 return (
6 $map?* (: 1. returns all values; same as: map:keys($map) ! $map(.) :),
7 $map?R (: 2. returns the value associated with the key 'R'; same as: $map('R') :),
8 $map?('G','B') (: 3. returns the values associated with the key 'G' and 'B' :)
9 ),
10
11 ('A', 'B', 'C') => count(),
12
13 for $country in db:open('factbook')//country
14 where $country/@population > 100000000
15 let $name := $country/name[1]
16 for $city in $country//city[population > 1000000]
17 group by $name
18 return <country name='{ $name }'>{ $city/name }</country>
19
20 )