From 545645ad5c3c109eea6f7448059f8e5388aa3da1 Mon Sep 17 00:00:00 2001 From: Michael Kay Date: Wed, 11 Dec 2024 08:25:52 +0000 Subject: [PATCH] Use function markup --- .../src/function-catalog.xml | 627 +++++++++--------- .../src/xpath-functions.xml | 522 +++++++-------- specifications/xquery-40/src/expressions.xml | 288 ++++---- specifications/xquery-40/src/query-prolog.xml | 8 +- specifications/xslt-40/src/xslt.xml | 4 +- 5 files changed, 725 insertions(+), 724 deletions(-) diff --git a/specifications/xpath-functions-40/src/function-catalog.xml b/specifications/xpath-functions-40/src/function-catalog.xml index 97e6abfa6..71de27634 100644 --- a/specifications/xpath-functions-40/src/function-catalog.xml +++ b/specifications/xpath-functions-40/src/function-catalog.xml @@ -33,8 +33,8 @@ -

The original URI. This element is returned by fn:parse-uri, - but ignored by fn:build-uri.

+

The original URI. This element is returned by fn:parse-uri, + but ignored by fn:build-uri.

@@ -154,7 +154,7 @@

For a simple type, a function item that can be used to construct instances of this type. In the case of a named type that is present in the dynamic context, the result is the same function as returned by - fn:function-lookup applied to the type name (with arity one). For details see + fn:function-lookup applied to the type name (with arity one). For details see and . Constructor function items are also available for anonymous types, and for types that might not be present in the dynamic context. @@ -205,7 +205,7 @@ xs:integer value, and its associated value is a function item obtained as if by evaluating a named function reference Q#N, using the static and dynamic context of the call on - fn:load-xquery-module. The function item can be invoked + fn:load-xquery-module. The function item can be invoked using the rules for dynamic function invocation.

@@ -287,7 +287,7 @@

This entry is a sequence of arrays of strings, holding the parsed rows of the CSV data. The format is the same as the result of the - fn:csv-to-arrays function, except that the first row + fn:csv-to-arrays function, except that the first row is omitted in the case where the header option is true. If there are no data rows in the CSV, the value will be an empty sequence.

@@ -382,7 +382,7 @@ xs:integer value, and its associated value is a function item obtained as if by evaluating a named function reference Q#N, using the static and dynamic context of the call on - fn:load-xquery-module. The function item can be invoked + fn:load-xquery-module. The function item can be invoked using the rules for dynamic function invocation.

