default.txt 638 B

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