Changes

Jump to navigation Jump to search
72 bytes removed ,  18:29, 1 December 2023
m
Text replacement - "<syntaxhighlight lang="xquery">" to "<pre lang='xquery'>"
* The [[XQuery 3.0#Simple Map Operator|Simple Map Operator]] can be used to trigger an action if a value has a single item. The following two expressions are equivalent:
<syntaxhighlight pre lang="'xquery"'>
let $s := "X" return (
(: OLD :) if(count($s) = 1) then 'OK' else (),
* If you want to choose the first non-empty item from two arguments, we can use the position predicate:
<syntaxhighlight pre lang="'xquery"'>
let $s := "X" return (
(: OLD :) if(exists($s)) then $s else 'default',
== Computed Elements ==
Returns dynamically named elements:
<syntaxhighlight pre lang="'xquery"'>
let $root := "element"
let $value := "hi"
This snippet transform a ''flat'' list of elements with <code>parentId</code>-references to a nested list.
<syntaxhighlight pre lang="'xquery"'>
declare function local:link($entries as node()*, $id as xs:string) {
let $entry := $entries[@id eq $id],
This snippet converts an IP address to its numeric representation:
<syntaxhighlight pre lang="'xquery"'>
let $ip := '134.34.226.65'
return fold-left(
This snippets returns the number of JPG files in a directory and its subdirectories:
<syntaxhighlight pre lang="'xquery"'>
basex "count(file:list('.',true(),'*.jpg'))"</syntaxhighlight>
Bureaucrats, editor, reviewer, Administrators
13,551

edits

Navigation menu