diff --git a/specifications/xpath-functions-40/src/function-catalog.xml b/specifications/xpath-functions-40/src/function-catalog.xml index 38ee0d762..78f9b12ae 100644 --- a/specifications/xpath-functions-40/src/function-catalog.xml +++ b/specifications/xpath-functions-40/src/function-catalog.xml @@ -13581,8 +13581,8 @@ return error((), 'Duplicate IDs found: ' || string-join($ids, ', ')) - - + + @@ -13612,6 +13612,8 @@ let $end := index-where($input, $to)[. ge $start][1] otherwise (count($input) + 1) return slice($input, $start, $end) + + @@ -13636,6 +13638,9 @@ return slice($input, $start, $end) element if it exists, or up to the end of the sequence otherwise, the simplest solution is perhaps to write:

slice($input, end:=index-where($input, fn { boolean(self::h2) })[1]) + +

A return value of () from the $from or $to + predicate is treated as false.

@@ -13959,7 +13964,7 @@ return slice($input, $start, $end) - + @@ -13986,7 +13991,7 @@ every(for-each-pair($input, $subsequence, $compare))]]>

There is no requirement that the $compare function should have the traditional qualities of equality comparison. The result is well-defined, for example, even if $compare is not transitive - or not symmetric.

+ or not symmetric. A return value of () from the function is treated as false.

