From e2b7d5648d9785b3b92a8e07213e30a6b19b2dcb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christian=20Gr=C3=BCn?= Date: Thu, 16 Jan 2025 14:32:25 +0100 Subject: [PATCH] Examples revised --- specifications/xquery-40/src/expressions.xml | 31 ++++++++++++++++---- 1 file changed, 25 insertions(+), 6 deletions(-) diff --git a/specifications/xquery-40/src/expressions.xml b/specifications/xquery-40/src/expressions.xml index fa0ae7fed..7b54f83dc 100644 --- a/specifications/xquery-40/src/expressions.xml +++ b/specifications/xquery-40/src/expressions.xml @@ -22086,14 +22086,16 @@ raised -

Tokenizes a string, creates a new string from the tokens and returns - "a/b/c":

- 'a b c' -> tokenize(.) -> string-join(., '/') +

Tokenizes a string, counts the tokens, creates a concatenated string and returns + count=3:

+ 'a b c' -> tokenize(.) -> count(.) -> concat('count=', .) +

An equivalent expression is: let $string := 'a b c' let $tokens := tokenize($string) -return string-join($tokens, '/') +let $count := count($tokens) +return concat('count=', $count)

@@ -22119,16 +22121,33 @@ return sum($powers) (1 to 4) -> for-each(., op('+')) -> for-each-pair(4 to 7, ., op('>')) --> some(.) +-> some(.) +

An equivalent expression is: -let $data := (1 to 4) +let $data := 1 to 4 let $data := for-each($data, op('+')) let $data := for-each-pair(4 to 7, $data, op('>')) return some($data)

+ +

Reduces a long sequence to at most 9 elements, with dots appended, + and returns a single string.

+ +$dictionary/word +-> (if(count(.) < 10) then . else (.[1 to 9], '…')) +-> string-join(., '; ') + +

An equivalent expression is: + +let $words := $dictionary/word +let $chopped := (if(count($words) < 10) then $words else ($words[1 to 9], '…')) +return string-join($chopped, '; ') + +

+