XQuery 4.0
This article is part of the XQuery Portal. It provides a summary of the most important features of the XPath and XQuery Functions and Operators 4.0 W3C Editor's Draft.
Contents
Otherwise operator
$a otherwise $b
… is equivalent to …
if(exists($a)) then $a else $b
Braced if, optional else
if($a) { $b } else { $c }
if($a) { if($b) { $c } }
Arrow map operator
"The cat sat on the mat"
=> tokenize()
=!> concat(".")
=!> upper-case()
=> string-join(" ")
Numeric literals
1_048_576
0xFC00
0b111000
Abbreviated function syntax
let $inc := fn($n) { $n + 1 } return $inc(99)
… is equivalent to …
let $inc := function($n) { $n + 1 } return $inc(99)
Focus functions (arity-one)
let $inc := fn { . + 1 } return $inc(99)
fn:filter($integers, fn { . > 5 })
fn:iterate-while($number, fn { . < 100 }, fn { . * . })
Maps
20 new map functions have been added in XPath and XQuery Functions and Operators 4.0, namely
fn:atomic-equal
map:build
map:contains
map:entries
map:entry
map:filter
map:find
map:for-each
map:get
map:keys
map:merge
map:of-pairs
map:pair
map:pairs
map:put
map:remove
map:replace
map:size
map:substitute
map:values
Map functions are described in Map Module.
Arrays
30 new array functions have been added in XPath and XQuery Functions and Operators 4.0, namely
array:append
array:build
array:empty
array:exists
array:filter
array:flatten
array:fold-left
array:fold-right
array:foot
array:for-each
array:for-each-pair
array:get
array:head
array:index-where
array:insert-before
array:join
array:members
array:of-members
array:put
array:remove
array:replace
array:reverse
array:size
array:slice
array:sort
array:split
array:subarray
array:tail
array:trunk
array:values
Array functions are described in Array Module.
Changelog
- Version 11.0
- Added
otherwise
operator