@@ -654,7 +654,7 @@ $node ! (

For each item in $value, construct a string representing its item type as described below.

-

Eliminate duplicate strings from this list by applying the fn:distinct-values +

Eliminate duplicate strings from this list by applying the fn:distinct-values function, forming a sequence of strings $ss.

If $ss contains only one string, use that string.

Otherwise, return the result of the expression `({fn:string-join($ss, "|")})`.

@@ -960,7 +960,7 @@ $node ! (

If the argument is omitted, it defaults to the context value (.). The behavior of the function if the argument is omitted is exactly the same as if the context value had been passed as the argument.

-

The result of fn:data is the sequence of atomic items produced by +

The result of fn:data is the sequence of atomic items produced by applying the following rules to each item in $input:

@@ -975,7 +975,7 @@ $node ! ( />).

-

If the item is an array, the result of applying fn:data to +

If the item is an array, the result of applying fn:data to each member of the array, in order, is appended to the result sequence.

@@ -993,8 +993,8 @@ $node ! ( absent.

-

The process of applying the fn:data function to a sequence is referred to - as atomization. In many cases an explicit call on fn:data is +

The process of applying the fn:data function to a sequence is referred to + as atomization. In many cases an explicit call on fn:data is not required, because atomization is invoked implicitly when a node or sequence of nodes is supplied in a context where an atomic item or sequence of atomic items is required.

@@ -1080,7 +1080,7 @@ $node ! ( the parent element.

-

See also fn:static-base-uri.

+

See also fn:static-base-uri.

The following errors may be raised when $node is omitted:

@@ -1158,23 +1158,23 @@ $node ! ( resource having the same document-uri property. In addition, the specification explicitly allows implementations, at user request, to relax the requirements for determinism of resource access functions, which makes it possible for multiple calls of functions such as - fn:doc, fn:json-doc, or fn:collection to return + fn:doc, fn:json-doc, or fn:collection to return different results for the same supplied URI.

Although the uniqueness of the document-uri property is no longer an absolute constraint, it is still desirable that implementations should where possible respect the principle that URIs are usable as identifiers for resources.

-

In the case of a document node $D returned by the fn:doc +

In the case of a document node $D returned by the fn:doc function, it will generally be the case that fn:document-uri($D) returns a URI $U such that a call on fn:doc($U) in the same dynamic context will return the same document node $D. The URI $U will not necessarily be the same URI that was originally - passed to the fn:doc function, since several URIs may identify the same resource.

+ passed to the fn:doc function, since several URIs may identify the same resource.

-

It is recommended that implementations of fn:collection +

It is recommended that implementations of fn:collection should ensure that any documents included in the returned collection, if they have a non-empty - fn:document-uri property, should be such that a call on fn:doc supplying this URI + fn:document-uri property, should be such that a call on fn:doc supplying this URI returns the same document node.

@@ -1200,13 +1200,13 @@ $node ! ( focus-independent -

Calling the fn:error function raises an application-defined error.

+

Calling the fn:error function raises an application-defined error.

This function never returns a value. Instead it always raises an error. The effect of the error is identical to the effect of dynamic errors raised implicitly, for example when an incorrect argument is supplied to a function.

-

The parameters to the fn:error function supply information that is +

The parameters to the fn:error function supply information that is associated with the error condition and that is made available to a caller that asks for information about the error. The error may be caught either by the host language (using a try/catch construct in XSLT or XQuery, for example), or by the calling application or @@ -1338,7 +1338,7 @@ $node ! (

If the trace information is unrelated to a specific value, - fn:message can be used instead.

+ fn:message can be used instead.

@@ -1387,11 +1387,11 @@ $node ! (

Outputs trace information and discards the result.

-

Similar to fn:trace, the values of $input, +

Similar to fn:trace, the values of $input, typically serialized and converted to an xs:string, and $label (if supplied and non-empty) may be output to an destination.

-

In contrast to fn:trace, the function returns an empty sequence.

+

In contrast to fn:trace, the function returns an empty sequence.

Any serialization of the implementation’s log output must not raise an error. This can e.g. be achieved by using a serialization method that can handle arbitrary input, such as the .

@@ -2310,7 +2310,7 @@ compare($N * $arg2, 0) eq compare($arg1, 0). value 150.014999389..., which is closer to 150.01 than to 150.02.

From 4.0, the effect of this function can also be achieved by - calling fn:round with the third argument set to "half-to-even".

+ calling fn:round with the third argument set to "half-to-even".

@@ -3144,7 +3144,7 @@ compare($N * $arg2, 0) eq compare($arg1, 0).

-

The evaluation of the fn:format-number function takes place in two +

The evaluation of the fn:format-number function takes place in two phases, an analysis phase described in and a @@ -3190,11 +3190,11 @@ compare($N * $arg2, 0) eq compare($arg1, 0).

In previous versions of XSLT and XQuery, decimal formats were typically defined in the static context using custom declarations (<xsl:decimal-format> in XSLT, declare decimal-format in XQuery) and then selected by name in a call on - fn:format-number. This mechanism remains available, but in 4.0, + fn:format-number. This mechanism remains available, but in 4.0, it may be more convenient to dispense with these declarations, and instead to define a decimal format as a map bound to a global variable, which can be referenced in the $options argument of the - fn:format-number call.

+ fn:format-number call.

@@ -3362,11 +3362,11 @@ return if (starts-with($preprocessed, "-")) then -$abs else +$abs the function delivers the same result as casting $value (after removal of whitespace and underscores) to xs:integer.

If underscores or whitespace in the input need to be rejected, then - the string should first be validated, perhaps using fn:matches.

+ the string should first be validated, perhaps using fn:matches.

If other characters may legitimately appear in the input, for example a leading 0x, then this must first be removed by pre-processing the input.

If the input uses a different family of digits, then the value should first - be converted to the required digits using fn:translate.

+ be converted to the required digits using fn:translate.

A string in the lexical space of xs:hexBinary will always be an acceptable input, provided it is not too long. So, for example, the expression "1DE=" => xs:base64Binary() => xs:hexBinary() => xs:string() => parse-integer(16) @@ -4961,8 +4961,8 @@ translate(value := '٢٠٢٣', replace := '٠١٢٣٤٥٦٧٨٩', with := '01234 is true, because those expressions convert the xs:decimal value 0.1 to the xs:double value 0.1e0 before the comparison.

-

Although operations such as sorting and the fn:min and fn:max - functions invoke fn:compare to perform numeric comparison, these functions +

Although operations such as sorting and the fn:min and fn:max + functions invoke fn:compare to perform numeric comparison, these functions in some cases treat NaN differently.

@@ -5164,7 +5164,7 @@ translate(value := '٢٠٢٣', replace := '٠١٢٣٤٥٦٧٨٩', with := '01234

concat(("a", "b"), (), ("c", "d")) returns "abcd".

-

A static call on the concat function must use positional arguments, +

A static call on the fn:concat function must use positional arguments, it cannot use keywords.

Each of the parameters has the required type @@ -5172,18 +5172,18 @@ translate(value := '٢٠٢٣', replace := '٠١٢٣٤٥٦٧٨٩', with := '01234 a sequence of atomic items by applying atomization. These sequences are then combined (by sequence concatenation) into a single sequence, and each item in the combined sequence - is converted to a string using the fn:string function. The strings are then concatenated + is converted to a string using the fn:string function. The strings are then concatenated with no separator.

If XPath 1.0 compatibility mode is set to true in the static context of a - static function call to fn:concat, then each supplied argument + static function call to fn:concat, then each supplied argument $v is first reduced to a single string, the result of the expression xs:string($v[1]). This is special-case - processing for the fn:concat function, it is not something + processing for the fn:concat function, it is not something that follows from the general rules for calling variadic functions. This reflects the fact that - fn:concat had custom behavior in XPath 1.0. This rule applies only to + fn:concat had custom behavior in XPath 1.0. This rule applies only to static function calls.

A named function reference can be used to create a function item with any arity: for example @@ -5198,9 +5198,9 @@ translate(value := '٢٠٢٣', replace := '٠١٢٣٤٥٦٧٨٩', with := '01234

As mentioned in Unicode normalization is not automatically - applied to the result of fn:concat. If a normalized result is required, - fn:normalize-unicode can be applied to the xs:string - returned by fn:concat. The following XQuery:

+ applied to the result of fn:concat. If a normalized result is required, + fn:normalize-unicode can be applied to the xs:string + returned by fn:concat. The following XQuery:

let $v1 := "I plan to go to Mu" let $v2 := "?nchen in September" @@ -5220,9 +5220,9 @@ return normalize-unicode(concat($v1, $v2)) or the numeric character reference &#x0308;, will return:

"I plan to go to München in September"

This returned result is normalized in NFC.

-

Alternatives to the fn:concat function include the concatenation operator +

Alternatives to the fn:concat function include the concatenation operator || (for example $x || '-' || $y), the use of string templates - (for example `{$x}-{$y}`), and the fn:string-join function.

+ (for example `{$x}-{$y}`), and the fn:string-join function.

@@ -5632,7 +5632,7 @@ return normalize-unicode(concat($v1, $v2)) ref="xml"/>.

If no argument is supplied, then $value defaults to the string value - (calculated using fn:string) of the context value (.).

+ (calculated using fn:string) of the context value (.).

@@ -5785,7 +5785,7 @@ return normalize-unicode(concat($v1, $v2)) details of the stability policy regarding changes to the normalization rules in future versions of Unicode. If the input string contains codepoints that are unassigned in the relevant version of Unicode, or for which no normalization rules are defined, the - fn:normalize-unicode function leaves such codepoints unchanged. If the + fn:normalize-unicode function leaves such codepoints unchanged. If the implementation supports the requested normalization form then it must be able to handle every input string without raising an error.

@@ -5829,7 +5829,7 @@ return normalize-unicode(concat($v1, $v2))

Case mappings may change the length of a string. In general, the - fn:upper-case and fn:lower-case functions are not inverses + fn:upper-case and fn:lower-case functions are not inverses of each other: fn:lower-case(fn:upper-case($s)) is not guaranteed to return $s, nor is fn:upper-case(fn:lower-case($s)). The character U+0131 (used in Turkish) @@ -5890,7 +5890,7 @@ return normalize-unicode(concat($v1, $v2))

Case mappings may change the length of a string. In general, the - fn:upper-case and fn:lower-case functions are not inverses + fn:upper-case and fn:lower-case functions are not inverses of each other: fn:lower-case(fn:upper-case($s)) is not guaranteed to return $s, nor is fn:upper-case(fn:lower-case($s)). The character U+0131 (used in Turkish) @@ -7175,7 +7175,7 @@ Tak, tak, tak! - da kommen sie.

Note that the rules for function coercion mean that the function actually supplied for the $action parameter may be an arity-1 function: the second argument does not need to be declared if it is not used.

-

The replacement string is obtained by invoking fn:string +

The replacement string is obtained by invoking fn:string for the result of the function call.

Otherwise, if the $replacement argument is present and is not @@ -7441,7 +7441,7 @@ Tak, tak, tak! - da kommen sie. form strips leading and trailing whitespace, whereas the two-argument form delivers an extra zero-length token if leading or trailing whitespace is present.

The function returns no information about the separators that were found - in the string. If this information is required, the fn:analyze-string function + in the string. If this information is required, the fn:analyze-string function can be used instead.

The separator used by the one-argument form of the function is any sequence of tab (U+0009), newline (U+000A), carriage return @@ -7536,9 +7536,9 @@ Tak, tak, tak! - da kommen sie. >implementation-dependent. The children of this element are a sequence of fn:match and fn:non-match elements. This sequence is formed by breaking the $value string into a sequence of strings, - returning any substring that matches $pattern as the content of a - match element, and any intervening substring as the content of a - non-match element.

+ returning any substring that matches $pattern as the content of an + fn:match element, and any intervening substring as the content of an + fn:non-match element.

More specifically, the function starts at the beginning of the input string and attempts to find the first substring that matches the regular expression. If there are several matches, the first match is defined to be the one whose starting position comes first in @@ -7610,7 +7610,7 @@ Tak, tak, tak! - da kommen sie. The concept of “schema awareness”, however, is a matter for host languages to define and is outside the scope of the function library specification.

The declarations and definitions in the schema are not automatically available in - the static context of the fn:analyze-string call (or of any other + the static context of the fn:analyze-string call (or of any other expression). The contents of the static context are host-language defined, and in some host languages are implementation-defined.

The schema defines the outermost element, analyze-string-result, in such @@ -7989,34 +7989,34 @@ some $t in $value ! tokenize(.) satisfies spec="XP31" ref="id-ebv"/>.

-

If $input is the empty sequence, fn:boolean returns +

If $input is the empty sequence, fn:boolean returns false.

If $input is a sequence whose first item is a node, - fn:boolean returns true.

+ fn:boolean returns true.

If $input is a singleton value of type xs:boolean or a - derived from xs:boolean, fn:boolean returns + derived from xs:boolean, fn:boolean returns $input.

If $input is a singleton value of type xs:untypedAtomic, xs:string, xs:anyURI, or a type derived from xs:string - or xs:anyURI, fn:boolean returns false if the operand value has + or xs:anyURI, fn:boolean returns false if the operand value has zero length; otherwise it returns true.

If $input is a singleton value of any numeric type or a type derived - from a numeric type, fn:boolean returns false if the + from a numeric type, fn:boolean returns false if the operand value is NaN or is numerically equal to zero; otherwise it returns true.

-

In all cases other than those listed above, fn:boolean raises a type error In all cases other than those listed above, fn:boolean raises a type error .

@@ -8812,7 +8812,7 @@ xs:dayTimeDuration($arg2) div xs:dayTimeDuration('PT1S')

The result is the xs:yearMonthDuration whose length in months is equal to - the result of applying the fn:round function to the value obtained by + the result of applying the fn:round function to the value obtained by multiplying the length in months of $arg1 by the value of $arg2.

If $arg2 is positive or negative zero, the result is a zero-length @@ -8858,7 +8858,7 @@ xs:dayTimeDuration($arg2) div xs:dayTimeDuration('PT1S')

The result is the xs:yearMonthDuration whose length in months is equal to - the result of applying the fn:round function to the value obtained by + the result of applying the fn:round function to the value obtained by dividing the length in months of $arg1 by the value of $arg2.

If $arg2 is positive or negative infinity, the result is a zero-length @@ -12266,7 +12266,7 @@ represented by the $value argument took place or will take place. format described here is very widely used.

An date can be generated approximately using fn:format-dateTime with a picture + /> date can be generated approximately using fn:format-dateTime with a picture string of "[FNn3], [D01] [MNn3] [Y04] [H01]:[m01]:[s01] [Z0000]".

@@ -12574,8 +12574,8 @@ else QName("", $value)

The namespace URI parts are considered equal if they are both absent, or if they are both present and equal under the rules - of the fn:codepoint-equal function.

-

The local parts are also compared under the rules of the fn:codepoint-equal + of the fn:codepoint-equal function.

+

The local parts are also compared under the rules of the fn:codepoint-equal function.

@@ -12713,7 +12713,7 @@ else QName("", $value)

Reformulated in 4.0 in terms of the new - fn:in-scope-namespaces function; the semantics are unchanged.

+ fn:in-scope-namespaces function; the semantics are unchanged.

@@ -12793,7 +12793,7 @@ else QName("", $value)

Reformulated in 4.0 in terms of the new - fn:in-scope-namespaces function; the semantics are unchanged.

+ fn:in-scope-namespaces function; the semantics are unchanged.

@@ -12885,8 +12885,8 @@ else QName("", $value)

The namespace URI parts are considered equal if they are both absent, or if they are both present and equal under the rules - of the fn:codepoint-equal function.

-

The local parts are also compared under the rules of the fn:codepoint-equal + of the fn:codepoint-equal function.

+

The local parts are also compared under the rules of the fn:codepoint-equal function.

@@ -13226,7 +13226,7 @@ else QName("", $value) def="implementation-defined" >implementation-defined whether XSD 1.1 is supported.

-

Generally fn:number returns NaN rather than raising a dynamic +

Generally fn:number returns NaN rather than raising a dynamic error if the argument cannot be converted to xs:double. However, a type error is raised in the usual way if the supplied argument cannot be atomized or if the result of atomization does not match the required argument type.

@@ -13711,7 +13711,7 @@ let $newi := $o/tool ]]>

This is because it makes two downward selections to read the child row - elements. The use of fn:has-children in the xsl:if conditional + elements. The use of fn:has-children in the xsl:if conditional is intended to circumvent this restriction.

Although the function was introduced to support streaming use cases, it has general utility as a convenience function.

@@ -14338,7 +14338,7 @@ return exists($break)

The items of $values are compared against each other, according to the - rules of fn:distinct-values and with $coll as the collation + rules of fn:distinct-values and with $coll as the collation selected according to the rules in .

From each resulting set of values that are considered equal, one value will be returned if the set contains more than one value.

@@ -14813,7 +14813,7 @@ filter($input, fn($item, $pos) { $pos gt 1 }) which means that a type error occurs if it is called with a negative value.

If the input sequence contains nodes, these are not copied: instead, the result sequence contains multiple references to the same node. So, for example, fn:count(fn:replicate(/, 6)|()) - returns 1, because the fn:replicate call creates duplicates, and the + returns 1, because the fn:replicate call creates duplicates, and the union operation eliminates them.

@@ -15141,9 +15141,9 @@ return slice($input, $start, $end)

The result includes both the item that matches the $from condition and the item that matches the $to condition. To select a subsequence that - starts after the $from item, apply the fn:tail function + starts after the $from item, apply the fn:tail function to the result. To select a subsequence that ends before the $to item, - apply the fn:trunk function to the result.

+ apply the fn:trunk function to the result.

The predicate functions supplied to the $from and $to parameters can include an integer position argument as well as the item itself. @@ -15273,7 +15273,7 @@ return slice($input, $start, $end) fn:items-at($input, 3) returns the same result as $input[3].

Compared with a simple positional filter expression, the function is useful because:

-

It can select items at multiple positions, and unlike fn:subsequence, +

It can select items at multiple positions, and unlike fn:subsequence, these do not need to be contiguous.

The $at expression can depend on the focus.

The order of the returned items can differ from their order in the $input sequence.

@@ -15899,7 +15899,7 @@ return contains-subsequence(

The function can be used to discard unneeded output of expressions (functions, third-party libraries, etc.).

It can also be used to discard results during development.

-

The function is utilized by built-in functions such as map:get +

The function is utilized by built-in functions such as map:get to return an empty sequence for arbitrary input.

It is implementation-dependent whether the supplied argument is evaluated or ignored. An implementation may decide to @@ -16157,7 +16157,7 @@ else error(parse-QName('Q{http://www.w3.org/2005/xqt-errors}FORG0005')) If present, indicates that text and attributes are converted to the specified Unicode normalization form prior to comparison. The value is as for the corresponding - argument of fn:normalize-unicode. + argument of fn:normalize-unicode. xs:string? () @@ -16215,7 +16215,7 @@ else error(parse-QName('Q{http://www.w3.org/2005/xqt-errors}FORG0005')) consisting entirely of whitespace. The value normalize ignores whitespace text nodes in the same way as the strip option, and additionally compares text and attribute nodes after - normalizing whitespace in accordance with the rules of the fn:normalize-space + normalizing whitespace in accordance with the rules of the fn:normalize-space function. The detailed rules, given below, also take into account type annotations and xml:space attributes. @@ -16228,7 +16228,7 @@ else error(parse-QName('Q{http://www.w3.org/2005/xqt-errors}FORG0005'))

As a general rule for boolean options (but not invariably), the value true indicates that the comparison is more strict.

-

In the following rules, where a recursive call on fn:deep-equal is made, this is assumed +

In the following rules, where a recursive call on fn:deep-equal is made, this is assumed to use the same values of $options as the original call.

The rules reference a function equal-strings which compares two xs:string @@ -16236,9 +16236,9 @@ else error(parse-QName('Q{http://www.w3.org/2005/xqt-errors}FORG0005'))

If the whitespace option is set to normalize, then each string is processed - by calling the fn:normalize-space function.

+ by calling the fn:normalize-space function.

If the normalization-form option is present, each string is then normalized - by calling the fn:normalize-unicode function, supplying the specified normalization + by calling the fn:normalize-unicode function, supplying the specified normalization form.

The two strings are then compared for equality under the requested collation.

@@ -16350,7 +16350,7 @@ declare function equal-strings( collation is not used when comparing keys), and

-

has the same associated value (compared using the fn:deep-equal +

has the same associated value (compared using the fn:deep-equal function, recursively).

@@ -16588,7 +16588,7 @@ declare function equal-strings(

Namespace nodes are not considered directly unless they appear in the top-level sequences - passed explicitly to the fn:deep-equal function.

+ passed explicitly to the fn:deep-equal function.

Both nodes are comment nodes, and the equal-strings function @@ -16662,7 +16662,7 @@ declare function equal-strings( two numeric values, it might return true if they are equal to six decimal places.

It is good practice for the items-equal callback function to be reflexive, - symmetric, and transitive; if it is not, then the fn:deep-equal function itself + symmetric, and transitive; if it is not, then the fn:deep-equal function itself will lack these qualities. Reflexive means that every item (including NaN) should be equal to itself; symmetric means that items-equal(A, B) should return the same result as items-equal(B, A), and transitive @@ -17118,7 +17118,7 @@ declare function equal-strings( compare equal under the selected collation, or if two different xs:dateTime values compare equal despite being in different timezones.

If the converted sequence contains exactly one value then that value is returned.

-

The default type when the fn:max function is applied to +

The default type when the fn:max function is applied to xs:untypedAtomic values is xs:double. This differs from the default type for operators such as lt, and for sorting in XQuery and XSLT, which is xs:string.

@@ -17189,7 +17189,7 @@ declare function equal-strings( -

The way that fn:min and fn:max compare numeric values of different types +

The way that fn:min and fn:max compare numeric values of different types has changed. The most noticeable effect is that when these functions are applied to a sequence of xs:integer or xs:decimal values, the result is an xs:integer or xs:decimal, rather than the result of converting this to an xs:double

@@ -17279,7 +17279,7 @@ declare function equal-strings( compare equal under the selected collation, or if two different xs:dateTime values compare equal despite being in different timezones.

If the converted sequence contains exactly one value then that value is returned.

-

The default type when the fn:min function is applied to +

The default type when the fn:min function is applied to xs:untypedAtomic values is xs:double. This differs from the default type for operators such as lt, and for sorting in XQuery and XSLT, which is xs:string.

@@ -17351,7 +17351,7 @@ declare function equal-strings( -

The way that fn:min and fn:max compare numeric values of different types +

The way that fn:min and fn:max compare numeric values of different types has changed. The most noticeable effect is that when these functions are applied to a sequence of xs:integer or xs:decimal values, the result is an xs:integer or xs:decimal, rather than the result of converting this to an xs:double

@@ -17645,7 +17645,7 @@ return tokenize(normalize-space($s), ' ')[. castable as xs:IDREF] is-id property. For legacy reasons, this function returns the element that has the is-id property, whereas it would be more appropriate to return its parent, that being the element that is uniquely identified by the ID. A new function - fn:element-with-id has been introduced with the desired + fn:element-with-id has been introduced with the desired behavior.

If the data model is constructed from an Infoset, an attribute will have the @@ -17700,7 +17700,7 @@ return tokenize(normalize-space($s), ' ')[. castable as xs:IDREF] Assuming the empnr element is given the type xs:ID as a result of schema validation, the element will have the is-id property and is therefore selected. Note the difference from - the behavior of fn:element-with-id. + the behavior of fn:element-with-id. @@ -17729,10 +17729,10 @@ return tokenize(normalize-space($s), ' ')[. castable as xs:IDREF] -

The effect of this function is identical to fn:id in respect of +

The effect of this function is identical to fn:id in respect of elements that have an attribute with the is-id property. However, it behaves differently in respect of element nodes with the is-id property. - Whereas the fn:id function, for legacy reasons, returns the element that has the + Whereas the fn:id function, for legacy reasons, returns the element that has the is-id property, this function returns the element identified by the ID, which is the parent of the element having the is-id property.

@@ -17817,8 +17817,8 @@ return tokenize(normalize-space($s), ' ')[. castable as xs:IDREF] -

This function is equivalent to the fn:id function except when dealing with - ID-valued element nodes. Whereas the fn:id function selects the element +

This function is equivalent to the fn:id function except when dealing with + ID-valued element nodes. Whereas the fn:id function selects the element containing the identifier, this function selects its parent.

If the data model is constructed from an Infoset, an attribute will have the is-id property if the corresponding attribute in the Infoset had an @@ -17875,7 +17875,7 @@ return tokenize(normalize-space($s), ' ')[. castable as xs:IDREF] Assuming the empnr element is given the type xs:ID as a result of schema validation, the element will have the is-id property and is therefore its parent is selected. Note the - difference from the behavior of fn:id. + difference from the behavior of fn:id. @@ -18028,9 +18028,9 @@ return tokenize(normalize-space($s), ' ')[. castable as xs:IDREF] )/ancestor::employee/last => string() "Brown" - Assuming that manager has the is-idref property, the call on fn:idref selects + Assuming that manager has the is-idref property, the call on fn:idref selects the manager element. If, instead, the manager had a ref - attribute with the is-idref property, the call on fn:idref would select the attribute node. + attribute with the is-idref property, the call on fn:idref would select the attribute node. @@ -18040,7 +18040,7 @@ return tokenize(normalize-space($s), ' ')[. castable as xs:IDREF] )/ancestor::employee/last => string() "Singh" - Assuming that employee/deputy has the is-idref property, the call on fn:idref selects + Assuming that employee/deputy has the is-idref property, the call on fn:idref selects the deputy element. @@ -18078,7 +18078,8 @@ return tokenize(normalize-space($s), ' ')[. castable as xs:IDREF] expression (if it does not raise an error) will always return true:

doc("foo.xml") is doc("foo.xml")

This equivalence applies only because the two calls on - the doc function have the same dynamic context. If two calls on doc + the fn:doc function have the same dynamic context. + If two calls on fn:doc have different dynamic contexts, then the mapping from URIs to document nodes in the two contexts may differ, which means that different document nodes may be returned for the same URI. @@ -18096,8 +18097,8 @@ return tokenize(normalize-space($s), ' ')[. castable as xs:IDREF]

If $source is read from a source document, it is generally appropriate to resolve it relative to the base URI property of the relevant node in the source - document. This can be achieved by calling the fn:resolve-uri function, - and passing the resulting absolute URI as an argument to the fn:doc + document. This can be achieved by calling the fn:resolve-uri function, + and passing the resulting absolute URI as an argument to the fn:doc function.

If two calls to this function supply different absolute URI References as arguments, the @@ -18190,7 +18191,7 @@ return tokenize(normalize-space($s), ' ')[. castable as xs:IDREF] -

The rule that multiple calls on fn:doc +

The rule that multiple calls on fn:doc supplying the same absolute URI must return the same document node has been clarified; in particular the rule does not apply if the dynamic context for the two calls requires different processing of the documents (such as schema validation or whitespace stripping).

@@ -18224,7 +18225,7 @@ return tokenize(normalize-space($s), ' ')[. castable as xs:IDREF] within the same must return a document node. However, - if nondeterministic processing has been selected for the fn:doc function, + if nondeterministic processing has been selected for the fn:doc function, this guarantee is lost.

@@ -18292,7 +18293,7 @@ return tokenize(normalize-space($s), ' ')[. castable as xs:IDREF] a valid xs:anyURI.

-

In earlier versions of this specification, the primary use for the fn:collection function +

In earlier versions of this specification, the primary use for the fn:collection function was to retrieve a collection of XML documents, perhaps held as lexical XML in operating system filestore, or perhaps held in an XML database. In this release the concept has been generalised to allow other resources to be retrieved: for example JSON documents might @@ -18366,7 +18367,7 @@ return tokenize(normalize-space($s), ' ')[. castable as xs:IDREF]

In some implementations, there might be a close relationship between collections (as retrieved - by the fn:collection function), and URI collections (as retrieved by this function). + by the fn:collection function), and URI collections (as retrieved by this function). For example, a collection might return XML documents, and the corresponding URI collection might return the URIs of those documents. However, this specification does not impose such a close relationship. For example, there may be collection URIs accepted by one of the two functions and not by the other; a collection might contain @@ -18374,22 +18375,22 @@ return tokenize(normalize-space($s), ' ')[. castable as xs:IDREF] resource.

-

Thus, some implementations might ensure that calling fn:uri-collection and then - applying fn:doc to each of the returned URIs delivers the same result as - calling fn:collection with the same argument; however, this is not +

Thus, some implementations might ensure that calling fn:uri-collection and then + applying fn:doc to each of the returned URIs delivers the same result as + calling fn:collection with the same argument; however, this is not guaranteed.

-

In the case where fn:uri-collection returns the URIs of resources that - could also be retrieved directly using fn:collection, there are several reasons why it +

In the case where fn:uri-collection returns the URIs of resources that + could also be retrieved directly using fn:collection, there are several reasons why it might be appropriate to use this function in preference - to the fn:collection function. For example:

+ to the fn:collection function. For example:

It allows different URIs for different kinds of resource to be dereferenced in different ways: for example, the returned URIs might be referenced using the - fn:unparsed-text function rather than the fn:doc + fn:unparsed-text function rather than the fn:doc function.

@@ -18398,7 +18399,7 @@ return tokenize(normalize-space($s), ' ')[. castable as xs:IDREF]

It allows recovery from failures to read, parse, or validate individual documents, - by calling the fn:doc (or other dereferencing) function within the scope of try/catch.

+ by calling the fn:doc (or other dereferencing) function within the scope of try/catch.

It allows selection of which documents to read based on their URI, for example @@ -18419,7 +18420,7 @@ return tokenize(normalize-space($s), ' ')[. castable as xs:IDREF]

For some of these use cases, this assumes that the cost of calling - fn:collection might be significant (for example, it might involving + fn:collection might be significant (for example, it might involving retrieving all the documents in the collection over the network and parsing them). This will not necessarily be true of all implementations.

@@ -18443,7 +18444,7 @@ return tokenize(normalize-space($s), ' ')[. castable as xs:IDREF] focus-independent -

The fn:unparsed-text function reads an external resource (for example, a +

The fn:unparsed-text function reads an external resource (for example, a file) and returns a string representation of the resource.

@@ -18554,10 +18555,10 @@ return tokenize(normalize-space($s), ' ')[. castable as xs:IDREF]

If it is appropriate to use a base URI other than the dynamic base URI (for example, when resolving a relative URI reference read from a source document) then it is - advisable to resolve the relative URI reference using the fn:resolve-uri - function before passing it to the fn:unparsed-text function.

+ advisable to resolve the relative URI reference using the fn:resolve-uri + function before passing it to the fn:unparsed-text function.

There is no essential relationship between the sets of URIs accepted by the two - functions fn:unparsed-text and fn:doc (a URI accepted by one + functions fn:unparsed-text and fn:doc (a URI accepted by one may or may not be accepted by the other), and if a URI is accepted by both there is no essential relationship between the results (different resource representations are permitted by the architecture of the web).

@@ -18659,7 +18660,7 @@ return tokenize(normalize-space($s), ' ')[. castable as xs:IDREF] focus-independent -

The fn:unparsed-text-lines function reads an external resource (for +

The fn:unparsed-text-lines function reads an external resource (for example, a file) and returns its contents as a sequence of strings, one for each line of text in the string representation of the resource.

@@ -18676,7 +18677,7 @@ return tokenize(normalize-space($s), ' ')[. castable as xs:IDREF] - Defines the encoding of the resource, following the rules of fn:unparsed-text. + Defines the encoding of the resource, following the rules of fn:unparsed-text. xs:string? () @@ -18702,12 +18703,12 @@ return $lines[not(position() = last() and . = '')] line ending were not present.

-

Error conditions are the same as for the fn:unparsed-text function.

+

Error conditions are the same as for the fn:unparsed-text function.

-

See the notes for fn:unparsed-text.

+

See the notes for fn:unparsed-text.

@@ -18729,51 +18730,51 @@ return $lines[not(position() = last() and . = '')]

Allows an application to determine - whether a call on fn:unparsed-text with particular arguments + whether a call on fn:unparsed-text with particular arguments would succeed.

-

The fn:unparsed-text-available function determines whether a call - on the fn:unparsed-text function with identical arguments would +

The fn:unparsed-text-available function determines whether a call + on the fn:unparsed-text function with identical arguments would return a string.

If the first argument is an empty sequence, the function returns false.

In other cases, the function returns true if a call on - fn:unparsed-text or fn:unparsed-text-lines + fn:unparsed-text or fn:unparsed-text-lines with the same arguments would succeed, and - false if a call on fn:unparsed-text - or fn:unparsed-text-lines with the same arguments would + false if a call on fn:unparsed-text + or fn:unparsed-text-lines with the same arguments would fail with a non-recoverable dynamic error.

-

The functions fn:unparsed-text and - fn:unparsed-text-available have the same requirement for +

The functions fn:unparsed-text and + fn:unparsed-text-available have the same requirement for determinism as the functions - fn:doc and fn:doc-available. This means that unless the + fn:doc and fn:doc-available. This means that unless the user has explicitly stated a requirement for a reduced level of determinism, either of these functions if called twice with the same arguments during the course of a transformation must return the same results each time; moreover, the - results of a call on fn:unparsed-text-available + results of a call on fn:unparsed-text-available must be consistent with the results of a subsequent call on unparsed-text with the same arguments.

This function was introduced before XQuery and XSLT allowed errors to be caught; with current versions of these host languages, catching an error from - fn:unparsed-text may provide a better alternative.

-

The specification requires that the fn:unparsed-text-available function should + fn:unparsed-text may provide a better alternative.

+

The specification requires that the fn:unparsed-text-available function should actually attempt to read the resource identified by the URI, and check that it is correctly encoded and contains no characters that are invalid in XML. Implementations may avoid the cost of repeating these checks for example by caching the validated contents of the resource, to anticipate a subsequent call on the - fn:unparsed-text or fn:unparsed-text-lines + fn:unparsed-text or fn:unparsed-text-lines function. Alternatively, implementations may be able to rewrite an expression such as if (unparsed-text-available(A)) then unparsed-text(A) else ... to generate a single call internally.

-

Since the function fn:unparsed-text-lines succeeds or fails under - exactly the same circumstances as fn:unparsed-text, the - fn:unparsed-text-available function may equally be used to test - whether a call on fn:unparsed-text-lines would succeed.

+

Since the function fn:unparsed-text-lines succeeds or fails under + exactly the same circumstances as fn:unparsed-text, the + fn:unparsed-text-available function may equally be used to test + whether a call on fn:unparsed-text-lines would succeed.

@@ -18846,7 +18847,7 @@ return $lines[not(position() = last() and . = '')] access to environment variables. For example, the name of the account under which the query is running may be useful information to a would-be intruder. An implementation may therefore choose to restrict access to the environment, or may provide a facility to - make fn:environment-variable always return the empty sequence.

+ make fn:environment-variable always return the empty sequence.

@@ -18861,7 +18862,7 @@ return $lines[not(position() = last() and . = '')]

Returns a list of environment variable names that are suitable for passing to - fn:environment-variable, as a (possibly empty) sequence of strings.

+ fn:environment-variable, as a (possibly empty) sequence of strings.

The function returns a sequence of strings, being the names of the environment variables @@ -18874,11 +18875,11 @@ return $lines[not(position() = last() and . = '')]

The function returns a list of strings, containing no duplicates.

It is intended that the strings in this list should be suitable for passing to - fn:environment-variable.

+ fn:environment-variable.

See also the note on security under the definition of the - fn:environment-variable function. If access to environment variables has - been disabled, fn:available-environment-variables always returns the empty + fn:environment-variable function. If access to environment variables has + been disabled, fn:available-environment-variables always returns the empty sequence.

@@ -19000,7 +19001,7 @@ return $lines[not(position() = last() and . = '')]

The result of the function is a parcel. A parcel is a single item, but its exact form is implementation-dependent. The only guaranteed operations - that apply to parcels are the fn:unparcel and array:of-members + that apply to parcels are the fn:unparcel and array:of-members functions.

@@ -19008,10 +19009,10 @@ return $lines[not(position() = last() and . = '')]

The main use case for this function is for temporary values used while constructing - or deconstructing arrays using the array:of-members and array:members + or deconstructing arrays using the array:of-members and array:members functions, and higher-level constructs that may be defined in terms of these primitives - in XSLT or XQuery. The array:of-members function constructs an array from a sequence - of parcels, and the array:members function does the reverse.

+ in XSLT or XQuery. The array:of-members function constructs an array from a sequence + of parcels, and the array:members function does the reverse.

Applications may also choose to use parcels to represent nested sequences directly, without converting these to arrays. However, there are few operations available on parcels unless they are first converted to something else.

@@ -19159,7 +19160,7 @@ return $lines[not(position() = last() and . = '')]

A common use case for this function is to handle input documents that contain nested XML documents embedded within CDATA sections. Since the content of the CDATA section are exposed as text, the receiving query or stylesheet may pass this text to the - fn:parse-xml function to create a tree representation of the nested + fn:parse-xml function to create a tree representation of the nested document.

Similarly, nested XML within comments is sometimes encountered, and lexical XML is sometimes returned by extension functions, for example, functions that access web @@ -19167,8 +19168,8 @@ return $lines[not(position() = last() and . = '')]

A use case arises in XSLT where there is a need to preprocess an input document before parsing. For example, an application might wish to edit the document to remove its DOCTYPE declaration. This can be done by reading the raw text using the - fn:unparsed-text function, editing the resulting string, and then - passing it to the fn:parse-xml function.

+ fn:unparsed-text function, editing the resulting string, and then + passing it to the fn:parse-xml function.

@@ -19276,11 +19277,11 @@ return $lines[not(position() = last() and . = '')] incorporates this well-formed parsed entity would not be namespace-well-formed.

-

See also the notes for the fn:parse-xml function.

-

The main differences between fn:parse-xml and - fn:parse-xml-fragment are that for fn:parse-xml, the +

See also the notes for the fn:parse-xml function.

+

The main differences between fn:parse-xml and + fn:parse-xml-fragment are that for fn:parse-xml, the children of the resulting document node must contain exactly one element node and no - text nodes, wheras for fn:parse-xml-fragment, the resulting document node + text nodes, wheras for fn:parse-xml-fragment, the resulting document node can have any number (including zero) of element and text nodes among its children. An additional difference is that the text declaration at the start of an external entity has slightly different syntax from the XML declaration at @@ -19315,8 +19316,8 @@ return $lines[not(position() = last() and . = '')] class="DC" code="0006" /> because the standalone keyword is not permitted in the text declaration that appears at the start of an external general parsed entity. (Thus, it - is not the case that any input accepted by the fn:parse-xml function - will also be accepted by fn:parse-xml-fragment.)

+ is not the case that any input accepted by the fn:parse-xml function + will also be accepted by fn:parse-xml-fragment.)

@@ -19759,13 +19760,13 @@ return $lines[not(position() = last() and . = '')] /> is raised. (For example, this occurs if the map supplied to use-character-maps includes a key that is a string whose length is not one (1)).

If any serialization error occurs, including the detection of an invalid value for a - serialization parameter as described above, this results in the fn:serialize call failing with + serialization parameter as described above, this results in the fn:serialize call failing with a dynamic error.

One use case for this function arises when there is a need to construct an XML document containing nested XML documents within a CDATA section (or on occasions within a - comment). See fn:parse-xml for further details.

+ comment). See fn:parse-xml for further details.

Another use case arises when there is a need to call an extension function that expects a lexical XML document as input.

Another use case for this function is serializing instances of the data model into a human @@ -20173,7 +20174,7 @@ serialize( spec="XP31" ref="id-xp-evaluation-context-components" />.) This is an xs:dateTime that is current at some time during the evaluation of a - query or transformation in which fn:current-dateTime is executed.

+ query or transformation in which fn:current-dateTime is executed.

This function is . The precise instant during the query or transformation represented by the value of fn:current-dateTime() is @@ -20212,10 +20213,10 @@ serialize(

Returns xs:date(fn:current-dateTime()). This is an xs:date (with timezone) that is current at some time during the evaluation of a query or - transformation in which fn:current-date is executed.

+ transformation in which fn:current-date is executed.

This function is . The precise instant during the query - or transformation represented by the value of fn:current-date is fn:current-date is implementation-dependent.

@@ -20245,7 +20246,7 @@ serialize(

Returns xs:time(fn:current-dateTime()). This is an xs:time (with timezone) that is current at some time during the evaluation of a query or - transformation in which fn:current-time is executed.

+ transformation in which fn:current-time is executed.

This function is . The precise instant during the query or transformation represented by the value of fn:current-time() is .

-

The default language property can never be absent. The functions fn:format-integer, - fn:format-date, fn:format-time, and fn:format-dateTime +

The default language property can never be absent. The functions fn:format-integer, + fn:format-date, fn:format-time, and fn:format-dateTime are defined to use the default language if no explicit language is supplied. The default language may play a role in selection of a default collation, but this is not a requirement.

@@ -20363,9 +20364,9 @@ serialize( and run-time resources respectively. This is appropriate when the implementation allows the output of static analysis (a “compiled” query or stylesheet) to be deployed for execution to a different location from the one where static analysis took place. In this situation, the - fn:static-base-uri function should return a URI suitable for locating + fn:static-base-uri function should return a URI suitable for locating resources needed during dynamic evaluation.

-

If a call on the fn:static-base-uri function appears within the expression used +

If a call on the fn:static-base-uri function appears within the expression used to define the value of an optional parameter to a user-defined function, then the value supplied to the function (if the argument is omitted) will be the executable base URI from the dynamic context of the function caller. This allows such a function to resolve relative URIs supplied @@ -20390,10 +20391,10 @@ serialize(

Returns a function item having a given name and arity, if there is one.

-

A call to fn:function-lookup starts by looking for a +

A call to fn:function-lookup starts by looking for a function definition in the named functions component of the dynamic context - (specifically, the dynamic context of the call to fn:function-lookup), + (specifically, the dynamic context of the call to fn:function-lookup), using the expanded QName supplied as $name and the arity supplied as $arity. There can be at most one such function definition.

@@ -20404,10 +20405,10 @@ serialize( definition using the same rules as for evaluation of a named function reference (see ). The captured context of the returned function item (if it is context dependent) is the static and dynamic context of - the call on fn:function-lookup.

+ the call on fn:function-lookup.

-

If the arguments to fn:function-lookup identify a function that is present +

If the arguments to fn:function-lookup identify a function that is present in the static context of the function call, the function will always return the same function that a static reference to this function would bind to. If there is no such function in the static context, then the results depend on what is present in the @@ -20441,31 +20442,31 @@ serialize( contain a particular function, and to call a function in that module only if it is available in the version that was imported. A static call would cause a static error if the function is not available, whereas getting the function using - fn:function-lookup allows the caller to take fallback action in this + fn:function-lookup allows the caller to take fallback action in this situation.

-

If the function that is retrieved by fn:function-lookup is If the function that is retrieved by fn:function-lookup is context-dependent, that is, if it has dependencies on the static or dynamic context of its caller, the context that applies is - the static and/or dynamic context of the call to the fn:function-lookup + the static and/or dynamic context of the call to the fn:function-lookup function itself. The context thus effectively forms part of the closure of the returned function. This mainly applies when the target of - fn:function-lookup is a built-in function, because user-defined + fn:function-lookup is a built-in function, because user-defined functions typically have no dependency on the static or dynamic context of the function call (an exception arises when the expressions used to define default values for parameters are context-dependent). The rule - applies recursively, since fn:function-lookup is itself a context-dependent + applies recursively, since fn:function-lookup is itself a context-dependent built-in function.

-

However, the static and dynamic context of the call to fn:function-lookup +

However, the static and dynamic context of the call to fn:function-lookup may play a role even when the selected function definition is not itself context dependent, if the expressions used to establish default parameter values are context dependent.

-

User-defined XSLT or XQuery functions should be accessible to fn:function-lookup - only if they are statically visible at the location where the call to fn:function-lookup +

User-defined XSLT or XQuery functions should be accessible to fn:function-lookup + only if they are statically visible at the location where the call to fn:function-lookup appears. This means that private functions, if they are not statically visible in the containing - module, should not be accessible using fn:function-lookup.

+ module, should not be accessible using fn:function-lookup.

The function identity is determined in the same way as for a named function reference. Specifically, if there is no context dependency, two calls - on fn:function-lookup with the same name and arity must return the same function.

+ on fn:function-lookup with the same name and arity must return the same function.

These specifications do not define any circumstances in which the dynamic context will contain functions that are not present in the static context, but neither do they rule this out. For example an API may provide the ability to add functions @@ -20473,7 +20474,7 @@ serialize(

The mere fact that a function exists and has a name does not of itself mean that the function is present in the dynamic context. For example, functions obtained through - use of the fn:load-xquery-module function are not added to the dynamic context.

+ use of the fn:load-xquery-module function are not added to the dynamic context.

@@ -20557,7 +20558,7 @@ returns the result of

Returns the arity of the function identified by a function item.

-

The fn:function-arity function returns the arity (number of arguments) of +

The fn:function-arity function returns the arity (number of arguments) of the function identified by $function.

@@ -20598,7 +20599,7 @@ return function-arity($initial)

Returns the annotations of the function item.

-

The fn:function-annotations function returns the annotations of +

The fn:function-annotations function returns the annotations of $function as a sequence of (key, value) pairs. Note that several annotations on a function can share the same name. The order of the annotations is retained.

@@ -20615,9 +20616,9 @@ return function-arity($initial)

The type of the result is the same as the type of the first argument - to the map:of-pairs function. This means that in the common case where the annotation names are all unique, + to the map:of-pairs function. This means that in the common case where the annotation names are all unique, the result of the function can readily be converted into a map by calling - map:of-pairs.

+ map:of-pairs.

@@ -20769,7 +20770,7 @@ fold-left($input, (), fn($result, $next, $pos) {

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 an optional 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 @@ -21079,10 +21080,10 @@ declare function fold-right ( the case of multiplication, or a zero-length string in the case of string concatenation) that causes the function to return the value of the other argument unchanged.

In cases where the function performs an associative operation on its two arguments (such - as addition or multiplication), fn:fold-right produces the same result as - fn:fold-left.

+ as addition or multiplication), fn:fold-right produces the same result as + fn:fold-left.

The value of the third argument of $action corresponds to the position - of the item in the input sequence. Thus, in contrast to fn:fold-left, + of the item in the input sequence. Thus, in contrast to fn:fold-left, it is initally set to the number of items in the input sequence.

@@ -21207,7 +21208,7 @@ return fn($input as item()*, $functions as fn(*)*) as item()* {

An error is raised if the arity of any function $f in $functions is different from the number of - members in the array that is passed to fn:apply.

+ members in the array that is passed to fn:apply.

An error is raised if any item supplied as a function argument cannot be coerced to the required type.

@@ -21223,7 +21224,7 @@ return fn($input as item()*, $functions as fn(*)*) as item()* { arity of one. Any function may have any arity.

-

Using fn:chain may result in more readable XPath expressions than +

Using fn:chain may result in more readable XPath expressions than chaining expressions using arrow operators.

@@ -21516,7 +21517,7 @@ declare function while-do( side-effects. As long as a given condition is met, an new value is computed and tested again. Depending on the use case, the value can be a simple atomic item or an arbitrarily complex data structure.

-

The function fn:do-until can be used to perform the action before the +

The function fn:do-until can be used to perform the action before the first predicate test.

Note that, just as when writing recursive functions, it is easy to construct infinite loops.

@@ -21671,7 +21672,7 @@ declare function do-until( side-effects. A new value is computed and tested until a given condition fails. Depending on the use case, the value can be a simple atomic item or an arbitrarily complex data structure.

-

The function fn:while-do can be used to perform the action after the +

The function fn:while-do can be used to perform the action after the first predicate test.

Note that, just as when writing recursive functions, it is easy to construct infinite loops.

@@ -22032,7 +22033,7 @@ return sort($in, $SWEDISH) using the supplied $comparators. The result is a sorted sequence.

Each comparator function takes two items and returns an xs:integer that defines the relationship between these items, in accordance with the - fn:compare function:

+ fn:compare function:

The comparators are evaluated one after the other, either completely or until the result is an integer other than 0.

@@ -22140,7 +22141,7 @@ return sort-with($persons/person, ( empty sequence, the function returns an empty sequence.

The value of $step is a function that takes a single node as input, and returns a set of nodes as its result.

-

The result of the fn:transitive-closure function is the set of nodes that are reachable from +

The result of the fn:transitive-closure function is the set of nodes that are reachable from $node by applying the $step function one or more times.

Although $step may return any sequence of nodes, the result is treated as a set: the order of nodes @@ -22570,7 +22571,7 @@ xs:QName('xs:double')

Determines whether two atomic items are equal, under the rules used for comparing keys in a map.

-

The function fn:atomic-equal is used to compare two atomic items for equality. This function +

The function fn:atomic-equal is used to compare two atomic items for equality. This function has the following properties (which do not all apply to the eq operator):

Any two atomic items can be compared, regardless of their type.

@@ -22727,8 +22728,8 @@ xs:QName('xs:double')

The function is used to assess whether two atomic items are considered to be duplicates when used as keys in a map. A map cannot contain two separate entries whose keys are the same as defined by this function. - The function is also used when matching keys in functions such as map:get - and map:remove.

+ The function is also used when matching keys in functions such as map:get + and map:remove.

The rules for comparing keys in a map are chosen to ensure that the comparison is:

@@ -22746,11 +22747,11 @@ xs:QName('xs:double')

Two atomic items may be distinguishable even though they are equal under this comparison. For example: they may have different type annotations; dates and times may have different timezones; xs:QName values may have different prefixes.

-

Unlike the eq operator and the fn:deep-equal function, xs:hexBinary and +

Unlike the eq operator and the fn:deep-equal function, xs:hexBinary and xs:base64Binary values are considered distinct. This decision was made in order to preserve backwards compatibility: if the values were treated as interchangeable, it would become impossible to construct certain maps that could be validly constructed using earlier versions of the specification, and it would be difficult to make maps fully - interoperable between processors supporting different language versions, for example when calling fn:transform.

+ interoperable between processors supporting different language versions, for example when calling fn:transform.

As always, any algorithm that delivers the right result is acceptable. For example, when testing whether an xs:double value D is the same key as an xs:decimal value that has N significant digits, it is not necessary to know all the digits in the decimal expansion of D to establish the result: computing the first N+1 @@ -22820,7 +22821,7 @@ xs:QName('xs:double')

Returns a map that combines the entries from a number of existing maps.

-

The function map:merge +

The function map:merge returns a map that is formed by combining the contents of the maps supplied in the $maps argument.

@@ -22955,16 +22956,16 @@ return fold-left($maps, {},

By way of explanation, $combine is a function that combines two maps by iterating over the keys of the second map, adding each key and its corresponding - value to the first map as it proceeds. The second call of fn:fold-left + value to the first map as it proceeds. The second call of fn:fold-left in the return clause then iterates over the maps supplied in the call - to map:merge, accumulating a single map that absorbs successive maps + to map:merge, accumulating a single map that absorbs successive maps in the input sequence by calling $combine.

This algorithm processes the supplied maps in a defined order, but processes the keys within each map in implementation-dependent order.

-

The use of fn:random-number-generator represents one possible conformant +

The use of fn:random-number-generator represents one possible conformant implementation for "duplicates": "use-any", but it is not the only conformant implementation and is not intended to be a realistic implementation. The purpose of this option is to allow the implementation to use whatever strategy is most efficient; for example, @@ -23074,7 +23075,7 @@ return fold-left($maps, {}, -

The function map:of-pairs +

The function map:of-pairs returns a map that is formed by combining key-value pair maps supplied in the $input @@ -23092,7 +23093,7 @@ map:build($input, map:get(?, 'key'), map:get(?, 'value'), $combine)

The function can be made to fail with a dynamic error in the event that duplicate keys are present in the input sequence by supplying a $combine - function that invokes the fn:error function.

+ function that invokes the fn:error function.

@@ -23122,8 +23123,8 @@ map:build($input, map:get(?, 'key'), map:get(?, 'value'), $combine) 5: "Freitag", 6: "Samstag" } - The function map:of-pairs is the inverse of - map:pairs. + The function map:of-pairs is the inverse of + map:pairs. Returns a sequence containing all the keys present in a map.

-

Informally, the function map:keys takes any +

Informally, the function map:keys takes any map as its $map argument and returns the keys that are present in the map as a sequence of atomic items, in implementation-dependent order.

@@ -23247,7 +23248,7 @@ map:build($input, map:get(?, 'key'), map:get(?, 'value'), $combine)

Returns a sequence containing selected keys present in a map.

-

Informally, the function map:keys takes any +

Informally, the function map:keys takes any map as its $map argument. The $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 @@ -23338,7 +23339,7 @@ return map:keys-where($birthdays, fn($name, $date) {

Returns a sequence containing all the values present in a map, in unpredictable order.

-

The function map:values takes any The function map:values takes any map as its $map argument and returns the values that are present in the map as a sequence, in .

-

The function map:entries takes any The function map:entries takes any map as its $map argument and returns the key-value pairs that are present in the map as a sequence of singleton maps, in .

-

The function map:pairs takes any The function map:pairs takes any map as its $map argument and returns the keys that are present in the map as a sequence of key-value pair maps, in Tests whether a supplied map contains an entry for a given key.

-

The function map:contains returns true if the The function map:contains returns true if the map supplied as $map contains an entry with the same key as $key; otherwise it returns false.

@@ -23591,7 +23592,7 @@ return map:keys-where($birthdays, fn($name, $date) {

Returns the value associated with a supplied key in a given map.

-

The function map:get attempts to find an entry within the The function map:get attempts to find an entry within the map supplied as $map that has the -

A return value of () from map:get could indicate that +

A return value of () from map:get could indicate that the key is present in the map with an associated value of (), or it could indicate that the key is not present in the map. The two cases can be distinguished by - calling map:contains, or by using + calling map:contains, or by using a $fallback function to return a value known never to appear in the map.

The $fallback function can be used in a number of ways:

@@ -23626,7 +23627,7 @@ return (

It might return a conventional value such as NaN to indicate that no matching key was found.

-

It might raise a dynamic error, by means of a call on fn:error.

+

It might raise a dynamic error, by means of a call on fn:error.

It might compute a result algorithmically. For example, if the map holds a table of abbreviations, such as { 'CA': 'Canada', 'UK': 'United Kingdom', 'US': 'United States' }, then specifying fallback := fn:identity#1 has the effect that the key value is returned @@ -23692,7 +23693,7 @@ return ( and returns the corresponding values.

-

The function map:find searches the sequence supplied as $input +

The function map:find searches the sequence supplied as $input looking for map entries whose key is the same key @@ -23813,7 +23814,7 @@ declare function map:find($input as item()*, any existing entry for the same key.

-

The function map:put returns a The function map:put returns a map that contains all entries from the supplied $map, with the exception of any entry whose key is the -

The function map:entry returns a The function map:entry returns a map which contains a single entry. The key of the entry in the new map is $key, and its associated value is $value.

@@ -23902,8 +23903,8 @@ declare function map:find($input as item()*, -

The function map:entry is intended primarily for use in conjunction with - the function map:merge. For example, a map containing seven entries may be +

The function map:entry is intended primarily for use in conjunction with + the function map:merge. For example, a map containing seven entries may be constructed like this:

-

The map:merge function can be used to construct +

The map:merge function can be used to construct a map with a variable number of entries, for example:

@@ -23948,7 +23949,7 @@ map:merge(//book ! map:entry(isbn, .))]]>
represents a single key-value pair.

-

The function map:pair returns a The function map:pair returns a map which contains two entries, one (with the key "key") containing $key and the other (with the key "value") containing $value.

@@ -23961,8 +23962,8 @@ map:merge(//book ! map:entry(isbn, .))]]>

The function call map:pair(K, V) produces the same result as the expression { "key": K, "value": V }.

-

The function map:pair is intended primarily for use in conjunction with - the function map:of-pairs. A map may be constructed like this:

+

The function map:pair is intended primarily for use in conjunction with + the function map:of-pairs. A map may be constructed like this:

-

The map:of-pairs function can be used to construct +

The map:of-pairs function can be used to construct a map with a variable number of entries, for example:

@@ -24007,7 +24008,7 @@ map:of-pairs((

Returns a map containing all the entries from a supplied map, except those having a specified key.

-

The function map:remove returns a The function map:remove returns a map containing all the entries in $map except for any entry whose key is the same key as an item in @@ -24066,7 +24067,7 @@ map:filter($map, fn($k, $v) { not(some($keys, atomic-equal($k, ?))) }) sequence concatenation of the results.

-

The function map:for-each takes any The function map:for-each takes any map as its $map argument and applies the supplied function to each entry in the map, in (1, 2) - This function call is equivalent to calling map:keys. The + This function call is equivalent to calling map:keys. The result is in implementation-dependent order. @@ -24152,7 +24153,7 @@ return {

Selects entries from a map, returning a new map.

-

The function map:filter takes any 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. A return value of () from the @@ -24277,7 +24278,7 @@ else map:put($map, $key, $action(())) have the same keys as the input, but (potentially) different associated values.

-

The function map:substitute takes any The function map:substitute takes any map as its $map argument and applies the supplied function to each entry in the map; the result is a map that associates the original set of key values with the results of these function calls.

@@ -24363,7 +24364,7 @@ fold-left($input, {}, fn($map, $item, $pos) {

The default action for combining entries with duplicate keys is to perform a sequence concatenation of the corresponding values, - equivalent to the duplicates: combine option on map:merge. Other potentially useful + equivalent to the duplicates: combine option on map:merge. Other potentially useful functions for combining duplicates include:

fn($a, $b) { $a } Use the first value and discard the remainder

@@ -24392,7 +24393,7 @@ fold-left($input, {}, fn($map, $item, $pos) { )
{ 1: "one", 2: "two", 3: "three", 4: "four", 5: "five" } Returns a map with five entries. The function to compute the key is an identity function, the - function to compute the value invokes fn:format-integer. + function to compute the value invokes fn:format-integer.
map:build( @@ -24485,7 +24486,7 @@ return map:build($titles/title, fn($title) { $title/ix })

The following expression creates a map allowing efficient access to every element in a document by means - of its fn:generate-id value:

+ of its fn:generate-id value:

map:build(//*, generate-id#1)
@@ -24509,7 +24510,7 @@ return map:build($titles/title, fn($title) { $title/ix })

Returns the number of entries in the supplied map.

-

The function map:size takes any The function map:size takes any map as its $map argument and returns the number of entries that are present in the map.

@@ -24563,7 +24564,7 @@ return map:build($titles/title, fn($title) { $title/ix })

The function does not check whether the implementation actually recognizes - the resulting collation URI: that can be achieved using the fn:collation-available + the resulting collation URI: that can be achieved using the fn:collation-available function.

@@ -24728,13 +24729,13 @@ return map:build($titles/title, fn($title) { $title/ix })

equality indicates that the intended purpose of the collation URI is to compare strings for equality, for example in functions such as - fn:index-of or fn:deep-equal.

+ fn:index-of or fn:deep-equal.

sort indicates that the intended purpose of the collation URI is to sort or compare different strings in a collating sequence, for example - in functions such as fn:sort or fn:max.

+ in functions such as fn:sort or fn:max.

substring indicates that the intended purpose of the collation URI is to establish whether one string is a substring of another, for example - in functions such as fn:contains or fn:starts-with.

+ in functions such as fn:contains or fn:starts-with.

The function returns true if and only if the implementation recognizes the candidate @@ -24839,8 +24840,8 @@ return map:build($titles/title, fn($title) { $title/ix }) codepoint equality is inappropriate for comparing keys, then a common technique is to normalize the key so that equality matching becomes feasible. There are many ways keys can be normalized, for example by use of functions such as - fn:upper-case, fn:lower-case, - fn:normalize-space, or fn:normalize-unicode, but this + fn:upper-case, fn:lower-case, + fn:normalize-space, or fn:normalize-unicode, but this function provides a way of normalizing them according to the rules of a specified collation. For example, if the collation ignores accents, then the function will generate the same collation key for two input strings that differ only in their use of @@ -25088,9 +25089,9 @@ return $M(collation-key("a", $C))

By default, the escape sequence is replaced with the Unicode REPLACEMENT CHARACTER. The function is not called for an escape sequence that is invalid against the grammar (for example \x0A). - The string, which results from invoking fn:string on the result + The string, which results from invoking fn:string on the result of the function, is inserted into the result in place of the invalid character. The - function also has the option of raising a dynamic error by calling fn:error.

+ function also has the option of raising a dynamic error by calling fn:error.

@@ -25188,7 +25189,7 @@ return $M(collation-key("a", $C))

To read a JSON file, this function can be used in conjunction with the - fn:unparsed-text function.

+ fn:unparsed-text function.

Many JSON implementations allow commas to be used after the last item in an object or array, although the specification does not permit it. The option spec="liberal" is provided to allow such deviations from the @@ -25482,7 +25483,7 @@ return json-to-xml($json, $options)]]>

The output uses exponential notation if and only if the input uses exponential notation.

The rules have changed since version 3.1 of this specification. In previous versions, the supplied number was cast to an xs:double, and then serialized using the rules of the - fn:string function. This resulted in JSON numbers using exponential notation + fn:string function. This resulted in JSON numbers using exponential notation for values outside the range 1e-6 to 1e6, and led to a loss of precision for 64-bit integer values.

@@ -25609,7 +25610,7 @@ return json-to-xml($json, $options)]]>

The rule allowing the top-level element to have a key attribute (which is ignored) - allows any element in the output of the fn:json-to-xml function + allows any element in the output of the fn:json-to-xml function to be processed: for example, it is possible to take a JSON document, convert it to XML, select a subtree based on the value of a key attribute, and then convert this subtree back to JSON, perhaps after a transformation. The rule means that an element with the appropriate name will be @@ -25701,8 +25702,8 @@ return json-to-xml($json, $options)]]> xs:string "default" - Names are output in the form produced by the fn:name function. - Names are output in the form produced by the fn:local-name function. + Names are output in the form produced by the fn:name function. + Names are output in the form produced by the fn:local-name function. Names in a namespace are output in the form "Q{uri}local". Names in no namespace are output using the local name alone. An element name is output as a local name alone if either (a) it is @@ -25844,8 +25845,8 @@ return json-to-xml($json, $options)]]>

The $value argument is CSV data, as defined in , in the form of an xs:string value. The function first parses this string using - fn:csv-to-arrays, and then further processes the result. The initial - parsing is exactly as defined for fn:csv-to-arrays, and can be controlled + fn:csv-to-arrays, and then further processes the result. The initial + parsing is exactly as defined for fn:csv-to-arrays, and can be controlled using the same options. Additional options are available to control the way in which header information and column names are handled.

@@ -26508,7 +26509,7 @@ return csv-to-arrays(

The arguments have the same meaning, and are subject to the same constraints, as - the arguments of fn:parse-csv.

+ the arguments of fn:parse-csv.

If $value is the empty sequence, the function returns the empty sequence.

@@ -26562,7 +26563,7 @@ return document {
-

See fn:parse-csv.

+

See fn:parse-csv.

@@ -27000,9 +27001,9 @@ return document {

By default, the escape sequence is replaced with the Unicode REPLACEMENT CHARACTER. The function is not called for an escape sequence that is invalid against the grammar (for example \x0A). - The string, which results from invoking fn:string on the result + The string, which results from invoking fn:string on the result of the function, is inserted into the result in place of the invalid character. The - function also has the option of raising a dynamic error by calling fn:error.

+ function also has the option of raising a dynamic error by calling fn:error.

@@ -27278,12 +27279,12 @@ return document {
-

The function may raise any error defined for the fn:unparsed-text or fn:parse-json +

The function may raise any error defined for the fn:unparsed-text or fn:parse-json functions.

If the input cannot be decoded (that is, converted into a sequence of Unicode codepoints, which may or may not represent characters), - then a dynamic error occurs as with the fn:unparsed-text function.

+ then a dynamic error occurs as with the fn:unparsed-text function.

If the input can be decoded, then the possibility still arises that the resulting sequence of codepoints includes codepoints that do not represent characters that are valid in the version of XML that the processor supports. Such codepoints are translated into JSON escape sequences (for example, \uFFFF), @@ -27291,7 +27292,7 @@ return document { defaults to a function that returns the Unicode REPLACEMENT CHARACTER (xFFFD).

-

Additional options are available, as defined by fn:parse-json.

+

Additional options are available, as defined by fn:parse-json.

@@ -27415,7 +27416,7 @@ return document {

The property value is the result of atomizing the attribute node and applying the - fn:json function to the result. (For untyped attributes, the result + fn:json function to the result. (For untyped attributes, the result will always be a single string.)

@@ -27429,7 +27430,7 @@ return document {

If the element has a type annotation that is a simple type, or if its content comprises a single text node, then a property #value set to the result - of atomizing the element node and applying the fn:json function + of atomizing the element node and applying the fn:json function to the result.

@@ -27446,7 +27447,7 @@ return document {

Otherwise, a property #content whose value is an array, with one member for each child node (including whitespace-only text nodes), obtained - by applying the fn:json function to that child node.

+ by applying the fn:json function to that child node.

@@ -27476,7 +27477,7 @@ return document { (if non-empty) set to the prefix of the attribute’s name, #namespace (if non-empty) set to the namespace URI, and #value set to the result of atomizing the attribute value and applying the - fn:json function to the result.

+ fn:json function to the result.

Namespace nodes

Namespace nodes that are reached via an element node result in no output.

@@ -27492,7 +27493,7 @@ return document { and applying escaping rules. If the property name thus generated is the same as a previously output property name, then it is made unique by appending "(N)" where N is the smallest positive integer that makes the resulting value unique.

-

The property value is derived by applying the fn:json function to the value in the map entry.

+

The property value is derived by applying the fn:json function to the value in the map entry.

Conflicts between property names can arise because the XDM model allows keys of different types, for example the xs:date value 2020-12-31 and the string value @@ -27506,7 +27507,7 @@ return document {

Arrays

An XDM array is output as a JSON array. Each member of the XDM array generates one entry in the - JSON array, in order, obtained by applying the fn:json function to the XDM array member.

+ JSON array, in order, obtained by applying the fn:json function to the XDM array member.

Functions

@@ -27628,7 +27629,7 @@ return document { count(array:members($array)) -

Note that because an array is an item, the fn:count function +

Note that because an array is an item, the fn:count function when applied to an array always returns 1.

@@ -27727,7 +27728,7 @@ return document { If $position is less than one or greater than array:size($array), then the $fallback function is called, supplying the value of $position as the argument value; and the result of this call is returned.

-

The default $fallback function raises a dynamic error. The call on fn:error +

The default $fallback function raises a dynamic error. The call on fn:error shown as the default is for illustrative purposes only; apart from the error code (err:FOAY0001) the details of the error (such as the error message) are implementation-dependent.

@@ -28136,7 +28137,7 @@ $array

Informally, all members of $array are compared with $target. An array member is compared to the target value using the rules of the - fn:deep-equal function, with the specified (or defaulted) collation. + fn:deep-equal function, with the specified (or defaulted) collation. The index position of the member is included in the result sequence if the comparison returns true.

@@ -28291,7 +28292,7 @@ array:fold-left($array, (), fn($indices, $member, $pos) {

Returns an array containing selected members of a supplied input array based on their position.

-

Informally, the array is converted to a sequence, the function fn:slice +

Informally, the array is converted to a sequence, the function fn:slice is applied to this sequence, and the resulting sequence is converted back to an array.

-

The function is defined formally below, in terms of the equivalent fn:fold-left +

The function is defined formally below, in terms of the equivalent fn:fold-left function for sequences.

-

The function is defined formally below, in terms of the equivalent fn:fold-right +

The function is defined formally below, in terms of the equivalent fn:fold-right function for sequences.

If the supplied array contains two members $m and $n, the function returns $action($m, $action($n, $zero)); and similarly for an input array with more than two members.

The value of the third argument of $action corresponds to the position - of the member in the input array. Thus, in contrast to array:fold-left, + of the member in the input array. Thus, in contrast to array:fold-left, it is initally set to the number of members in the input array.

@@ -29246,7 +29247,7 @@ array:build( dm:iterate-array($array, map:entry('value', ?))
-

This function is the inverse of array:of-members.

+

This function is the inverse of array:of-members.

@@ -29304,7 +29305,7 @@ array:for-each($array, fn($member) { [] => array:append($member) })

The function call array:split($array) produces the same result as the expression for member $m in $array return [ $m ].

-

This function is the inverse of array:join.

+

This function is the inverse of array:join.

@@ -29380,7 +29381,7 @@ fold-left($input, [], fn($array, $record) {
-

This function is the inverse of array:members.

+

This function is the inverse of array:members.

@@ -29472,7 +29473,7 @@ fold-left($input, [], fn($array, $record) { (for example, in the case where a non-string sort key is followed by another sort key that requires a collation) the empty string can be supplied.

-

The result of the function is defined by reference to the fn:sort function.

+

The result of the function is defined by reference to the fn:sort function.

-

Unlike array:flatten, the function does not apply recursively +

Unlike array:flatten, the function does not apply recursively to nested arrays.

If $A is a single array item, then array:values($A) returns the same result as $A?*.

@@ -29769,7 +29770,7 @@ declare function array:flatten( def="execution-scope">execution scope as the calling module.

The library module that is loaded may import other modules using an import module declaration. The result of - fn:load-xquery-module does not include global variables or functions declared in such a transitively imported module. + fn:load-xquery-module does not include global variables or functions declared in such a transitively imported module. However, the options map supplied in the function call may (and if no default is defined, must) supply values for external variables declared in transitively loaded library modules.

@@ -29835,7 +29836,7 @@ declare function array:flatten( its arity range will be from 3 to 4, so the result will include two function items corresponding to F#3 and F#4. In the lower-arity function item, F#3, the fourth parameter will take its default value. If the expression that initializes the default value is context sensitive, the static and dynamic - context for its evaluation are the static and dynamic contexts of the fn:load-xquery-module + context for its evaluation are the static and dynamic contexts of the fn:load-xquery-module function call itself.

@@ -30185,7 +30186,7 @@ return $variables(QName("http://example.com/dyn", "value"))1.0, 2.0, 3.0 The URI of the principal result document; also used as the base URI for resolving relative URIs of secondary result documents. If the value is a relative - reference, it is resolved against the static base URI of the fn:transform + reference, it is resolved against the static base URI of the fn:transform function call. xs:string @@ -30222,7 +30223,7 @@ return $variables(QName("http://example.com/dyn", "value"))The result is delivered as a string, representing the results of serialization. Note that (as with the - fn:serialize function) the final encoding stage of + fn:serialize function) the final encoding stage of serialization (which turns a sequence of characters into a sequence of octets) is either skipped, or reversed by decoding the octet stream back into a character stream. @@ -30252,7 +30253,7 @@ return $variables(QName("http://example.com/dyn", "value")) 2.0, 3.0 - Indicates whether any fn:trace functions in the stylesheet are to + Indicates whether any fn:trace functions in the stylesheet are to generate diagnostic messages. The destination and formatting of any such messages is implementation-defined. xs:boolean @@ -30340,10 +30341,10 @@ return $variables(QName("http://example.com/dyn", "value"))fn:transform function (for example, this will be the supplied + by the fn:transform function (for example, this will be the supplied base output URI in the case of the principal result, or the string “output” if no base output URI was supplied). The second argument is the - actual value. The value that is returned in the result of the fn:transform + actual value. The value that is returned in the result of the fn:transform function is the result of applying this post-processing. @@ -30361,10 +30362,10 @@ return $variables(QName("http://example.com/dyn", "value"))implementation-defined.

If the primary purpose of the post-processing function is achieved by means of such side-effects, and if the actual results are not needed by - the caller of the fn:transform function, then it does not matter what + the caller of the fn:transform function, then it does not matter what the post-processing function actually returns (it could be an empty sequence, for example).

-

Calls to fn:transform can potentially have side-effects +

Calls to fn:transform can potentially have side-effects even in the absence of the post-processing option, because the XSLT specification allows a stylesheet to invoke extension functions that have side-effects. The semantics in this case are 1.0, 2.0, 3.0 Serialization parameters for the principal result document. The supplied map follows the same rules that apply to a map supplied as the second argument of - fn:serialize. + fn:serialize.

When a parameter is supplied, the corresponding value overrides or augments the value specified in the unnamed xsl:output declaration (or its default), following the same rules as when one xsl:output @@ -30452,14 +30453,14 @@ return $variables(QName("http://example.com/dyn", "value"))implementation-defined whether this parameter has any effect. If the value is a relative reference, it is resolved against - the static base URI of the fn:transform function call. + the static base URI of the fn:transform function call. xs:string n/a 1.0, 2.0, 3.0 URI that can be used to locate the principal stylesheet module. If relative, it - is resolved against the static base URI of the fn:transform function call. + is resolved against the static base URI of the fn:transform function call. The value also acts as the default for stylesheet-base-uri. xs:string n/a @@ -30560,8 +30561,8 @@ return $variables(QName("http://example.com/dyn", "value"))implementation-dependent whether running the function twice against the same inputs produces identical results. The results of two invocations may differ in the identity of any returned nodes; they may also - differ in other respects, for example because the value of fn:current-dateTime is different for the two invocations, - or because the contents of external documents accessed using fn:doc or xsl:source-document change between + differ in other respects, for example because the value of fn:current-dateTime is different for the two invocations, + or because the contents of external documents accessed using fn:doc or xsl:source-document change between one invocation and the next.

@@ -30589,7 +30590,7 @@ return $variables(QName("http://example.com/dyn", "value"))If a static or dynamic error is reported by the XSLT processor, this function fails with a dynamic error, retaining the XSLT error code.

A dynamic error is raised if the XSLT transformation invoked by a call on - fn:transform fails with a static or dynamic error, and no more specific error code is available.

+ fn:transform fails with a static or dynamic error, and no more specific error code is available.

XSLT 1.0 does not define any error codes, so this is the likely outcome with an XSLT 1.0 processor. XSLT 2.0 and 3.0 do define error codes, but some APIs do not expose them. If multiple errors are signaled by the transformation (which is most likely @@ -30604,7 +30605,7 @@ return $variables(QName("http://example.com/dyn", "value"))A dynamic error is raised if the transformation produces output containing characters available only in XML 1.1, and the calling processor cannot handle such characters.

-

Recursive use of the fn:transform function may lead to catastrophic failures such as +

Recursive use of the fn:transform function may lead to catastrophic failures such as non-termination or stack overflow. No error code is assigned to such conditions, since they cannot necessarily be detected by the processor.

@@ -30664,9 +30665,9 @@ return $result?output//body -

Calling the fn:random-number-generator function with no arguments is equivalent to calling the single-argument +

Calling the fn:random-number-generator function with no arguments is equivalent to calling the single-argument form of the function with an implementation-dependent seed.

-

Calling the fn:random-number-generator function with an empty sequence as $seed +

Calling the fn:random-number-generator function with an empty sequence as $seed is equivalent to calling the single-argument form of the function with an implementation-dependent seed.

If a $seed is supplied, it may be an atomic item of any type.

Both forms of the function are The function returned in the permute entry should be such that all permutations of the supplied sequence are equally likely to be chosen.

-

The map returned by the fn:random-number-generator function may contain additional entries beyond +

The map returned by the fn:random-number-generator function may contain additional entries beyond those specified here, but it must match the -

An equivalent result can be achieved with fn:fold-left:

+

An equivalent result can be achieved with fn:fold-left:

tail(fold-left( (1 to 200), @@ -31153,8 +31154,8 @@ fn($item) {

That is, the supplied function for computing key values is wrapped in a function that converts any xs:untypedAtomic values in its result to xs:double. This makes - the function consistent with the behavior of fn:min and fn:max, - but inconsistent with fn:sort, which treats untyped values as strings.

+ the function consistent with the behavior of fn:min and fn:max, + but inconsistent with fn:sort, which treats untyped values as strings.

The result of the function is obtained as follows:

@@ -31507,8 +31508,8 @@ return $item

That is, the supplied function for computing key values is wrapped in a function that converts any xs:untypedAtomic values in its result to xs:double. This makes - the function consistent with the behavior of fn:min and fn:max, - but inconsistent with fn:sort, which treats untyped values as strings.

+ the function consistent with the behavior of fn:min and fn:max, + but inconsistent with fn:sort, which treats untyped values as strings.

The result of the function is obtained as follows:

@@ -31728,7 +31729,7 @@ fold-left($input, false(), fn($result, $item, $pos) {

The result of the function fn:all-equal($values, $collation) is true if and only if the result of fn:count(fn:distinct-values($values, $collation)) le 1 is true (that is, if the sequence is empty, or if all the items in the sequence are equal under the rules of the - fn:distinct-values function).

+ fn:distinct-values function).

@@ -31811,7 +31812,7 @@ fold-left($input, false(), fn($result, $item, $pos) { of fn:count(fn:distinct-values($values, $collation)) eq fn:count($values) is true (that is, if the sequence is empty, or if all the items in the sequence are distinct under the rules of the - fn:distinct-values function).

+ fn:distinct-values function).

@@ -32196,7 +32197,7 @@ fold-left($input, false(), fn($result, $item, $pos) { trailing / as special cases.

Applying uri decoding is equivalent to - calling fn:decode-from-uri on the string.

+ calling fn:decode-from-uri on the string.

The query-parameters value is constructed as follows. Start with an empty map. Tokenize the query on @@ -32237,14 +32238,14 @@ fold-left($input, false(), fn($result, $item, $pos) { -

Like fn:resolve-uri, this function handles the additional characters +

Like fn:resolve-uri, this function handles the additional characters allowed in IRIs in the same way that other unreserved characters are handled.

-

Unlike fn:resolve-uri, this function is not attempting to resolve +

Unlike fn:resolve-uri, this function is not attempting to resolve one URI against another and consequently, the errors that can arise under those - circumstances do not apply here. The fn:parse-uri function will + circumstances do not apply here. The fn:parse-uri function will accept strings that would raise errors if resolution was attempted; - see fn:build-uri.

+ see fn:build-uri.

@@ -32616,7 +32617,7 @@ specifically aware of the jar: scheme.

This example demonstrates that parsing the URI treats non-URI characters in lexical IRIs as “unreserved characters”. The rationale for this is given in the -description of fn:resolve-uri.

+description of fn:resolve-uri.

parse-uri("http://www.example.org/Dürst") { @@ -32793,7 +32794,7 @@ path with an explicit file: scheme.

is made to determine if a password or standard port are present, the authority value is simply added to the string.)

-

The fn:parse-uri function removes +

The fn:parse-uri function removes percent-escaping when it constructs the path-segments, query-parameters, and fragment properties. That’s often the most @@ -33281,7 +33282,7 @@ month = '0', d | '1', ['0'|'1'|'2'] . exclude the “00” forms for month and day, but this is only intended to be an illustrative example.

-

The fn:invisible-xml function takes a grammar and +

The fn:invisible-xml function takes a grammar and returns a function that can be used to parse input strings. In practice, constructing a parser from a grammar may be an expensive operation. Returning a parsing function makes it easy to efficiently reuse @@ -33310,7 +33311,7 @@ month = '0', d | '1', ['0'|'1'|'2'] . for the Invisible XML specification grammar. This should be the same grammar that the implementation uses to parse iXML grammars. If $grammar is not empty, it must be a valid Invisible XML grammar. - If it is not, fn:invisible-xml raises + If it is not, fn:invisible-xml raises err:FOIX0001.

The parsing function that is returned behaves as follows:

@@ -33421,7 +33422,7 @@ return $result

The id property described in the previous paragraphs is allocated only to the top-level map or array (the one supplied as an explicit argument to the - fn:pin function). The function is not + fn:pin function). The function is not deterministic: that is, if the function is called twice with the same arguments, it is implementation-dependent whether the same id property is allocated on both @@ -33555,8 +33556,8 @@ return pin($data)??languages[. = 'German'] ! label(.)?path()[1].

The data model allows any item to be labeled, and allows the label to be any map with string-valued keys. Currently the only operation that creates labeled values is - the fn:pin function. For examples illustrating the use of fn:label, - see fn:pin.

+ the fn:pin function. For examples illustrating the use of fn:label, + see fn:pin.

diff --git a/specifications/xpath-functions-40/src/xpath-functions.xml b/specifications/xpath-functions-40/src/xpath-functions.xml index 1b09ce306..7e10068d3 100644 --- a/specifications/xpath-functions-40/src/xpath-functions.xml +++ b/specifications/xpath-functions-40/src/xpath-functions.xml @@ -403,7 +403,7 @@ for transition to Proposed Recommendation.

'> bound to the correct URI. The host language may also define a default namespace for function calls, in which case function names in that namespace need not be prefixed at all. In many cases the default namespace will be - http://www.w3.org/2005/xpath-functions, allowing a call on the fn:name + http://www.w3.org/2005/xpath-functions, allowing a call on the fn:name function (for example) to be written as name() rather than fn:name(); in this document, however, all example function calls are explicitly prefixed.

@@ -488,7 +488,7 @@ for transition to Proposed Recommendation.

'>

Sometimes there is a need to use an operator as a function. - To meet this requirement, the function fn:op takes any simple binary operator as its argument, + To meet this requirement, the function fn:op takes any simple binary operator as its argument, and returns a corresponding function. So for example fn:for-each-pair($seq1, $seq2, op("+")) performs a pairwise addition of the values in two input sequences.

@@ -508,7 +508,7 @@ for transition to Proposed Recommendation.

'>

A function is uniquely defined by its name and arity (number of arguments); it is therefore not possible to have two different functions that have the same name and arity, but different types in their signature. That is, function overloading in this sense of the term is not permitted. - Consequently, functions such as fn:string which accept arguments of many different + Consequently, functions such as fn:string which accept arguments of many different types have a signature that defines a very general argument type, in this case item()? which accepts any single item; supplying an inappropriate item (such as a function item) causes a dynamic error.

@@ -543,7 +543,7 @@ for transition to Proposed Recommendation.

'> used only where there is a strong precedent in other programming languages (as with math:sin and math:cos for sine and cosine). If a function name contains a datatype name, it may have - intercapitalized spelling and is used in the function name as such. An example is fn:timezone-from-dateTime.

+ intercapitalized spelling and is used in the function name as such. An example is fn:timezone-from-dateTime.

Function summary @@ -651,7 +651,7 @@ for transition to Proposed Recommendation.

'> formal specifications that invoke fn:atomic-equal.

There is no attempt to write formal equivalents for functions that have complex logic - (such as fn:format-number) or dependencies (such as fn:doc); the aim + (such as fn:format-number) or dependencies (such as fn:doc); the aim of the formal equivalents is to define as rigorously as possible a platform of basic functionality that can be used as a solid foundation for more complex features.

@@ -674,7 +674,7 @@ for transition to Proposed Recommendation.

'>

Many of the examples are given in structured form, showing example expressions and their expected results. These published examples are derived from executable test cases, so they follow a standard format. In general, the actual result of the expression is expected to be deep-equal to the presented result, under the - rules of the fn:deep-equal function with default options. In some cases the result is qualified + rules of the fn:deep-equal function with default options. In some cases the result is qualified to indicate that the order of items in the result is implementation-dependent, or that numeric results are approximate.

@@ -727,7 +727,7 @@ for transition to Proposed Recommendation.

'>

Note that this function signature is different from a signature in which the parameter is omitted. See, for example, the two signatures - for fn:string. In the first signature, the parameter is omitted + for fn:string. In the first signature, the parameter is omitted and the argument defaults to the context value, referred to as .. In the second signature, the argument must be present but may be the empty sequence, written as (). @@ -764,7 +764,7 @@ for transition to Proposed Recommendation.

'>

As a matter of convention, a number of functions defined in this document take a parameter whose value is a map, defining options controlling the detail of how the function is evaluated. Maps are a new datatype introduced in XPath 3.1.

-

For example, the function fn:xml-to-json has an options parameter +

For example, the function fn:xml-to-json has an options parameter allowing specification of whether the output is to be indented. A call might be written:

Functions @@ -787,8 +787,8 @@ for transition to Proposed Recommendation.

'> For example, instances of xs:untypedAtomic or xs:anyURI are equally acceptable.

This means that the implementation of the function can check for the - presence and value of particular options using the functions map:contains - and/or map:get.

+ presence and value of particular options using the functions map:contains + and/or map:get.

Implementations may attach an implementation-defined meaning to options in the map that are not described in this specification. These options @@ -822,7 +822,7 @@ for transition to Proposed Recommendation.

'> of the option explicitly accepts either. Accepting a sequence is convenient if the value is generated programmatically using an XPath expression; while accepting an array allows the options to be held in an external file in JSON format, to be read using - a call on the fn:json-doc function.

+ a call on the fn:json-doc function.

In cases where the value of an option is itself a map, the specification of the particular function must indicate whether or not these rules apply recursively to the contents of that map.

@@ -999,8 +999,8 @@ This includes all the built-in datatypes defined in . returned xs:string values are normalized in the sense of .

In functions that involve character counting such - as fn:substring, fn:string-length and - fn:translate, what is counted is the number of XML characters + as fn:substring, fn:string-length and + fn:translate, what is counted is the number of XML characters in the string (or equivalently, the number of Unicode codepoints). Some implementations may represent a codepoint above U+FFFF using two 16-bit values known as a surrogate pair. A surrogate pair counts as one character, not two.

@@ -1095,7 +1095,7 @@ This includes all the built-in datatypes defined in .

An execution scope is a sequence of calls to the function library during which certain aspects of the state are required to remain invariant. - For example, two calls to fn:current-dateTime within the same execution scope will return the same result. + For example, two calls to fn:current-dateTime within the same execution scope will return the same result. The execution scope is defined by the host language that invokes the function library. In XSLT, for example, any two function calls executed during the same transformation are in the same execution scope (except that static expressions, such as those used in @@ -1137,8 +1137,8 @@ This includes all the built-in datatypes defined in . evaluation context of the caller as well as on the actual supplied arguments (if any). A function definition may be context-dependent for some arities in its arity range, and context-independent - for others: for example fn:name#0 is context-dependent - while fn:name#1 is context-independent.

+ for others: for example fn:name#0 is context-dependent + while fn:name#1 is context-independent.

A function definition @@ -1149,13 +1149,13 @@ This includes all the built-in datatypes defined in .

Functions that explicitly deliver the value of a component of the static or dynamic context, - for example fn:static-base-uri, fn:default-collation, - fn:position, or fn:last.

+ for example fn:static-base-uri, fn:default-collation, + fn:position, or fn:last.

Functions with an optional parameter whose default value is taken from the static - or dynamic context of the caller, usually either the context value (for example, fn:node-name) - or the default collation (for example, fn:index-of).

+ or dynamic context of the caller, usually either the context value (for example, fn:node-name) + or the default collation (for example, fn:index-of).

Functions that use the static context of the caller to expand or disambiguate - the values of supplied arguments: for example fn:doc expands its first + the values of supplied arguments: for example fn:doc expands its first argument using the static base URI of the caller, and xs:QName expands its first argument using the in-scope namespaces of the caller.

@@ -1200,12 +1200,12 @@ This includes all the built-in datatypes defined in .

A function definition that is context-dependent can be used as the target of a named - function reference, can be partially applied, and can be found using fn:function-lookup. + function reference, can be partially applied, and can be found using fn:function-lookup. The principle in such cases is that the static context used for the function evaluation is taken from the static context of the named function reference, partial function application, or the call - on fn:function-lookup; and the dynamic context for the function evaluation is taken from the dynamic + on fn:function-lookup; and the dynamic context for the function evaluation is taken from the dynamic context of the evaluation of the named function reference, partial function application, or the call - of fn:function-lookup. These constructs all deliver a + of fn:function-lookup. These constructs all deliver a function item having a captured context based on the static and dynamic context of the construct that created the function item. This captured context forms @@ -1220,22 +1220,22 @@ This includes all the built-in datatypes defined in . -

The functions fn:current-date, fn:current-dateTime, fn:current-time, - fn:default-language, fn:implicit-timezone, - fn:adjust-date-to-timezone, fn:adjust-dateTime-to-timezone, and - fn:adjust-time-to-timezone depend on properties of the dynamic context that are +

The functions fn:current-date, fn:current-dateTime, fn:current-time, + fn:default-language, fn:implicit-timezone, + fn:adjust-date-to-timezone, fn:adjust-dateTime-to-timezone, and + fn:adjust-time-to-timezone depend on properties of the dynamic context that are fixed within the execution scope. The same applies to a number of functions in the op: namespace that manipulate dates and times and that make use of the implicit timezone. These functions will return the same result if called repeatedly during a single execution scope.

-

A number of functions including fn:base-uri#0, fn:data#0, - fn:document-uri#0, fn:element-with-id#1, fn:id#1, - fn:idref#1, fn:lang#1, fn:last#0, fn:local-name#0, - fn:name#0, fn:namespace-uri#0, fn:normalize-space#0, - fn:number#0, fn:path#0, fn:position#0, - fn:root#0, fn:string#0, and - fn:string-length#0 depend on the focus. +

A number of functions including fn:base-uri#0, fn:data#0, + fn:document-uri#0, fn:element-with-id#1, fn:id#1, + fn:idref#1, fn:lang#1, fn:last#0, fn:local-name#0, + fn:name#0, fn:namespace-uri#0, fn:normalize-space#0, + fn:number#0, fn:path#0, fn:position#0, + fn:root#0, fn:string#0, and + fn:string-length#0 depend on the focus. These functions will in general return different results on different calls if the focus is different.

A function is focus-dependent @@ -1247,7 +1247,7 @@ This includes all the built-in datatypes defined in . -

The function fn:default-collation and many +

The function fn:default-collation and many string-handling operators and functions depend on the default collation and the in-scope collations, which are both properties of the static context. If a particular call of one of these functions is @@ -1257,7 +1257,7 @@ This includes all the built-in datatypes defined in . appearing in different places in the source code) may produce different results even if the explicit arguments are the same.

-

Functions such as fn:static-base-uri, fn:doc, and fn:collection depend on +

Functions such as fn:static-base-uri, fn:doc, and fn:collection depend on other aspects of the static context. As with functions that depend on collations, a single call will produce the same results on each call if the explicit arguments are the same, but two calls appearing in different places in @@ -1265,11 +1265,11 @@ This includes all the built-in datatypes defined in . -

The fn:function-lookup function is a special case because it is +

The fn:function-lookup function is a special case because it is potentially dependent on everything in the static and dynamic context. This is because the static and dynamic - context of the call to fn:function-lookup + context of the call to fn:function-lookup form the captured context of the - function item that fn:function-lookup returns.

+ function item that fn:function-lookup returns.

For a context-dependent function, @@ -1291,24 +1291,24 @@ This includes all the built-in datatypes defined in .

Some - functions (such as fn:distinct-values, fn:unordered, map:keys, - and map:for-each) produce results in an + functions (such as fn:distinct-values, fn:unordered, map:keys, + and map:for-each) produce results in an implementation-defined or implementation-dependent order. In such cases two calls with the same arguments are not guaranteed to produce the results in the same order. These functions are said to be nondeterministic with respect to ordering.

-

Some functions (such as fn:analyze-string, - fn:parse-xml, fn:parse-xml-fragment, - fn:parse-html, and fn:json-to-xml) +

Some functions (such as fn:analyze-string, + fn:parse-xml, fn:parse-xml-fragment, + fn:parse-html, and fn:json-to-xml) construct a tree of nodes to represent their results. There is no guarantee that repeated calls with the same arguments will return the same identical node (in the sense of the is operator). However, if non-identical nodes are returned, their content will be the - same in the sense of the fn:deep-equal function. Such a function is said + same in the sense of the fn:deep-equal function. Such a function is said to be nondeterministic with respect to node identity.

-

Some functions (such as fn:doc and fn:collection) create new nodes by reading external +

Some functions (such as fn:doc and fn:collection) create new nodes by reading external documents. Such functions are guaranteed to be deterministic with the exception that an implementation is allowed to make them nondeterministic as a user option.

@@ -1321,7 +1321,7 @@ This includes all the built-in datatypes defined in . repeated calls with the same explicit and implicit arguments must return identical results.

-

The function fn:concat +

The function fn:concat is defined to be variadic: it accepts any number of arguments. No other function has this property.

@@ -1337,7 +1337,7 @@ This includes all the built-in datatypes defined in .

Each of these functions has an arity-zero signature which is equivalent to the arity-one form, with the context value supplied as the implicit first argument. In addition, each of the arity-one functions accepts an empty sequence as the argument, in which case it generally delivers - an empty sequence as the result: the exception is fn:string, which delivers + an empty sequence as the result: the exception is fn:string, which delivers a zero-length string.

@@ -1354,7 +1354,7 @@ This includes all the built-in datatypes defined in . + This has the same meaning as in the second argument of fn:format-integer. @@ -4491,7 +4491,7 @@ a second presentation modifier as follows:

seventh, or for an ordinal number. This has the same meaning as -in the second argument of fn:format-integer. +in the second argument of fn:format-integer. The actual representation of the ordinal form of a number may depend not only on the language, but also on the grammatical context (for example, in some languages it must agree in gender). @@ -4501,7 +4501,7 @@ in some languages it must agree in gender).

Although the formatting rules are expressed in terms of the rules -for format tokens in fn:format-integer, the formats actually used may be specialized +for format tokens in fn:format-integer, the formats actually used may be specialized to the numbering of date components where appropriate. For example, in Italian, it is conventional to use an ordinal number (primo) for the first day of the month, and cardinal numbers (due, tre, quattro ...) for the remaining days. A processor may therefore use @@ -4668,7 +4668,7 @@ modifier is also present, then the width modifier takes precedence.

seconds value is 25.8235, the reversed fractional seconds value is 5328.

The reversed fractional seconds value is formatted using the reversed decimal digit pattern according to the - rules of the fn:format-integer function. Given the examples above, the result is 5'328 + rules of the fn:format-integer function. Given the examples above, the result is 5'328

The resulting string is reversed. In our example, the result is 823'5.

If the result contains more digits than the number of mandatory-digit-signs and optional-digit-signs in the @@ -4681,7 +4681,7 @@ modifier is also present, then the width modifier takes precedence.

The reason for presenting the algorithm in this way is that it enables maximum reuse of the rules defined for - fn:format-integer. Since the fractional seconds value is not properly an integer, the rules do not + fn:format-integer. Since the fractional seconds value is not properly an integer, the rules do not work if used directly: for example, the positions of grouping separators need to be counted from the left rather than from the right. Implementations, as always, are free to use a different algorithm that yields the same result.

@@ -5624,11 +5624,11 @@ correctly in all browsers, depending on the system configuration.

--> Functions that test the cardinality of sequences

The following functions test the cardinality of their sequence arguments.

-

The functions fn:zero-or-one, fn:one-or-more, and - fn:exactly-one defined in this section, check that the cardinality +

The functions fn:zero-or-one, fn:one-or-more, and + fn:exactly-one defined in this section, check that the cardinality of a sequence is in the expected range. They are particularly useful with regard to static typing. For example, the function call fn:remove($seq, fn:index-of($seq2, 'abc')) - requires the result of the call on fn:index-of to be a singleton integer, + requires the result of the call on fn:index-of to be a singleton integer, but the static type system cannot infer this; writing the expression as fn:remove($seq, fn:exactly-one(fn:index-of($seq2, 'abc'))) will provide a suitable static type at query analysis time, and ensures that the length of the sequence is @@ -5669,7 +5669,7 @@ correctly in all browsers, depending on the system configuration.

--> Aggregate functions

Aggregate functions take a sequence as argument and return a single value - computed from values in the sequence. Except for fn:count, the + computed from values in the sequence. Except for fn:count, the sequence must consist of values of a single type or one if its subtypes, or they must be numeric. xs:untypedAtomic values are permitted in the input sequence and handled by special conversion rules. The type of the items in @@ -5762,7 +5762,7 @@ correctly in all browsers, depending on the system configuration.

--> Functions on XML Data

These functions convert between the lexical representation of XML and the tree representation.

-

(The fn:serialize function also handles HTML and JSON output, but is included in this section +

(The fn:serialize function also handles HTML and JSON output, but is included in this section for editorial convenience.)

@@ -5788,7 +5788,7 @@ correctly in all browsers, depending on the system configuration.

--> XDM Mapping from HTML DOM Nodes -

The fn:parse-html function conceptually works in two phases:

+

The fn:parse-html function conceptually works in two phases:

The lexical HTML (supplied as a string) is parsed into an HTML DOM @@ -6608,7 +6608,7 @@ correctly in all browsers, depending on the system configuration.

--> HTML parser options

This section describes the record structure used to pass options to the - fn:parse-html function.

+ fn:parse-html function.

@@ -6638,7 +6638,7 @@ correctly in all browsers, depending on the system configuration.

--> -

Note also that the function fn:serialize has an option to act as the inverse function to fn:parse-json.

+

Note also that the function fn:serialize has an option to act as the inverse function to fn:parse-json.

@@ -6647,18 +6647,18 @@ correctly in all browsers, depending on the system configuration.

-->

This section defines a mapping from JSON data to XDM maps and arrays. Two functions are available - to support this mapping: fn:parse-json and fn:serialize (with options + to support this mapping: fn:parse-json and fn:serialize (with options selecting JSON as the output method). - The fn:parse-json function will accept any JSON text as input, and converts it - to XDM data values. The fn:serialize function (with JSON as the output method) will accept any XDM - value produced using fn:parse-json and convert it back to the original JSON text + The fn:parse-json function will accept any JSON text as input, and converts it + to XDM data values. The fn:serialize function (with JSON as the output method) will accept any XDM + value produced using fn:parse-json and convert it back to the original JSON text (subject to insignificant variations such as reordering the properties in a JSON object).

The conversion is lossless if recommended JSON good practice is followed. Information may however be lost if (a) JSON numbers are not exactly representable as double-precision floating point, or (b) duplicate key values appear within a JSON object.

-

The representation of JSON data produced by the fn:parse-json function +

The representation of JSON data produced by the fn:parse-json function has been chosen with ease of manipulation as a design aim. For example, a simple JSON object such as { "Sun": 1, "Mon": 2, "Tue": 3, ... } produces a simple map, so if the result of parsing is held in $weekdays, the number for a given weekday can be extracted @@ -6676,8 +6676,8 @@ correctly in all browsers, depending on the system configuration.

-->

This section defines a mapping from JSON data to XML (specifically, to XDM element and attribute nodes). A - function fn:json-to-xml is provided to take a JSON string as input and convert it - to the XML representation, and a second function fn:xml-to-json performs the reverse operation.

+ function fn:json-to-xml is provided to take a JSON string as input and convert it + to the XML representation, and a second function fn:xml-to-json performs the reverse operation.

The XML representation is designed to be capable of representing any valid JSON text including one that uses characters which are not valid in XML. The transformation is normally lossless: that is, @@ -6816,15 +6816,15 @@ correctly in all browsers, depending on the system configuration.

-->

The JSON value null is represented by an element named null, with empty content.

The JSON values true and false are represented by an element named boolean, with content conforming to the type xs:boolean. When the element is created by the - fn:json-to-xml function, the string value of the element will be true or false. - The fn:xml-to-json function also recognizes other strings that validate as xs:boolean, + fn:json-to-xml function, the string value of the element will be true or false. + The fn:xml-to-json function also recognizes other strings that validate as xs:boolean, for example 1 and 0. Leading and trailing whitespace is accepted.

A JSON number is represented by an element named number, with content conforming to the type xs:double, with the additional restriction that the value must not be positive or negative infinity, nor NaN. The - fn:json-to-xml function creates an element whose string value is lexically the same as the JSON representation - of the number. The fn:xml-to-json function generates a JSON representation that is the result of casting the + fn:json-to-xml function creates an element whose string value is lexically the same as the JSON representation + of the number. The fn:xml-to-json function generates a JSON representation that is the result of casting the (typed or untyped) value of the node to xs:double and then casting the result to xs:string. Leading and trailing whitespace is accepted. Since JSON does not impose limits on the range or precision @@ -6844,8 +6844,8 @@ correctly in all browsers, depending on the system configuration.

--> of child elements each of which represents one of the name/value pairs in the object. The representation of the name/value pair N:V is obtained by taking the element that represents the value V (by applying these rules recursively) and adding an attribute with name key (in no namespace), whose - value is N as an instance of xs:string. The functions fn:json-to-xml and - fn:xml-to-json both retain the order of entries, subject to rules about how duplicate keys are handled. The + value is N as an instance of xs:string. The functions fn:json-to-xml and + fn:xml-to-json both retain the order of entries, subject to rules about how duplicate keys are handled. The key may be represented in escaped or unescaped form.

@@ -6876,8 +6876,8 @@ correctly in all browsers, depending on the system configuration.

--> of schema validation.

The namespace prefix associated with the namespace http://www.w3.org/2005/xpath-functions (if any) is immaterial. - The effect of the fn:xml-to-json function does not depend on the choice of prefix, and the prefix (if any) generated by the - fn:json-to-xml function is implementation-dependent.

+ The effect of the fn:xml-to-json function does not depend on the choice of prefix, and the prefix (if any) generated by the + fn:json-to-xml function is implementation-dependent.

@@ -6955,7 +6955,7 @@ correctly in all browsers, depending on the system configuration.

--> -

The most basic function for parsing CSV is fn:csv-to-arrays +

The most basic function for parsing CSV is fn:csv-to-arrays which recognizes the delimiters for rows and fields and returns a sequence of arrays each corresponding to one row. The fields within each array are represented as instances of xs:string.

@@ -7042,11 +7042,11 @@ correctly in all browsers, depending on the system configuration.

--> Basic parsing of CSV to arrays -

The result of fn:csv-to-arrays is a sequence of rows, where +

The result of fn:csv-to-arrays is a sequence of rows, where each row is represented as an array of xs:string values.

The first row of the CSV is returned in the same way as all the other rows. - fn:csv-to-arrays does not distinguish between a header row and data + fn:csv-to-arrays does not distinguish between a header row and data rows, and returns all of them.

@@ -7059,7 +7059,7 @@ Field 1A,Field 1B,Field 1C Field 2A,Field 2B,Field 2C' -

the fn:csv-to-arrays function produces

+

the fn:csv-to-arrays function produces

( @@ -7097,7 +7097,7 @@ Field 2A,Field 2B,Field 2C,Field 2D' However, the reality is that CSVs can, and sometimes do, contain a variable number of fields in a row. As a result, this function does not truncate or pad the number of fields in each row for any reason. - The fn:csv-to-xml and fn:parse-csv functions provide + The fn:csv-to-xml and fn:parse-csv functions provide facilities to enforce uniformity and an expected number of columns.

@@ -7111,8 +7111,8 @@ Field 2A,Field 2B,Field 2C,Field 2D' Enhanced parsing of CSV data to maps and arrays -

While fn:csv-to-arrays simply delivers the CSV content - as a sequence of arrays, the fn:parse-csv function goes a step +

While fn:csv-to-arrays simply delivers the CSV content + as a sequence of arrays, the fn:parse-csv function goes a step further and enables access to the data using column names. The column names may be taken either from the first row of the CSV data, or from data supplied by the caller in the options parameter.

@@ -7130,7 +7130,7 @@ Field 2A,Field 2B,Field 2C,Field 2D' Representing CSV data as XML -

The fn:csv-to-xml function returns an XDM node tree representing the CSV data. +

The fn:csv-to-xml function returns an XDM node tree representing the CSV data. Following is a CSV text and the XML serialization of the corresponding node tree.

Name,Date,Amount @@ -7207,7 +7207,7 @@ Bob,2023-07-14,2.34 let $crlf := fn:char(0x0D)||fn:char(0x0A) - Converting a CSV into an HTML-style table using fn:parse-csv + Converting a CSV into an HTML-style table using fn:parse-csv

Direct conversion is a matter of iterating across the records and fields to generate <tr> and <td> elements.

@@ -7266,9 +7266,9 @@ return
- fn:node-name + fn:node-name node-name @@ -1365,7 +1365,7 @@ This includes all the built-in datatypes defined in .
- fn:nilled + fn:nilled nilled @@ -1376,7 +1376,7 @@ This includes all the built-in datatypes defined in .
- fn:string + fn:string string-value @@ -1388,7 +1388,7 @@ This includes all the built-in datatypes defined in .
- fn:data + fn:data typed-value @@ -1398,7 +1398,7 @@ This includes all the built-in datatypes defined in .
- fn:base-uri + fn:base-uri base-uri @@ -1409,7 +1409,7 @@ This includes all the built-in datatypes defined in .
- fn:document-uri + fn:document-uri document-uri @@ -1496,7 +1496,7 @@ This includes all the built-in datatypes defined in .

In this document, as well as in and , the phrase an error is raised - is used. Raising an error is equivalent to calling the fn:error + is used. Raising an error is equivalent to calling the fn:error function defined in this section with the provided error code. Except where otherwise specified, errors defined in this specification are dynamic errors. Some errors, however, are classified as type errors. Type errors are typically used where the presence @@ -1508,9 +1508,9 @@ This includes all the built-in datatypes defined in . in this document is identified by an xs:QName that is in the http://www.w3.org/2005/xqt-errors namespace, represented in this document by the err prefix. It is this xs:QName that is actually passed as an argument to the - fn:error function. Calling this function raises an error. For a + fn:error function. Calling this function raises an error. For a more detailed treatment of error handing, see .

-

The fn:error function is a general function that may be called as above +

The fn:error function is a general function that may be called as above but may also be called from or applications with, for example, an xs:QName argument.

@@ -1902,9 +1902,9 @@ This differs from , which defines boolean value.

For a description of the different ways of comparing numeric values using the operators = and eq and the functions - fn:deep-equal and fn:atomic-equal, + fn:deep-equal and fn:atomic-equal, see .

-

See also the function fn:compare.

+

See also the function fn:compare.

@@ -1926,7 +1926,7 @@ This differs from , which defines argument is NaN, NaN is returned.

-

With the exception of fn:abs, functions with arguments of +

With the exception of fn:abs, functions with arguments of type xs:float and xs:double that are positive or negative infinity return positive or negative infinity.

@@ -1934,9 +1934,9 @@ This differs from , which defines -

The fn:round function has been extended with a third argument - in version 4.0 of this specification; this means that the fn:ceiling, - fn:floor, and fn:round-half-to-even functions are now +

The fn:round function has been extended with a third argument + in version 4.0 of this specification; this means that the fn:ceiling, + fn:floor, and fn:round-half-to-even functions are now technically redundant. They are retained, however, both for backwards compatibility and for convenience.

@@ -1967,7 +1967,7 @@ This differs from , which defines xs:float, xs:decimal, or xs:double using the constructor functions described in or using cast expressions as described in .

-

In addition the fn:number function is available to convert strings +

In addition the fn:number function is available to convert strings to values of type xs:double. It differs from the xs:double constructor function in that any value outside the lexical space of the xs:double datatype is converted to the xs:double value NaN.

@@ -2002,7 +2002,7 @@ This differs from , which defines

This function can be used to format any numeric quantity, including an integer. For integers, however, - the fn:format-integer function offers additional possibilities. Note also that the picture + the fn:format-integer function offers additional possibilities. Note also that the picture strings used by the two functions are not 100% compatible, though they share some options in common.

@@ -2302,12 +2302,12 @@ be preceded by the Formatting the number

This section describes the second phase of processing of the -fn:format-number function. This phase takes as input a number to be formatted +fn:format-number function. This phase takes as input a number to be formatted (referred to as the input number), and the variables set up by analyzing the decimal format in the static context and the picture string, as described above. The result of this phase is a string, which forms the return value of -the fn:format-number function.

+the fn:format-number function.

The algorithm for this second stage of processing is as follows:

@@ -2376,7 +2376,7 @@ For example, 1.0 is preferred to rounded so that it uses no more than maximum-fractional-part-size digits in its fractional part. The rounded number is defined to be the result of converting the mantissa to an xs:decimal value, as described above, -and then calling the function fn:round-half-to-even with this converted number +and then calling the function fn:round-half-to-even with this converted number as the first argument and the maximum-fractional-part-size as the second argument, again with no limits on the totalDigits or fractionDigits in the result.

@@ -2634,7 +2634,7 @@ string conversion of the number as obtained above, and the appropriate suff One possible candidate is that the resource is a locale description expressed using the Locale Data Markup Language: see .

-

Functions such as fn:compare and fn:max that +

Functions such as fn:compare and fn:max that compare xs:string values use a single collation URI to identify all aspects of the collation rules. This means that any parameters such as the strength of the collation must be specified as part of the collation @@ -2676,7 +2676,7 @@ string conversion of the number as obtained above, and the appropriate suff supplied strings.

The collation is defined as follows. Each of the two strings is - converted to a sequence of integers using the fn:string-to-codepoints + converted to a sequence of integers using the fn:string-to-codepoints function. These two sequences $A and $B are then compared as follows:

@@ -2783,7 +2783,7 @@ string conversion of the number as obtained above, and the appropriate suff or that are applicable only to substring matching.

UCA collation URIs can be conveniently generated using the - fn:collation function.

+ fn:collation function.

The HTML ASCII Case-Insensitive Collation @@ -2819,7 +2819,7 @@ string conversion of the number as obtained above, and the appropriate suff

HTML5 defines the semantics of equality matching using this collation; this specification additionally defines ordering rules. The collation supports collation units and can therefore - be used with functions such as fn:contains; each Unicode codepoint is a single collation unit.

+ be used with functions such as fn:contains; each Unicode codepoint is a single collation unit.

The corresponding HTML5 definition is: A string A is an ASCII case-insensitive match for a string B, if the ASCII lowercase of A is the ASCII lowercase of B.

@@ -2835,7 +2835,7 @@ string conversion of the number as obtained above, and the appropriate suff

If the function specifies an explicit collation, CollationA (e.g., if the optional collation argument is specified in a call of the - fn:compare function), then:

+ fn:compare function), then:

If CollationA is supported by the implementation, then @@ -2902,8 +2902,8 @@ string conversion of the number as obtained above, and the appropriate suff xs:string, they are guaranteed to return values that are instances of xs:string, but the value might or might not be an instance of the particular subtype of xs:string to which they were applied.

-

The strings returned by fn:concat and fn:string-join are not guaranteed to be normalized. - But see note in fn:concat. +

The strings returned by fn:concat and fn:string-join are not guaranteed to be normalized. + But see note in fn:concat.

@@ -2959,8 +2959,8 @@ string conversion of the number as obtained above, and the appropriate suff

When a collation is specified, the rules are more complex.

All collations support the capability of deciding whether two strings are considered equal, and if not, which of the strings should be regarded as - preceding the other. For functions such as fn:compare, this is - all that is required. For other functions, such as fn:contains, + preceding the other. For functions such as fn:compare, this is + all that is required. For other functions, such as fn:contains, the collation needs to support an additional property: it must be able to decompose the string into a sequence of collation units, each unit consisting of one or more characters, such that two strings can be compared by pairwise @@ -3172,7 +3172,7 @@ It is recommended that implementers consult for inf this rule is unchanged from 1.0, but is renumbered [67])

Reluctant quantifiers have no effect on the results of the - boolean fn:matches function, since this + boolean fn:matches function, since this function is only interested in discovering whether a match exists, and not where it exists.

@@ -3184,7 +3184,7 @@ It is recommended that implementers consult for inf recognized. The regular expression syntax defined by allows a regular expression to contain parenthesized sub-expressions, but attaches no special significance to them. Some operations associated with regular expressions (for example, - back-references, and the fn:replace function) allow access to the parts of the + back-references, and the fn:replace function) allow access to the parts of the input string that matched a sub-expression (called captured substrings).

A @@ -3240,7 +3240,7 @@ It is recommended that implementers consult for inf

In the absence of back-references (see below), the presence of the optional ?: has no effect on the set of strings that match the regular expression, but causes the left parenthesis not to be counted - by operations (such as fn:replace and back-references) that number the capturing sub-expressions + by operations (such as fn:replace and back-references) that number the capturing sub-expressions within a regular expression.

@@ -3464,7 +3464,7 @@ It is recommended that implementers consult for inf by preceding it with a backslash.

Furthermore, when this flag is present, the characters $ and \ have no special significance when used in the replacement string - supplied to the fn:replace function.

+ supplied to the fn:replace function.

This flag can be used in conjunction with the i flag. If it is used together with the m, s, x, or c flag, that flag @@ -3556,7 +3556,7 @@ It is recommended that implementers consult for inf convenient access to commonly used information.

The path, if there is one, is tokenized on “/” characters and - each segment is unescaped (as per the fn:decode-from-uri function). Consider the URI + each segment is unescaped (as per the fn:decode-from-uri function). Consider the URI http://example.com/path/to/a%2fb. The path portion has to be returned as /path/to/a%2fb because decoding the %2f would change the nature of the path. @@ -3666,7 +3666,7 @@ It is recommended that implementers consult for inf is precisely equivalent to the duration PT90S (ninety seconds); these are different representations of the same value, and the result of any operation will be the same regardless which representation is used. For example, the function - fn:seconds-from-duration returns 30 in both cases.

+ fn:seconds-from-duration returns 30 in both cases.

@@ -3789,7 +3789,7 @@ For xs:duration and its subtypes, including the two subtypes Constructing durations -

This section decribes the fn:seconds function, which constructs +

This section decribes the fn:seconds function, which constructs an xs:dayTimeDuration value representing a decimal number of seconds.

@@ -4270,8 +4270,8 @@ the year, month and day components are re The date/time formatting functions -

The fn:format-dateTime, fn:format-date, -and fn:format-time +

The fn:format-dateTime, fn:format-date, +and fn:format-time functions format $value as a string using the picture string specified by the $picture argument, the calendar specified by the $calendar argument, @@ -4281,8 +4281,8 @@ The result of the function is the formatted string representation of the supplie xs:dateTime, xs:date, or xs:time value.

The three - functions fn:format-dateTime, fn:format-date, - and fn:format-time are referred to collectively as the + functions fn:format-dateTime, fn:format-date, + and fn:format-time are referred to collectively as the date formatting functions.

If $value is the empty sequence, the function returns the empty sequence.

@@ -4435,7 +4435,7 @@ variation thereof for the chosen language, and the remainder of the value is for

A dynamic error is reported if a component specifier within the picture refers to components that are not available in the given type of $value, - for example if the picture supplied to the fn:format-time refers + for example if the picture supplied to the fn:format-time refers to the year, month, or day component.

It is not an error to include a timezone component when the supplied value has no timezone. In these circumstances the timezone component will be ignored.

@@ -4445,7 +4445,7 @@ either:

any format token permitted as a primary format token in the second argument -of the fn:format-integer function, indicating +of the fn:format-integer function, indicating that the value of the component is to be output numerically using the specified number format (for example, 1, 01, i, I, w, W, or Ww) or

@@ -4482,7 +4482,7 @@ a second presentation modifier as follows:

either a or t indicates alphabetic or traditional numbering respectively, the default being . - This has the same meaning as in the second argument of fn:format-integer.
either c or o
]]> - Converting a CSV into an HTML-style table using fn:csv-to-xml + Converting a CSV into an HTML-style table using fn:csv-to-xml -

The fn:csv-to-xml function makes these kinds of +

The fn:csv-to-xml function makes these kinds of conversion-to-XML-table tasks simpler by providing a simple XML represenation of the data. Here, in XQuery:

Invisible XML defines a BNF-like language for specifying grammars, together with a mapping from sentences in that grammar to an XML representation. By defining an Invisible XML grammar, a great variety of non-XML data formats can be manipulated - as if they were XML. The function fn:invisible-xml takes a grammar + as if they were XML. The function fn:invisible-xml takes a grammar as input, and returns a function which can be used for parsing data instances and converting them to XML node trees.

@@ -7401,7 +7401,7 @@ return
Some host languages may exclude higher-order functions from the set of functions that they support, or may include such functions in an optional conformance feature.

-

Some functions such as fn:parse-json allow the option of supplying a callback function +

Some functions such as fn:parse-json allow the option of supplying a callback function for example to define exception behavior. Where this is not essential to the use of the function, the function has not been classified as higher-order for this purpose; in applications where function items cannot be created, these particular options will not be available.

@@ -7541,15 +7541,15 @@ return
of the same type (for example, they can include a mixture of integers and strings).

Maps are immutable, and have no identity separate from their content. - For example, the map:remove function returns a map that differs + For example, the map:remove function returns a map that differs from the supplied map by the omission (typically) of one entry, but the supplied map is not changed by the operation. - Two calls on map:remove with the same arguments return maps that are + Two calls on map:remove with the same arguments return maps that are indistinguishable from each other; there is no way of asking whether these are “the same map”.

A map can also be viewed as a function from keys to associated values. To achieve this, a map is also a function item. The function corresponding to the map has the signature function($key as xs:anyAtomicValue) as item()*. Calling the function has the same effect as calling - the get function: the expression + the map:get function: the expression $map($key) returns the same result as get($map, $key). For example, if $books-by-isbn is a map whose keys are ISBNs and whose assocated values are book elements, then the expression $books-by-isbn("0470192747") returns the book element with the given ISBN. @@ -7652,8 +7652,8 @@ return

an empty map, in preference to a call on dm:empty-map().

The formal equivalents are not intended to provide a realistic way of implementating the - functions (in particular, any real implementation might be expected to implement map:get - and map:put much more efficiently). They do, however, provide a framework that allows + functions (in particular, any real implementation might be expected to implement map:get + and map:put much more efficiently). They do, however, provide a framework that allows the correctness of a practical implementation to be verified.

TODO: as yet there is no formal equivalent for map:find(). @@ -7672,7 +7672,7 @@ return
-

There is no operation to atomize a map or convert it to a string. The function fn:serialize can in some cases +

There is no operation to atomize a map or convert it to a string. The function fn:serialize can in some cases be used to produce a JSON representation of a map.

@@ -7749,12 +7749,12 @@ return
Converting Elements to Maps - A new function fn:elements-to-maps is provided for converting XDM trees - to maps suitable for serialization as JSON. Unlike the fn:xml-to-json function + A new function fn:elements-to-maps is provided for converting XDM trees + to maps suitable for serialization as JSON. Unlike the fn:xml-to-json function retained from 3.1, this can handle arbitrary XML as input. -

The fn:elements-to-maps function converts XML element nodes to maps, in a form +

The fn:elements-to-maps function converts XML element nodes to maps, in a form suitable for serialization as JSON. This section describes the mappings used by this function.

This mapping is designed with three objectives:

@@ -7860,7 +7860,7 @@ return

The layout to be used for a specific element name can be explicitly selected in the options - to the fn:elements-to-maps function.

+ to the fn:elements-to-maps function.

In the absence of an explicit selection, if the data has been schema-validated, the layout is inferred from the content model for the element type as defined in the schema.

@@ -7888,7 +7888,7 @@ return

Layout name: the name to be used to select this layout in - the $options parameter of the fn:elements-to-maps function.

+ the $options parameter of the fn:elements-to-maps function.

Usage: the situations for which this layout is designed.

Example input: an example of a typical element for which this layout is appropriate, shown as serialized XML.

@@ -7897,7 +7897,7 @@ return
for the top-level elements supplied in the $elements argument; when used to convert a descendant element, the corresponding key-value pair may appear as part of a larger map, depending on the layout chosen for its parent element..

-

The fn:elements-to-maps function produces maps as its result, but it is convenient +

The fn:elements-to-maps function produces maps as its result, but it is convenient to illustrate the form of the map by showing the effect of serializing the map as JSON.

Mapping rules: The rules for mapping the XML element to an XDM map @@ -8333,7 +8333,7 @@ return

list layout.

If there are no children and the element is untyped (which can occur when - this layout is chosen explicitly via the options to fn:elements-to-maps) + this layout is chosen explicitly via the options to fn:elements-to-maps) then the content property is omitted (since the child element name is unknown). But if the element is typed, then the content property is included and set to an empty array.

@@ -8663,7 +8663,7 @@ return
--> -
Mapping rules

The element node is serialized as if by the fn:serialize +

The element node is serialized as if by the fn:serialize function, and the resulting content is output as an atomic item of type xs:string.

The serialization parameter method is set to @@ -8698,10 +8698,10 @@ return

If an explicit layout is given for the element name of $E in the - options argument of the fn:elements-to-maps function call, then that layout is used.

+ options argument of the fn:elements-to-maps function call, then that layout is used.

Let $elements be the value of the first argument to the - fn:elements-to-maps function call.

+ fn:elements-to-maps function call.

A layout is said to be disabled if its name is listed in the disable-layouts option.

@@ -8926,7 +8926,7 @@ return

The option local discards all namespace information: all elements and attributes are output using the local name alone.

The option lexical outputs element and attribute names in the form - obtained by calling the function fn:name. If the name has a prefix, + obtained by calling the function fn:name. If the name has a prefix, the prefix is retained in the output. However, the output contains no information that enables the prefix to be associated with a namespace URI, so this format is suitable only when prefixes in the input documents are used predictably.

@@ -8988,7 +8988,7 @@ return
-

Atomic items in the result of the fn:elements-to-maps function +

Atomic items in the result of the fn:elements-to-maps function may be of any atomic type. The type information is lost if the result is subsequently serialized as JSON.

@@ -8997,7 +8997,7 @@ return
Lost XDM Information

This section is non-normative. Its purpose is to explain what information available - in the XDM nodes supplied as input to the fn:elements-to-maps function + in the XDM nodes supplied as input to the fn:elements-to-maps function is missing from the output.

@@ -9219,12 +9219,12 @@ return

This section is non-normative.

Because a map is a function item, functions that apply to functions also apply - to maps. A map is an anonymous function, so fn:function-name returns the empty - sequence; fn:function-arity always returns 1.

+ to maps. A map is an anonymous function, so fn:function-name returns the empty + sequence; fn:function-arity always returns 1.

-

Maps may be compared using the fn:deep-equal function.

+

Maps may be compared using the fn:deep-equal function.

-

There is no function or operator to atomize a map or convert it to a string (other than fn:serialize, +

There is no function or operator to atomize a map or convert it to a string (other than fn:serialize, which can be used to serialize some maps as JSON texts).

XPath 4.0 defines a number of syntactic constructs that operate on maps. These all have equivalents @@ -9284,7 +9284,7 @@ return

an empty array, in preference to a call on dm:empty-array().

The formal equivalents are not intended to provide a realistic way of implementating the - functions (in particular, any real implementation might be expected to implement array:get + functions (in particular, any real implementation might be expected to implement array:get much more efficiently). They do, however, provide a framework that allows the correctness of a practical implementation to be verified.

@@ -9300,9 +9300,9 @@ return
is assumed to be bound to the namespace URI http://www.w3.org/2005/xpath-functions/array.

As with all other values, arrays are treated as immutable. - For example, the array:reverse function returns an array that differs from the supplied + For example, the array:reverse function returns an array that differs from the supplied array in the order of its members, but the supplied array is not changed by the operation. Two calls - on array:reverse with the same argument will return arrays that are indistinguishable from + on array:reverse with the same argument will return arrays that are indistinguishable from each other; there is no way of asking whether these are “the same array”. Like sequences, arrays have no identity.

@@ -9310,9 +9310,9 @@ return

All functionality on arrays is defined in terms of two primitives:

-

The function array:members decomposes an array to a sequence of +

The function array:members decomposes an array to a sequence of value records.

-

The function array:of-members composes an array from a sequence of +

The function array:of-members composes an array from a sequence of value records.

@@ -9420,7 +9420,7 @@ return
Other Operations on Arrays

This section is non-normative.

-

Arrays may be compared using the fn:deep-equal function.

+

Arrays may be compared using the fn:deep-equal function.

The XPath language provides explicit syntax for certain operations on arrays. These constructs can all be specified in terms of function primitives:

@@ -9933,8 +9933,8 @@ There is no constructor function for xs:NOTATION. Constructors are

When a constructor function for a namespace-sensitive type is used as a literal function item or in a partial function application (for example, xs:QName#1 or xs:QName(?)) the namespace bindings that are relevant are those from the static context of the literal function item or partial function application. - When a constructor function for a namespace-sensitive type is obtained by means of the fn:function-lookup - function, the relevant namespace bindings are those from the static context of the call on fn:function-lookup.

+ When a constructor function for a namespace-sensitive type is obtained by means of the fn:function-lookup + function, the relevant namespace bindings are those from the static context of the call on fn:function-lookup.

When the supplied argument to the xs:QName constructor function is a node, the node is atomized in the usual way, and if the result is xs:untypedAtomic it is then @@ -10028,7 +10028,7 @@ There is no constructor function for xs:NOTATION. Constructors are types of xs:numeric, and its lexical space subsumes the lexical space of the other numeric types. Thus, unlike XPath numeric literals, the result does not depend on the lexical form of the supplied value. The reason for this design choice is to retain compatibility with the function conversion rules: - functions such as fn:abs and fn:round are declared to expect an instance + functions such as fn:abs and fn:round are declared to expect an instance of xs:numeric as their first or only argument, and compatibility with the function conversion rules defined in earlier versions of these specifications demands that when an untyped atomic item (or untyped node) is supplied as the argument, it is converted to an xs:double value @@ -11520,7 +11520,7 @@ There is no constructor function for xs:NOTATION. Constructors are Casting to date and time types

In several situations, casting to date and time types requires the extraction of a component from SV or from the result of - fn:current-dateTime and converting it to an + fn:current-dateTime and converting it to an xs:string. These conversions must follow certain rules. For example, converting an xs:integer year value requires converting to an xs:string with four or more characters, preceded @@ -12458,7 +12458,7 @@ If SV is an instance of xs:string or xs:untypedAto

If the list type has a pattern facet, the pattern must match the supplied value after collapsing whitespace (an operation equivalent to the - use of the fn:normalize-space function).

+ use of the fn:normalize-space function).

For example, the expression cast "A B C D" as xs:NMTOKENS produces a sequence of four xs:NMTOKEN values, @@ -12788,10 +12788,10 @@ ISBN 0 521 77752 6.

The error text provided with these errors is non-normative.

-

Error code used by fn:error when no other error code is provided.

+

Error code used by fn:error when no other error code is provided.

-

Raised when fn:apply is called and the arity of the supplied function is not +

Raised when fn:apply is called and the arity of the supplied function is not the same as the number of members in the supplied array.

@@ -12805,7 +12805,7 @@ ISBN 0 521 77752 6.

This error is raised when an integer used to select a member of an array is outside the range of values for that array.

-

This error is raised when the $length argument to array:subarray is negative.

+

This error is raised when the $length argument to array:subarray is negative.

@@ -12813,7 +12813,7 @@ ISBN 0 521 77752 6. implementation-defined limits for the datatype.

-

Raised by fn:resolve-QName and fn:QName when a supplied value does not have the lexical +

Raised by fn:resolve-QName and fn:QName when a supplied value does not have the lexical form of a QName or URI respectively; and when casting to decimal, if the supplied value is NaN or Infinity.

than the implementation can represent (the implementation also has the option of rounding).

-

Raised by fn:codepoints-to-string if the input contains an integer that is not the codepoint +

Raised by fn:codepoints-to-string if the input contains an integer that is not the codepoint of a permitted character.

Raised by any function that uses a collation if the requested collation is not recognized.

-

Raised by fn:normalize-unicode if the requested normalization form is not +

Raised by fn:normalize-unicode if the requested normalization form is not supported by the implementation.

-

Raised by functions such as fn:contains if the requested collation does +

Raised by functions such as fn:contains if the requested collation does not operate on a character-by-character basis.

-

Raised by fn:char if the supplied character name is not recognized, or +

Raised by fn:char if the supplied character name is not recognized, or if it represents a codepoint that is not a permitted character.

@@ -12876,7 +12876,7 @@ ISBN 0 521 77752 6. -

Raised by fn:id, fn:idref, and fn:element-with-id +

Raised by fn:id, fn:idref, and fn:element-with-id if the node that identifies the tree to be searched is a node in a tree whose root is not a document node.

-

Raised by fn:doc, fn:collection, and fn:uri-collection +

Raised by fn:doc, fn:collection, and fn:uri-collection to indicate that either the supplied URI cannot be dereferenced to obtain a resource, or the resource that is returned is not parseable as XML.

-

Raised by fn:doc, fn:collection, and fn:uri-collection +

Raised by fn:doc, fn:collection, and fn:uri-collection to indicate that it is not possible to return a result that is guaranteed deterministic.

-

Raised by fn:collection and fn:uri-collection +

Raised by fn:collection and fn:uri-collection if the argument is not a valid xs:anyURI.

-

Raised (optionally) by fn:doc if the argument +

Raised (optionally) by fn:doc if the argument is not a valid xs:anyURI.

-

Raised by fn:parse-xml if the supplied string is not a well-formed and namespace-well-formed XML document; +

Raised by fn:parse-xml if the supplied string is not a well-formed and namespace-well-formed XML document; or if DTD validation is requested and the document is not valid against its DTD.

-

Raised by fn:parse-xml if DTD validation is requested and the supplied string +

Raised by fn:parse-xml if DTD validation is requested and the supplied string has no DTD or is not valid against the DTD.

-

Raised when the xsd-validation option to fn:parse-xml is supplied, +

Raised when the xsd-validation option to fn:parse-xml is supplied, and the value is not one of the permitted values; for example if the option type Q{U}NNN is used, and Q{U}NNN does not identify a type in the static context.

-

Raised when the xsd-validation option to fn:parse-xml is set to +

Raised when the xsd-validation option to fn:parse-xml is set to a value other than skip, if the processor is not schema-aware.

-

Raised when fn:serialize is called and the processor does not support serialization, +

Raised when fn:serialize is called and the processor does not support serialization, in cases where the host language makes serialization an optional feature.

-

Raised by fn:parse-html if the supplied string is not a well-formed HTML document.

+

Raised by fn:parse-html if the supplied string is not a well-formed HTML document.

-

Raised by fn:parse-html if a key passed to $options, or its value, +

Raised by fn:parse-html if a key passed to $options, or its value, is not supported by the implementation.

-

Raised when the dtd-validation option to fn:parse-xml is set, +

Raised when the dtd-validation option to fn:parse-xml is set, if no validating XML parser is available. Note: it is recommended that all processors should support the dtd-validation option, but there may be environments (such as web browsers) where this is not practically feasible.

-

Raised by fn:parse-xml if XSD validation is requested and the XML document +

Raised by fn:parse-xml if XSD validation is requested and the XML document represented by the supplied string is not valid against the relevant XSD schema.

-

This error is raised if the decimal format name supplied to fn:format-number is not a valid QName, +

This error is raised if the decimal format name supplied to fn:format-number is not a valid QName, or if the prefix in the QName is undeclared, or if there is no decimal format in the static context with a matching name.

@@ -12972,15 +12972,15 @@ ISBN 0 521 77752 6.

This error is raised if a decimal format value supplied to - fn:format-number is not valid for the associated property, + fn:format-number is not valid for the associated property, or if the properties of the decimal format resulting from a supplied map do not have distinct values.

-

This error is raised if the picture string supplied to fn:format-number or - fn:format-integer has invalid syntax.

+

This error is raised if the picture string supplied to fn:format-number or + fn:format-integer has invalid syntax.

@@ -13000,50 +13000,50 @@ ISBN 0 521 77752 6. -

This error is raised if the picture string or calendar supplied to fn:format-date, fn:format-time, - or fn:format-dateTime has invalid syntax.

+

This error is raised if the picture string or calendar supplied to fn:format-date, fn:format-time, + or fn:format-dateTime has invalid syntax.

-

This error is raised if the picture string supplied to fn:format-date - selects a component that is not present in a date, or if the picture string supplied to fn:format-time +

This error is raised if the picture string supplied to fn:format-date + selects a component that is not present in a date, or if the picture string supplied to fn:format-time selects a component that is not present in a time.

-

Raised by fn:hash if the effective value of the supplied +

Raised by fn:hash if the effective value of the supplied algorithm is not one of the values supported by the implementation.

-

Raised by functions such as fn:json-doc, fn:parse-json - or fn:json-to-xml +

Raised by functions such as fn:json-doc, fn:parse-json + or fn:json-to-xml if the string supplied as input does not conform to the JSON grammar (optionally with implementation-defined extensions).

-

Raised by functions such as map:merge, fn:json-doc, - fn:parse-json or fn:json-to-xml +

Raised by functions such as map:merge, fn:json-doc, + fn:parse-json or fn:json-to-xml if the input contains duplicate keys, when the chosen policy is to reject duplicates.

-

Raised by fn:json-to-xml if validation +

Raised by fn:json-to-xml if validation is requested when the processor does not support schema validation or typed nodes.

-

Raised by functions such as map:merge, fn:parse-json, - and fn:xml-to-json if the $options map contains an invalid entry.

+

Raised by functions such as map:merge, fn:parse-json, + and fn:xml-to-json if the $options map contains an invalid entry.

-

Raised by fn:xml-to-json if the XML input does not +

Raised by fn:xml-to-json if the XML input does not conform to the rules for the XML representation of JSON.

-

Raised by fn:xml-to-json if the XML input uses the attribute +

Raised by fn:xml-to-json if the XML input uses the attribute escaped="true" or escaped-key="true", and the corresponding string or key contains an invalid JSON escape sequence.

@@ -13051,37 +13051,37 @@ ISBN 0 521 77752 6. -

Raised by fn:resolve-QName and analogous functions if a supplied QName has a +

Raised by fn:resolve-QName and analogous functions if a supplied QName has a prefix that has no binding to a namespace.

-

Raised by fn:resolve-uri if no base URI is available for resolving a relative URI.

+

Raised by fn:resolve-uri if no base URI is available for resolving a relative URI.

-

Raised by fn:load-xquery-module if the supplied module URI is zero-length.

+

Raised by fn:load-xquery-module if the supplied module URI is zero-length.

-

Raised by fn:load-xquery-module if no module can be found with the supplied module URI.

+

Raised by fn:load-xquery-module if no module can be found with the supplied module URI.

-

Raised by fn:load-xquery-module if a static error +

Raised by fn:load-xquery-module if a static error (including a statically detected type error) is encountered when processing the library module.

-

Raised by fn:load-xquery-module if a value is supplied for the initial context +

Raised by fn:load-xquery-module if a value is supplied for the initial context item or for an external variable, and the value does not conform to the required type declared in the dynamically loaded module.

-

Raised by fn:load-xquery-module if no XQuery processor is available supporting the requested +

Raised by fn:load-xquery-module if no XQuery processor is available supporting the requested XQuery version (or if none is available at all).

@@ -13093,53 +13093,53 @@ ISBN 0 521 77752 6. -

Raised when either argument to fn:resolve-uri is not a valid URI/IRI.

+

Raised when either argument to fn:resolve-uri is not a valid URI/IRI.

-

Raised by fn:zero-or-one if the supplied value contains more than one item.

+

Raised by fn:zero-or-one if the supplied value contains more than one item.

-

Raised by fn:one-or-more if the supplied value is an empty sequence.

+

Raised by fn:one-or-more if the supplied value is an empty sequence.

-

Raised by fn:exactly-one if the supplied value is not a singleton sequence.

+

Raised by fn:exactly-one if the supplied value is not a singleton sequence.

-

Raised by functions such as fn:max, fn:min, fn:avg, fn:sum +

Raised by functions such as fn:max, fn:min, fn:avg, fn:sum if the supplied sequence contains values inappropriate to this function.

-

Raised by fn:dateTime if the two arguments both have timezones and the timezones are different.

+

Raised by fn:dateTime if the two arguments both have timezones and the timezones are different.

-

A catch-all error for fn:resolve-uri, recognizing that the implementation can choose between a variety +

A catch-all error for fn:resolve-uri, recognizing that the implementation can choose between a variety of algorithms and that some of these may fail for a variety of reasons.

-

Raised when the input to fn:parse-ietf-date does not match the prescribed +

Raised when the input to fn:parse-ietf-date does not match the prescribed grammar, or when it represents an invalid date/time such as 31 February.

-

Raised when the radix supplied to fn:parse-integer is not in the range 2 to 36.

+

Raised when the radix supplied to fn:parse-integer is not in the range 2 to 36.

-

Raised when the digits in the string supplied to fn:parse-integer are not in the range appropriate +

Raised when the digits in the string supplied to fn:parse-integer are not in the range appropriate to the chosen radix.

-

Raised by regular expression functions such as fn:matches and fn:replace if the +

Raised by regular expression functions such as fn:matches and fn:replace if the regular expression flags contain a character other than i, m, q, s, or x.

-

Raised by regular expression functions such as fn:matches and fn:replace if the +

Raised by regular expression functions such as fn:matches and fn:replace if the regular expression is syntactically invalid.

-

For functions such as fn:replace and fn:tokenize, raises an error if +

For functions such as fn:replace and fn:tokenize, raises an error if the supplied regular expression is capable of matching a zero length string.

-

Raised by fn:replace to report errors in the replacement string.

+

Raised by fn:replace to report errors in the replacement string.

-

Raised by fn:replace if both the $replacement +

Raised by fn:replace if both the $replacement and $action arguments are supplied.

-

Raised by fn:data, or by implicit atomization, if applied to a node with no typed value, +

Raised by fn:data, or by implicit atomization, if applied to a node with no typed value, the main example being an element validated against a complex type that defines it to have element-only content.

-

Raised by fn:data, or by implicit atomization, if the sequence to be atomized contains +

Raised by fn:data, or by implicit atomization, if the sequence to be atomized contains a function item other than an array.

-

Raised by fn:string, or by implicit string conversion, if the input sequence contains +

Raised by fn:string, or by implicit string conversion, if the input sequence contains a function item.

-

Raised by fn:unparsed-text or fn:unparsed-text-lines +

Raised by fn:unparsed-text or fn:unparsed-text-lines if the $source argument contains a fragment identifier, or if it cannot be resolved to an absolute URI (for example, because the base-URI property in the static context is absent), or if it cannot be used to @@ -13201,7 +13201,7 @@ ISBN 0 521 77752 6. -

Raised by fn:unparsed-text or fn:unparsed-text-lines +

Raised by fn:unparsed-text or fn:unparsed-text-lines if the $encoding argument is not a valid encoding name, if the processor does not support the specified encoding, if the string representation of the retrieved resource contains octets that cannot be decoded @@ -13211,7 +13211,7 @@ ISBN 0 521 77752 6. -

Raised by fn:unparsed-text or fn:unparsed-text-lines +

Raised by fn:unparsed-text or fn:unparsed-text-lines if the $encoding argument is absent and the processor cannot infer the encoding using external information and the encoding is not UTF-8.

@@ -13228,26 +13228,26 @@ ISBN 0 521 77752 6.
-

A dynamic error is raised if the parameters supplied to fn:transform are invalid, for example +

A dynamic error is raised if the parameters supplied to fn:transform are invalid, for example if two mutually exclusive parameters are supplied. If a suitable XSLT error code is available (for example in the case where the requested initial-template does not exist in the stylesheet), that error code should be used in preference.

-

A dynamic error is raised if an XSLT transformation invoked using fn:transform fails with a +

A dynamic error is raised if an XSLT transformation invoked using fn:transform fails with a static or dynamic error. The XSLT error code is used if available; this error code provides a fallback when no XSLT error code is returned, for example because the processor is an XSLT 1.0 processor.

-

A dynamic error is raised if the fn:transform function is invoked when XSLT transformation (or a specific +

A dynamic error is raised if the fn:transform function is invoked when XSLT transformation (or a specific transformation option) has been disabled for security or other reasons.

-

A dynamic error is raised if the result of the fn:transform function contains characters available +

A dynamic error is raised if the result of the fn:transform function contains characters available only in XML 1.1 and the calling processor cannot handle such characters.

@@ -13264,8 +13264,8 @@ ISBN 0 521 77752 6. the fn namespace. -

Two functions in this specification, fn:analyze-string and - fn:json-to-xml, produce results in the form of an XDM node tree that must conform +

Two functions in this specification, fn:analyze-string and + fn:json-to-xml, produce results in the form of an XDM node tree that must conform to a specified schema, defined in this appendix. In both cases the elements in the result are in the namespace http://www.w3.org/2005/xpath-functions, which is therefore the target namespace @@ -13289,21 +13289,21 @@ ISBN 0 521 77752 6. - Schema for the result of fn:analyze-string -

This schema describes the output of the function fn:analyze-string.

+ Schema for the result of fn:analyze-string +

This schema describes the output of the function fn:analyze-string.

The schema is reproduced below, and can also be found in analyze-string.xsd:

- Schema for the result of fn:json-to-xml -

This schema describes the output of the function fn:json-to-xml, and the input to the - function fn:xml-to-json.

+ Schema for the result of fn:json-to-xml +

This schema describes the output of the function fn:json-to-xml, and the input to the + function fn:xml-to-json.

The schema is reproduced below, and can also be found in schema-for-json.xsd:

- Schema for the result of fn:csv-to-xml -

This schema describes the output of the function fn:csv-to-xml.

+ Schema for the result of fn:csv-to-xml +

This schema describes the output of the function fn:csv-to-xml.

The schema is reproduced below, and can also be found in schema-for-csv.xsd:

@@ -13518,8 +13518,8 @@ ISBN 0 521 77752 6.

The keyword for the argument has changed from arg to value.

The argument is now optional, and defaults to the context value (which is atomized if necessary). This change aligns constructor functions such as xs:string, xs:boolean, - and xs:numeric with fn:string, fn:boolean, - and fn:number.

+ and xs:numeric with fn:string, fn:boolean, + and fn:number.

@@ -13580,8 +13580,8 @@ ISBN 0 521 77752 6. -

In fn:deep-equal, and in other functions such as fn:distinct-values - that refer to fn:deep-equal, the rules for comparing values of different numeric types +

In fn:deep-equal, and in other functions such as fn:distinct-values + that refer to fn:deep-equal, the rules for comparing values of different numeric types (for example, xs:double and xs:decimal) have changed. In previous versions of the specification, xs:decimal values were converted to xs:double, leading to a possible loss of precision. This could make @@ -13604,30 +13604,30 @@ ISBN 0 521 77752 6.

In previous versions, unrecognized options supplied to the $options - parameter of functions such as fn:parse-json were silently ignored. In + parameter of functions such as fn:parse-json were silently ignored. In 4.0, they are rejected as a type error, unless they are QNames with a non-absent namespace, or are extensions recognized by the implementation.

-

In version 4.0, omitting the $value of fn:error has the same +

In version 4.0, omitting the $value of fn:error has the same effect as setting it to an empty sequence. In 3.1, the effects could be different (the effect of omitting the argument was implementation-defined).

-

In version 3.1, the fn:deep-equal function did not merge adjacent text nodes after stripping +

In version 3.1, the fn:deep-equal function did not merge adjacent text nodes after stripping comments and processing instructions, so the elements abcdef]]> and abcdef]]> were considered non-equal. In version 4.0, the text nodes are now merged prior to comparison, so these two elements compare equal.

-

The format of numeric values in the output of fn:xml-to-json may be different. +

The format of numeric values in the output of fn:xml-to-json may be different. In version 3.1, the supplied value was parsed as an xs:double and then serialized using the casting rules, resulting in an input value of 10000000 being output as 1e7. In version 4.0, the value is output as is, except for any changes (such as stripping of leading zeroes or a leading plus sign) that might be needed to ensure the result is valid JSON.

-

In version 4.0, the function signature of fn:namespace-uri-for-prefix constrains the +

In version 4.0, the function signature of fn:namespace-uri-for-prefix constrains the first argument to be either an xs:NCName or a zero-length string (the new coercion rules mean that any string in the form of an xs:NCName is acceptable). If a string is supplied that does not meet these requirements, a type error will be raised. In version 3.1, this was not an error: @@ -13647,13 +13647,13 @@ ISBN 0 521 77752 6. have been changed to use an argument type of xs:string?.

-

The way that fn:min and fn:max compare numeric values of different types +

The way that fn:min and fn:max compare numeric values of different types has changed. The most noticeable effect is that when these functions are applied to a sequence of xs:integer or xs:decimal values, the result is an xs:integer or xs:decimal, rather than the result of converting this to an xs:double.

-

The type of the third argument of fn:format-number has +

The type of the third argument of fn:format-number has changed from xs:string to (xs:string | xs:QName). Because the expected type of this parameter is no longer xs:string, the special coercion rules for xs:string parameters no longer apply. diff --git a/specifications/xquery-40/src/expressions.xml b/specifications/xquery-40/src/expressions.xml index 576030a17..28a0e214d 100644 --- a/specifications/xquery-40/src/expressions.xml +++ b/specifications/xquery-40/src/expressions.xml @@ -891,13 +891,13 @@ constructor, as described in

The Static Base URI is available during dynamic evaluation by use of the - fn:static-base-uri function, and is used implicitly during dynamic - evaluation by functions such as fn:doc. Relative URI references are + fn:static-base-uri function, and is used implicitly during dynamic + evaluation by functions such as fn:doc. Relative URI references are resolved as described in .

At execution time, - relative URIs supplied to functions such as fn:doc + relative URIs supplied to functions such as fn:doc are resolved against the , which may or may not be the same as the Static Base URI.

@@ -914,7 +914,7 @@ constructor, as described in import module declarations as when retrieving source - documents using the fn:doc function. If an implementation uses different + documents using the fn:doc function. If an implementation uses different values for the Static Base URI during static analysis and during dynamic evaluation, then it is implementation-defined which of the two values is used for particular operations that rely on the Static Base URI; for @@ -929,7 +929,7 @@ constructor, as described in Statically known decimal formats. This is a mapping from QNames to decimal formats, with one default format that has no visible name, referred to as the unnamed decimal format. Each - format is available for use when formatting numbers using the fn:format-number function. + format is available for use when formatting numbers using the fn:format-number function.

Decimal formats are described in .

@@ -979,8 +979,8 @@ constructor, as described in For an overview of variadic functions, see .

-

Examples of system functions defined to be variadic are fn:concat - and fn:codepoints-to-string. User-written functions in XQuery may +

Examples of system functions defined to be variadic are fn:concat + and fn:codepoints-to-string. User-written functions in XQuery may be declared as variadic by using the %variadic annotation; the equivalent in XSLT is to use the attribute xsl:function/@variadic = "yes".

@@ -1055,11 +1055,11 @@ constructor, as described in fn:name#0 is context-dependent - while fn:name#1 is context-independent.

+ for others: for example fn:name#0 is context-dependent + while fn:name#1 is context-independent.

-

Some system functions, such as fn:position, fn:last, - and fn:static-base-uri, exist for the sole purpose of providing information +

Some system functions, such as fn:position, fn:last, + and fn:static-base-uri, exist for the sole purpose of providing information about the static or dynamic context of their caller.

Application functions are context dependent only to the extent that they define optional parameters with default @@ -1112,7 +1112,7 @@ constructor, as described in

Each decimal format defines a set of properties, which control the interpretation of characters - in the picture string supplied to the fn:format-number + in the picture string supplied to the fn:format-number function, and also specify characters to be used in the result of formatting the number.

@@ -1204,7 +1204,7 @@ constructor, as described in

The following properties specify - characters to be used in the picture string supplied to the fn:format-number + characters to be used in the picture string supplied to the fn:format-number function, but not in the formatted number. In each case the value must be a single character.

@@ -1272,7 +1272,7 @@ constructor, as described in The rules regarding the document-uri property of nodes returned by the - fn:collection function have been relaxed. + fn:collection function have been relaxed.

@@ -1496,7 +1496,7 @@ the number of items in the sequence obtained by evaluating

-

The function definitions in the dynamic context are used primarily by the fn:function-lookup +

The function definitions in the dynamic context are used primarily by the fn:function-lookup function.

If two function definitions in the have the same name, then their arity ranges must not overlap.

@@ -1504,7 +1504,7 @@ the number of items in the sequence obtained by evaluating fn:function-lookup function allows dynamic discovery of resources that were not + The fn:function-lookup function allows dynamic discovery of resources that were not available statically.

The detailed rules for evaluating static function calls and function references are defined @@ -9619,8 +9619,8 @@ At evaluation time, the value of a variable reference is the value to which the

A named function reference (see ) constructs a function item by reference to function definitions - in the static context. For example, fn:node-name#1 - returns a function item whose effect is to call the static fn:node-name function + in the static context. For example, fn:node-name#1 + returns a function item whose effect is to call the static fn:node-name function with one argument.

An inline function (see ) constructs a function item whose body is defined locally. For example, the @@ -9633,12 +9633,12 @@ At evaluation time, the value of a variable reference is the value to which the ".txt".

Maps and arrays are also function items. See and .

-

The fn:function-lookup function can be called to discover functions +

The fn:function-lookup function can be called to discover functions that are present in the .

-

The fn:load-xquery-module function can be called to load functions +

The fn:load-xquery-module function can be called to load functions dynamically from an external XQuery library module.

-

Some system functions such as fn:random-number-generator - and fn:op return a as their result.

+

Some system functions such as fn:random-number-generator + and fn:op return a as their result.

These constructs are described in detail in the following sections, or in @@ -10018,7 +10018,7 @@ return $vat(doc('wares.xml')/shop/article)

A partial function application need not have any explicitly supplied parameters. For example, the partial function application fn:string(?) is allowed; it has exactly the same effect as the named function reference - fn:string#1.

+ fn:string#1.

Explicitly supplied parameters and defaulted parameters are evaluated and @@ -10044,7 +10044,7 @@ return $vat(doc('wares.xml')/shop/article)

In the particular case where all the supplied arguments are placeholders, the error behavior should be the same as - for an equivalent : for example, fn:id#1 + for an equivalent : for example, fn:id#1 fails if there is no context node, and fn:id(?) should fail likewise.

@@ -10087,7 +10087,7 @@ return $vat(doc('wares.xml')/shop/article)

A partial function application can be used to change the order of parameters, for example fn:contains(substring := ?, value := ?) - returns a function item that is equivalent to fn:contains#2, + returns a function item that is equivalent to fn:contains#2, but with the order of arguments reversed.

@@ -10128,7 +10128,7 @@ return $vat(doc('wares.xml')/shop/article)

- $sum-of-squares is an anonymous function. It has one parameter, named $seq, which is taken from the corresponding parameter in fn:fold-right (the other two parameters are fixed). The implementation is the implementation of fn:fold-right, which is a context-independent system function. The nonlocal bindings contain the fixed bindings for the second and third parameters of fn:fold-right.

+ $sum-of-squares is an anonymous function. It has one parameter, named $seq, which is taken from the corresponding parameter in fn:fold-right (the other two parameters are fixed). The implementation is the implementation of fn:fold-right, which is a context-independent system function. The nonlocal bindings contain the fixed bindings for the second and third parameters of fn:fold-right.

@@ -10336,7 +10336,7 @@ return $a("A")]]>

Consider:

/fn:name#0 return /$f()]]>

The function fn:name(), with no arguments, returns the name of the context node. The function - item delivered by evaluating the expression fn:name#0 returns the name of the element that was the + item delivered by evaluating the expression fn:name#0 returns the name of the element that was the context node at the point where the function reference was evaluated (that is, the <foo> element). This expression therefore returns "foo", not "bar".

@@ -10344,9 +10344,9 @@ return $a("A")]]>

An error is raised if the identified function depends on components of the static or dynamic context that are not present, or that have unsuitable values. For example is raised for the expression fn:name#0 + class="DY" code="0002" type="type"/> is raised for the expression fn:name#0 if the context item is absent, and is raised for the call fn:id#1 if the context item is not a node + /> is raised for the call fn:id#1 if the context item is not a node in a tree that is rooted at a document node. The error that is raised is the same as the error that would be raised by the corresponding function if called with the same static and dynamic context.

@@ -10383,12 +10383,12 @@ return $a("A")]]>

This rule applies even across different execution scopes: for example if a parameter to a call to fn:transform is set to the - result of the expression fn:abs#1, then the function item passed as the parameter - value will be identical to that obtained by evaluating the expression fn:abs#1 + result of the expression fn:abs#1, then the function item passed as the parameter + value will be identical to that obtained by evaluating the expression fn:abs#1 within the target XSLT stylesheet.

This rule also applies when the target function definition is nondeterministic. - For example all evaluations of the named function reference map:keys#2 + For example all evaluations of the named function reference map:keys#2 return identical function items, even though two evaluations of map:keys with the same arguments may produce different results.

@@ -10414,7 +10414,7 @@ return $a("A")]]> the required type of each excess parameter in the result is the same as the required type of the last declared parameter of FD.

The required type of each - parameter of fn:concat#3 is thus xs:anyAtomicType*, + parameter of fn:concat#3 is thus xs:anyAtomicType*, which means that a call such as concat#3(("a","b"), ("c","d"), ()) is allowed.

--> @@ -10432,11 +10432,11 @@ return $a("A")]]>

-

Consider the system function fn:format-date, - which has an arity range of 2 to 5. The named function reference fn:format-date#3 +

Consider the system function fn:format-date, + which has an arity range of 2 to 5. The named function reference fn:format-date#3 returns a function item whose three parameters correspond to the first three parameters - of fn:format-date; the remaining two arguments will take their default values. - To obtain an arity-3 function that binds to arguments 1, 2, and 5 of fn:format-date, + of fn:format-date; the remaining two arguments will take their default values. + To obtain an arity-3 function that binds to arguments 1, 2, and 5 of fn:format-date, use the partial function application format-date(?, ?, place := ?).

@@ -10452,12 +10452,12 @@ return $a("A")]]>

fn:abs#1 references the fn:abs function which takes a single argument.

+ >fn:abs#1 references the fn:abs function which takes a single argument.

fn:concat#5 references the fn:concat function which takes 5 arguments.

+ >fn:concat#5 references the fn:concat function which takes 5 arguments.

@@ -10696,7 +10696,7 @@ return $incrementors[2](4)]]>

function { head(.) + foot(.) } - a function that expects a sequence of numbers as its argument, and returns the sum of the first and last items in the sequence.

-

Focus functions are often useful as arguments to simple higher-order functions such as fn:sort. +

Focus functions are often useful as arguments to simple higher-order functions such as fn:sort. For example, to sort employees by salary, write sort(//employee, (), fn { +@salary }). (The unary plus has the effect of converting the attribute’s value to a number, for numeric sorting).

Focus functions can also be useful on the right-hand side of the @@ -10768,7 +10768,7 @@ return $incrementors[2](4)]]>

Some system functions - such as fn:concat and fn:codepoints-to-string + such as fn:concat and fn:codepoints-to-string are defined to be variadic.

User-written functions defined in XQuery can be defined as variadic by use of the annotation %variadic on the function declaration.

@@ -10790,7 +10790,7 @@ return $incrementors[2](4)]]>

In static function calls the effect of defining a function as variadic is that the value for the (single or final) parameter can be spread across multiple arguments rather than being supplied as a single argument. For example a sequence - of strings can be supplied to the fn:concat function either as + of strings can be supplied to the fn:concat function either as a single argument: concat(("a", "b", "c")) or as a series of separate arguments: concat("a", "b", "c"). It is also possible to mix the two approaches: the call concat("a", (), ("b", "c")) has @@ -10812,7 +10812,7 @@ return $incrementors[2](4)]]> variadic: a function item always has a fixed arity and must be called with the correct number of arguments.

-

So, for example, fn:concat#3 creates a function item with +

So, for example, fn:concat#3 creates a function item with arity 3, which must always be called with three arguments. The required type for each of these arguments is the same as the required type declared on the final parameter in the function definition, which in this case is @@ -10824,7 +10824,7 @@ return $incrementors[2](4)]]> parameter being xs:anyAtomicType*. This function is equivalent to the anonymous function fn($x) { fn:concat("[", $x, "]") }. The semantics of partial function application are equivalent to first evaluating - a named function reference with appropriate arity (in this case fn:concat#3) + a named function reference with appropriate arity (in this case fn:concat#3) and then performing a dynamic partial application of the resulting function item.

@@ -12831,7 +12831,7 @@ every integer between the two operands, in increasing order.

10 to 10

The result of this example is a sequence of length zero.

15 to 10 -

This example uses the fn:reverse function to construct a sequence of six integers in decreasing order. +

This example uses the fn:reverse function to construct a sequence of six integers in decreasing order. It evaluates to the sequence 15, 14, 13, 12, 11, 10.

reverse(10 to 15)
@@ -12846,7 +12846,7 @@ every integer between the two operands, in increasing order.

is -200 to -100 by 2.

--> -

To construct a sequence of integers based on steps other than 1, use the fn:slice +

To construct a sequence of integers based on steps other than 1, use the fn:slice function, as defined in .

@@ -13042,7 +13042,7 @@ Similarly, the operands of a MultiplicativeExpr are grouped from le

If the atomized operand is now an instance of type xs:boolean, xs:string, xs:decimal (including xs:integer), xs:float, or xs:untypedAtomic, then it -is converted to the type xs:double by applying the fn:number function. (Note that fn:number returns the value NaN if its operand cannot be converted to a number.)

+is converted to the type xs:double by applying the fn:number function. (Note that fn:number returns the value NaN if its operand cannot be converted to a number.)

@@ -13298,7 +13298,7 @@ return `The months with 31 days are: { $longMonths }.`]]> way of writing a string literal: "Goethe", 'Goethe', and `Goethe` are interchangeable. This means that back-ticks can sometimes be a useful way of delimiting a string that contains both single and double quotes: `He said: "I didn't."`.

-

It is sometimes useful to use string templates in conjunction with the fn:char function +

It is sometimes useful to use string templates in conjunction with the fn:char function to build strings containing special characters, for example `Chapter{ fn:char("nbsp") }{ $chapNr }`.

@@ -13709,7 +13709,7 @@ always true or false.

If the comparison operator is <, <=, >, or >=, then each item in both of the operand sequences is converted to the type xs:double by applying the -fn:number function. (Note that fn:number returns the value NaN if its operand cannot be converted to a number.)

+fn:number function. (Note that fn:number returns the value NaN if its operand cannot be converted to a number.)

@@ -13728,7 +13728,7 @@ applying the following rules. If a cast operation called for by the

If at least one of the two atomic items is an instance of a numeric type, then both atomic items are converted to the type xs:double by -applying the fn:number function.

+applying the fn:number function.

@@ -14162,19 +14162,19 @@ following expression must raise a

In addition to and- and or-expressions, &language; provides a -function named fn:not that takes a general sequence as -parameter and returns a boolean value. The fn:not function +function named fn:not that takes a general sequence as +parameter and returns a boolean value. The fn:not function is defined in . The -fn:not function reduces its parameter to an fn:not function reduces its parameter to an effective boolean value. It then returns true if the effective boolean value of its parameter is false, and false if the effective boolean value of its parameter is true. If an error is encountered in finding the effective boolean value of its operand, -fn:not raises the same error.

+fn:not raises the same error.

@@ -16448,7 +16448,7 @@ serialized (see ), and may also affect the behavior of certain functions that operate on nodes, such -as fn:name. Note the difference between fn:name. Note the difference between in-scope namespaces, which is a dynamic property of an element node, and

If a collation name is specified, it must be supplied as a literal string; it cannot be computed dynamically. A workaround in such cases is to use - the fn:collation-key function. For example:

+ the fn:collation-key function. For example:

for $p in $products group by collation-key($p/description, $collation) return $product/@code -

Note however that the fn:collation-key function might not work +

Note however that the fn:collation-key function might not work for all collations.

@@ -18606,9 +18606,9 @@ return $e/name]]>

If a collation name is specified, it must be supplied as a literal string; it cannot - be computed dynamically. Two possible workarounds are to use the fn:sort function - or the fn:collation-key function.

-

Using fn:sort the expression

+ be computed dynamically. Two possible workarounds are to use the fn:sort function + or the fn:collation-key function.

+

Using fn:sort the expression

for $b in $books/book[price < 100] order by $b/title return $b @@ -18630,7 +18630,7 @@ sort( order by collation-key($b/title, $collation) return $b -

Note however that the fn:collation-key function might not work +

Note however that the fn:collation-key function might not work for all collations.

@@ -18909,7 +18909,7 @@ are listed after the name of the author. The ordering of author elements in the result is implementation-dependent due to the semantics of the fn:distinct-values function.

+ >implementation-dependent
due to the semantics of the fn:distinct-values function.

Stevens TCP/IP Illustrated Advanced Programming in the Unix environment @@ -20136,7 +20136,7 @@ declare function recursive-content($item as item()) as record(key, value)* { expression $A?$x, if $A is an array and $x (after atomization) is xs:untypedAtomic then the value of $x is converted to an integer (by virtue of the coercion rules applying to a call - on array:get). With a deep lookup expression $A??$x, by + on array:get). With a deep lookup expression $A??$x, by contrast, the semantics are defined in terms of a map lookup, in which xs:untypedAtomic items are always treated as strings.

@@ -20173,7 +20173,7 @@ declare function recursive-content($item as item()) as record(key, value)* { Examples of Deep Lookup Expressions -

Consider the tree $tree of maps and arrays that results from applying the fn:parse-json +

Consider the tree $tree of maps and arrays that results from applying the fn:parse-json function to the following input:

with an expression such as ??name, there is no way of navigating from the items in the result to any related items. Pinned maps and arrays provide a solution to this problem; if a map or array - is pinned (by calling the fn:pin function), then values found by navigating + is pinned (by calling the fn:pin function), then values found by navigating within the map or array are labeled, which provides supplementary information about their location within the containing tree structure.

@@ -20484,7 +20484,7 @@ return $map?[?key ge 2]

More specifically, if a map $M or an array $A is pinned, then any value returned by map:get($M, $key) or array:get($A, $index) will be a sequence of labeled items. The label can be obtained by calling the function - fn:label, and the result will be a map having the following properties:

+ fn:label, and the result will be a map having the following properties:

pinned: set to true. This means that any @@ -20495,7 +20495,7 @@ return $map?[?key ge 2]

key: the key ($key) or index ($index) that was used to select the item.

position: in the general case the value returned by - map:get or array:get is a sequence, and each item in the + map:get or array:get is a sequence, and each item in the sequence is labeled with its 1-based position in that sequence.

ancestors: a zero-arity function that delivers the item's parent (its containing map or array), that item's parent, and so on, recursively, up to @@ -20507,7 +20507,7 @@ return $map?[?key ge 2] key or index of the item comes last).

-

The formal model for the fn:pin is that it returns a deep copy of the +

The formal model for the fn:pin is that it returns a deep copy of the supplied map or array in which all items in the recursive content have been labeled. This is a useful model because it avoids the need to specify the effect of each individual function and operator on the structure. For example, the rule has the consequence that the result of @@ -20515,13 +20515,13 @@ return $map?[?key ge 2] [ 1, 2, 4 ]. In a practical implementation, however, it is likely that labels will be attached to items lazily, at the time they are retrieved. Such an implementation will need to recognize pinned maps and arrays and treat them specially when operations such as - array:get, array:remove, array:for-each, - array:subarray, and their map counterparts, are evaluated.

+ array:get, array:remove, array:for-each, + array:subarray, and their map counterparts, are evaluated.

Because maps and arrays selected from a pinned map or array are themselves pinned, deep lookup operations (whether conducted using the deep lookup operator ??, - or the map:find function, or by user-written recursive code) will deliver + or the map:find function, or by user-written recursive code) will deliver a labeled value whose parent or ancestor properties can be used to navigate back up through the tree.

@@ -20540,7 +20540,7 @@ return $map?[?key ge 2]
and ?? flatten their result to a single sequence, so any empty values are effectively discarded from the result. For this reason, pinned arrays and maps work best when all values in arrays and maps are singleton items. An option is therefore provided - on the fn:parse-json and fn:json-doc functions to change + on the fn:parse-json and fn:json-doc functions to change the representation of JSON null values (whose default is an empty sequence, ()) to a user-supplied value.

@@ -20574,13 +20574,13 @@ return $map?[?key ge 2] of evaluating the expression E.

In addition to ordered and unordered expressions, - XQuery provides a function named fn:unordered that operates on any sequence + XQuery provides a function named fn:unordered that operates on any sequence of items and returns the same sequence in an implementation-defined order. A call to the fn:unordered + >implementation-defined order. A call to the fn:unordered function may be thought of as giving permission for the argument expression to be - materialized in whatever order the system finds most efficient. The fn:unordered + materialized in whatever order the system finds most efficient. The fn:unordered function relaxes ordering only for the sequence that is its immediate operand, whereas the unordered expression in earlier XQuery versions sets the ordering mode for its operand expression and all nested expressions.

@@ -20834,7 +20834,7 @@ raised . In the absence of a switch comparand,

Otherwise, the singleton switch value is compared individually with each item in the case value in turn, and a match occurs if and only if these two atomic items compare equal under the rules of - the fn:deep-equal function with default options, using the default + the fn:deep-equal function with default options, using the default collation in the static context.

@@ -20890,11 +20890,11 @@ switch { default return "not comparable" }]]> -

The comparisons are performed using the fn:deep-equal +

The comparisons are performed using the fn:deep-equal function, after atomization. This means that a case expression such as @married tests fn:data(@married) rather than fn:boolean(@married). If the effective boolean value of the expression is wanted, - this can be achieved with an explicit call of fn:boolean.

+ this can be achieved with an explicit call of fn:boolean.

@@ -21010,7 +21010,7 @@ one employee element satisfies the given comparison expression:

Like many quantified expressions, this can be simplified. This example can be written every $emp in /emps/employee satisfies $emp/salary[@current = 'true'], or even more concisely as empty(/emps/employee[not(salary/@current = 'true')].

-

Another alternative in &language; is to use the higher-order functions fn:some and fn:every. +

Another alternative in &language; is to use the higher-order functions fn:some and fn:every. This example can be written fn:every(/emps/employee, fn { salary/@current = 'true' })

@@ -21632,7 +21632,7 @@ sequence is permitted.

Casting a node to xs:QName can cause surprises because it uses the static context of the cast expression to provide the namespace bindings for this operation. -Instead of casting to xs:QName, it is generally preferable to use the fn:QName function, which allows the namespace context to be taken from the document containing the QName.

+Instead of casting to xs:QName, it is generally preferable to use the fn:QName function, which allows the namespace context to be taken from the document containing the QName.

The semantics of the cast expression diff --git a/specifications/xquery-40/src/query-prolog.xml b/specifications/xquery-40/src/query-prolog.xml index 8d2f51d43..d1f69d230 100644 --- a/specifications/xquery-40/src/query-prolog.xml +++ b/specifications/xquery-40/src/query-prolog.xml @@ -238,8 +238,8 @@ overriding any implementation-defined default. The default collation is the collation that is used by functions and operators that require a collation if no other collation is specified. For example, the gt operator on strings is defined by a - call to the fn:compare function, which takes an optional collation parameter. - Since the gt operator does not specify a collation, the fn:compare + call to the fn:compare function, which takes an optional collation parameter. + Since the gt operator does not specify a collation, the fn:compare function implements gt by using the default collation.

If neither the implementation nor the Prolog specifies a default collation, the Unicode codepoint collation (http://www.w3.org/2005/xpath-functions/collation/codepoint) @@ -269,7 +269,7 @@ resolving relative URI references. For example, the Static Base URI property is used when resolving relative references for module import and for the - fn:doc function.

+ fn:doc function.

As discussed in the definition of Static Base @@ -1140,7 +1140,7 @@ return $node/xx:bing]]> eg:sequential. If the namespace URI of an annotation is not recognized by the implementation, then the annotation has no effect, other than being available for inspection - using the fn:function-annotations function.

+ using the fn:function-annotations function.

Implementations may also provide a way for users to define their own annotations. Implementations must not define annotations, or allow users to define annotations, in diff --git a/specifications/xslt-40/src/xslt.xml b/specifications/xslt-40/src/xslt.xml index ffdfcd245..dee3b123b 100644 --- a/specifications/xslt-40/src/xslt.xml +++ b/specifications/xslt-40/src/xslt.xml @@ -10842,7 +10842,7 @@ and version="1.0" otherwise.

A function call at the outermost level can now be named using any valid EQName - (for example fn:doc) provided it binds to one of the permitted functions + (for example fn:doc) provided it binds to one of the permitted functions fn:doc, fn:id, fn:element-with-id, fn:key, or fn:root. If two functions are called, for example doc('a.xml')/id('abc'), @@ -33441,7 +33441,7 @@ the same group, and the--> , I = , T = , N = ). So, for example, the entry fn:remove(T, A) means that for the function - fn:remove#2, the of the first + fn:remove#2, the of the first argument is , and the of the second argument is . By reference to the general rules in , this demonstrates that if the is , the posture and sweep of the expression sum(remove(*,1)) will be grounded and consuming respectively.