@@ -14075,7 +14080,7 @@ return starts-with-subsequence( - + @@ -14101,6 +14106,7 @@ return starts-with-subsequence(

There is no requirement that the $compare function should have the traditional qualities of equality comparison. The result is well-defined, for example, even if $compare is not transitive or not symmetric.

+

A return value of () from the function is treated as false.

@@ -14189,7 +14195,7 @@ return ends-with-subsequence( - + @@ -14220,6 +14226,7 @@ some $i in 0 to count($input) - count($subsequence) satisfies (

There is no requirement that the $compare function should have the traditional qualities of equality comparison. The result is well-defined, for example, even if $compare is not transitive or not symmetric.

+

A return value of () from the function is treated as false.

@@ -14582,7 +14589,8 @@ return for-each(1 to 10, $mapping otherwise void#0) or false to indicate that two items are or are not equal, overriding the normal rules that would apply to those items; or it can return an empty sequence, to indicate that the normal - rules should be followed. + rules should be followed. Note that returning () + is not equivalent to returning false. function(item(), item()) as xs:boolean? fn:void#0 @@ -18826,7 +18834,7 @@ return $action($item, $pos) - + @@ -18851,14 +18859,14 @@ return $item

As a consequence of the function signature and the function calling rules, a type error occurs if the supplied $predicate function returns anything other than a single - xs:boolean item; there is no conversion to an effective boolean - value.

+ xs:boolean item or an empty sequence; there is no conversion to an effective boolean + value, but an empty sequence is interpreted as false.

If $predicate is an arity-1 function, the function call fn:filter($input, $predicate) has a very similar effect to the expression $input[$predicate(.)]. There are some differences, however. In the case of - fn:filter, the function $F is required to return a boolean; + fn:filter, the function $F is required to return an optional boolean; there is no special treatment for numeric predicate values, and no conversion to an effective boolean value. Also, with a filter expression $input[$predicate(.)], the focus within the predicate is different from that outside; this means that the use of a @@ -18871,6 +18879,12 @@ return $item filter(1 to 10, fn($a) { $a mod 2 = 0 }) (2, 4, 6, 8, 10) + + ')//a, fn{@id eq "2"})]]> + ]]> + The function returns () when there is no @id attribute; + this is treated as false. + @@ -18890,7 +18904,8 @@ return filter( - Changed in 4.0: Positional parameter added to predicate function. + Changed in 4.0: + Positional parameter added to predicate function. Return type of predicate changed to boolean? @@ -19530,7 +19545,7 @@ chain((1, 2, 3, 4), $product3) - + @@ -19552,7 +19567,7 @@ chain((1, 2, 3, 4), $product3)

$predicate($input, $pos) is evaluated. If the result is - false, the function returns the value of $input.

+ false or (), the function returns the value of $input.

Otherwise, $action($input, $pos) is evaluated, the resulting value is @@ -19564,7 +19579,7 @@ chain((1, 2, 3, 4), $product3) - + @@ -19704,8 +19719,9 @@ return $result?numbers

$predicate($input, $pos) is evaluated. If the result is true, the function returns the value of $input. - Otherwise , the process repeats from step 2 with $pos incremented by + Otherwise, the process repeats from step 2 with $pos incremented by 1.

+

When the predicate returns an empty sequence, this is treated as false.

More formally, the function is equivalent to the following implementation in XQuery:

@@ -19713,7 +19729,7 @@ return $result?numbers declare %private function do-until-helper( $input as item()*, $action as function(item()*, xs:integer) as item()*, - $predicate as function(item()*, xs:integer) as xs:boolean, + $predicate as function(item()*, xs:integer) as xs:boolean?, $pos as xs:integer ) as item()* { let $result := $action($input, $pos) @@ -19727,7 +19743,7 @@ declare %private function do-until-helper( declare function do-until( $input as item()*, $action as function(item()*, xs:integer) as item()*, - $predicate as function(item()*, xs:integer) as xs:boolean + $predicate as function(item()*, xs:integer) as xs:boolean? ) as item()* { do-until-helper($input, $action, $predicate, 1) };]]> @@ -21214,7 +21230,7 @@ map:for-each($map, fn($key, $value) { $key }) - + @@ -21231,7 +21247,8 @@ map:for-each($map, fn($key, $value) { $key }) $predicate function takes the key and the value of the corresponding map entry as an argument, and the result is a sequence containing the keys of those entries for which the predicate function returns true in implementation-dependent order.

+ def="implementation-dependent">implementation-dependent order. + A return value of () is treated as false.

More formally, the function returns the value of the expression:

{ - @@ -22048,7 +22065,8 @@ return {

The function map:filter takes any map as its $map argument and applies the supplied function to each entry in the map; the result is a new map containing those entries for which - the function returns true.

+ the function returns true. A return value of () from the + predicate is treated as false.

The function supplied as $predicate takes two arguments. It is called supplying the key of the map entry as the first argument, and the associated value as @@ -25870,7 +25888,7 @@ array:index-of( - + @@ -25885,9 +25903,11 @@ array:index-of(

The result of the function is a sequence of integers, in monotonic ascending order, representing the 1-based positions in the input array of those members for which the supplied predicate function - returns true.

-

More formally, the function returns the result of the expression:

- index-of($array => array:for-each($predicate) => array:values(), true()) + returns true. A return value of () is treated as false.

+

More formally, the function returns the result of the XQuery expression:

+ for member $m at $pos in $array +return $pos[$predicate($m, $pos)] + @@ -26469,7 +26489,7 @@ return [ $action($member, $pos) ] - + @@ -26480,7 +26500,8 @@ return [ $action($member, $pos) ]

Returns an array containing those members of the $array for which - $predicate returns true.

+ $predicate returns true. A return value of () + is treated as false.

Informally, the function returns an array containing those members of the input @@ -26488,15 +26509,15 @@ return [ $action($member, $pos) ]

More formally, the function returns the result of the expression:

As a consequence of the function signature and the function calling rules, a type error occurs if the supplied - function $function returns anything other than a single xs:boolean item; there is no conversion - to an effective boolean value.

+ function $function returns anything other than a single xs:boolean item + or an empty sequence; there is no conversion to an effective boolean value.

@@ -28391,7 +28412,7 @@ tail(fold-left( - @@ -28411,7 +28432,7 @@ every $boolean in ( return $predicate($item, $pos) ) satisfies $boolean ]]>
- +

A return value of () from the predicate is treated as false.

An error is raised if the $predicate function raises an error. In particular, @@ -28786,7 +28807,7 @@ function($item) { - + @@ -28801,7 +28822,8 @@ function($item) {

The result of the function is a sequence of integers, in monotonic ascending order, representing the 1-based positions in the input sequence of those items for which the supplied predicate function - returns true.

+ returns true. A return value of () from the predicate function + is treated as false.

More formally, the function is equivalent to the following expression in XQuery:

for $item at $pos in $input @@ -29016,7 +29038,7 @@ head(index-where($input, $predicate)) ! subsequence($input, . + 1) - + @@ -29036,7 +29058,7 @@ return $it ]]>

That is, it returns all items in the sequence prior to the first one where the result of calling the supplied $predicate function, with the current item and its position - as arguments, returns the value false.

+ as arguments, returns the value false or ().

@@ -29380,7 +29402,7 @@ subsequence($input, 1, head(index-where($input, $predicate)) + 1) - @@ -30624,7 +30646,7 @@ path with an explicit file: scheme.

- + @@ -30646,7 +30668,7 @@ path with an explicit file: scheme.

the sequence of arrays.

If the $split-when function returns true, the current partition is wrapped as an array and added to the result, and a new current partition is created, initially containing the item J only. If the $split-when - function returns false, the item J is added to the current partition.

+ function returns false or (), the item J is added to the current partition.

More formally, the function returns the result of the expression:

fold-left($input, (), fn($partitions, $next, $pos) { if (empty($partitions) or $split-when(foot($partitions)?*, $next, $pos))