How many three digit numbers are there in which the sum of the digits is even?

Correct option  (A) 450 

Show

Let the three-digits of number n = x1,x2,x3.

Since, x1 + x2 + x3 is even, there are following cases:

(a)  x1,x2,x3 all are even. So

4. 5. 5 = 100 ways

(b)  x1 even and x2 , x3 are odd. So

4. 5. 5 = 100 ways

(c)  x1 odd, x2 even, x3 odd. So

5. 5. 5 = 125 ways

(d)  x1 odd, x2 odd, x3 even. So

5. 5. 5 = 125 ways

Solution : 

How many three digit numbers are there in which the sum of the digits is even?

Case I : All the digits are even
Number of numbers `=4xx5xx5=100`
Case II : One digit is even and two digits are odd
If fist digit is even then number of numbers `=5xx5xx5=125`
If third digit is even then number of numbers `=5xx5xx5=125`
So, total number of numbers `=100+100+125+125=450`

Unfortunately, the footnote ends there, so there's not much in the way of detail about what these restrictions are or how long they'd remain in effect in a potential post-acquisition world. Given COD's continued non-appearance on Game Pass, you've got to imagine the restrictions are fairly significant if they're not an outright block on COD coming to the service. Either way, the simple fact that Microsoft is apparently willing to maintain any restrictions on its own ability to put first-party games on Game Pass is rather remarkable, given that making Game Pass more appealing is one of the reasons for its acquisition spree.

The irony of Sony making deals like this one while fretting about COD's future on PlayStation probably isn't lost on Microsoft's lawyers, which is no doubt part of why they brought it up to the CMA. While it's absolutely reasonable to worry about a world in which more and more properties are concentrated in the hands of singular, giant megacorps, it does look a bit odd if you're complaining about losing access to games while stopping them from joining competing services.

The purpose of this document is to catalog the functions and operators required for XPath 3.1, XQuery 3.1, and XSLT 3.0 (at the time of writing, XSLT 3.0 requires support for version 3.0 of this specification, and makes support for version 3.1 optional). The exact syntax used to call these functions and operators is specified in [XML Path Language (XPath) 3.1], [XQuery 3.1: An XML Query Language] and [XSL Transformations (XSLT) Version 3.0].

This document defines three classes of functions:

  • General purpose functions, available for direct use in user-written queries, stylesheets, and XPath expressions, whose arguments and results are values defined by the [XQuery and XPath Data Model (XDM) 3.1].

  • Constructor functions, used for creating instances of a datatype from values of (in general) a different datatype. These functions are also available for general use; they are named after the datatype that they return, and they always take a single argument.

  • Functions that specify the semantics of operators defined in [XML Path Language (XPath) 3.1] and [XQuery 3.1: An XML Query Language]. These exist for specification purposes only, and are not intended for direct calling from user-written code.

[XML Schema Part 2: Datatypes Second Edition] defines a number of primitive and derived datatypes, collectively known as built-in datatypes. This document defines functions and operations on these datatypes as well as the other types (for example, nodes and sequences of nodes) defined in Section 2.7 Schema Information DM31 of the [XQuery and XPath Data Model (XDM) 3.1]. These functions and operations are available for use in [XML Path Language (XPath) 3.1], [XQuery 3.1: An XML Query Language] and any other host language that chooses to reference them. In particular, they may be referenced in future versions of XSLT and related XML standards.

[Schema 1.1 Part 2] adds to the datatypes defined in [XML Schema Part 2: Datatypes Second Edition]. It introduces a new derived type

let $para := 
In a hole in the ground there lived a hobbit.
         
23, and it incorporates as built-in types the two types
let $para := 
In a hole in the ground there lived a hobbit.
         
24 and
let $para := 
In a hole in the ground there lived a hobbit.
         
25 which were previously XDM additions to the type system. In addition, XSD 1.1 clarifies and updates many aspects of the definitions of the existing datatypes: for example, it extends the value space of
let $para := 
In a hole in the ground there lived a hobbit.
         
26 to allow both positive and negative zero, and extends the lexical space to allow
let $para := 
In a hole in the ground there lived a hobbit.
         
27; it modifies the value space of
let $para := 
In a hole in the ground there lived a hobbit.
         
28 to permit additional Unicode characters; it allows year zero and disallows leap seconds in
let $para := 
In a hole in the ground there lived a hobbit.
         
29 values; and it allows any character string to appear as the value of an
let $para := 
In a hole in the ground there lived a hobbit.
         
30 item. Implementations of this specification may support either XSD 1.0 or XSD 1.1 or both.

References to specific sections of some of the above documents are indicated by cross-document links in this document. Each such link consists of a pointer to a specific section followed a superscript specifying the linked document. The superscripts have the following meanings: 'XQ' [XQuery 3.1: An XML Query Language], 'XT' [XSL Transformations (XSLT) Version 3.0], 'XP' [XML Path Language (XPath) 3.1], and 'DM' [XQuery and XPath Data Model (XDM) 3.1].

1.1 Conformance

This recommendation contains a set of function specifications. It defines conformance at the level of individual functions. An implementation of a function conforms to a function specification in this recommendation if all the following conditions are satisfied:

  • For all combinations of valid inputs to the function (both explicit arguments and implicit context dependencies), the result of the function meets the mandatory requirements of this specification.

  • For all invalid inputs to the function, the implementation signals (in some way appropriate to the calling environment) that a dynamic error has occurred.

  • For a sequence of calls within the same ·execution scope·, the requirements of this recommendation regarding the ·determinism· of results are satisfied (see 1.7.4 Properties of functions).

Other recommendations ("host languages") that reference this document may dictate:

  • Subsets or supersets of this set of functions to be available in particular environments;

  • Mechanisms for invoking functions, supplying arguments, initializing the static and dynamic context, receiving results, and handling errors;

  • A concrete realization of concepts such as ·execution scope·;

  • Which versions of other specifications referenced herein (for example, XML, XSD, or Unicode) are to be used.

Any behavior that is discretionary (implementation-defined or implementation-dependent) in this specification may be constrained by a host language.

Note:

Adding such constraints in a host language, however, is discouraged because it makes it difficult to re-use implementations of the function library across host languages.

This specification allows flexibility in the choice of versions of specifications on which it depends:

  • It is ·implementation-defined· which version of Unicode is supported, but it is recommended that the most recent version of Unicode be used.

  • It is ·implementation-defined· whether the type system is based on XML Schema 1.0 or XML Schema 1.1.

  • It is ·implementation-defined· whether definitions that rely on XML (for example, the set of valid XML characters) should use the definitions in XML 1.0 or XML 1.1.

Note:

The XML Schema 1.1 recommendation introduces one new concrete datatype:

let $para := 
In a hole in the ground there lived a hobbit.
         
23; it also incorporates the types
let $para := 
In a hole in the ground there lived a hobbit.
         
25,
let $para := 
In a hole in the ground there lived a hobbit.
         
24, and
let $para := 
In a hole in the ground there lived a hobbit.
         
34 which were previously defined in earlier versions of [XQuery and XPath Data Model (XDM) 3.1]. Furthermore, XSD 1.1 includes the option of supporting revised definitions of types such as
let $para := 
In a hole in the ground there lived a hobbit.
         
35 based on the rules in XML 1.1 rather than 1.0.

In this document, text labeled as an example or as a Note is provided for explanatory purposes and is not normative.

1.2 Namespaces and prefixes

The functions and operators defined in this document are contained in one of several namespaces (see [Namespaces in XML]) and referenced using an

let $para := 
In a hole in the ground there lived a hobbit.
         
36.

This document uses conventional prefixes to refer to these namespaces. User-written applications can choose a different prefix to refer to the namespace, so long as it is 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

let $para := 
In a hole in the ground there lived a hobbit.
         
37, allowing a call on the
let $para := 
In a hole in the ground there lived a hobbit.
         
38 function (for example) to be written as
let $para := 
In a hole in the ground there lived a hobbit.
         
39 rather than
let $para := 
In a hole in the ground there lived a hobbit.
         
40; in this document, however, all example function calls are explicitly prefixed.

The URIs of the namespaces and the conventional prefixes associated with them are:

  • let $para := 
    In a hole in the ground there lived a hobbit.
             
    41 for constructors — associated with
    let $para := 
    In a hole in the ground there lived a hobbit.
             
    42.

    The section 18 Constructor functions defines constructor functions for the built-in datatypes defined in [XML Schema Part 2: Datatypes Second Edition] and in Section 2.7 Schema Information DM31 of [XQuery and XPath Data Model (XDM) 3.1]. These datatypes and the corresponding constructor functions are in the XML Schema namespace,

    let $para := 
    In a hole in the ground there lived a hobbit.
             
    41, and are named in this document using the
    let $para := 
    In a hole in the ground there lived a hobbit.
             
    42 prefix.

  • let $para := 
    In a hole in the ground there lived a hobbit.
             
    37 for functions — associated with
    let $para := 
    In a hole in the ground there lived a hobbit.
             
    46.

    The namespace prefix used in this document for most functions that are available to users is

    let $para := 
    In a hole in the ground there lived a hobbit.
             
    46.

  • let $para := 
    In a hole in the ground there lived a hobbit.
             
    48 for functions — associated with
    let $para := 
    In a hole in the ground there lived a hobbit.
             
    49.

    This namespace is used for some mathematical functions. The namespace prefix used in this document for these functions is

    let $para := 
    In a hole in the ground there lived a hobbit.
             
    49. These functions are available to users in exactly the same way as those in the
    let $para := 
    In a hole in the ground there lived a hobbit.
             
    46 namespace.

  • let $para := 
    In a hole in the ground there lived a hobbit.
             
    52 for functions — associated with
    let $para := 
    In a hole in the ground there lived a hobbit.
             
    53.

    This namespace is used for some functions that manipulate maps (see 17.1 Functions that Operate on Maps). The namespace prefix used in this document for these functions is

    let $para := 
    In a hole in the ground there lived a hobbit.
             
    53. These functions are available to users in exactly the same way as those in the
    let $para := 
    In a hole in the ground there lived a hobbit.
             
    46 namespace.

  • let $para := 
    In a hole in the ground there lived a hobbit.
             
    56 for functions — associated with
    let $para := 
    In a hole in the ground there lived a hobbit.
             
    57.

    This namespace is used for some functions that manipulate maps (see 17.3 Functions that Operate on Arrays). The namespace prefix used in this document for these functions is

    let $para := 
    In a hole in the ground there lived a hobbit.
             
    57. These functions are available to users in exactly the same way as those in the
    let $para := 
    In a hole in the ground there lived a hobbit.
             
    46 namespace.

  • let $para := 
    In a hole in the ground there lived a hobbit.
             
    60 — associated with
    let $para := 
    In a hole in the ground there lived a hobbit.
             
    61.

    There are no functions in this namespace; it is used for error codes.

    This document uses the prefix

    let $para := 
    In a hole in the ground there lived a hobbit.
             
    61 to represent the namespace URI
    let $para := 
    In a hole in the ground there lived a hobbit.
             
    60, which is the namespace for all XPath and XQuery error codes and messages. This namespace prefix is not predeclared and its use in this document is not normative.

  • let $para := 
    In a hole in the ground there lived a hobbit.
             
    64 — associated with
    let $para := 
    In a hole in the ground there lived a hobbit.
             
    65.

    There are no functions in this namespace: it is used for serialization parameters, as described in [XSLT and XQuery Serialization 3.1]

  • Functions defined with the

    let $para := 
    In a hole in the ground there lived a hobbit.
             
    66 prefix are described here to underpin the definitions of the operators in [XML Path Language (XPath) 3.1], [XQuery 3.1: An XML Query Language] and [XSL Transformations (XSLT) Version 3.0]. These functions are not available directly to users, and there is no requirement that implementations should actually provide these functions. For this reason, no namespace is associated with the
    let $para := 
    In a hole in the ground there lived a hobbit.
             
    66 prefix. For example, multiplication is generally associated with the
    let $para := 
    In a hole in the ground there lived a hobbit.
             
    68 operator, but it is described as a function in this document:

    let $para := 
    In a hole in the ground there lived a hobbit.
             
    69(
    let $para := 
    In a hole in the ground there lived a hobbit.
             
    70
    let $para := 
    In a hole in the ground there lived a hobbit.
             
    71
    let $para := 
    In a hole in the ground there lived a hobbit.
             
    72,
    let $para := 
    In a hole in the ground there lived a hobbit.
             
    73
    let $para := 
    In a hole in the ground there lived a hobbit.
             
    71
    let $para := 
    In a hole in the ground there lived a hobbit.
             
    72)
    let $para := 
    In a hole in the ground there lived a hobbit.
             
    71
    let $para := 
    In a hole in the ground there lived a hobbit.
             
    72

Note:

The above namespace URIs are not expected to change from one version of this document to another. The contents of these namespaces may be extended to allow additional functions (and errors, and serialization parameters) to be defined.

1.3 Function overloading

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

let $para := 
In a hole in the ground there lived a hobbit.
         
78 which accept arguments of many different types have a signature that defines a very general argument type, in this case
let $para := 
In a hole in the ground there lived a hobbit.
         
79 which accepts any single item; supplying an inappropriate item (such as a function item) causes a dynamic error.

Some functions on numeric types include the type

let $para := 
In a hole in the ground there lived a hobbit.
         
72 in their signature as an argument or result type. In this version of the specification,
let $para := 
In a hole in the ground there lived a hobbit.
         
72 has been redefined as a built-in union type representing the union of
let $para := 
In a hole in the ground there lived a hobbit.
         
82,
let $para := 
In a hole in the ground there lived a hobbit.
         
83,
let $para := 
In a hole in the ground there lived a hobbit.
         
26 (and thus automatically accepting types derived from these, including
let $para := 
In a hole in the ground there lived a hobbit.
         
85).

Operators such as "+" may be overloaded: they map to different underlying functions depending on the dynamic types of the supplied operands.

It is possible for two functions to have the same name provided they have different arity (number of arguments). For the functions defined in this specification, where two functions have the same name and different arity, they also have closely related behavior, so they are defined in the same section of this document.

1.4 Function signatures and descriptions

Each function (or group of functions having the same name) is defined in this specification using a standard proforma.

The function name is a

let $para := 
In a hole in the ground there lived a hobbit.
         
86 as defined in [XML Schema Part 2: Datatypes Second Edition] and must adhere to its syntactic conventions. Following the precedent set by [XML Path Language (XPath) Version 1.0], function names are generally composed of English words separated by hyphens ("-"). Abbreviations are used only where there is a strong precedent in other programming languages (as with
let $para := 
In a hole in the ground there lived a hobbit.
         
87 and
let $para := 
In a hole in the ground there lived a hobbit.
         
88 for sine and cosine). If a function name contains a [XML Schema Part 2: Datatypes Second Edition] datatype name, it may have intercapitalized spelling and is used in the function name as such. An example is
let $para := 
In a hole in the ground there lived a hobbit.
         
89.

The first section in the proforma is a short summary of what the function does. This is intended to be informative rather than normative.

Each function is then defined by specifying its signature, which defines the types of the parameters and of the result value.

Each function's signature is presented in a form like this:

let $para := 
In a hole in the ground there lived a hobbit.
         
90(
let $para := 
In a hole in the ground there lived a hobbit.
         
91
let $para := 
In a hole in the ground there lived a hobbit.
         
71
let $para := 
In a hole in the ground there lived a hobbit.
         
93, ...)
let $para := 
In a hole in the ground there lived a hobbit.
         
71
let $para := 
In a hole in the ground there lived a hobbit.
         
95

In this notation, function-name, in bold-face, is the name of the function whose signature is being specified. If the function takes no parameters, then the name is followed by an empty parameter list: "

let $para := 
In a hole in the ground there lived a hobbit.
         
96"; otherwise, the name is followed by a parenthesized list of parameter declarations, in which each declaration specifies the static type of the parameter, in italics, and a descriptive, but non-normative, name. If there are two or more parameter declarations, they are separated by a comma. The
let $para := 
In a hole in the ground there lived a hobbit.
         
95, also in italics, specifies the static type of the value returned by the function. The dynamic type of the value returned by the function is the same as its static type or derived from the static type. All parameter types and return types are specified using the SequenceType notation defined in Section 2.5.4 SequenceType Syntax XP31.

One function,

let $para := 
In a hole in the ground there lived a hobbit.
         
98, has a variable number of arguments (two or more). More strictly, there is an infinite set of functions having the name
let $para := 
In a hole in the ground there lived a hobbit.
         
98, with arity ranging from 2 to infinity. For this special case, a single function signature is given, with an ellipsis indicating an indefinite number of arguments.

The next section in the proforma defines the semantics of the function as a set of rules. The order in which the rules appear is significant; they are to be applied in the order in which they are written. Error conditions, however, are generally listed in a separate section that follows the main rules, and take precedence over non-error rules except where otherwise stated. The principles outlined in Section 2.3.4 Errors and Optimization XP31 apply by default: to paraphrase, if the result of the function can be determined without evaluating all its arguments, then it is not necessary to evaluate the remaining arguments merely in order to determine whether any error conditions apply.

Where the proforma includes sections headed Notes or Examples, these are non-normative.

Rules for passing parameters to operators are described in the relevant sections of [XQuery 3.1: An XML Query Language] and [XML Path Language (XPath) 3.1]. For example, the rules for passing parameters to arithmetic operators are described in Section 3.5 Arithmetic Expressions XP31. Specifically, rules for parameters of type

let $para := 
In a hole in the ground there lived a hobbit.
         
00 and the empty sequence are specified in this section.

As is customary, the parameter type name indicates that the function or operator accepts arguments of that type, or types derived from it, in that position. This is called subtype substitution (See Section 2.5.5 SequenceType Matching XP31). In addition, numeric type instances and instances of type

let $para := 
In a hole in the ground there lived a hobbit.
         
30 can be promoted to produce an argument of the required type. (See Section B.1 Type Promotion XP31).

  1. Subtype Substitution: A derived type may substitute for its base type. In particular,

    let $para := 
    In a hole in the ground there lived a hobbit.
             
    85 may be used where
    let $para := 
    In a hole in the ground there lived a hobbit.
             
    82 is expected.

  2. Numeric Type Promotion:

    let $para := 
    In a hole in the ground there lived a hobbit.
             
    82 may be promoted to
    let $para := 
    In a hole in the ground there lived a hobbit.
             
    83 or
    let $para := 
    In a hole in the ground there lived a hobbit.
             
    26. Promotion to
    let $para := 
    In a hole in the ground there lived a hobbit.
             
    26 should be done directly, not via
    let $para := 
    In a hole in the ground there lived a hobbit.
             
    83, to avoid loss of precision.

  3. anyURI Type Promotion: A value of type

    let $para := 
    In a hole in the ground there lived a hobbit.
             
    30 can be promoted to the type
    let $para := 
    In a hole in the ground there lived a hobbit.
             
    10.

Some functions accept a single value or the empty sequence as an argument and some may return a single value or the empty sequence. This is indicated in the function signature by following the parameter or return type name with a question mark: "

let $para := 
In a hole in the ground there lived a hobbit.
         
11", indicating that either a single value or the empty sequence must appear. See below.

let $para := 
In a hole in the ground there lived a hobbit.
         
90(
let $para := 
In a hole in the ground there lived a hobbit.
         
91
let $para := 
In a hole in the ground there lived a hobbit.
         
71
let $para := 
In a hole in the ground there lived a hobbit.
         
15)
let $para := 
In a hole in the ground there lived a hobbit.
         
71
let $para := 
In a hole in the ground there lived a hobbit.
         
17

Note that this function signature is different from a signature in which the parameter is omitted. See, for example, the two signatures for

let $para := 
In a hole in the ground there lived a hobbit.
         
78. In the first signature, the parameter is omitted and the argument defaults to the context item, referred to as
let $para := 
In a hole in the ground there lived a hobbit.
         
19. In the second signature, the argument must be present but may be the empty sequence, written as
let $para := 
In a hole in the ground there lived a hobbit.
         
96.

Some functions accept a sequence of zero or more values as an argument. This is indicated by following the name of the type of the items in the sequence with

let $para := 
In a hole in the ground there lived a hobbit.
         
68. The sequence may contain zero or more items of the named type. For example, the function below accepts a sequence of
let $para := 
In a hole in the ground there lived a hobbit.
         
26 and returns a
let $para := 
In a hole in the ground there lived a hobbit.
         
26 or the empty sequence.

let $para := 
In a hole in the ground there lived a hobbit.
         
24(
let $para := 
In a hole in the ground there lived a hobbit.
         
25
let $para := 
In a hole in the ground there lived a hobbit.
         
71
let $para := 
In a hole in the ground there lived a hobbit.
         
27)
let $para := 
In a hole in the ground there lived a hobbit.
         
71
let $para := 
In a hole in the ground there lived a hobbit.
         
29

1.5 Options

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

let $para := 
In a hole in the ground there lived a hobbit.
         
30 has an options parameter allowing specification of whether the output is to be indented. A call might be written:

fn:xml-to-json($input, map{'indent':true()})

[Definition] Functions that take an options parameter adopt common conventions on how the options are used. These are referred to as the option parameter conventions. These rules apply only to functions that explicitly refer to them.

Where a function adopts the ·option parameter conventions·, the following rules apply:

  1. The value of the relevant argument must be a map. The entries in the map are referred to as options: the key of the entry is called the option name, and the associated value is the option value. Option names defined in this specification are always strings (single

    let $para := 
    In a hole in the ground there lived a hobbit.
             
    10 values). Option values may be of any type.

  2. The type of the options parameter in the function signature is always given as

    let $para := 
    In a hole in the ground there lived a hobbit.
             
    32.

  3. Although option names are described above as strings, the actual key may be any value that compares equal to the required string (using the

    let $para := 
    In a hole in the ground there lived a hobbit.
             
    33 operator with Unicode codepoint collation; or equivalently, the
    let $para := 
    In a hole in the ground there lived a hobbit.
             
    34 relation). For example, instances of
    let $para := 
    In a hole in the ground there lived a hobbit.
             
    00 or
    let $para := 
    In a hole in the ground there lived a hobbit.
             
    30 are equally acceptable.

    Note:

    This means that the implementation of the function can check for the presence and value of particular options using the functions

    let $para := 
    In a hole in the ground there lived a hobbit.
             
    37 and/or
    let $para := 
    In a hole in the ground there lived a hobbit.
             
    38.

  4. It is not an error if the options map contains options with names other than those described in this specification. Implementations may attach an ·implementation-defined· meaning to such entries, and may define errors that arise if such entries are present with invalid values. Implementations must ignore such entries unless they have a specific ·implementation-defined· meaning. Implementations that define additional options in this way should use values of type

    let $para := 
    In a hole in the ground there lived a hobbit.
             
    36 as the option names, using an appropriate namespace.

  5. All entries in the options map are optional, and supplying an empty map has the same effect as omitting the relevant argument in the function call, assuming this is permitted.

  6. For each named option, the function specification defines a required type for the option value. The value that is actually supplied in the map is converted to this required type using the function conversion rulesXP31. This will result in an error (typically [err:XPTY0004]XP31 or [err:FORG0001]FO31) if conversion of the supplied value to the required type is not possible. A type error also occurs if this conversion delivers a coerced function whose invocation fails with a type error. A dynamic error occurs if the supplied value after conversion is not one of the permitted values for the option in question: the error codes for this error are defined in the specification of each function.

    Note:

    It is the responsibility of each function implementation to invoke this conversion; it does not happen automatically as a consequence of the function calling rules.

  7. In cases where an option is list-valued, by convention the value may be supplied either as a sequence or as an array. 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

    let $para := 
    In a hole in the ground there lived a hobbit.
             
    40 function.

  8. 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.

1.6 Type System

The diagrams in this section show how nodes, functions, primitive simple types, and user defined types fit together into a type system. This type system comprises two distinct subsystems that both include the primitive atomic types. In the diagrams, connecting lines represent relationships between derived types and the types from which they are derived; the arrowheads point toward the type from which they are derived. The dashed line represents relationships not present in this diagram, but that appear in one of the other diagrams. Dotted lines represent additional relationships that follow an evident pattern. The information that appears in each diagram is recapitulated in tabular form.

The

let $para := 
In a hole in the ground there lived a hobbit.
         
41,
let $para := 
In a hole in the ground there lived a hobbit.
         
42,
let $para := 
In a hole in the ground there lived a hobbit.
         
43 types, and
let $para := 
In a hole in the ground there lived a hobbit.
         
72 and both the
let $para := 
In a hole in the ground there lived a hobbit.
         
45 and
let $para := 
In a hole in the ground there lived a hobbit.
         
46 are special types in that these types are lists or unions rather than types derived by extension or restriction.

1.6.1 Item Types

The first diagram and its corresponding table illustrate the relationship of various item types.

Item types are used to characterize the various types of item that can appear in a sequence (nodes, atomic values, and functions), and they are therefore used in declaring the types of variables or the argument types and result types of functions.

Item types in the data model form a directed graph, rather than a hierarchy or lattice: in the relationship defined by the

let $para := 
In a hole in the ground there lived a hobbit.
         
47 function, some types are derived from more than one other type. Examples include functions (
let $para := 
In a hole in the ground there lived a hobbit.
         
48 is substitutable for
let $para := 
In a hole in the ground there lived a hobbit.
         
49 and also for
let $para := 
In a hole in the ground there lived a hobbit.
         
50), and union types (
let $para := 
In a hole in the ground there lived a hobbit.
         
51 is substitutable for
let $para := 
In a hole in the ground there lived a hobbit.
         
52 and also for
let $para := 
In a hole in the ground there lived a hobbit.
         
53. In XDM, item types include node types, function types, and built-in atomic types. The diagram, which shows only hierarchic relationships, is therefore a simplification of the full model.

How many three digit numbers are there in which the sum of the digits is even?

In the table, each type whose name is indented is derived from the type whose name appears nearest above it with one less level of indentation.

Item Type Hierarchyitem   xs:anyAtomicType  node  attribute user-defined attribute typescomment document user-defined document typeselement user-defined element typesnamespace processing-instruction text function(*) array(*) map(*) 

1.6.2 Schema Type Hierarchy

The next diagram and table illustrate the schema type subsystem, in which all types are derived from the distinguished type

let $para := 
In a hole in the ground there lived a hobbit.
         
54.

Schema types include built-in types defined in the XML Schema specification, and user-defined types defined using mechanisms described in the XML Schema specification. Schema types define the permitted contents of nodes. The main categories are complex types, which define the permitted content of elements, and simple types, which can be used to constrain the values of both elements and attributes.

How many three digit numbers are there in which the sum of the digits is even?

In the table, each type whose name is indented is derived from the type whose name appears nearest above it with one less level of indentation.

xs:anyType   xs:anySimpleType  xs:anyAtomicType list types xs:IDREFSxs:NMTOKENSxs:ENTITIESuser-defined list typesunion types xs:numericuser-defined union typescomplex types  xs:untyped user-defined complex types 

1.6.3 Atomic Type Hierarchy

The final diagram and table show all of the atomic types, including the primitive simple types and the built-in types derived from the primitive simple types. This includes all the built-in datatypes defined in [XML Schema Part 2: Datatypes Second Edition].

Atomic types are both item types and schema types, so the root type

let $para := 
In a hole in the ground there lived a hobbit.
         
34 may be found in both the previous diagrams.

How many three digit numbers are there in which the sum of the digits is even?

In the table, each type whose name is indented is derived from the type whose name appears nearest above it with one less level of indentation.

xs:untypedAtomic      xs:dateTime      xs:dateTimeStamp     xs:date      xs:time      xs:duration      xs:yearMonthDuration     xs:dayTimeDuration     xs:float      xs:double      xs:decimal      xs:integer     xs:nonPositiveInteger    xs:negativeInteger   xs:long    xs:int   xs:short  xs:byte xs:nonNegativeInteger    xs:unsignedLong   xs:unsignedInt  xs:unsignedShort xs:unsignedBytexs:positiveInteger   xs:gYearMonth      xs:gYear      xs:gMonthDay      xs:gDay      xs:gMonth      xs:string      xs:normalizedString     xs:token    xs:language   xs:NMTOKEN   xs:Name   xs:NCName  xs:ID xs:IDREF xs:ENTITY xs:boolean      xs:base64Binary      xs:hexBinary      xs:anyURI      xs:QName      xs:NOTATION      

1.7 Terminology

The terminology used to describe the functions and operators on types defined in [XML Schema Part 2: Datatypes Second Edition] is defined in the body of this specification. The terms defined in this section are used in building those definitions.

Note:

Following in the tradition of [XML Schema Part 2: Datatypes Second Edition], the terms type and datatype are used interchangeably.

1.7.1 Strings, characters, and codepoints

This document uses the terms

let $para := 
In a hole in the ground there lived a hobbit.
         
56,
let $para := 
In a hole in the ground there lived a hobbit.
         
57, and
let $para := 
In a hole in the ground there lived a hobbit.
         
58 with meanings that are normatively defined in [XQuery and XPath Data Model (XDM) 3.1], and which are paraphrased here for ease of reference:

[Definition] A character is an instance of the CharXML production of [Extensible Markup Language (XML) 1.0 (Fifth Edition)].

Note:

This definition excludes Unicode characters in the surrogate blocks as well as xFFFE and xFFFF, while including characters with codepoints greater than xFFFF which some programming languages treat as two characters. The valid characters are defined by their codepoints, and include some whose codepoints have not been assigned by the Unicode consortium to any character.

[Definition] A string is a sequence of zero or more ·characters·, or equivalently, a value in the value space of the

let $para := 
In a hole in the ground there lived a hobbit.
         
10 datatype.

[Definition] A codepoint is an integer assigned to a ·character· by the Unicode consortium, or reserved for future assignment to a character.

Note:

The set of codepoints is thus wider than the set of characters.

This specification spells "codepoint" as one word; the Unicode specification spells it as "code point". Equivalent terms found in other specifications are "character number" or "code position". See [Character Model for the World Wide Web 1.0: Fundamentals]

Because these terms appear so frequently, they are hyperlinked to the definition only when there is a particular desire to draw the reader's attention to the definition; the absence of a hyperlink does not mean that the term is being used in some other sense.

It is ·implementation-defined· which version of [The Unicode Standard] is supported, but it is recommended that the most recent version of Unicode be used.

Unless explicitly stated, the

let $para := 
In a hole in the ground there lived a hobbit.
         
10 values returned by the functions in this document are not normalized in the sense of [Character Model for the World Wide Web 1.0: Fundamentals].

Notes:

In functions that involve character counting such as

let $para := 
In a hole in the ground there lived a hobbit.
         
61,
let $para := 
In a hole in the ground there lived a hobbit.
         
62 and
let $para := 
In a hole in the ground there lived a hobbit.
         
63, 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 xFFFF using two 16-bit values known as a surrogate pair. A surrogate pair counts as one character, not two.

1.7.2 Namespaces and URIs

This document uses the phrase "namespace URI" to identify the concept identified in [Namespaces in XML] as "namespace name", and the phrase "local name" to identify the concept identified in [Namespaces in XML] as "local part".

It also uses the term "expanded-QName" defined below.

[Definition] An expanded-QName is a value in the value space of the

let $para := 
In a hole in the ground there lived a hobbit.
         
36 datatype as defined in the XDM data model (see [XQuery and XPath Data Model (XDM) 3.1]): that is, a triple containing namespace prefix (optional), namespace URI (optional), and local name. Two expanded QNames are equal if the namespace URIs are the same (or both absent) and the local names are the same. The prefix plays no part in the comparison, but is used only if the expanded QName needs to be converted back to a string.

The term URI is used as follows:

[Definition] Within this specification, the term URI refers to Universal Resource Identifiers as defined in [RFC 3986] and extended in [RFC 3987] with a new name IRI. The term URI Reference, unless otherwise stated, refers to a string in the lexical space of the

let $para := 
In a hole in the ground there lived a hobbit.
         
30 datatype as defined in [XML Schema Part 2: Datatypes Second Edition].

Note:

Note that this means, in practice, that where this specification requires a "URI Reference", an IRI as defined in [RFC 3987] will be accepted, provided that other relevant specifications also permit an IRI. The term URI has been retained in preference to IRI to avoid introducing new names for concepts such as "Base URI" that are defined or referenced across the whole family of XML specifications. Note also that the definition of

let $para := 
In a hole in the ground there lived a hobbit.
         
30 is a wider definition than the definition in [RFC 3987]; for example it does not require non-ASCII characters to be escaped.

1.7.3 Conformance terminology

In this specification:

  • The auxiliary verb must, when rendered in small capitals, indicates a precondition for conformance.

    • When the sentence relates to an implementation of a function (for example "All implementations must recognize URIs of the form ...") then an implementation is not conformant unless it behaves as stated.

    • When the sentence relates to the result of a function (for example "The result must have the same type as

      let $para := 
      In a hole in the ground there lived a hobbit.
               
      25") then the implementation is not conformant unless it delivers a result as stated.

    • When the sentence relates to the arguments to a function (for example "The value of

      let $para := 
      In a hole in the ground there lived a hobbit.
               
      25 must be a valid regular expression") then the implementation is not conformant unless it enforces the condition by raising a dynamic error whenever the condition is not satisfied.

  • The auxiliary verb may, when rendered in small capitals, indicates optional or discretionary behavior. The statement "An implementation may do X" implies that it is implementation-dependent whether or not it does X.

  • The auxiliary verb should, when rendered in small capitals, indicates desirable or recommended behavior. The statement "An implementation should do X" implies that it is desirable to do X, but implementations may choose to do otherwise if this is judged appropriate.

[Definition] Where behavior is described as implementation-defined, variations between processors are permitted, but a conformant implementation must document the choices it has made.

[Definition] Where behavior is described as implementation-dependent, variations between processors are permitted, and conformant implementations are not required to document the choices they have made.

Note:

Where this specification states that something is implementation-defined or implementation-dependent, it is open to host languages to place further constraints on the behavior.

1.7.4 Properties of functions

This section is concerned with the question of whether two calls on a function, with the same arguments, may produce different results.

[Definition] 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

let $para := 
In a hole in the ground there lived a hobbit.
         
69 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
let $para := 
In a hole in the ground there lived a hobbit.
         
70 attributes, are in a separate execution scope).

The following definition explains more precisely what it means for two function calls to return the same result:

[Definition] Two values are defined to be identical if they contain the same number of items and the items are pairwise identical. Two items are identical if and only if one of the following conditions applies:

  1. Both items are atomic values, of precisely the same type, and the values are equal as defined using the

    let $para := 
    In a hole in the ground there lived a hobbit.
             
    33 operator, using the Unicode codepoint collation when comparing strings.

  2. Both items are nodes, and represent the same node.

  3. Both items are maps, both maps have the same number of entries, and for every entry E1 in the first map there is an entry E2 in the second map such that the keys of E1 and E2 are ·the same key·, and the corresponding values V1 and V2 are ·identical·.

  4. Both items are arrays, both arrays have the same number of members, and the members are pairwise ·identical·.

  5. Both items are function items, neither item is a map or array, and all the following conditions apply:

    1. Either both functions have the same name, or both names are absentDM31.

    2. Both functions have the same arity.

    3. Both functions have the same function signature. Two function signatures are defined to be the same if the declared result types are identical and the declared argument types are pairwise identical. Two types S and T are defined to be identical if and only if

      let $para := 
      In a hole in the ground there lived a hobbit.
               
      72 and
      let $para := 
      In a hole in the ground there lived a hobbit.
               
      73 both hold, where the subtype relation is defined in Section 2.5.6.1 The judgement subtype(A, B) XP31.

      Note:

      Under this definition, a union type with

      let $para := 
      In a hole in the ground there lived a hobbit.
               
      74 is identical to a union type with
      let $para := 
      In a hole in the ground there lived a hobbit.
               
      75. However, two functions whose signatures differ in this way will probably be deemed non-identical under rule (e) below, because they are likely to have different effect when invoked with an argument of type
      let $para := 
      In a hole in the ground there lived a hobbit.
               
      00.

    4. Both functions have the same nonlocal variable bindings (sometimes called the function's closure).

    5. The processor is able to determine that the implementations of the two functions are equivalent, in the sense that for all possible combinations of arguments, the two functions have the same effect.

    Note:

    There is no function or operator defined in the specification that tests whether two function items are identical. Where the specification requires two function items to be identical, for example in the results of repeated calls of a function whose result is a function, then the processor must ensure that it returns functions that are indistinguishable in their observable effect. Where the specification defines behavior conditional on two function items being identical, the determination of identity is to some degree implementation-dependent. There are cases where function items are definitely not identical (for example if they have different name or arity), but positive determination of identity is possible only using implementation-dependent techniques, for example when both items contain references to the same piece of code representing the function's implementation.

Some functions produce results that depend not only on their explicit arguments, but also on the static and dynamic context.

[Definition] A function may have the property of being context-dependent: the result of such a function depends on the values of properties in the static and dynamic evaluation context as well as on the actual supplied arguments (if any).

[Definition] A function that is not ·context-dependent· is called context-independent.

A function that is context-dependent can be used as a named function reference, can be partially applied, and can be found using

let $para := 
In a hole in the ground there lived a hobbit.
         
77. 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
let $para := 
In a hole in the ground there lived a hobbit.
         
77; 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
let $para := 
In a hole in the ground there lived a hobbit.
         
77. In effect, the static and dynamic part of the context thus act as part of the closure of the function item.

Context-dependent functions fall into a number of categories:

  1. The functions

    let $para := 
    In a hole in the ground there lived a hobbit.
             
    80,
    let $para := 
    In a hole in the ground there lived a hobbit.
             
    69,
    let $para := 
    In a hole in the ground there lived a hobbit.
             
    82,
    let $para := 
    In a hole in the ground there lived a hobbit.
             
    83,
    let $para := 
    In a hole in the ground there lived a hobbit.
             
    84,
    let $para := 
    In a hole in the ground there lived a hobbit.
             
    85,
    let $para := 
    In a hole in the ground there lived a hobbit.
             
    86, and
    let $para := 
    In a hole in the ground there lived a hobbit.
             
    87 depend on properties of the dynamic context that are fixed within the ·execution scope·. The same applies to a number of functions in the
    let $para := 
    In a hole in the ground there lived a hobbit.
             
    88 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·.

  2. A number of functions including

    let $para := 
    In a hole in the ground there lived a hobbit.
             
    89,
    let $para := 
    In a hole in the ground there lived a hobbit.
             
    90,
    let $para := 
    In a hole in the ground there lived a hobbit.
             
    91,
    let $para := 
    In a hole in the ground there lived a hobbit.
             
    92,
    let $para := 
    In a hole in the ground there lived a hobbit.
             
    93,
    let $para := 
    In a hole in the ground there lived a hobbit.
             
    94,
    let $para := 
    In a hole in the ground there lived a hobbit.
             
    95,
    let $para := 
    In a hole in the ground there lived a hobbit.
             
    96,
    let $para := 
    In a hole in the ground there lived a hobbit.
             
    97,
    let $para := 
    In a hole in the ground there lived a hobbit.
             
    98,
    let $para := 
    In a hole in the ground there lived a hobbit.
             
    99,
    op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
    00,
    op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
    01,
    op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
    02,
    op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
    03,
    op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
    04,
    op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
    05, and
    op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
    06 depend on the focusXP31. These functions will in general return different results on different calls if the focus is different.

    [Definition] A function is focus-dependent if its result depends on the focusXP31 (that is, the context item, position, or size).

    [Definition] A function that is not ·focus-dependent· is called focus-independent

  3. The function

    op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
    07 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 evaluated twice with the same arguments then it will return the same result each time (because the static context, by definition, does not change at run time). However, two distinct calls (that is, two calls on the function appearing in different places in the source code) may produce different results even if the explicit arguments are the same.

  4. Functions such as

    op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
    08,
    op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
    09, and
    op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
    10 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 the source code may produce different results.

The

let $para := 
In a hole in the ground there lived a hobbit.
         
77 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
let $para := 
In a hole in the ground there lived a hobbit.
         
77 are used as the static and dynamic context of the function that
let $para := 
In a hole in the ground there lived a hobbit.
         
77 returns.

[Definition] For a ·context-dependent· function, the parts of the context on which it depends are referred to as implicit arguments.

[Definition] A function that is guaranteed to produce ·identical· results from repeated calls within a single ·execution scope· if the explicit and implicit arguments are identical is referred to as deterministic.

[Definition] A function that is not ·deterministic· is referred to as nondeterministic.

All functions defined in this specification are ·deterministic· unless otherwise stated. Exceptions include the following:

  • [Definition] Some functions (such as

    op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
    14,
    op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
    15,
    op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
    16, and
    op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
    17
    ) 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

    op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
    18,
    op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
    19,
    op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
    20,
    and
    op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
    21) 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
    op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
    22 operator). However, if non-identical nodes are returned, their content will be the same in the sense of the
    op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
    23 function. Such a function is said to be non-deterministic with respect to node identity.

  • Some functions (such as

    op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
    09 and
    op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
    10) 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 non-deterministic as a user option.

Where the results of a function are described as being (to a greater or lesser extent) ·implementation-defined· or ·implementation-dependent·, this does not by itself remove the requirement that the results should be deterministic: that is, that repeated calls with the same explicit and implicit arguments must return identical results.

2 Accessors

Accessors and their semantics are described in [XQuery and XPath Data Model (XDM) 3.1]. Some of these accessors are exposed to the user through the functions described below.

Each of these functions has an arity-zero signature which is equivalent to the arity-one form, with the context item 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

let $para := 
In a hole in the ground there lived a hobbit.
         
78, which delivers a zero-length string.

FunctionAccessorAcceptsReturns
op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
27
op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
28node (optional)
let $para := 
In a hole in the ground there lived a hobbit.
         
36 (optional)
op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
30
op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
31node (optional)
op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
32 (optional)
let $para := 
In a hole in the ground there lived a hobbit.
         
78
op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
34item (optional)
let $para := 
In a hole in the ground there lived a hobbit.
         
10
op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
36
op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
37zero or more itemsa sequence of atomic values
op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
38
op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
39node (optional)
let $para := 
In a hole in the ground there lived a hobbit.
         
30 (optional)
op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
41
op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
42node (optional)
let $para := 
In a hole in the ground there lived a hobbit.
         
30 (optional)

2.1 fn:node-name

Summary

Returns the name of a node, as an

let $para := 
In a hole in the ground there lived a hobbit.
         
36.

Signatures

op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
27()
let $para := 
In a hole in the ground there lived a hobbit.
         
71
op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
47

op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
27(
let $para := 
In a hole in the ground there lived a hobbit.
         
25
let $para := 
In a hole in the ground there lived a hobbit.
         
71
op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
51)
let $para := 
In a hole in the ground there lived a hobbit.
         
71
op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
47

Properties

The zero-argument form of this function is ·deterministic·, ·context-dependent·, and ·focus-dependent·.

The one-argument form of this function is ·deterministic·, ·context-independent·, and ·focus-independent·.

Rules

If the argument is omitted, it defaults to the context item (

let $para := 
In a hole in the ground there lived a hobbit.
         
19). The behavior of the function if the argument is omitted is exactly the same as if the context item had been passed as the argument.

If

let $para := 
In a hole in the ground there lived a hobbit.
         
25 is the empty sequence, the empty sequence is returned.

Otherwise, the function returns the result of the

op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
56 accessor as defined in [XQuery and XPath Data Model (XDM) 3.1] (see Section 5.10 node-name Accessor DM31).

Error Conditions

The following errors may be raised when

let $para := 
In a hole in the ground there lived a hobbit.
         
25 is omitted:

  • If the context item is absentDM31, dynamic error [err:XPDY0002]XP31

  • If the context item is not a node, type error [err:XPTY0004]XP31.

Notes

For element and attribute nodes, the name of the node is returned as an

let $para := 
In a hole in the ground there lived a hobbit.
         
36, retaining the prefix, namespace URI, and local part.

For processing instructions, the name of the node is returned as an

let $para := 
In a hole in the ground there lived a hobbit.
         
36 in which the prefix and namespace URI are absentDM31.

For a namespace node, the function returns an empty sequence if the node represents the default namespace; otherwise it returns an

let $para := 
In a hole in the ground there lived a hobbit.
         
36 in which prefix and namespace URI are absentDM31 and the local part is the namespace prefix being bound.

For all other kinds of node, the function returns the empty sequence.

2.2 fn:nilled

Summary

Returns true for an element that is nilled.

Signatures

op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
30()
let $para := 
In a hole in the ground there lived a hobbit.
         
71
op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
63

op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
30(
let $para := 
In a hole in the ground there lived a hobbit.
         
25
let $para := 
In a hole in the ground there lived a hobbit.
         
71
op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
51)
let $para := 
In a hole in the ground there lived a hobbit.
         
71
op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
63

Properties

The zero-argument form of this function is ·deterministic·, ·context-dependent·, and ·focus-dependent·.

The one-argument form of this function is ·deterministic·, ·context-independent·, and ·focus-independent·.

Rules

If the argument is omitted, it defaults to the context item (

let $para := 
In a hole in the ground there lived a hobbit.
         
19). The behavior of the function if the argument is omitted is exactly the same as if the context item had been passed as the argument.

If

let $para := 
In a hole in the ground there lived a hobbit.
         
25 is the empty sequence, the function returns the empty sequence.

Otherwise the function returns the result of the

op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
72 accessor as defined in [XQuery and XPath Data Model (XDM) 3.1] (see Section 5.8 nilled Accessor DM31).

Error Conditions

The following errors may be raised when

let $para := 
In a hole in the ground there lived a hobbit.
         
25 is omitted:

  • If the context item is absentDM31, dynamic error [err:XPDY0002]XP31

  • If the context item is not a node, type error [err:XPTY0004]XP31.

Notes

If

let $para := 
In a hole in the ground there lived a hobbit.
         
25 is not an element node, the function returns the empty sequence.

If

let $para := 
In a hole in the ground there lived a hobbit.
         
25 is an untyped element node, the function returns false.

In practice, the function returns

op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
76 only for an element node that has the attribute
op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
77 and that is successfully validated against a schema that defines the element to be nillable; the detailed rules, however, are defined in [XQuery and XPath Data Model (XDM) 3.1].

2.3 fn:string

Summary

Returns the value of

let $para := 
In a hole in the ground there lived a hobbit.
         
25 represented as an
let $para := 
In a hole in the ground there lived a hobbit.
         
10.

Signatures

let $para := 
In a hole in the ground there lived a hobbit.
         
78()
let $para := 
In a hole in the ground there lived a hobbit.
         
71
let $para := 
In a hole in the ground there lived a hobbit.
         
10

let $para := 
In a hole in the ground there lived a hobbit.
         
78(
let $para := 
In a hole in the ground there lived a hobbit.
         
25
let $para := 
In a hole in the ground there lived a hobbit.
         
71
let $para := 
In a hole in the ground there lived a hobbit.
         
79)
let $para := 
In a hole in the ground there lived a hobbit.
         
71
let $para := 
In a hole in the ground there lived a hobbit.
         
10

Properties

The zero-argument form of this function is ·deterministic·, ·context-dependent·, and ·focus-dependent·.

The one-argument form of this function is ·deterministic·, ·context-independent·, and ·focus-independent·.

Rules

In the zero-argument version of the function,

let $para := 
In a hole in the ground there lived a hobbit.
         
25 defaults to the context item. That is, calling
op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
90 is equivalent to calling
op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
91.

If

let $para := 
In a hole in the ground there lived a hobbit.
         
25 is the empty sequence, the function returns the zero-length string.

If $arg is a node, the function returns the string value of the node, as obtained using the

op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
93 accessor defined in [XQuery and XPath Data Model (XDM) 3.1] (see Section 5.12 string-value Accessor DM31).

If $arg is an atomic value, the function returns the result of the expression

op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
94 (see 19 Casting).

In all other cases, a dynamic error occurs (see below).

Error Conditions

A dynamic error is raised [err:XPDY0002]XP31 by the zero-argument version of the function if the context item is absentDM31.

A type error is raised [err:FOTY0014] if

let $para := 
In a hole in the ground there lived a hobbit.
         
25 is a function item (this includes maps and arrays).

Notes

Every node has a string value, even an element with element-only content (which has no typed value). Moreover, casting an atomic value to a string always succeeds. Functions, maps, and arrays have no string value, so these are the only arguments that satisfy the type signature but cause failure.

Examples

The expression

op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
96 returns
op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
97.

The expression

op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
98 returns
op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
99.

The expression

op:operation(fenceHeight, xs:integer) => op:operation(xs:integer, xs:integer)
00 returns
op:operation(fenceHeight, xs:integer) => op:operation(xs:integer, xs:integer)
01.

The expression

op:operation(fenceHeight, xs:integer) => op:operation(xs:integer, xs:integer)
02 raises error
op:operation(fenceHeight, xs:integer) => op:operation(xs:integer, xs:integer)
03.

The expression

op:operation(fenceHeight, xs:integer) => op:operation(xs:integer, xs:integer)
04 raises error
op:operation(fenceHeight, xs:integer) => op:operation(xs:integer, xs:integer)
05.

The expression

op:operation(fenceHeight, xs:integer) => op:operation(xs:integer, xs:integer)
06 raises error
op:operation(fenceHeight, xs:integer) => op:operation(xs:integer, xs:integer)
05.

let $para := 
In a hole in the ground there lived a hobbit.
         

The expression

op:operation(fenceHeight, xs:integer) => op:operation(xs:integer, xs:integer)
08 returns
op:operation(fenceHeight, xs:integer) => op:operation(xs:integer, xs:integer)
09.

2.4 fn:data

Summary

Returns the result of atomizing a sequence. This process flattens arrays, and replaces nodes by their typed values.

Signatures

op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
36()
let $para := 
In a hole in the ground there lived a hobbit.
         
71
op:operation(fenceHeight, xs:integer) => op:operation(xs:integer, xs:integer)
12

op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
36(
let $para := 
In a hole in the ground there lived a hobbit.
         
25
let $para := 
In a hole in the ground there lived a hobbit.
         
71
op:operation(fenceHeight, xs:integer) => op:operation(xs:integer, xs:integer)
16)
let $para := 
In a hole in the ground there lived a hobbit.
         
71
op:operation(fenceHeight, xs:integer) => op:operation(xs:integer, xs:integer)
12

Properties

The zero-argument form of this function is ·deterministic·, ·context-dependent·, and ·focus-dependent·.

The one-argument form of this function is ·deterministic·, ·context-independent·, and ·focus-independent·.

Rules

If the argument is omitted, it defaults to the context item (

let $para := 
In a hole in the ground there lived a hobbit.
         
19). The behavior of the function if the argument is omitted is exactly the same as if the context item had been passed as the argument.

The result of

op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
36 is the sequence of atomic values produced by applying the following rules to each item in
let $para := 
In a hole in the ground there lived a hobbit.
         
25:

  • If the item is an atomic value, it is appended to the result sequence.

  • If the item is a node, the typed value of the node is appended to the result sequence. The typed value is a sequence of zero or more atomic values: specifically, the result of the

    op:operation(fenceHeight, xs:integer) => op:operation(xs:integer, xs:integer)
    22 accessor as defined in [XQuery and XPath Data Model (XDM) 3.1] (See Section 5.14 typed-value Accessor DM31).

  • If the item is an array, the result of applying

    op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
    36 to each member of the array, in order, is appended to the result sequence.

Error Conditions

A type error is raised [err:FOTY0012] if an item in the sequence

let $para := 
In a hole in the ground there lived a hobbit.
         
25 is a node that does not have a typed value.

A type error is raised [err:FOTY0013] if an item in the sequence

let $para := 
In a hole in the ground there lived a hobbit.
         
25 is a function item other than an array.

A dynamic error is raised if

let $para := 
In a hole in the ground there lived a hobbit.
         
25 is omitted and the context item is absentDM31.

Notes

The process of applying the

op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
36 function to a sequence is referred to as
op:operation(fenceHeight, xs:integer) => op:operation(xs:integer, xs:integer)
28. In many cases an explicit call on
op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
36 is not required, because atomization is invoked implicitly when a node or sequence of nodes is supplied in a context where an atomic value or sequence of atomic values is required.

The result of atomizing an empty sequence is an empty sequence.

The result of atomizing an empty array is an empty sequence.

Examples

The expression

op:operation(fenceHeight, xs:integer) => op:operation(xs:integer, xs:integer)
30 returns
op:operation(fenceHeight, xs:integer) => op:operation(xs:integer, xs:integer)
31.

The expression

op:operation(fenceHeight, xs:integer) => op:operation(xs:integer, xs:integer)
32 returns
op:operation(fenceHeight, xs:integer) => op:operation(xs:integer, xs:integer)
33.

The expression

op:operation(fenceHeight, xs:integer) => op:operation(xs:integer, xs:integer)
34 returns
op:operation(fenceHeight, xs:integer) => op:operation(xs:integer, xs:integer)
35.

let $para := 
In a hole in the ground there lived a hobbit.
         

The expression

op:operation(fenceHeight, xs:integer) => op:operation(xs:integer, xs:integer)
36 returns
op:operation(fenceHeight, xs:integer) => op:operation(xs:integer, xs:integer)
37.

The expression

op:operation(fenceHeight, xs:integer) => op:operation(xs:integer, xs:integer)
38 returns
op:operation(fenceHeight, xs:integer) => op:operation(xs:integer, xs:integer)
39.

The expression

op:operation(fenceHeight, xs:integer) => op:operation(xs:integer, xs:integer)
40 raises error
op:operation(fenceHeight, xs:integer) => op:operation(xs:integer, xs:integer)
41.

2.5 fn:base-uri

Summary

Returns the base URI of a node.

Signatures

op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
38()
let $para := 
In a hole in the ground there lived a hobbit.
         
71
op:operation(fenceHeight, xs:integer) => op:operation(xs:integer, xs:integer)
44

op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
38(
let $para := 
In a hole in the ground there lived a hobbit.
         
25
let $para := 
In a hole in the ground there lived a hobbit.
         
71
op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
51)
let $para := 
In a hole in the ground there lived a hobbit.
         
71
op:operation(fenceHeight, xs:integer) => op:operation(xs:integer, xs:integer)
44

Properties

The zero-argument form of this function is ·deterministic·, ·context-dependent·, and ·focus-dependent·.

The one-argument form of this function is ·deterministic·, ·context-independent·, and ·focus-independent·.

Rules

The zero-argument version of the function returns the base URI of the context node: it is equivalent to calling

op:operation(fenceHeight, xs:integer) => op:operation(xs:integer, xs:integer)
51.

The single-argument version of the function behaves as follows:

  1. If
    let $para := 
    In a hole in the ground there lived a hobbit.
             
    25 is the empty sequence, the function returns the empty sequence.
  2. Otherwise, the function returns the value of the
    op:operation(fenceHeight, xs:integer) => op:operation(xs:integer, xs:integer)
    53 accessor applied to the node
    let $para := 
    In a hole in the ground there lived a hobbit.
             
    25. This accessor is defined, for each kind of node, in the XDM specification (See Section 5.2 base-uri Accessor DM31).

Note:

As explained in XDM, document, element and processing-instruction nodes have a base-uri property which may be empty. The base-uri property for all other node kinds is the empty sequence. The dm:base-uri accessor returns the base-uri property of a node if it exists and is non-empty; otherwise it returns the result of applying the dm:base-uri accessor to its parent, recursively. If the node does not have a parent, or if the recursive ascent up the ancestor chain encounters a parentless node whose base-uri property is empty, the empty sequence is returned. In the case of namespace nodes, however, the result is always an empty sequence — it does not depend on the base URI of the parent element.

See also

op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
08.

Error Conditions

The following errors may be raised when

let $para := 
In a hole in the ground there lived a hobbit.
         
25 is omitted:

  • If the context item is absentDM31, dynamic error [err:XPDY0002]XP31

  • If the context item is not a node, type error [err:XPTY0004]XP31.

2.6 fn:document-uri

Summary

Returns the URI of a resource where a document can be found, if available.

Signatures

op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
41()
let $para := 
In a hole in the ground there lived a hobbit.
         
71
op:operation(fenceHeight, xs:integer) => op:operation(xs:integer, xs:integer)
44

op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
41(
let $para := 
In a hole in the ground there lived a hobbit.
         
25
let $para := 
In a hole in the ground there lived a hobbit.
         
71
op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
51)
let $para := 
In a hole in the ground there lived a hobbit.
         
71
op:operation(fenceHeight, xs:integer) => op:operation(xs:integer, xs:integer)
44

Properties

The zero-argument form of this function is ·deterministic·, ·context-dependent·, and ·focus-dependent·.

The one-argument form of this function is ·deterministic·, ·context-independent·, and ·focus-independent·.

Rules

If the argument is omitted, it defaults to the context item (

let $para := 
In a hole in the ground there lived a hobbit.
         
19). The behavior of the function if the argument is omitted is exactly the same as if the context item had been passed as the argument.

If

let $para := 
In a hole in the ground there lived a hobbit.
         
25 is the empty sequence, the function returns the empty sequence.

If

let $para := 
In a hole in the ground there lived a hobbit.
         
25 is not a document node, the function returns the empty sequence.

Otherwise, the function returns the value of the

op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
42 accessor applied to
let $para := 
In a hole in the ground there lived a hobbit.
         
25, as defined in [XQuery and XPath Data Model (XDM) 3.1] (See Section 6.1.2 Accessors DM31).

Error Conditions

The following errors may be raised when

let $para := 
In a hole in the ground there lived a hobbit.
         
25 is omitted:

  • If the context item is absentDM31, dynamic error [err:XPDY0002]XP31

  • If the context item is not a node, type error [err:XPTY0004]XP31.

Notes

In the case of a document node

op:operation(fenceHeight, xs:integer) => op:operation(xs:integer, xs:integer)
72 returned by the
op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
09 function, or a document node at the root of a tree containing a node returned by the
op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
10 function, it will always be true that either
op:operation(fenceHeight, xs:integer) => op:operation(xs:integer, xs:integer)
75 returns the empty sequence, or that the following expression is true:
op:operation(fenceHeight, xs:integer) => op:operation(xs:integer, xs:integer)
76 is
op:operation(fenceHeight, xs:integer) => op:operation(xs:integer, xs:integer)
72. It is ·implementation-defined· whether this guarantee also holds for document nodes obtained by other means, for example a document node passed as the initial context node of a query or transformation.

3 Errors and diagnostics

3.1 Raising errors

In this document, as well as in [XQuery 3.1: An XML Query Language] and [XML Path Language (XPath) 3.1], the phrase "an error is raised" is used. Raising an error is equivalent to calling the

op:operation(fenceHeight, xs:integer) => op:operation(xs:integer, xs:integer)
78 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 of the error can be inferred from knowledge of the type of the actual arguments to a function, for example with a call such as
op:operation(fenceHeight, xs:integer) => op:operation(xs:integer, xs:integer)
79. Host languages may allow type errors to be reported statically if they are discovered during static analysis.

When function specifications indicate that an error is to be raised, the notation "[error code]". os used to specify an error code. Each error defined in this document is identified by an

let $para := 
In a hole in the ground there lived a hobbit.
         
36 that is in the
let $para := 
In a hole in the ground there lived a hobbit.
         
60 namespace, represented in this document by the
let $para := 
In a hole in the ground there lived a hobbit.
         
61 prefix. It is this
let $para := 
In a hole in the ground there lived a hobbit.
         
36 that is actually passed as an argument to the
op:operation(fenceHeight, xs:integer) => op:operation(xs:integer, xs:integer)
78 function. Calling this function raises an error. For a more detailed treatment of error handing, see Section 2.3.3 Handling Dynamic Errors XP31.

The

op:operation(fenceHeight, xs:integer) => op:operation(xs:integer, xs:integer)
78 function is a general function that may be called as above but may also be called from [XQuery 3.1: An XML Query Language] or [XML Path Language (XPath) 3.1] applications with, for example, an
let $para := 
In a hole in the ground there lived a hobbit.
         
36 argument.

3.1.1 fn:error

Summary

Calling the

op:operation(fenceHeight, xs:integer) => op:operation(xs:integer, xs:integer)
78 function raises an application-defined error.

Signatures

op:operation(fenceHeight, xs:integer) => op:operation(xs:integer, xs:integer)
78()
let $para := 
In a hole in the ground there lived a hobbit.
         
71
op:operation(fenceHeight, xs:integer) => op:operation(xs:integer, xs:integer)
90

op:operation(fenceHeight, xs:integer) => op:operation(xs:integer, xs:integer)
78(
op:operation(fenceHeight, xs:integer) => op:operation(xs:integer, xs:integer)
92
let $para := 
In a hole in the ground there lived a hobbit.
         
71
op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
47)
let $para := 
In a hole in the ground there lived a hobbit.
         
71
op:operation(fenceHeight, xs:integer) => op:operation(xs:integer, xs:integer)
90

op:operation(fenceHeight, xs:integer) => op:operation(xs:integer, xs:integer)
78(
op:operation(fenceHeight, xs:integer) => op:operation(xs:integer, xs:integer)
92
let $para := 
In a hole in the ground there lived a hobbit.
         
71
op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
47,
fn:abs($N * $arg2) le fn:abs($arg1) 
               and fn:compare($N * $arg2, 0) eq fn:compare($arg1, 0).
01
let $para := 
In a hole in the ground there lived a hobbit.
         
71
let $para := 
In a hole in the ground there lived a hobbit.
         
10)
let $para := 
In a hole in the ground there lived a hobbit.
         
71
op:operation(fenceHeight, xs:integer) => op:operation(xs:integer, xs:integer)
90

op:operation(fenceHeight, xs:integer) => op:operation(xs:integer, xs:integer)
78(
op:operation(fenceHeight, xs:integer) => op:operation(xs:integer, xs:integer)
92
let $para := 
In a hole in the ground there lived a hobbit.
         
71
op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
47,
fn:abs($N * $arg2) le fn:abs($arg1) 
               and fn:compare($N * $arg2, 0) eq fn:compare($arg1, 0).
01
let $para := 
In a hole in the ground there lived a hobbit.
         
71
let $para := 
In a hole in the ground there lived a hobbit.
         
10,
fn:abs($N * $arg2) le fn:abs($arg1) 
               and fn:compare($N * $arg2, 0) eq fn:compare($arg1, 0).
13
let $para := 
In a hole in the ground there lived a hobbit.
         
71
op:operation(fenceHeight, xs:integer) => op:operation(xs:integer, xs:integer)
16)
let $para := 
In a hole in the ground there lived a hobbit.
         
71
op:operation(fenceHeight, xs:integer) => op:operation(xs:integer, xs:integer)
90

Properties

This function is ·nondeterministic·, ·context-independent·, and ·focus-independent·.

Rules

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

op:operation(fenceHeight, xs:integer) => op:operation(xs:integer, xs:integer)
78 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 external processing environment. The way in which error information is returned to the external processing environment is ·implementation-dependent·.

There are three pieces of information that may be associated with an error:

  • The

    op:operation(fenceHeight, xs:integer) => op:operation(xs:integer, xs:integer)
    92 is an error code that distinguishes this error from others. It is an
    let $para := 
    In a hole in the ground there lived a hobbit.
             
    36; the namespace URI conventionally identifies the component, subsystem, or authority responsible for defining the meaning of the error code, while the local part identifies the specific error condition. The namespace URI
    let $para := 
    In a hole in the ground there lived a hobbit.
             
    60 is used for errors defined in this specification; other namespace URIs may be used for errors defined by the application.

    If the external processing environment expects the error code to be returned as a URI or a string rather than as an

    let $para := 
    In a hole in the ground there lived a hobbit.
             
    36, then an error code with namespace URI
    fn:abs($N * $arg2) le fn:abs($arg1) 
                   and fn:compare($N * $arg2, 0) eq fn:compare($arg1, 0).
    23 and local part
    fn:abs($N * $arg2) le fn:abs($arg1) 
                   and fn:compare($N * $arg2, 0) eq fn:compare($arg1, 0).
    24 will be returned in the form
    fn:abs($N * $arg2) le fn:abs($arg1) 
                   and fn:compare($N * $arg2, 0) eq fn:compare($arg1, 0).
    25. The namespace URI part of the error code should therefore not include a fragment identifier.

    If no value is supplied for the

    op:operation(fenceHeight, xs:integer) => op:operation(xs:integer, xs:integer)
    92 argument (that is, if the function is called with no arguments or if the first argument is an empty sequence), the effective value of the error code is
    fn:abs($N * $arg2) le fn:abs($arg1) 
                   and fn:compare($N * $arg2, 0) eq fn:compare($arg1, 0).
    27.

  • The

    fn:abs($N * $arg2) le fn:abs($arg1) 
                   and fn:compare($N * $arg2, 0) eq fn:compare($arg1, 0).
    01 is a natural-language description of the error condition.

    If no value is supplied for the

    fn:abs($N * $arg2) le fn:abs($arg1) 
                   and fn:compare($N * $arg2, 0) eq fn:compare($arg1, 0).
    01 argument (that is, if the function is called with less than two arguments), then the effective value of the description is ·implementation-dependent·.

  • The

    fn:abs($N * $arg2) le fn:abs($arg1) 
                   and fn:compare($N * $arg2, 0) eq fn:compare($arg1, 0).
    13 is an arbitrary value used to convey additional information about the error, and may be used in any way the application chooses.

    If no value is supplied for the

    fn:abs($N * $arg2) le fn:abs($arg1) 
                   and fn:compare($N * $arg2, 0) eq fn:compare($arg1, 0).
    13 argument (that is, if the function is called with less than three arguments), then the effective value of the error object is ·implementation-dependent·.

Error Conditions

This function always raises a dynamic error. By default, it raises [err:FOER0000]

Notes

The value of the

fn:abs($N * $arg2) le fn:abs($arg1) 
               and fn:compare($N * $arg2, 0) eq fn:compare($arg1, 0).
01 parameter may need to be localized.

The type "none" is a special type defined in [XQuery 1.0 and XPath 2.0 Formal Semantics] and is not available to the user. It indicates that the function never returns and ensures that it has the correct static type.

Any QName may be used as an error code; there are no reserved names or namespaces. The error is always classified as a dynamic error, even if the error code used is one that is normally used for static errors or type errors.

Examples

The expression

fn:abs($N * $arg2) le fn:abs($arg1) 
               and fn:compare($N * $arg2, 0) eq fn:compare($arg1, 0).
33 raises error
fn:abs($N * $arg2) le fn:abs($arg1) 
               and fn:compare($N * $arg2, 0) eq fn:compare($arg1, 0).
34. (This returns the URI
fn:abs($N * $arg2) le fn:abs($arg1) 
               and fn:compare($N * $arg2, 0) eq fn:compare($arg1, 0).
35 (or the corresponding
let $para := 
In a hole in the ground there lived a hobbit.
         
36) to the external processing environment, unless the error is caught using a try/catch construct in the host language.)

The expression

fn:abs($N * $arg2) le fn:abs($arg1) 
               and fn:compare($N * $arg2, 0) eq fn:compare($arg1, 0).
37 raises error
fn:abs($N * $arg2) le fn:abs($arg1) 
               and fn:compare($N * $arg2, 0) eq fn:compare($arg1, 0).
38. (This returns
fn:abs($N * $arg2) le fn:abs($arg1) 
               and fn:compare($N * $arg2, 0) eq fn:compare($arg1, 0).
39 and the
let $para := 
In a hole in the ground there lived a hobbit.
         
10
fn:abs($N * $arg2) le fn:abs($arg1) 
               and fn:compare($N * $arg2, 0) eq fn:compare($arg1, 0).
41 (or the corresponding
let $para := 
In a hole in the ground there lived a hobbit.
         
36) to the external processing environment, unless the error is caught using a try/catch construct in the host language.)

3.2 Diagnostic tracing

3.2.1 fn:trace

Summary

Provides an execution trace intended to be used in debugging queries.

Signatures

fn:abs($N * $arg2) le fn:abs($arg1) 
               and fn:compare($N * $arg2, 0) eq fn:compare($arg1, 0).
43(
fn:abs($N * $arg2) le fn:abs($arg1) 
               and fn:compare($N * $arg2, 0) eq fn:compare($arg1, 0).
44
let $para := 
In a hole in the ground there lived a hobbit.
         
71
op:operation(fenceHeight, xs:integer) => op:operation(xs:integer, xs:integer)
16)
let $para := 
In a hole in the ground there lived a hobbit.
         
71
op:operation(fenceHeight, xs:integer) => op:operation(xs:integer, xs:integer)
16

fn:abs($N * $arg2) le fn:abs($arg1) 
               and fn:compare($N * $arg2, 0) eq fn:compare($arg1, 0).
43(
fn:abs($N * $arg2) le fn:abs($arg1) 
               and fn:compare($N * $arg2, 0) eq fn:compare($arg1, 0).
44
let $para := 
In a hole in the ground there lived a hobbit.
         
71
op:operation(fenceHeight, xs:integer) => op:operation(xs:integer, xs:integer)
16,
fn:abs($N * $arg2) le fn:abs($arg1) 
               and fn:compare($N * $arg2, 0) eq fn:compare($arg1, 0).
53
let $para := 
In a hole in the ground there lived a hobbit.
         
71
let $para := 
In a hole in the ground there lived a hobbit.
         
10)
let $para := 
In a hole in the ground there lived a hobbit.
         
71
op:operation(fenceHeight, xs:integer) => op:operation(xs:integer, xs:integer)
16

Properties

This function is ·deterministic·, ·context-independent·, and ·focus-independent·.

Rules

The function returns the value of

fn:abs($N * $arg2) le fn:abs($arg1) 
               and fn:compare($N * $arg2, 0) eq fn:compare($arg1, 0).
44, unchanged.

In addition, the values of

fn:abs($N * $arg2) le fn:abs($arg1) 
               and fn:compare($N * $arg2, 0) eq fn:compare($arg1, 0).
44, converted to an
let $para := 
In a hole in the ground there lived a hobbit.
         
10, and
fn:abs($N * $arg2) le fn:abs($arg1) 
               and fn:compare($N * $arg2, 0) eq fn:compare($arg1, 0).
53 (if supplied) may be directed to a trace data set. The destination of the trace output is ·implementation-defined·. The format of the trace output is ·implementation-dependent·. The ordering of output from calls of the
fn:abs($N * $arg2) le fn:abs($arg1) 
               and fn:compare($N * $arg2, 0) eq fn:compare($arg1, 0).
43 function is ·implementation-dependent·.

Notes

Sometimes there is a need to output trace information unrelated to a specific value. In such cases it can be useful to set

fn:abs($N * $arg2) le fn:abs($arg1) 
               and fn:compare($N * $arg2, 0) eq fn:compare($arg1, 0).
44 to an empty string or an empty sequence, and to compute the value of the
fn:abs($N * $arg2) le fn:abs($arg1) 
               and fn:compare($N * $arg2, 0) eq fn:compare($arg1, 0).
53 argument:
fn:abs($N * $arg2) le fn:abs($arg1) 
               and fn:compare($N * $arg2, 0) eq fn:compare($arg1, 0).
65.

Examples

Consider a situation in which a user wants to investigate the actual value passed to a function. Assume that in a particular execution,

fn:abs($N * $arg2) le fn:abs($arg1) 
               and fn:compare($N * $arg2, 0) eq fn:compare($arg1, 0).
66 is an
let $para := 
In a hole in the ground there lived a hobbit.
         
82 with value
fn:abs($N * $arg2) le fn:abs($arg1) 
               and fn:compare($N * $arg2, 0) eq fn:compare($arg1, 0).
68. Writing
fn:abs($N * $arg2) le fn:abs($arg1) 
               and fn:compare($N * $arg2, 0) eq fn:compare($arg1, 0).
69 will put the strings
fn:abs($N * $arg2) le fn:abs($arg1) 
               and fn:compare($N * $arg2, 0) eq fn:compare($arg1, 0).
70 and
fn:abs($N * $arg2) le fn:abs($arg1) 
               and fn:compare($N * $arg2, 0) eq fn:compare($arg1, 0).
71 in the trace data set in implementation dependent order.

4 Functions and operators on numerics

This section specifies arithmetic operators on the numeric datatypes defined in [XML Schema Part 2: Datatypes Second Edition].

4.1 Numeric types

The operators described in this section are defined on the following atomic types. Each type whose name is indented is derived from the type whose name appears nearest above with one less level of indentation.

xs:decimal xs:integerxs:float xs:double 

They also apply to types derived by restriction from the above types.

The type

let $para := 
In a hole in the ground there lived a hobbit.
         
72 is defined as a union type whose member types are (in order)
let $para := 
In a hole in the ground there lived a hobbit.
         
26,
let $para := 
In a hole in the ground there lived a hobbit.
         
83, and
let $para := 
In a hole in the ground there lived a hobbit.
         
82. This type is implicitly imported into the static context, so it can also be used in defining the signature of user-written functions. Apart from the fact that it is implicitly imported, it behaves exactly like a user-defined type with the same definition. This means, for example:

  • If the expected type of a function parameter is given as

    let $para := 
    In a hole in the ground there lived a hobbit.
             
    72, the actual value supplied can be an instance of any of these three types, or any type derived from these three by restriction (this includes the built-in type
    let $para := 
    In a hole in the ground there lived a hobbit.
             
    85, which is derived from
    let $para := 
    In a hole in the ground there lived a hobbit.
             
    82).

  • If the expected type of a function parameter is given as

    let $para := 
    In a hole in the ground there lived a hobbit.
             
    72, and the actual value supplied is
    let $para := 
    In a hole in the ground there lived a hobbit.
             
    00 (or a node whose atomized value is
    let $para := 
    In a hole in the ground there lived a hobbit.
             
    00), then it will be cast to the union type
    let $para := 
    In a hole in the ground there lived a hobbit.
             
    72 using the rules in 19.3.5 Casting to union types. Because the lexical space of
    let $para := 
    In a hole in the ground there lived a hobbit.
             
    26 subsumes the lexical space of the other member types, and
    let $para := 
    In a hole in the ground there lived a hobbit.
             
    26 is listed first, the effect is that if the untyped atomic value is in the lexical space of
    let $para := 
    In a hole in the ground there lived a hobbit.
             
    26, it will be converted to an
    let $para := 
    In a hole in the ground there lived a hobbit.
             
    26, and if not, a dynamic error occurs.

  • When the return type of a function is given as

    let $para := 
    In a hole in the ground there lived a hobbit.
             
    72, the actual value returned will be an instance of one of the three member types (and perhaps also of types derived from these by restriction). The rules for the particular function will specify how the type of the result depends on the values supplied as arguments. In many cases, for the functions in this specification, the result is defined to be the same type as the first argument.

Note:

This specification uses [IEEE 754-2008] arithmetic for

let $para := 
In a hole in the ground there lived a hobbit.
         
83 and
let $para := 
In a hole in the ground there lived a hobbit.
         
26 values. One consequence of this is that some operations result in the value
fn:abs($N * $arg2) le fn:abs($arg1) 
               and fn:compare($N * $arg2, 0) eq fn:compare($arg1, 0).
90 (not-a number), which has the unusual property that it is not equal to itself. Another consequence is that some operations return the value negative zero. This differs from [XML Schema Part 2: Datatypes Second Edition] which defines
fn:abs($N * $arg2) le fn:abs($arg1) 
               and fn:compare($N * $arg2, 0) eq fn:compare($arg1, 0).
90 as being equal to itself and defines only a single zero in the value space. The text accompanying several functions defines behavior for both positive and negative zero inputs and outputs in the interest of alignment with [IEEE 754-2008]. A conformant implementation must respect these semantics. In consequence, the expression
fn:abs($N * $arg2) le fn:abs($arg1) 
               and fn:compare($N * $arg2, 0) eq fn:compare($arg1, 0).
92 (which is actually a unary minus operator applied to an
let $para := 
In a hole in the ground there lived a hobbit.
         
26 value) will always return negative zero: see 4.2.8 op:numeric-unary-minus. As a concession to implementations that rely on implementations of XSD 1.0, however, when casting from string to double the lexical form
fn:abs($N * $arg2) le fn:abs($arg1) 
               and fn:compare($N * $arg2, 0) eq fn:compare($arg1, 0).
94 may be converted to positive zero, though negative zero is recommended.

XML Schema 1.1 introduces support for positive and negative zero as distinct values, and also uses the [IEEE 754-2008] semantics for comparisons involving

fn:abs($N * $arg2) le fn:abs($arg1) 
               and fn:compare($N * $arg2, 0) eq fn:compare($arg1, 0).
90.

4.2 Arithmetic operators on numeric values

The following functions define the semantics of arithmetic operators defined in [XQuery 3.1: An XML Query Language] and [XML Path Language (XPath) 3.1] on these numeric types.

OperatorMeaning
fn:abs($N * $arg2) le fn:abs($arg1) 
               and fn:compare($N * $arg2, 0) eq fn:compare($arg1, 0).
96Addition
fn:abs($N * $arg2) le fn:abs($arg1) 
               and fn:compare($N * $arg2, 0) eq fn:compare($arg1, 0).
97Subtraction
let $para := 
In a hole in the ground there lived a hobbit.
         
69Multiplication
fn:abs($N * $arg2) le fn:abs($arg1) 
               and fn:compare($N * $arg2, 0) eq fn:compare($arg1, 0).
99Division
1º 2º 3º 4º ...
00Integer division
1º 2º 3º 4º ...
01Modulus
1º 2º 3º 4º ...
02Unary plus
1º 2º 3º 4º ...
03Unary minus (negation)

The parameters and return types for the above operators are in most cases declared to be of type

let $para := 
In a hole in the ground there lived a hobbit.
         
72, which permits the basic numeric types:
let $para := 
In a hole in the ground there lived a hobbit.
         
85,
let $para := 
In a hole in the ground there lived a hobbit.
         
82,
let $para := 
In a hole in the ground there lived a hobbit.
         
83 and
let $para := 
In a hole in the ground there lived a hobbit.
         
26, and types derived from them. In general the two-argument functions require that both arguments are of the same primitive type, and they return a value of this same type. The exceptions are
fn:abs($N * $arg2) le fn:abs($arg1) 
               and fn:compare($N * $arg2, 0) eq fn:compare($arg1, 0).
99, which returns an
let $para := 
In a hole in the ground there lived a hobbit.
         
82 if called with two
let $para := 
In a hole in the ground there lived a hobbit.
         
85 operands, and
1º 2º 3º 4º ...
00 which always returns an
let $para := 
In a hole in the ground there lived a hobbit.
         
85.

If the two operands of an arithmetic expression are not of the same type, subtype substitution and numeric type promotion are used to obtain two operands of the same type. Section B.1 Type Promotion XP31 and Section B.2 Operator Mapping XP31 describe the semantics of these operations in detail.

The result type of operations depends on their argument datatypes and is defined in the following table:

OperatorReturns
1º 2º 3º 4º ...
14
let $para := 
In a hole in the ground there lived a hobbit.
         
85 (except for
1º 2º 3º 4º ...
16, which returns
let $para := 
In a hole in the ground there lived a hobbit.
         
82)
1º 2º 3º 4º ...
18
let $para := 
In a hole in the ground there lived a hobbit.
         
82
1º 2º 3º 4º ...
20
let $para := 
In a hole in the ground there lived a hobbit.
         
83
1º 2º 3º 4º ...
22
let $para := 
In a hole in the ground there lived a hobbit.
         
26
1º 2º 3º 4º ...
24
let $para := 
In a hole in the ground there lived a hobbit.
         
85
1º 2º 3º 4º ...
26
let $para := 
In a hole in the ground there lived a hobbit.
         
82
1º 2º 3º 4º ...
28
let $para := 
In a hole in the ground there lived a hobbit.
         
83
1º 2º 3º 4º ...
30
let $para := 
In a hole in the ground there lived a hobbit.
         
26

These rules define any operation on any pair of arithmetic types. Consider the following example:

op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)

For this operation,

1º 2º 3º 4º ...
32 must be converted to
let $para := 
In a hole in the ground there lived a hobbit.
         
26. This can be done, since by the rules above:
1º 2º 3º 4º ...
32 can be substituted for
let $para := 
In a hole in the ground there lived a hobbit.
         
85,
let $para := 
In a hole in the ground there lived a hobbit.
         
85 can be substituted for
let $para := 
In a hole in the ground there lived a hobbit.
         
82,
let $para := 
In a hole in the ground there lived a hobbit.
         
82 can be promoted to
let $para := 
In a hole in the ground there lived a hobbit.
         
26. As far as possible, the promotions should be done in a single step. Specifically, when an
let $para := 
In a hole in the ground there lived a hobbit.
         
82 is promoted to an
let $para := 
In a hole in the ground there lived a hobbit.
         
26, it should not be converted to an
let $para := 
In a hole in the ground there lived a hobbit.
         
83 and then to
let $para := 
In a hole in the ground there lived a hobbit.
         
26, as this risks loss of precision.

As another example, a user may define

1º 2º 3º 4º ...
44 as a derived type of
let $para := 
In a hole in the ground there lived a hobbit.
         
85 with a minimum value of 20 and a maximum value of 100. They may then derive
1º 2º 3º 4º ...
46 using an enumeration to restrict the permitted set of values to, say, 36, 48 and 60.

op:operation(fenceHeight, xs:integer) => op:operation(xs:integer, xs:integer)

1º 2º 3º 4º ...
46 can be substituted for its base type
1º 2º 3º 4º ...
44 and
1º 2º 3º 4º ...
44 can be substituted for its base type
let $para := 
In a hole in the ground there lived a hobbit.
         
85.

The basic rules for addition, subtraction, and multiplication of ordinary numbers are not set out in this specification; they are taken as given. In the case of

let $para := 
In a hole in the ground there lived a hobbit.
         
26 and
let $para := 
In a hole in the ground there lived a hobbit.
         
83 the rules are as defined in [IEEE 754-2008]. The rules for handling division and modulus operations, as well as the rules for handling special values such as infinity and
fn:abs($N * $arg2) le fn:abs($arg1) 
               and fn:compare($N * $arg2, 0) eq fn:compare($arg1, 0).
90, and exception conditions such as overflow and underflow, are described more explicitly since they are not necessarily obvious.

On overflow and underflow situations during arithmetic operations conforming implementations must behave as follows:

  • For

    let $para := 
    In a hole in the ground there lived a hobbit.
             
    83 and
    let $para := 
    In a hole in the ground there lived a hobbit.
             
    26 operations, overflow behavior must be conformant with [IEEE 754-2008]. This specification allows the following options:

    • Raising a dynamic error [err:FOAR0002] via an overflow trap.

    • Returning

      1º 2º 3º 4º ...
      56 or
      1º 2º 3º 4º ...
      57.

    • Returning the largest (positive or negative) non-infinite number.

  • For

    let $para := 
    In a hole in the ground there lived a hobbit.
             
    83 and
    let $para := 
    In a hole in the ground there lived a hobbit.
             
    26 operations, underflow behavior must be conformant with [IEEE 754-2008]. This specification allows the following options:

    • Raising a dynamic error [err:FOAR0002] via an underflow trap.

    • Returning

      1º 2º 3º 4º ...
      60 or
      1º 2º 3º 4º ...
      61 or a denormalized value; where
      1º 2º 3º 4º ...
      62 is the smallest possible
      let $para := 
      In a hole in the ground there lived a hobbit.
               
      83 or
      let $para := 
      In a hole in the ground there lived a hobbit.
               
      26 exponent.

  • For

    let $para := 
    In a hole in the ground there lived a hobbit.
             
    82 operations, overflow behavior must raise a dynamic error [err:FOAR0002]. On underflow,
    1º 2º 3º 4º ...
    66 must be returned.

  • For

    let $para := 
    In a hole in the ground there lived a hobbit.
             
    85 operations, implementations that support limited-precision integer operations must select from the following options:

    • They may choose to always raise a dynamic error [err:FOAR0002].

    • They may provide an ·implementation-defined· mechanism that allows users to choose between raising an error and returning a result that is modulo the largest representable integer value. See [ISO 10967].

The functions

fn:abs($N * $arg2) le fn:abs($arg1) 
               and fn:compare($N * $arg2, 0) eq fn:compare($arg1, 0).
96,
fn:abs($N * $arg2) le fn:abs($arg1) 
               and fn:compare($N * $arg2, 0) eq fn:compare($arg1, 0).
97,
let $para := 
In a hole in the ground there lived a hobbit.
         
69,
fn:abs($N * $arg2) le fn:abs($arg1) 
               and fn:compare($N * $arg2, 0) eq fn:compare($arg1, 0).
99,
1º 2º 3º 4º ...
00 and
1º 2º 3º 4º ...
01 are each defined for pairs of numeric operands, each of which has the same type:
let $para := 
In a hole in the ground there lived a hobbit.
         
85,
let $para := 
In a hole in the ground there lived a hobbit.
         
82,
let $para := 
In a hole in the ground there lived a hobbit.
         
83, or
let $para := 
In a hole in the ground there lived a hobbit.
         
26. The functions
1º 2º 3º 4º ...
02 and
1º 2º 3º 4º ...
03 are defined for a single operand whose type is one of those same numeric types.

For

let $para := 
In a hole in the ground there lived a hobbit.
         
83 and
let $para := 
In a hole in the ground there lived a hobbit.
         
26 arguments, if either argument is
fn:abs($N * $arg2) le fn:abs($arg1) 
               and fn:compare($N * $arg2, 0) eq fn:compare($arg1, 0).
90, the result is
fn:abs($N * $arg2) le fn:abs($arg1) 
               and fn:compare($N * $arg2, 0) eq fn:compare($arg1, 0).
90.

For

let $para := 
In a hole in the ground there lived a hobbit.
         
82 values, let N be the number of digits of precision supported by the implementation, and let M (
1º 2º 3º 4º ...
85) be the minimum limit on the number of digits required for conformance (18 digits for XSD 1.0, 16 digits for XSD 1.1). Then for addition, subtraction, and multiplication operations, the returned result should be accurate to N digits of precision, and for division and modulus operations, the returned result should be accurate to at least M digits of precision.
The actual precision is ·implementation-defined·. If the number of digits in the mathematical result exceeds the number of digits that the implementation retains for that operation, the result is truncated or rounded in an ·implementation-defined· manner.

Note:

This Recommendation does not specify whether

let $para := 
In a hole in the ground there lived a hobbit.
         
82 operations are fixed point or floating point. In an implementation using floating point it is possible for very simple operations to require more digits of precision than are available; for example adding
1º 2º 3º 4º ...
87 to
1º 2º 3º 4º ...
88 requires 200 digits of precision for an accurate representation of the result.

The [IEEE 754-2008] specification also describes handling of two exception conditions called

1º 2º 3º 4º ...
89 and
1º 2º 3º 4º ...
90. The IEEE
1º 2º 3º 4º ...
89 exception is raised not only by a direct attempt to divide by zero, but also by operations such as
1º 2º 3º 4º ...
92. The IEEE
1º 2º 3º 4º ...
90 exception is raised by attempts to call a function with an argument that is outside the function's domain (for example,
1º 2º 3º 4º ...
94 or
1º 2º 3º 4º ...
95). Although IEEE defines these as exceptions, it also defines "default non-stop exception handling" in which the operation returns a defined result, typically positive or negative infinity, or NaN. With this function library, these IEEE exceptions do not cause a dynamic error at the application level; rather they result in the relevant function or operator returning the defined non-error result. The underlying IEEE exception may be notified to the application or to the user by some ·implementation-defined· warning condition, but the observable effect on an application using the functions and operators defined in this specification is simply to return the defined result (typically -INF, +INF, or NaN) with no error.

The [IEEE 754-2008] specification distinguishes two NaN values, a quiet NaN and a signaling NaN. These two values are not distinguishable in the XDM model: the value spaces of

let $para := 
In a hole in the ground there lived a hobbit.
         
83 and
let $para := 
In a hole in the ground there lived a hobbit.
         
26 each include only a single
fn:abs($N * $arg2) le fn:abs($arg1) 
               and fn:compare($N * $arg2, 0) eq fn:compare($arg1, 0).
90 value. This does not prevent the implementation distinguishing them internally, and triggering different ·implementation-defined· warning conditions, but such distinctions do not affect the observable behavior of an application using the functions and operators defined in this specification.

4.2.1 op:numeric-add

Summary

Returns the arithmetic sum of its operands: (

1º 2º 3º 4º ...
99).

Operator Mapping

Defines the semantics of the "+" operator when applied to two numeric values

Signature

fn:abs($N * $arg2) le fn:abs($arg1) 
               and fn:compare($N * $arg2, 0) eq fn:compare($arg1, 0).
96(
let $para := 
In a hole in the ground there lived a hobbit.
         
70
let $para := 
In a hole in the ground there lived a hobbit.
         
71
let $para := 
In a hole in the ground there lived a hobbit.
         
72,
let $para := 
In a hole in the ground there lived a hobbit.
         
73
let $para := 
In a hole in the ground there lived a hobbit.
         
71
let $para := 
In a hole in the ground there lived a hobbit.
         
72)
let $para := 
In a hole in the ground there lived a hobbit.
         
71
let $para := 
In a hole in the ground there lived a hobbit.
         
72

Rules

General rules: see 4.2 Arithmetic operators on numeric values.

Notes

For

let $para := 
In a hole in the ground there lived a hobbit.
         
83 or
let $para := 
In a hole in the ground there lived a hobbit.
         
26 values, if one of the operands is a zero or a finite number and the other is
1º 2º 3º 4º ...
56 or
1º 2º 3º 4º ...
57,
1º 2º 3º 4º ...
56 or
1º 2º 3º 4º ...
57 is returned. If both operands are
1º 2º 3º 4º ...
56,
1º 2º 3º 4º ...
56 is returned. If both operands are
1º 2º 3º 4º ...
57,
1º 2º 3º 4º ...
57 is returned. If one of the operands is
1º 2º 3º 4º ...
56 and the other is
1º 2º 3º 4º ...
57,
fn:abs($N * $arg2) le fn:abs($arg1) 
               and fn:compare($N * $arg2, 0) eq fn:compare($arg1, 0).
90 is returned.

4.2.2 op:numeric-subtract

Summary

Returns the arithmetic difference of its operands: (

Primo Secondo Terzo Quarto Quinto ...
22).

Operator Mapping

Defines the semantics of the "-" operator when applied to two numeric values.

Signature

fn:abs($N * $arg2) le fn:abs($arg1) 
               and fn:compare($N * $arg2, 0) eq fn:compare($arg1, 0).
97(
let $para := 
In a hole in the ground there lived a hobbit.
         
70
let $para := 
In a hole in the ground there lived a hobbit.
         
71
let $para := 
In a hole in the ground there lived a hobbit.
         
72,
let $para := 
In a hole in the ground there lived a hobbit.
         
73
let $para := 
In a hole in the ground there lived a hobbit.
         
71
let $para := 
In a hole in the ground there lived a hobbit.
         
72)
let $para := 
In a hole in the ground there lived a hobbit.
         
71
let $para := 
In a hole in the ground there lived a hobbit.
         
72

Rules

General rules: see 4.2 Arithmetic operators on numeric values.

Notes

For

let $para := 
In a hole in the ground there lived a hobbit.
         
83 or
let $para := 
In a hole in the ground there lived a hobbit.
         
26 values, if one of the operands is a zero or a finite number and the other is
1º 2º 3º 4º ...
56 or
1º 2º 3º 4º ...
57, an infinity of the appropriate sign is returned. If both operands are
1º 2º 3º 4º ...
56 or
1º 2º 3º 4º ...
57,
fn:abs($N * $arg2) le fn:abs($arg1) 
               and fn:compare($N * $arg2, 0) eq fn:compare($arg1, 0).
90 is returned. If one of the operands is
1º 2º 3º 4º ...
56 and the other is
1º 2º 3º 4º ...
57, an infinity of the appropriate sign is returned.

4.2.3 op:numeric-multiply

Summary

Returns the arithmetic product of its operands: (

Primo Secondo Terzo Quarto Quinto ...
41).

Operator Mapping

Defines the semantics of the "*" operator when applied to two numeric values.

Signature

let $para := 
In a hole in the ground there lived a hobbit.
         
69(
let $para := 
In a hole in the ground there lived a hobbit.
         
70
let $para := 
In a hole in the ground there lived a hobbit.
         
71
let $para := 
In a hole in the ground there lived a hobbit.
         
72,
let $para := 
In a hole in the ground there lived a hobbit.
         
73
let $para := 
In a hole in the ground there lived a hobbit.
         
71
let $para := 
In a hole in the ground there lived a hobbit.
         
72)
let $para := 
In a hole in the ground there lived a hobbit.
         
71
let $para := 
In a hole in the ground there lived a hobbit.
         
72

Rules

General rules: see 4.2 Arithmetic operators on numeric values.

Notes

For

let $para := 
In a hole in the ground there lived a hobbit.
         
83 or
let $para := 
In a hole in the ground there lived a hobbit.
         
26 values, if one of the operands is a zero and the other is an infinity,
fn:abs($N * $arg2) le fn:abs($arg1) 
               and fn:compare($N * $arg2, 0) eq fn:compare($arg1, 0).
90 is returned. If one of the operands is a non-zero number and the other is an infinity, an infinity with the appropriate sign is returned.

4.2.4 op:numeric-divide

Summary

Returns the arithmetic quotient of its operands: (

Primo Secondo Terzo Quarto Quinto ...
54).

Operator Mapping

Defines the semantics of the "div" operator when applied to two numeric values.

Signature

fn:abs($N * $arg2) le fn:abs($arg1) 
               and fn:compare($N * $arg2, 0) eq fn:compare($arg1, 0).
99(
let $para := 
In a hole in the ground there lived a hobbit.
         
70
let $para := 
In a hole in the ground there lived a hobbit.
         
71
let $para := 
In a hole in the ground there lived a hobbit.
         
72,
let $para := 
In a hole in the ground there lived a hobbit.
         
73
let $para := 
In a hole in the ground there lived a hobbit.
         
71
let $para := 
In a hole in the ground there lived a hobbit.
         
72)
let $para := 
In a hole in the ground there lived a hobbit.
         
71
let $para := 
In a hole in the ground there lived a hobbit.
         
72

Rules

General rules: see 4.2 Arithmetic operators on numeric values.

As a special case, if the types of both

let $para := 
In a hole in the ground there lived a hobbit.
         
70 and
let $para := 
In a hole in the ground there lived a hobbit.
         
73 are
let $para := 
In a hole in the ground there lived a hobbit.
         
85, then the return type is
let $para := 
In a hole in the ground there lived a hobbit.
         
82.

Error Conditions

A dynamic error is raised [err:FOAR0001] for

let $para := 
In a hole in the ground there lived a hobbit.
         
82 and
let $para := 
In a hole in the ground there lived a hobbit.
         
85 operands, if the divisor is (positive or negative) zero.

Notes

For

let $para := 
In a hole in the ground there lived a hobbit.
         
83 and
let $para := 
In a hole in the ground there lived a hobbit.
         
26 operands, floating point division is performed as specified in [IEEE 754-2008]. A positive number divided by positive zero returns
1º 2º 3º 4º ...
56. A negative number divided by positive zero returns
1º 2º 3º 4º ...
57. Division by negative zero returns
1º 2º 3º 4º ...
57 and
1º 2º 3º 4º ...
56, respectively. Positive or negative zero divided by positive or negative zero returns
fn:abs($N * $arg2) le fn:abs($arg1) 
               and fn:compare($N * $arg2, 0) eq fn:compare($arg1, 0).
90. Also,
1º 2º 3º 4º ...
56 or
1º 2º 3º 4º ...
57 divided by
1º 2º 3º 4º ...
56 or
1º 2º 3º 4º ...
57 returns
fn:abs($N * $arg2) le fn:abs($arg1) 
               and fn:compare($N * $arg2, 0) eq fn:compare($arg1, 0).
90.

4.2.5 op:numeric-integer-divide

Summary

Performs an integer division.

Operator Mapping

Defines the semantics of the "idiv" operator when applied to two numeric values.

Signature

1º 2º 3º 4º ...
00(
let $para := 
In a hole in the ground there lived a hobbit.
         
70
let $para := 
In a hole in the ground there lived a hobbit.
         
71
let $para := 
In a hole in the ground there lived a hobbit.
         
72,
let $para := 
In a hole in the ground there lived a hobbit.
         
73
let $para := 
In a hole in the ground there lived a hobbit.
         
71
let $para := 
In a hole in the ground there lived a hobbit.
         
72)
let $para := 
In a hole in the ground there lived a hobbit.
         
71
let $para := 
In a hole in the ground there lived a hobbit.
         
85

Rules

General rules: see 4.2 Arithmetic operators on numeric values.

If

let $para := 
In a hole in the ground there lived a hobbit.
         
73 is
1º 2º 3º 4º ...
56 or
1º 2º 3º 4º ...
57, and
let $para := 
In a hole in the ground there lived a hobbit.
         
70 is not
1º 2º 3º 4º ...
56 or
1º 2º 3º 4º ...
57, then the result is zero.

Otherwise, subject to limits of precision and overflow/underflow conditions, the result is the largest (furthest from zero)

let $para := 
In a hole in the ground there lived a hobbit.
         
85 value
Primo Secondo Terzo Quarto Quinto ...
98 such that the following expression is true:

fn:abs($N * $arg2) le fn:abs($arg1) 
               and fn:compare($N * $arg2, 0) eq fn:compare($arg1, 0).

Note:

The second term in this condition ensures that the result has the correct sign.

The implementation may adopt a different algorithm provided that it is equivalent to this formulation in all cases where ·implementation-dependent· or ·implementation-defined· behavior does not affect the outcome, for example, the implementation-defined precision of the result of

let $para := 
In a hole in the ground there lived a hobbit.
         
82 division.

Error Conditions

A dynamic error is raised [err:FOAR0001] if the divisor is (positive or negative) zero.

A dynamic error is raised [err:FOAR0002] if either operand is

fn:abs($N * $arg2) le fn:abs($arg1) 
               and fn:compare($N * $arg2, 0) eq fn:compare($arg1, 0).
90 or if
let $para := 
In a hole in the ground there lived a hobbit.
         
70 is
1º 2º 3º 4º ...
56 or
1º 2º 3º 4º ...
57.

Notes

Except in situations involving errors, loss of precision, or overflow/underflow, the result of

declare %public function r:random-sequence($length as xs:integer) as xs:double* {
  r:random-sequence($length, fn:random-number-generator())
};

declare %private function r:random-sequence($length as xs:integer, 
                                            $G as map(xs:string, item())) {
  if ($length eq 0)
  then ()
  else ($G?number, r:random-sequence($length - 1, $G?next()))
};

r:random-sequence(200);
            
04 is the same as
declare %public function r:random-sequence($length as xs:integer) as xs:double* {
  r:random-sequence($length, fn:random-number-generator())
};

declare %private function r:random-sequence($length as xs:integer, 
                                            $G as map(xs:string, item())) {
  if ($length eq 0)
  then ()
  else ($G?number, r:random-sequence($length - 1, $G?next()))
};

r:random-sequence(200);
            
05.

The semantics of this function are different from integer division as defined in programming languages such as Java and C++.

Examples

The expression

declare %public function r:random-sequence($length as xs:integer) as xs:double* {
  r:random-sequence($length, fn:random-number-generator())
};

declare %private function r:random-sequence($length as xs:integer, 
                                            $G as map(xs:string, item())) {
  if ($length eq 0)
  then ()
  else ($G?number, r:random-sequence($length - 1, $G?next()))
};

r:random-sequence(200);
            
06 returns
declare %public function r:random-sequence($length as xs:integer) as xs:double* {
  r:random-sequence($length, fn:random-number-generator())
};

declare %private function r:random-sequence($length as xs:integer, 
                                            $G as map(xs:string, item())) {
  if ($length eq 0)
  then ()
  else ($G?number, r:random-sequence($length - 1, $G?next()))
};

r:random-sequence(200);
            
07.

The expression

declare %public function r:random-sequence($length as xs:integer) as xs:double* {
  r:random-sequence($length, fn:random-number-generator())
};

declare %private function r:random-sequence($length as xs:integer, 
                                            $G as map(xs:string, item())) {
  if ($length eq 0)
  then ()
  else ($G?number, r:random-sequence($length - 1, $G?next()))
};

r:random-sequence(200);
            
08 returns
declare %public function r:random-sequence($length as xs:integer) as xs:double* {
  r:random-sequence($length, fn:random-number-generator())
};

declare %private function r:random-sequence($length as xs:integer, 
                                            $G as map(xs:string, item())) {
  if ($length eq 0)
  then ()
  else ($G?number, r:random-sequence($length - 1, $G?next()))
};

r:random-sequence(200);
            
09.

The expression

declare %public function r:random-sequence($length as xs:integer) as xs:double* {
  r:random-sequence($length, fn:random-number-generator())
};

declare %private function r:random-sequence($length as xs:integer, 
                                            $G as map(xs:string, item())) {
  if ($length eq 0)
  then ()
  else ($G?number, r:random-sequence($length - 1, $G?next()))
};

r:random-sequence(200);
            
10 returns
declare %public function r:random-sequence($length as xs:integer) as xs:double* {
  r:random-sequence($length, fn:random-number-generator())
};

declare %private function r:random-sequence($length as xs:integer, 
                                            $G as map(xs:string, item())) {
  if ($length eq 0)
  then ()
  else ($G?number, r:random-sequence($length - 1, $G?next()))
};

r:random-sequence(200);
            
09.

The expression

declare %public function r:random-sequence($length as xs:integer) as xs:double* {
  r:random-sequence($length, fn:random-number-generator())
};

declare %private function r:random-sequence($length as xs:integer, 
                                            $G as map(xs:string, item())) {
  if ($length eq 0)
  then ()
  else ($G?number, r:random-sequence($length - 1, $G?next()))
};

r:random-sequence(200);
            
12 returns
declare %public function r:random-sequence($length as xs:integer) as xs:double* {
  r:random-sequence($length, fn:random-number-generator())
};

declare %private function r:random-sequence($length as xs:integer, 
                                            $G as map(xs:string, item())) {
  if ($length eq 0)
  then ()
  else ($G?number, r:random-sequence($length - 1, $G?next()))
};

r:random-sequence(200);
            
13.

The expression

declare %public function r:random-sequence($length as xs:integer) as xs:double* {
  r:random-sequence($length, fn:random-number-generator())
};

declare %private function r:random-sequence($length as xs:integer, 
                                            $G as map(xs:string, item())) {
  if ($length eq 0)
  then ()
  else ($G?number, r:random-sequence($length - 1, $G?next()))
};

r:random-sequence(200);
            
14 returns
declare %public function r:random-sequence($length as xs:integer) as xs:double* {
  r:random-sequence($length, fn:random-number-generator())
};

declare %private function r:random-sequence($length as xs:integer, 
                                            $G as map(xs:string, item())) {
  if ($length eq 0)
  then ()
  else ($G?number, r:random-sequence($length - 1, $G?next()))
};

r:random-sequence(200);
            
07.

The expression

declare %public function r:random-sequence($length as xs:integer) as xs:double* {
  r:random-sequence($length, fn:random-number-generator())
};

declare %private function r:random-sequence($length as xs:integer, 
                                            $G as map(xs:string, item())) {
  if ($length eq 0)
  then ()
  else ($G?number, r:random-sequence($length - 1, $G?next()))
};

r:random-sequence(200);
            
16 returns
declare %public function r:random-sequence($length as xs:integer) as xs:double* {
  r:random-sequence($length, fn:random-number-generator())
};

declare %private function r:random-sequence($length as xs:integer, 
                                            $G as map(xs:string, item())) {
  if ($length eq 0)
  then ()
  else ($G?number, r:random-sequence($length - 1, $G?next()))
};

r:random-sequence(200);
            
09.

The expression

declare %public function r:random-sequence($length as xs:integer) as xs:double* {
  r:random-sequence($length, fn:random-number-generator())
};

declare %private function r:random-sequence($length as xs:integer, 
                                            $G as map(xs:string, item())) {
  if ($length eq 0)
  then ()
  else ($G?number, r:random-sequence($length - 1, $G?next()))
};

r:random-sequence(200);
            
18 returns
declare %public function r:random-sequence($length as xs:integer) as xs:double* {
  r:random-sequence($length, fn:random-number-generator())
};

declare %private function r:random-sequence($length as xs:integer, 
                                            $G as map(xs:string, item())) {
  if ($length eq 0)
  then ()
  else ($G?number, r:random-sequence($length - 1, $G?next()))
};

r:random-sequence(200);
            
19.

The expression

declare %public function r:random-sequence($length as xs:integer) as xs:double* {
  r:random-sequence($length, fn:random-number-generator())
};

declare %private function r:random-sequence($length as xs:integer, 
                                            $G as map(xs:string, item())) {
  if ($length eq 0)
  then ()
  else ($G?number, r:random-sequence($length - 1, $G?next()))
};

r:random-sequence(200);
            
20 returns
declare %public function r:random-sequence($length as xs:integer) as xs:double* {
  r:random-sequence($length, fn:random-number-generator())
};

declare %private function r:random-sequence($length as xs:integer, 
                                            $G as map(xs:string, item())) {
  if ($length eq 0)
  then ()
  else ($G?number, r:random-sequence($length - 1, $G?next()))
};

r:random-sequence(200);
            
21.

The expression

declare %public function r:random-sequence($length as xs:integer) as xs:double* {
  r:random-sequence($length, fn:random-number-generator())
};

declare %private function r:random-sequence($length as xs:integer, 
                                            $G as map(xs:string, item())) {
  if ($length eq 0)
  then ()
  else ($G?number, r:random-sequence($length - 1, $G?next()))
};

r:random-sequence(200);
            
22 returns
declare %public function r:random-sequence($length as xs:integer) as xs:double* {
  r:random-sequence($length, fn:random-number-generator())
};

declare %private function r:random-sequence($length as xs:integer, 
                                            $G as map(xs:string, item())) {
  if ($length eq 0)
  then ()
  else ($G?number, r:random-sequence($length - 1, $G?next()))
};

r:random-sequence(200);
            
23.

4.2.6 op:numeric-mod

Summary

Returns the remainder resulting from dividing

let $para := 
In a hole in the ground there lived a hobbit.
         
70, the dividend, by
let $para := 
In a hole in the ground there lived a hobbit.
         
73, the divisor.

Operator Mapping

Defines the semantics of the "mod" operator when applied to two numeric values.

Signature

1º 2º 3º 4º ...
01(
let $para := 
In a hole in the ground there lived a hobbit.
         
70
let $para := 
In a hole in the ground there lived a hobbit.
         
71
let $para := 
In a hole in the ground there lived a hobbit.
         
72,
let $para := 
In a hole in the ground there lived a hobbit.
         
73
let $para := 
In a hole in the ground there lived a hobbit.
         
71
let $para := 
In a hole in the ground there lived a hobbit.
         
72)
let $para := 
In a hole in the ground there lived a hobbit.
         
71
let $para := 
In a hole in the ground there lived a hobbit.
         
72

Rules

General rules: see 4.2 Arithmetic operators on numeric values.

The operation

declare %public function r:random-sequence($length as xs:integer) as xs:double* {
  r:random-sequence($length, fn:random-number-generator())
};

declare %private function r:random-sequence($length as xs:integer, 
                                            $G as map(xs:string, item())) {
  if ($length eq 0)
  then ()
  else ($G?number, r:random-sequence($length - 1, $G?next()))
};

r:random-sequence(200);
            
35 for operands that are
let $para := 
In a hole in the ground there lived a hobbit.
         
85 or
let $para := 
In a hole in the ground there lived a hobbit.
         
82, or types derived from them, produces a result such that
declare %public function r:random-sequence($length as xs:integer) as xs:double* {
  r:random-sequence($length, fn:random-number-generator())
};

declare %private function r:random-sequence($length as xs:integer, 
                                            $G as map(xs:string, item())) {
  if ($length eq 0)
  then ()
  else ($G?number, r:random-sequence($length - 1, $G?next()))
};

r:random-sequence(200);
            
38 is equal to
declare %public function r:random-sequence($length as xs:integer) as xs:double* {
  r:random-sequence($length, fn:random-number-generator())
};

declare %private function r:random-sequence($length as xs:integer, 
                                            $G as map(xs:string, item())) {
  if ($length eq 0)
  then ()
  else ($G?number, r:random-sequence($length - 1, $G?next()))
};

r:random-sequence(200);
            
39 and the magnitude of the result is always less than the magnitude of
declare %public function r:random-sequence($length as xs:integer) as xs:double* {
  r:random-sequence($length, fn:random-number-generator())
};

declare %private function r:random-sequence($length as xs:integer, 
                                            $G as map(xs:string, item())) {
  if ($length eq 0)
  then ()
  else ($G?number, r:random-sequence($length - 1, $G?next()))
};

r:random-sequence(200);
            
40. This identity holds even in the special case that the dividend is the negative integer of largest possible magnitude for its type and the divisor is -1 (the remainder is 0). It follows from this rule that the sign of the result is the sign of the dividend.

For

let $para := 
In a hole in the ground there lived a hobbit.
         
83 and
let $para := 
In a hole in the ground there lived a hobbit.
         
26 operands the following rules apply:

  • If either operand is

    fn:abs($N * $arg2) le fn:abs($arg1) 
                   and fn:compare($N * $arg2, 0) eq fn:compare($arg1, 0).
    90, the result is
    fn:abs($N * $arg2) le fn:abs($arg1) 
                   and fn:compare($N * $arg2, 0) eq fn:compare($arg1, 0).
    90.

  • If the dividend is positive or negative infinity, or the divisor is positive or negative zero (0), or both, the result is

    fn:abs($N * $arg2) le fn:abs($arg1) 
                   and fn:compare($N * $arg2, 0) eq fn:compare($arg1, 0).
    90.

  • If the dividend is finite and the divisor is an infinity, the result equals the dividend.

  • If the dividend is positive or negative zero and the divisor is finite, the result is the same as the dividend.

  • In the remaining cases, where neither positive or negative infinity, nor positive or negative zero, nor

    fn:abs($N * $arg2) le fn:abs($arg1) 
                   and fn:compare($N * $arg2, 0) eq fn:compare($arg1, 0).
    90 is involved, the result obeys
    declare %public function r:random-sequence($length as xs:integer) as xs:double* {
      r:random-sequence($length, fn:random-number-generator())
    };
    
    declare %private function r:random-sequence($length as xs:integer, 
                                                $G as map(xs:string, item())) {
      if ($length eq 0)
      then ()
      else ($G?number, r:random-sequence($length - 1, $G?next()))
    };
    
    r:random-sequence(200);
                
    38 =
    declare %public function r:random-sequence($length as xs:integer) as xs:double* {
      r:random-sequence($length, fn:random-number-generator())
    };
    
    declare %private function r:random-sequence($length as xs:integer, 
                                                $G as map(xs:string, item())) {
      if ($length eq 0)
      then ()
      else ($G?number, r:random-sequence($length - 1, $G?next()))
    };
    
    r:random-sequence(200);
                
    39. Division is truncating division, analogous to integer division, not [IEEE 754-2008] rounding division i.e. additional digits are truncated, not rounded to the required precision.

Error Conditions

A dynamic error is raised [err:FOAR0001] for

let $para := 
In a hole in the ground there lived a hobbit.
         
85 and
let $para := 
In a hole in the ground there lived a hobbit.
         
82 operands, if
let $para := 
In a hole in the ground there lived a hobbit.
         
73 is zero.

Examples

The expression

declare %public function r:random-sequence($length as xs:integer) as xs:double* {
  r:random-sequence($length, fn:random-number-generator())
};

declare %private function r:random-sequence($length as xs:integer, 
                                            $G as map(xs:string, item())) {
  if ($length eq 0)
  then ()
  else ($G?number, r:random-sequence($length - 1, $G?next()))
};

r:random-sequence(200);
            
52 returns
declare %public function r:random-sequence($length as xs:integer) as xs:double* {
  r:random-sequence($length, fn:random-number-generator())
};

declare %private function r:random-sequence($length as xs:integer, 
                                            $G as map(xs:string, item())) {
  if ($length eq 0)
  then ()
  else ($G?number, r:random-sequence($length - 1, $G?next()))
};

r:random-sequence(200);
            
13.

The expression

declare %public function r:random-sequence($length as xs:integer) as xs:double* {
  r:random-sequence($length, fn:random-number-generator())
};

declare %private function r:random-sequence($length as xs:integer, 
                                            $G as map(xs:string, item())) {
  if ($length eq 0)
  then ()
  else ($G?number, r:random-sequence($length - 1, $G?next()))
};

r:random-sequence(200);
            
54 returns
declare %public function r:random-sequence($length as xs:integer) as xs:double* {
  r:random-sequence($length, fn:random-number-generator())
};

declare %private function r:random-sequence($length as xs:integer, 
                                            $G as map(xs:string, item())) {
  if ($length eq 0)
  then ()
  else ($G?number, r:random-sequence($length - 1, $G?next()))
};

r:random-sequence(200);
            
19.

The expression

declare %public function r:random-sequence($length as xs:integer) as xs:double* {
  r:random-sequence($length, fn:random-number-generator())
};

declare %private function r:random-sequence($length as xs:integer, 
                                            $G as map(xs:string, item())) {
  if ($length eq 0)
  then ()
  else ($G?number, r:random-sequence($length - 1, $G?next()))
};

r:random-sequence(200);
            
56 returns
declare %public function r:random-sequence($length as xs:integer) as xs:double* {
  r:random-sequence($length, fn:random-number-generator())
};

declare %private function r:random-sequence($length as xs:integer, 
                                            $G as map(xs:string, item())) {
  if ($length eq 0)
  then ()
  else ($G?number, r:random-sequence($length - 1, $G?next()))
};

r:random-sequence(200);
            
57.

The expression

declare %public function r:random-sequence($length as xs:integer) as xs:double* {
  r:random-sequence($length, fn:random-number-generator())
};

declare %private function r:random-sequence($length as xs:integer, 
                                            $G as map(xs:string, item())) {
  if ($length eq 0)
  then ()
  else ($G?number, r:random-sequence($length - 1, $G?next()))
};

r:random-sequence(200);
            
58 returns
declare %public function r:random-sequence($length as xs:integer) as xs:double* {
  r:random-sequence($length, fn:random-number-generator())
};

declare %private function r:random-sequence($length as xs:integer, 
                                            $G as map(xs:string, item())) {
  if ($length eq 0)
  then ()
  else ($G?number, r:random-sequence($length - 1, $G?next()))
};

r:random-sequence(200);
            
59.

4.2.7 op:numeric-unary-plus

Summary

Returns its operand with the sign unchanged: (

declare %public function r:random-sequence($length as xs:integer) as xs:double* {
  r:random-sequence($length, fn:random-number-generator())
};

declare %private function r:random-sequence($length as xs:integer, 
                                            $G as map(xs:string, item())) {
  if ($length eq 0)
  then ()
  else ($G?number, r:random-sequence($length - 1, $G?next()))
};

r:random-sequence(200);
            
60).

Operator Mapping

Defines the semantics of the unary "+" operator applied to a numeric value.

Signature

1º 2º 3º 4º ...
02(
let $para := 
In a hole in the ground there lived a hobbit.
         
25
let $para := 
In a hole in the ground there lived a hobbit.
         
71
let $para := 
In a hole in the ground there lived a hobbit.
         
72)
let $para := 
In a hole in the ground there lived a hobbit.
         
71
let $para := 
In a hole in the ground there lived a hobbit.
         
72

Rules

General rules: see 4.2 Arithmetic operators on numeric values.

The returned value is equal to

let $para := 
In a hole in the ground there lived a hobbit.
         
25, and is an instance of
let $para := 
In a hole in the ground there lived a hobbit.
         
85,
let $para := 
In a hole in the ground there lived a hobbit.
         
82,
let $para := 
In a hole in the ground there lived a hobbit.
         
26, or
let $para := 
In a hole in the ground there lived a hobbit.
         
83 depending on the type of
let $para := 
In a hole in the ground there lived a hobbit.
         
25.

Notes

Because function conversion rules are applied in the normal way, the unary

declare %public function r:random-sequence($length as xs:integer) as xs:double* {
  r:random-sequence($length, fn:random-number-generator())
};

declare %private function r:random-sequence($length as xs:integer, 
                                            $G as map(xs:string, item())) {
  if ($length eq 0)
  then ()
  else ($G?number, r:random-sequence($length - 1, $G?next()))
};

r:random-sequence(200);
            
73 operator can be used to force conversion of an untyped node to a number: the result of
declare %public function r:random-sequence($length as xs:integer) as xs:double* {
  r:random-sequence($length, fn:random-number-generator())
};

declare %private function r:random-sequence($length as xs:integer, 
                                            $G as map(xs:string, item())) {
  if ($length eq 0)
  then ()
  else ($G?number, r:random-sequence($length - 1, $G?next()))
};

r:random-sequence(200);
            
74 is the same as
declare %public function r:random-sequence($length as xs:integer) as xs:double* {
  r:random-sequence($length, fn:random-number-generator())
};

declare %private function r:random-sequence($length as xs:integer, 
                                            $G as map(xs:string, item())) {
  if ($length eq 0)
  then ()
  else ($G?number, r:random-sequence($length - 1, $G?next()))
};

r:random-sequence(200);
            
75 if the type of
declare %public function r:random-sequence($length as xs:integer) as xs:double* {
  r:random-sequence($length, fn:random-number-generator())
};

declare %private function r:random-sequence($length as xs:integer, 
                                            $G as map(xs:string, item())) {
  if ($length eq 0)
  then ()
  else ($G?number, r:random-sequence($length - 1, $G?next()))
};

r:random-sequence(200);
            
76 is
let $para := 
In a hole in the ground there lived a hobbit.
         
00.

4.2.8 op:numeric-unary-minus

Summary

Returns its operand with the sign reversed: (

declare %public function r:random-sequence($length as xs:integer) as xs:double* {
  r:random-sequence($length, fn:random-number-generator())
};

declare %private function r:random-sequence($length as xs:integer, 
                                            $G as map(xs:string, item())) {
  if ($length eq 0)
  then ()
  else ($G?number, r:random-sequence($length - 1, $G?next()))
};

r:random-sequence(200);
            
78).

Operator Mapping

Defines the semantics of the unary "-" operator when applied to a numeric value.

Signature

1º 2º 3º 4º ...
03(
let $para := 
In a hole in the ground there lived a hobbit.
         
25
let $para := 
In a hole in the ground there lived a hobbit.
         
71
let $para := 
In a hole in the ground there lived a hobbit.
         
72)
let $para := 
In a hole in the ground there lived a hobbit.
         
71
let $para := 
In a hole in the ground there lived a hobbit.
         
72

Rules

General rules: see 4.2 Arithmetic operators on numeric values.

The returned value is an instance of

let $para := 
In a hole in the ground there lived a hobbit.
         
85,
let $para := 
In a hole in the ground there lived a hobbit.
         
82,
let $para := 
In a hole in the ground there lived a hobbit.
         
26, or
let $para := 
In a hole in the ground there lived a hobbit.
         
83 depending on the type of
let $para := 
In a hole in the ground there lived a hobbit.
         
25.

For

let $para := 
In a hole in the ground there lived a hobbit.
         
85 and
let $para := 
In a hole in the ground there lived a hobbit.
         
82 arguments,
declare %public function r:random-sequence($length as xs:integer) as xs:double* {
  r:random-sequence($length, fn:random-number-generator())
};

declare %private function r:random-sequence($length as xs:integer, 
                                            $G as map(xs:string, item())) {
  if ($length eq 0)
  then ()
  else ($G?number, r:random-sequence($length - 1, $G?next()))
};

r:random-sequence(200);
            
19 and
1º 2º 3º 4º ...
66 return
declare %public function r:random-sequence($length as xs:integer) as xs:double* {
  r:random-sequence($length, fn:random-number-generator())
};

declare %private function r:random-sequence($length as xs:integer, 
                                            $G as map(xs:string, item())) {
  if ($length eq 0)
  then ()
  else ($G?number, r:random-sequence($length - 1, $G?next()))
};

r:random-sequence(200);
            
19 and
1º 2º 3º 4º ...
66, respectively. For
let $para := 
In a hole in the ground there lived a hobbit.
         
83 and
let $para := 
In a hole in the ground there lived a hobbit.
         
26 arguments,
fn:abs($N * $arg2) le fn:abs($arg1) 
               and fn:compare($N * $arg2, 0) eq fn:compare($arg1, 0).
90 returns
fn:abs($N * $arg2) le fn:abs($arg1) 
               and fn:compare($N * $arg2, 0) eq fn:compare($arg1, 0).
90,
1º 2º 3º 4º ...
60 returns
let $C := 'http://www.w3.org/2013/collation/UCA?strength=primary'
01 and vice versa.
1º 2º 3º 4º ...
56 returns
1º 2º 3º 4º ...
57.
1º 2º 3º 4º ...
57 returns
1º 2º 3º 4º ...
56.

4.3 Comparison operators on numeric values

This specification defines the following comparison operators on numeric values. Comparisons take two arguments of the same type. If the arguments are of different types, one argument is promoted to the type of the other as described above in 4.2 Arithmetic operators on numeric values. Each comparison operator returns a boolean value. If either, or both, operands are

fn:abs($N * $arg2) le fn:abs($arg1) 
               and fn:compare($N * $arg2, 0) eq fn:compare($arg1, 0).
90,
let $C := 'http://www.w3.org/2013/collation/UCA?strength=primary'
07 is returned.

FunctionMeaning
let $C := 'http://www.w3.org/2013/collation/UCA?strength=primary'
08Returns true if and only if the value of
let $para := 
In a hole in the ground there lived a hobbit.
         
70 is equal to the value of
let $para := 
In a hole in the ground there lived a hobbit.
         
73.
let $C := 'http://www.w3.org/2013/collation/UCA?strength=primary'
11Returns
op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
76 if and only if
let $para := 
In a hole in the ground there lived a hobbit.
         
70 is numerically less than
let $para := 
In a hole in the ground there lived a hobbit.
         
73.
let $C := 'http://www.w3.org/2013/collation/UCA?strength=primary'
15Returns
op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
76 if and only if
let $para := 
In a hole in the ground there lived a hobbit.
         
70 is numerically greater than
let $para := 
In a hole in the ground there lived a hobbit.
         
73.

4.3.1 op:numeric-equal

Summary

Returns true if and only if the value of

let $para := 
In a hole in the ground there lived a hobbit.
         
70 is equal to the value of
let $para := 
In a hole in the ground there lived a hobbit.
         
73.

Operator Mapping

Defines the semantics of the "eq" operator when applied to two numeric values, and is also used in defining the semantics of "ne", "le" and "ge".

Signature

let $C := 'http://www.w3.org/2013/collation/UCA?strength=primary'
08(
let $para := 
In a hole in the ground there lived a hobbit.
         
70
let $para := 
In a hole in the ground there lived a hobbit.
         
71
let $para := 
In a hole in the ground there lived a hobbit.
         
72,
let $para := 
In a hole in the ground there lived a hobbit.
         
73
let $para := 
In a hole in the ground there lived a hobbit.
         
71
let $para := 
In a hole in the ground there lived a hobbit.
         
72)
let $para := 
In a hole in the ground there lived a hobbit.
         
71
op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
32

Rules

General rules: see 4.2 Arithmetic operators on numeric values and 4.3 Comparison operators on numeric values.

For

let $para := 
In a hole in the ground there lived a hobbit.
         
83 and
let $para := 
In a hole in the ground there lived a hobbit.
         
26 values, positive zero and negative zero compare equal.
1º 2º 3º 4º ...
56 equals
1º 2º 3º 4º ...
56, and
1º 2º 3º 4º ...
57 equals
1º 2º 3º 4º ...
57.
fn:abs($N * $arg2) le fn:abs($arg1) 
               and fn:compare($N * $arg2, 0) eq fn:compare($arg1, 0).
90 does not equal itself.

4.3.2 op:numeric-less-than

Summary

Returns

op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
76 if and only if
let $para := 
In a hole in the ground there lived a hobbit.
         
70 is numerically less than
let $para := 
In a hole in the ground there lived a hobbit.
         
73.

Operator Mapping

Defines the semantics of the "lt" operator when applied to two numeric values, and is also used in defining the semantics of "le".

Signature

let $C := 'http://www.w3.org/2013/collation/UCA?strength=primary'
11(
let $para := 
In a hole in the ground there lived a hobbit.
         
70
let $para := 
In a hole in the ground there lived a hobbit.
         
71
let $para := 
In a hole in the ground there lived a hobbit.
         
72,
let $para := 
In a hole in the ground there lived a hobbit.
         
73
let $para := 
In a hole in the ground there lived a hobbit.
         
71
let $para := 
In a hole in the ground there lived a hobbit.
         
72)
let $para := 
In a hole in the ground there lived a hobbit.
         
71
op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
32

Rules

General rules: see 4.2 Arithmetic operators on numeric values and 4.3 Comparison operators on numeric values.

For

let $para := 
In a hole in the ground there lived a hobbit.
         
83 and
let $para := 
In a hole in the ground there lived a hobbit.
         
26 values, positive infinity is greater than all other non-
fn:abs($N * $arg2) le fn:abs($arg1) 
               and fn:compare($N * $arg2, 0) eq fn:compare($arg1, 0).
90 values; negative infinity is less than all other non-
fn:abs($N * $arg2) le fn:abs($arg1) 
               and fn:compare($N * $arg2, 0) eq fn:compare($arg1, 0).
90 values. If
let $para := 
In a hole in the ground there lived a hobbit.
         
70 or
let $para := 
In a hole in the ground there lived a hobbit.
         
73 is
fn:abs($N * $arg2) le fn:abs($arg1) 
               and fn:compare($N * $arg2, 0) eq fn:compare($arg1, 0).
90, the function returns
let $C := 'http://www.w3.org/2013/collation/UCA?strength=primary'
07.

4.3.3 op:numeric-greater-than

Summary

Returns

op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
76 if and only if
let $para := 
In a hole in the ground there lived a hobbit.
         
70 is numerically greater than
let $para := 
In a hole in the ground there lived a hobbit.
         
73.

Operator Mapping

Defines the semantics of the "gt" operator when applied to two numeric values, and is also used in defining the semantics of "ge".

Signature

let $C := 'http://www.w3.org/2013/collation/UCA?strength=primary'
15(
let $para := 
In a hole in the ground there lived a hobbit.
         
70
let $para := 
In a hole in the ground there lived a hobbit.
         
71
let $para := 
In a hole in the ground there lived a hobbit.
         
72,
let $para := 
In a hole in the ground there lived a hobbit.
         
73
let $para := 
In a hole in the ground there lived a hobbit.
         
71
let $para := 
In a hole in the ground there lived a hobbit.
         
72)
let $para := 
In a hole in the ground there lived a hobbit.
         
71
op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
32

Rules

The function call

let $C := 'http://www.w3.org/2013/collation/UCA?strength=primary'
69 is defined to return the same result as
let $C := 'http://www.w3.org/2013/collation/UCA?strength=primary'
70

4.4 Functions on numeric values

The following functions are defined on numeric types. Each function returns a value of the same type as the type of its argument.

  • If the argument is the empty sequence, the empty sequence is returned.

  • For

    let $para := 
    In a hole in the ground there lived a hobbit.
             
    83 and
    let $para := 
    In a hole in the ground there lived a hobbit.
             
    26 arguments, if the argument is "NaN", "NaN" is returned.

  • Except for

    let $C := 'http://www.w3.org/2013/collation/UCA?strength=primary'
    73, for
    let $para := 
    In a hole in the ground there lived a hobbit.
             
    83 and
    let $para := 
    In a hole in the ground there lived a hobbit.
             
    26 arguments, if the argument is positive or negative infinity, positive or negative infinity is returned.

FunctionMeaning
let $C := 'http://www.w3.org/2013/collation/UCA?strength=primary'
73Returns the absolute value of
let $para := 
In a hole in the ground there lived a hobbit.
         
25.
let $C := 'http://www.w3.org/2013/collation/UCA?strength=primary'
78Rounds
let $para := 
In a hole in the ground there lived a hobbit.
         
25 upwards to a whole number.
let $C := 'http://www.w3.org/2013/collation/UCA?strength=primary'
80Rounds
let $para := 
In a hole in the ground there lived a hobbit.
         
25 downwards to a whole number.
let $C := 'http://www.w3.org/2013/collation/UCA?strength=primary'
82Rounds a value to a specified number of decimal places, rounding upwards if two such values are equally near.
let $C := 'http://www.w3.org/2013/collation/UCA?strength=primary'
83Rounds a value to a specified number of decimal places, rounding to make the last digit even if two such values are equally near.

Note:

let $C := 'http://www.w3.org/2013/collation/UCA?strength=primary'
82 and
let $C := 'http://www.w3.org/2013/collation/UCA?strength=primary'
83 produce the same result in all cases except when the argument is exactly midway between two values with the required precision.

Other ways of rounding midway values can be achieved as follows:

  • Towards negative infinity:

    let $C := 'http://www.w3.org/2013/collation/UCA?strength=primary'
    86

  • Away from zero:

    let $C := 'http://www.w3.org/2013/collation/UCA?strength=primary'
    87

  • Towards zero:

    let $C := 'http://www.w3.org/2013/collation/UCA?strength=primary'
    88

4.4.1 fn:abs

Summary

Returns the absolute value of

let $para := 
In a hole in the ground there lived a hobbit.
         
25.

Signature

let $C := 'http://www.w3.org/2013/collation/UCA?strength=primary'
73(
let $para := 
In a hole in the ground there lived a hobbit.
         
25
let $para := 
In a hole in the ground there lived a hobbit.
         
71
let $C := 'http://www.w3.org/2013/collation/UCA?strength=primary'
93)
let $para := 
In a hole in the ground there lived a hobbit.
         
71
let $C := 'http://www.w3.org/2013/collation/UCA?strength=primary'
93

Properties

This function is ·deterministic·, ·context-independent·, and ·focus-independent·.

Rules

General rules: see 4.4 Functions on numeric values.

If

let $para := 
In a hole in the ground there lived a hobbit.
         
25 is negative the function returns
let $C := 'http://www.w3.org/2013/collation/UCA?strength=primary'
97, otherwise it returns
let $para := 
In a hole in the ground there lived a hobbit.
         
25.

For the four types

let $para := 
In a hole in the ground there lived a hobbit.
         
83,
let $para := 
In a hole in the ground there lived a hobbit.
         
26,
let $para := 
In a hole in the ground there lived a hobbit.
         
82 and
let $para := 
In a hole in the ground there lived a hobbit.
         
85, it is guaranteed that if the type of
let $para := 
In a hole in the ground there lived a hobbit.
         
25 is an instance of type T then the result will also be an instance of T. The result may also be an instance of a type derived from one of these four by restriction. For example, if
let $para := 
In a hole in the ground there lived a hobbit.
         
25 is an instance of
let $para := 
In a hole in the ground there lived a hobbit.
         
005 then the value of
let $para := 
In a hole in the ground there lived a hobbit.
         
25 may be returned unchanged.

For

let $para := 
In a hole in the ground there lived a hobbit.
         
83 and
let $para := 
In a hole in the ground there lived a hobbit.
         
26 arguments, if the argument is positive zero or negative zero, then positive zero is returned. If the argument is positive or negative infinity, positive infinity is returned.

Examples

The expression

let $para := 
In a hole in the ground there lived a hobbit.
         
009 returns
let $para := 
In a hole in the ground there lived a hobbit.
         
010.

The expression

let $para := 
In a hole in the ground there lived a hobbit.
         
011 returns
let $para := 
In a hole in the ground there lived a hobbit.
         
010.

4.4.2 fn:ceiling

Summary

Rounds

let $para := 
In a hole in the ground there lived a hobbit.
         
25 upwards to a whole number.

Signature

let $C := 'http://www.w3.org/2013/collation/UCA?strength=primary'
78(
let $para := 
In a hole in the ground there lived a hobbit.
         
25
let $para := 
In a hole in the ground there lived a hobbit.
         
71
let $C := 'http://www.w3.org/2013/collation/UCA?strength=primary'
93)
let $para := 
In a hole in the ground there lived a hobbit.
         
71
let $C := 'http://www.w3.org/2013/collation/UCA?strength=primary'
93

Properties

This function is ·deterministic·, ·context-independent·, and ·focus-independent·.

Rules

General rules: see 4.4 Functions on numeric values.

The function returns the smallest (closest to negative infinity) number with no fractional part that is not less than the value of

let $para := 
In a hole in the ground there lived a hobbit.
         
25.

For the four types

let $para := 
In a hole in the ground there lived a hobbit.
         
83,
let $para := 
In a hole in the ground there lived a hobbit.
         
26,
let $para := 
In a hole in the ground there lived a hobbit.
         
82 and
let $para := 
In a hole in the ground there lived a hobbit.
         
85, it is guaranteed that if the type of
let $para := 
In a hole in the ground there lived a hobbit.
         
25 is an instance of type T then the result will also be an instance of T. The result may also be an instance of a type derived from one of these four by restriction. For example, if
let $para := 
In a hole in the ground there lived a hobbit.
         
25 is an instance of
let $para := 
In a hole in the ground there lived a hobbit.
         
82 then the result may be an instance of
let $para := 
In a hole in the ground there lived a hobbit.
         
85.

For

let $para := 
In a hole in the ground there lived a hobbit.
         
83 and
let $para := 
In a hole in the ground there lived a hobbit.
         
26 arguments, if the argument is positive zero, then positive zero is returned. If the argument is negative zero, then negative zero is returned. If the argument is less than zero and greater than -1, negative zero is returned.

Examples

The expression

let $para := 
In a hole in the ground there lived a hobbit.
         
031 returns
let $para := 
In a hole in the ground there lived a hobbit.
         
032.

The expression

let $para := 
In a hole in the ground there lived a hobbit.
         
033 returns
let $para := 
In a hole in the ground there lived a hobbit.
         
034.

4.4.3 fn:floor

Summary

Rounds

let $para := 
In a hole in the ground there lived a hobbit.
         
25 downwards to a whole number.

Signature

let $C := 'http://www.w3.org/2013/collation/UCA?strength=primary'
80(
let $para := 
In a hole in the ground there lived a hobbit.
         
25
let $para := 
In a hole in the ground there lived a hobbit.
         
71
let $C := 'http://www.w3.org/2013/collation/UCA?strength=primary'
93)
let $para := 
In a hole in the ground there lived a hobbit.
         
71
let $C := 'http://www.w3.org/2013/collation/UCA?strength=primary'
93

Properties

This function is ·deterministic·, ·context-independent·, and ·focus-independent·.

Rules

General rules: see 4.4 Functions on numeric values.

The function returns the largest (closest to positive infinity) number with no fractional part that is not greater than the value of

let $para := 
In a hole in the ground there lived a hobbit.
         
25.

For the four types

let $para := 
In a hole in the ground there lived a hobbit.
         
83,
let $para := 
In a hole in the ground there lived a hobbit.
         
26,
let $para := 
In a hole in the ground there lived a hobbit.
         
82 and
let $para := 
In a hole in the ground there lived a hobbit.
         
85, it is guaranteed that if the type of
let $para := 
In a hole in the ground there lived a hobbit.
         
25 is an instance of type T then the result will also be an instance of T. The result may also be an instance of a type derived from one of these four by restriction. For example, if
let $para := 
In a hole in the ground there lived a hobbit.
         
25 is an instance of
let $para := 
In a hole in the ground there lived a hobbit.
         
82 then the result may be an instance of
let $para := 
In a hole in the ground there lived a hobbit.
         
85.

For

let $para := 
In a hole in the ground there lived a hobbit.
         
83 and
let $para := 
In a hole in the ground there lived a hobbit.
         
26 arguments, if the argument is positive zero, then positive zero is returned. If the argument is negative zero, then negative zero is returned.

Examples

The expression

let $para := 
In a hole in the ground there lived a hobbit.
         
053 returns
let $para := 
In a hole in the ground there lived a hobbit.
         
054.

The expression

let $para := 
In a hole in the ground there lived a hobbit.
         
055 returns
let $para := 
In a hole in the ground there lived a hobbit.
         
056.

4.4.4 fn:round

Summary

Rounds a value to a specified number of decimal places, rounding upwards if two such values are equally near.

Signatures

let $C := 'http://www.w3.org/2013/collation/UCA?strength=primary'
82(
let $para := 
In a hole in the ground there lived a hobbit.
         
25
let $para := 
In a hole in the ground there lived a hobbit.
         
71
let $C := 'http://www.w3.org/2013/collation/UCA?strength=primary'
93)
let $para := 
In a hole in the ground there lived a hobbit.
         
71
let $C := 'http://www.w3.org/2013/collation/UCA?strength=primary'
93

let $C := 'http://www.w3.org/2013/collation/UCA?strength=primary'
82(
let $para := 
In a hole in the ground there lived a hobbit.
         
25
let $para := 
In a hole in the ground there lived a hobbit.
         
71
let $C := 'http://www.w3.org/2013/collation/UCA?strength=primary'
93,
let $para := 
In a hole in the ground there lived a hobbit.
         
067
let $para := 
In a hole in the ground there lived a hobbit.
         
71
let $para := 
In a hole in the ground there lived a hobbit.
         
85)
let $para := 
In a hole in the ground there lived a hobbit.
         
71
let $C := 'http://www.w3.org/2013/collation/UCA?strength=primary'
93

Properties

This function is ·deterministic·, ·context-independent·, and ·focus-independent·.

Rules

General rules: see 4.4 Functions on numeric values.

The function returns the nearest (that is, numerically closest) value to

let $para := 
In a hole in the ground there lived a hobbit.
         
25 that is a multiple of ten to the power of minus
let $para := 
In a hole in the ground there lived a hobbit.
         
067. If two such values are equally near (for example, if the fractional part in
let $para := 
In a hole in the ground there lived a hobbit.
         
25 is exactly .5), the function returns the one that is closest to positive infinity.

For the four types

let $para := 
In a hole in the ground there lived a hobbit.
         
83,
let $para := 
In a hole in the ground there lived a hobbit.
         
26,
let $para := 
In a hole in the ground there lived a hobbit.
         
82 and
let $para := 
In a hole in the ground there lived a hobbit.
         
85, it is guaranteed that if the type of
let $para := 
In a hole in the ground there lived a hobbit.
         
25 is an instance of type T then the result will also be an instance of T. The result may also be an instance of a type derived from one of these four by restriction. For example, if
let $para := 
In a hole in the ground there lived a hobbit.
         
25 is an instance of
let $para := 
In a hole in the ground there lived a hobbit.
         
82 and
let $para := 
In a hole in the ground there lived a hobbit.
         
067 is less than one, then the result may be an instance of
let $para := 
In a hole in the ground there lived a hobbit.
         
85.

The single-argument version of this function produces the same result as the two-argument version with

let $para := 
In a hole in the ground there lived a hobbit.
         
084 (that is, it rounds to a whole number).

When

let $para := 
In a hole in the ground there lived a hobbit.
         
25 is of type
let $para := 
In a hole in the ground there lived a hobbit.
         
83 and
let $para := 
In a hole in the ground there lived a hobbit.
         
26:

  1. If

    let $para := 
    In a hole in the ground there lived a hobbit.
             
    25 is NaN, positive or negative zero, or positive or negative infinity, then the result is the same as the argument.

  2. For other values, the argument is cast to

    let $para := 
    In a hole in the ground there lived a hobbit.
             
    82 using an implementation of
    let $para := 
    In a hole in the ground there lived a hobbit.
             
    82 that imposes no limits on the number of digits that can be represented. The function is applied to this
    let $para := 
    In a hole in the ground there lived a hobbit.
             
    82 value, and the resulting
    let $para := 
    In a hole in the ground there lived a hobbit.
             
    82 is cast back to
    let $para := 
    In a hole in the ground there lived a hobbit.
             
    83 or
    let $para := 
    In a hole in the ground there lived a hobbit.
             
    26 as appropriate to form the function result. If the resulting
    let $para := 
    In a hole in the ground there lived a hobbit.
             
    82 value is zero, then positive or negative zero is returned according to the sign of
    let $para := 
    In a hole in the ground there lived a hobbit.
             
    25.

Notes

This function is typically used with a non-zero

let $para := 
In a hole in the ground there lived a hobbit.
         
067 in financial applications where the argument is of type
let $para := 
In a hole in the ground there lived a hobbit.
         
82. For arguments of type
let $para := 
In a hole in the ground there lived a hobbit.
         
83 and
let $para := 
In a hole in the ground there lived a hobbit.
         
26 the results may be counter-intuitive. For example, consider
let $para := 
In a hole in the ground there lived a hobbit.
         
101. The result is not 35.43, as might be expected, but 35.42. This is because the
let $para := 
In a hole in the ground there lived a hobbit.
         
26 written as 35.425e0 has an exact value equal to 35.42499999999..., which is closer to 35.42 than to 35.43.

Examples

The expression

let $para := 
In a hole in the ground there lived a hobbit.
         
103 returns
let $para := 
In a hole in the ground there lived a hobbit.
         
104.

The expression

let $para := 
In a hole in the ground there lived a hobbit.
         
105 returns
let $para := 
In a hole in the ground there lived a hobbit.
         
106.

The expression

let $para := 
In a hole in the ground there lived a hobbit.
         
107 returns
let $para := 
In a hole in the ground there lived a hobbit.
         
108. (Not the possible alternative,
let $para := 
In a hole in the ground there lived a hobbit.
         
109).

The expression

let $para := 
In a hole in the ground there lived a hobbit.
         
110 returns
let $para := 
In a hole in the ground there lived a hobbit.
         
111.

The expression

let $para := 
In a hole in the ground there lived a hobbit.
         
112 returns
let $para := 
In a hole in the ground there lived a hobbit.
         
113.

The expression

let $para := 
In a hole in the ground there lived a hobbit.
         
114 returns
let $para := 
In a hole in the ground there lived a hobbit.
         
115.

4.4.5 fn:round-half-to-even

Summary

Rounds a value to a specified number of decimal places, rounding to make the last digit even if two such values are equally near.

Signatures

let $C := 'http://www.w3.org/2013/collation/UCA?strength=primary'
83(
let $para := 
In a hole in the ground there lived a hobbit.
         
25
let $para := 
In a hole in the ground there lived a hobbit.
         
71
let $C := 'http://www.w3.org/2013/collation/UCA?strength=primary'
93)
let $para := 
In a hole in the ground there lived a hobbit.
         
71
let $C := 'http://www.w3.org/2013/collation/UCA?strength=primary'
93

let $C := 'http://www.w3.org/2013/collation/UCA?strength=primary'
83(
let $para := 
In a hole in the ground there lived a hobbit.
         
25
let $para := 
In a hole in the ground there lived a hobbit.
         
71
let $C := 'http://www.w3.org/2013/collation/UCA?strength=primary'
93,
let $para := 
In a hole in the ground there lived a hobbit.
         
067
let $para := 
In a hole in the ground there lived a hobbit.
         
71
let $para := 
In a hole in the ground there lived a hobbit.
         
85)
let $para := 
In a hole in the ground there lived a hobbit.
         
71
let $C := 'http://www.w3.org/2013/collation/UCA?strength=primary'
93

Properties

This function is ·deterministic·, ·context-independent·, and ·focus-independent·.

Rules

General rules: see 4.4 Functions on numeric values.

The function returns the nearest (that is, numerically closest) value to

let $para := 
In a hole in the ground there lived a hobbit.
         
25 that is a multiple of ten to the power of minus
let $para := 
In a hole in the ground there lived a hobbit.
         
067. If two such values are equally near (e.g. if the fractional part in
let $para := 
In a hole in the ground there lived a hobbit.
         
25 is exactly .500...), the function returns the one whose least significant digit is even.

For the four types

let $para := 
In a hole in the ground there lived a hobbit.
         
83,
let $para := 
In a hole in the ground there lived a hobbit.
         
26,
let $para := 
In a hole in the ground there lived a hobbit.
         
82 and
let $para := 
In a hole in the ground there lived a hobbit.
         
85, it is guaranteed that if the type of
let $para := 
In a hole in the ground there lived a hobbit.
         
25 is an instance of type T then the result will also be an instance of T. The result may also be an instance of a type derived from one of these four by restriction. For example, if
let $para := 
In a hole in the ground there lived a hobbit.
         
25 is an instance of
let $para := 
In a hole in the ground there lived a hobbit.
         
82 and
let $para := 
In a hole in the ground there lived a hobbit.
         
067 is less than one, then the result may be an instance of
let $para := 
In a hole in the ground there lived a hobbit.
         
85.

The first signature of this function produces the same result as the second signature with

let $para := 
In a hole in the ground there lived a hobbit.
         
084.

For arguments of type

let $para := 
In a hole in the ground there lived a hobbit.
         
83 and
let $para := 
In a hole in the ground there lived a hobbit.
         
26:

  1. If the argument is

    fn:abs($N * $arg2) le fn:abs($arg1) 
                   and fn:compare($N * $arg2, 0) eq fn:compare($arg1, 0).
    90, positive or negative zero, or positive or negative infinity, then the result is the same as the argument.

  2. In all other cases, the argument is cast to

    let $para := 
    In a hole in the ground there lived a hobbit.
             
    82 using an implementation of xs:decimal that imposes no limits on the number of digits that can be represented. The function is applied to this
    let $para := 
    In a hole in the ground there lived a hobbit.
             
    82 value, and the resulting
    let $para := 
    In a hole in the ground there lived a hobbit.
             
    82 is cast back to
    let $para := 
    In a hole in the ground there lived a hobbit.
             
    83 or
    let $para := 
    In a hole in the ground there lived a hobbit.
             
    26 as appropriate to form the function result. If the resulting
    let $para := 
    In a hole in the ground there lived a hobbit.
             
    82 value is zero, then positive or negative zero is returned according to the sign of the original argument.

Notes

This function is typically used in financial applications where the argument is of type

let $para := 
In a hole in the ground there lived a hobbit.
         
82. For arguments of type
let $para := 
In a hole in the ground there lived a hobbit.
         
83 and
let $para := 
In a hole in the ground there lived a hobbit.
         
26 the results may be counter-intuitive. For example, consider
let $para := 
In a hole in the ground there lived a hobbit.
         
156. The result is not 150.02 as might be expected, but 150.01. This is because the conversion of the
let $para := 
In a hole in the ground there lived a hobbit.
         
83 value represented by the literal 150.015 to an
let $para := 
In a hole in the ground there lived a hobbit.
         
82 produces the
let $para := 
In a hole in the ground there lived a hobbit.
         
82 value 150.014999389..., which is closer to 150.01 than to 150.02.

Examples

The expression

let $para := 
In a hole in the ground there lived a hobbit.
         
160 returns
1º 2º 3º 4º ...
66.

The expression

let $para := 
In a hole in the ground there lived a hobbit.
         
162 returns
let $para := 
In a hole in the ground there lived a hobbit.
         
106.

The expression

let $para := 
In a hole in the ground there lived a hobbit.
         
164 returns
let $para := 
In a hole in the ground there lived a hobbit.
         
106.

The expression

let $para := 
In a hole in the ground there lived a hobbit.
         
166 returns
let $para := 
In a hole in the ground there lived a hobbit.
         
167.

The expression

let $para := 
In a hole in the ground there lived a hobbit.
         
168 returns
let $para := 
In a hole in the ground there lived a hobbit.
         
169.

The expression

let $para := 
In a hole in the ground there lived a hobbit.
         
170 returns
let $para := 
In a hole in the ground there lived a hobbit.
         
171.

4.5 Parsing numbers

It is possible to convert strings to values of type

let $para := 
In a hole in the ground there lived a hobbit.
         
85,
let $para := 
In a hole in the ground there lived a hobbit.
         
83,
let $para := 
In a hole in the ground there lived a hobbit.
         
82, or
let $para := 
In a hole in the ground there lived a hobbit.
         
26 using the constructor functions described in 18 Constructor functions or using
let $para := 
In a hole in the ground there lived a hobbit.
         
176 expressions as described in 19 Casting.

In addition the

let $para := 
In a hole in the ground there lived a hobbit.
         
177 function is available to convert strings to values of type
let $para := 
In a hole in the ground there lived a hobbit.
         
26. It differs from the
let $para := 
In a hole in the ground there lived a hobbit.
         
26 constructor function in that any value outside the lexical space of the
let $para := 
In a hole in the ground there lived a hobbit.
         
26 datatype is converted to the
let $para := 
In a hole in the ground there lived a hobbit.
         
26 value
fn:abs($N * $arg2) le fn:abs($arg1) 
               and fn:compare($N * $arg2, 0) eq fn:compare($arg1, 0).
90.

FunctionMeaning
let $para := 
In a hole in the ground there lived a hobbit.
         
177Returns the value indicated by
let $para := 
In a hole in the ground there lived a hobbit.
         
25 or, if
let $para := 
In a hole in the ground there lived a hobbit.
         
25 is not specified, the context item after atomization, converted to an
let $para := 
In a hole in the ground there lived a hobbit.
         
26.

4.5.1 fn:number

Summary

Returns the value indicated by

let $para := 
In a hole in the ground there lived a hobbit.
         
25 or, if
let $para := 
In a hole in the ground there lived a hobbit.
         
25 is not specified, the context item after atomization, converted to an
let $para := 
In a hole in the ground there lived a hobbit.
         
26.

Signatures

let $para := 
In a hole in the ground there lived a hobbit.
         
177()
let $para := 
In a hole in the ground there lived a hobbit.
         
71
let $para := 
In a hole in the ground there lived a hobbit.
         
26

let $para := 
In a hole in the ground there lived a hobbit.
         
177(
let $para := 
In a hole in the ground there lived a hobbit.
         
25
let $para := 
In a hole in the ground there lived a hobbit.
         
71
let $para := 
In a hole in the ground there lived a hobbit.
         
196)
let $para := 
In a hole in the ground there lived a hobbit.
         
71
let $para := 
In a hole in the ground there lived a hobbit.
         
26

Properties

The zero-argument form of this function is ·deterministic·, ·context-dependent·, and ·focus-dependent·.

The one-argument form of this function is ·deterministic·, ·context-independent·, and ·focus-independent·.

Rules

Calling the zero-argument version of the function is defined to give the same result as calling the single-argument version with the context item (

let $para := 
In a hole in the ground there lived a hobbit.
         
19). That is,
let $para := 
In a hole in the ground there lived a hobbit.
         
200 is equivalent to
let $para := 
In a hole in the ground there lived a hobbit.
         
201, as defined by the rules that follow.

If

let $para := 
In a hole in the ground there lived a hobbit.
         
25 is the empty sequence or if
let $para := 
In a hole in the ground there lived a hobbit.
         
25 cannot be converted to an
let $para := 
In a hole in the ground there lived a hobbit.
         
26, the
let $para := 
In a hole in the ground there lived a hobbit.
         
26 value
fn:abs($N * $arg2) le fn:abs($arg1) 
               and fn:compare($N * $arg2, 0) eq fn:compare($arg1, 0).
90 is returned.

Otherwise,

let $para := 
In a hole in the ground there lived a hobbit.
         
25 is converted to an
let $para := 
In a hole in the ground there lived a hobbit.
         
26 following the rules of 19.1.2.2 Casting to xs:double. If the conversion to
let $para := 
In a hole in the ground there lived a hobbit.
         
26 fails, the
let $para := 
In a hole in the ground there lived a hobbit.
         
26 value
fn:abs($N * $arg2) le fn:abs($arg1) 
               and fn:compare($N * $arg2, 0) eq fn:compare($arg1, 0).
90 is returned.

Error Conditions

A dynamic error is raised [err:XPDY0002]XP31 if

let $para := 
In a hole in the ground there lived a hobbit.
         
25 is omitted and the context item is absentDM31.

As a consequence of the rules given above, a type error occurs if the context item cannot be atomized, or if the result of atomizing the context item is a sequence containing more than one atomic value.

Notes

XSD 1.1 allows the string

let $para := 
In a hole in the ground there lived a hobbit.
         
27 as a representation of positive infinity; XSD 1.0 does not. It is ·implementation-defined· whether XSD 1.1 is supported.

Generally

let $para := 
In a hole in the ground there lived a hobbit.
         
177 returns
fn:abs($N * $arg2) le fn:abs($arg1) 
               and fn:compare($N * $arg2, 0) eq fn:compare($arg1, 0).
90 rather than raising a dynamic error if the argument cannot be converted to
let $para := 
In a hole in the ground there lived a hobbit.
         
26. 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.

Examples

The expression

let $para := 
In a hole in the ground there lived a hobbit.
         
217 returns
let $para := 
In a hole in the ground there lived a hobbit.
         
218.

The expression

let $para := 
In a hole in the ground there lived a hobbit.
         
219 returns
let $para := 
In a hole in the ground there lived a hobbit.
         
220.

Assume that the context item is the

let $para := 
In a hole in the ground there lived a hobbit.
         
10 value "
let $para := 
In a hole in the ground there lived a hobbit.
         
222". Then
let $para := 
In a hole in the ground there lived a hobbit.
         
200 returns
let $para := 
In a hole in the ground there lived a hobbit.
         
224.

4.6 Formatting integers

FunctionMeaning
let $para := 
In a hole in the ground there lived a hobbit.
         
225Formats an integer according to a given picture string, using the conventions of a given natural language if specified.

4.6.1 fn:format-integer

Summary

Formats an integer according to a given picture string, using the conventions of a given natural language if specified.

Signatures

let $para := 
In a hole in the ground there lived a hobbit.
         
225(
fn:abs($N * $arg2) le fn:abs($arg1) 
               and fn:compare($N * $arg2, 0) eq fn:compare($arg1, 0).
44
let $para := 
In a hole in the ground there lived a hobbit.
         
71
let $para := 
In a hole in the ground there lived a hobbit.
         
229,
let $para := 
In a hole in the ground there lived a hobbit.
         
230
let $para := 
In a hole in the ground there lived a hobbit.
         
71
let $para := 
In a hole in the ground there lived a hobbit.
         
10)
let $para := 
In a hole in the ground there lived a hobbit.
         
71
let $para := 
In a hole in the ground there lived a hobbit.
         
10

let $para := 
In a hole in the ground there lived a hobbit.
         
225(
fn:abs($N * $arg2) le fn:abs($arg1) 
               and fn:compare($N * $arg2, 0) eq fn:compare($arg1, 0).
44
let $para := 
In a hole in the ground there lived a hobbit.
         
71
let $para := 
In a hole in the ground there lived a hobbit.
         
229,
let $para := 
In a hole in the ground there lived a hobbit.
         
230
let $para := 
In a hole in the ground there lived a hobbit.
         
71
let $para := 
In a hole in the ground there lived a hobbit.
         
10,
let $para := 
In a hole in the ground there lived a hobbit.
         
242
let $para := 
In a hole in the ground there lived a hobbit.
         
71
let $para := 
In a hole in the ground there lived a hobbit.
         
244)
let $para := 
In a hole in the ground there lived a hobbit.
         
71
let $para := 
In a hole in the ground there lived a hobbit.
         
10

Properties

The two-argument form of this function is ·deterministic·, ·context-dependent·, and ·focus-independent·. It depends on default language.

The three-argument form of this function is ·deterministic·, ·context-independent·, and ·focus-independent·.

Rules

If

fn:abs($N * $arg2) le fn:abs($arg1) 
               and fn:compare($N * $arg2, 0) eq fn:compare($arg1, 0).
44 is an empty sequence, the function returns a zero-length string.

In all other cases, the

let $para := 
In a hole in the ground there lived a hobbit.
         
230 argument describes the format in which
fn:abs($N * $arg2) le fn:abs($arg1) 
               and fn:compare($N * $arg2, 0) eq fn:compare($arg1, 0).
44 is output.

The rules that follow describe how non-negative numbers are output. If the value of

fn:abs($N * $arg2) le fn:abs($arg1) 
               and fn:compare($N * $arg2, 0) eq fn:compare($arg1, 0).
44 is negative, the rules below are applied to the absolute value of
fn:abs($N * $arg2) le fn:abs($arg1) 
               and fn:compare($N * $arg2, 0) eq fn:compare($arg1, 0).
44, and a minus sign is prepended to the result.

The value of

let $para := 
In a hole in the ground there lived a hobbit.
         
230 consists of a primary format token, optionally followed by a format modifier. The primary format token is always present and must not be zero-length. If the string contains one or more semicolons then everything that precedes the last semicolon is taken as the primary format token and everything that follows is taken as the format modifier; if the string contains no semicolon then the entire picture is taken as the primary format token, and the format modifier is taken to be absent (which is equivalent to supplying a zero-length string).

The primary format token is classified as one of the following:

  1. A decimal-digit-pattern made up of optional-digit-signs, mandatory-digit-signs, and grouping-separator-signs.

    • The optional-digit-sign is the character "#".

    • A mandatory-digit-sign is a ·character· in Unicode category Nd. All mandatory-digit-signs within the format token must be from the same digit family, where a digit family is a sequence of ten consecutive characters in Unicode category Nd, having digit values 0 through 9. Within the format token, these digits are interchangeable: a three-digit number may thus be indicated equivalently by

      let $para := 
      In a hole in the ground there lived a hobbit.
               
      253,
      let $para := 
      In a hole in the ground there lived a hobbit.
               
      254, or
      let $para := 
      In a hole in the ground there lived a hobbit.
               
      255.

    • a grouping-separator-sign is a non-alphanumeric character, that is a ·character· whose Unicode category is other than Nd, Nl, No, Lu, Ll, Lt, Lm or Lo.

    If the primary format token contains at least one Unicode digit then it is taken as a decimal digit pattern, and in this case it must match the regular expression

    let $para := 
    In a hole in the ground there lived a hobbit.
             
    256. If it contains a digit but does not match this pattern, a dynamic error is raised [err:FODF1310].

    Note:

    If a semicolon is to be used as a grouping separator, then the primary format token as a whole must be followed by another semicolon, to ensure that the grouping separator is not mistaken as a separator between the primary format token and the format modifier.

    There must be at least one mandatory-digit-sign. There may be zero or more optional-digit-signs, and (if present) these must precede all mandatory-digit-signs. There may be zero or more grouping-separator-signs. A grouping-separator-sign must not appear at the start or end of the decimal-digit-pattern, nor adjacent to another grouping-separator-sign.

    The corresponding output format is a decimal number, using this digit family, with at least as many digits as there are mandatory-digit-signs in the format token. Thus, a format token

    declare %public function r:random-sequence($length as xs:integer) as xs:double* {
      r:random-sequence($length, fn:random-number-generator())
    };
    
    declare %private function r:random-sequence($length as xs:integer, 
                                                $G as map(xs:string, item())) {
      if ($length eq 0)
      then ()
      else ($G?number, r:random-sequence($length - 1, $G?next()))
    };
    
    r:random-sequence(200);
                
    13 generates the sequence
    let $para := 
    In a hole in the ground there lived a hobbit.
             
    258, and a format token
    let $para := 
    In a hole in the ground there lived a hobbit.
             
    259 (or equivalently,
    let $para := 
    In a hole in the ground there lived a hobbit.
             
    260 or
    let $para := 
    In a hole in the ground there lived a hobbit.
             
    261) generates the sequence
    let $para := 
    In a hole in the ground there lived a hobbit.
             
    262. A format token of
    let $para := 
    In a hole in the ground there lived a hobbit.
             
    263 (Arabic-Indic digit one) generates the sequence
    let $para := 
    In a hole in the ground there lived a hobbit.
             
    264 then
    let $para := 
    In a hole in the ground there lived a hobbit.
             
    265 then
    let $para := 
    In a hole in the ground there lived a hobbit.
             
    266 ...

    The grouping-separator-signs are handled as follows:

    1. The position of grouping separators within the format token, counting backwards from the last digit, indicates the position of grouping separators to appear within the formatted number, and the character used as the grouping-separator-sign within the format token indicates the character to be used as the corresponding grouping separator in the formatted number.

    2. More specifically, the position of a grouping separator is the number of optional-digit-signs and mandatory-digit-signs appearing between the grouping separator and the right-hand end of the primary format token.

    3. Grouping separators are defined to be regular if the following conditions apply:

      1. There is at least one grouping separator.

      2. Every grouping separator is the same character (call it C).

      3. There is a positive integer G (the grouping size) such that:

        1. The position of every grouping separator is an integer multiple of G, and

        2. Every positive integer multiple of G that is less than the number of optional-digit-signs and mandatory-digit-signs in the primary format token is the position of a grouping separator.

    4. The grouping separator template is a (possibly infinite) set of (position, character) pairs.

    5. If grouping separators are regular, then the grouping separator template contains one pair of the form

      let $para := 
      In a hole in the ground there lived a hobbit.
               
      267 for every positive integer n where G is the grouping size and C is the grouping character.

    6. Otherwise (when grouping separators are not regular), the grouping separator template contains one pair of the form

      let $para := 
      In a hole in the ground there lived a hobbit.
               
      268 for every grouping separator found in the primary formatting token, where C is the grouping separator character and P is its position.

    7. Note:

      If there are no grouping separators, then the grouping separator template is an empty set.

    The number is formatted as follows:

    1. Let S1 be the result of formatting the supplied number in decimal notation as if by casting it to

      let $para := 
      In a hole in the ground there lived a hobbit.
               
      10.

    2. Let S2 be the result of padding S1 on the left with as many leading zeroes as are needed to ensure that it contains at least as many digits as the number of mandatory-digit-signs in the primary format token.

    3. Let S3 be the result of replacing all decimal digits (0-9) in S2 with the corresponding digits from the selected digit family.

    4. Let S4 be the result of inserting grouping separators into S3: for every (position P, character C) pair in the grouping separator template where P is less than the number of digits in S3, insert character C into S3 at position P, counting from the right-hand end.

    5. Let S5 be the result of converting S4 into ordinal form, if an ordinal modifier is present, as described below.

    6. The result of the function is then S5.

  2. The format token

    let $para := 
    In a hole in the ground there lived a hobbit.
             
    51, which generates the sequence
    let $para := 
    In a hole in the ground there lived a hobbit.
             
    271.

  3. The format token

    declare %public function r:random-sequence($length as xs:integer) as xs:double* {
      r:random-sequence($length, fn:random-number-generator())
    };
    
    declare %private function r:random-sequence($length as xs:integer, 
                                                $G as map(xs:string, item())) {
      if ($length eq 0)
      then ()
      else ($G?number, r:random-sequence($length - 1, $G?next()))
    };
    
    r:random-sequence(200);
                
    39, which generates the sequence
    let $para := 
    In a hole in the ground there lived a hobbit.
             
    273.

  4. The format token

    let $para := 
    In a hole in the ground there lived a hobbit.
             
    274, which generates the sequence
    let $para := 
    In a hole in the ground there lived a hobbit.
             
    275.

  5. The format token

    let $para := 
    In a hole in the ground there lived a hobbit.
             
    276, which generates the sequence
    let $para := 
    In a hole in the ground there lived a hobbit.
             
    277.

  6. The format token

    let $para := 
    In a hole in the ground there lived a hobbit.
             
    278, which generates numbers written as lower-case words, for example in English,
    let $para := 
    In a hole in the ground there lived a hobbit.
             
    279

  7. The format token

    let $para := 
    In a hole in the ground there lived a hobbit.
             
    280, which generates numbers written as upper-case words, for example in English,
    let $para := 
    In a hole in the ground there lived a hobbit.
             
    281

  8. The format token

    let $para := 
    In a hole in the ground there lived a hobbit.
             
    282, which generates numbers written as title-case words, for example in English,
    let $para := 
    In a hole in the ground there lived a hobbit.
             
    283

  9. Any other format token, which indicates a numbering sequence in which that token represents the number 1 (one) (but see the note below). It is ·implementation-defined· which numbering sequences, additional to those listed above, are supported. If an implementation does not support a numbering sequence represented by the given token, it must use a format token of

    declare %public function r:random-sequence($length as xs:integer) as xs:double* {
      r:random-sequence($length, fn:random-number-generator())
    };
    
    declare %private function r:random-sequence($length as xs:integer, 
                                                $G as map(xs:string, item())) {
      if ($length eq 0)
      then ()
      else ($G?number, r:random-sequence($length - 1, $G?next()))
    };
    
    r:random-sequence(200);
                
    13.

    Note:

    In some traditional numbering sequences additional signs are added to denote that the letters should be interpreted as numbers; these are not included in the format token. An example (see also the example below) is classical Greek where a dexia keraia (x0374, ʹ) and sometimes an aristeri keraia (x0375, ͵) is added.

For all format tokens other than a decimal-digit-pattern, there may be ·implementation-defined· lower and upper bounds on the range of numbers that can be formatted using this format token; indeed, for some numbering sequences there may be intrinsic limits. For example, the format token

let $para := 
In a hole in the ground there lived a hobbit.
         
285 (circled digit one, ①) has a range imposed by the Unicode character repertoire — zero to 20 in Unicode versions prior to 3.2, or zero to 50 in subsequent versions. For the numbering sequences described above any upper bound imposed by the implementation must not be less than 1000 (one thousand) and any lower bound must not be greater than 1. Numbers that fall outside this range must be formatted using the format token
declare %public function r:random-sequence($length as xs:integer) as xs:double* {
  r:random-sequence($length, fn:random-number-generator())
};

declare %private function r:random-sequence($length as xs:integer, 
                                            $G as map(xs:string, item())) {
  if ($length eq 0)
  then ()
  else ($G?number, r:random-sequence($length - 1, $G?next()))
};

r:random-sequence(200);
            
13.

The above expansions of numbering sequences for format tokens such as

declare %public function r:random-sequence($length as xs:integer) as xs:double* {
  r:random-sequence($length, fn:random-number-generator())
};

declare %private function r:random-sequence($length as xs:integer, 
                                            $G as map(xs:string, item())) {
  if ($length eq 0)
  then ()
  else ($G?number, r:random-sequence($length - 1, $G?next()))
};

r:random-sequence(200);
            
39 and
let $para := 
In a hole in the ground there lived a hobbit.
         
274 are indicative but not prescriptive. There are various conventions in use for how alphabetic sequences continue when the alphabet is exhausted, and differing conventions for how roman numerals are written (for example,
let $para := 
In a hole in the ground there lived a hobbit.
         
289 versus
let $para := 
In a hole in the ground there lived a hobbit.
         
290 as the representation of the number 4). Sometimes alphabetic sequences are used that omit letters such as
let $para := 
In a hole in the ground there lived a hobbit.
         
274 and
let $para := 
In a hole in the ground there lived a hobbit.
         
292. This specification does not prescribe the detail of any sequence other than those sequences consisting entirely of decimal digits.

Many numbering sequences are language-sensitive. This applies especially to the sequence selected by the tokens

let $para := 
In a hole in the ground there lived a hobbit.
         
278,
let $para := 
In a hole in the ground there lived a hobbit.
         
280 and
let $para := 
In a hole in the ground there lived a hobbit.
         
282. It also applies to other sequences, for example different languages using the Cyrillic alphabet use different sequences of characters, each starting with the letter #x410 (Cyrillic capital letter A). In such cases, the
let $para := 
In a hole in the ground there lived a hobbit.
         
242 argument specifies which language's conventions are to be used. If the argument is specified, the value should be either an empty sequence or a value that would be valid for the
let $para := 
In a hole in the ground there lived a hobbit.
         
297 attribute (see [Extensible Markup Language (XML) 1.0 (Fifth Edition)]). Note that this permits the identification of sublanguages based on country codes (from ISO 3166-1) as well as identification of dialects and regions within a country.

The set of languages for which numbering is supported is ·implementation-defined·. If the

let $para := 
In a hole in the ground there lived a hobbit.
         
242 argument is absent, or is set to an empty sequence, or is invalid, or is not a language supported by the implementation, then the number is formatted using the default language from the dynamic context.

The format modifier must be a string that matches the regular expression

let $para := 
In a hole in the ground there lived a hobbit.
         
299. That is, if it is present it must consist of one or more of the following, in order:

  • either

    let $para := 
    In a hole in the ground there lived a hobbit.
             
    300 or
    let $para := 
    In a hole in the ground there lived a hobbit.
             
    292, optionally followed by a sequence of characters enclosed between parentheses, to indicate cardinal or ordinal numbering respectively, the default being cardinal numbering

  • either

    declare %public function r:random-sequence($length as xs:integer) as xs:double* {
      r:random-sequence($length, fn:random-number-generator())
    };
    
    declare %private function r:random-sequence($length as xs:integer, 
                                                $G as map(xs:string, item())) {
      if ($length eq 0)
      then ()
      else ($G?number, r:random-sequence($length - 1, $G?next()))
    };
    
    r:random-sequence(200);
                
    39 or
    let $para := 
    In a hole in the ground there lived a hobbit.
             
    303, to indicate alphabetic or traditional numbering respectively, the default being ·implementation-defined·.

If the

let $para := 
In a hole in the ground there lived a hobbit.
         
292 modifier is present, this indicates a request to output ordinal numbers rather than cardinal numbers. For example, in English, when used with the format token
declare %public function r:random-sequence($length as xs:integer) as xs:double* {
  r:random-sequence($length, fn:random-number-generator())
};

declare %private function r:random-sequence($length as xs:integer, 
                                            $G as map(xs:string, item())) {
  if ($length eq 0)
  then ()
  else ($G?number, r:random-sequence($length - 1, $G?next()))
};

r:random-sequence(200);
            
13, this outputs the sequence
let $para := 
In a hole in the ground there lived a hobbit.
         
306, and when used with the format token
let $para := 
In a hole in the ground there lived a hobbit.
         
278 outputs the sequence
let $para := 
In a hole in the ground there lived a hobbit.
         
308.

The string of characters between the parentheses, if present, is used to select between other possible variations of cardinal or ordinal numbering sequences. The interpretation of this string is ·implementation-defined·. No error occurs if the implementation does not define any interpretation for the defined string.

It is ·implementation-defined· what combinations of values of the format token, the language, and the cardinal/ordinal modifier are supported. If ordinal numbering is not supported for the combination of the format token, the language, and the string appearing in parentheses, the request is ignored and cardinal numbers are generated instead.

The use of the

declare %public function r:random-sequence($length as xs:integer) as xs:double* {
  r:random-sequence($length, fn:random-number-generator())
};

declare %private function r:random-sequence($length as xs:integer, 
                                            $G as map(xs:string, item())) {
  if ($length eq 0)
  then ()
  else ($G?number, r:random-sequence($length - 1, $G?next()))
};

r:random-sequence(200);
            
39 or
let $para := 
In a hole in the ground there lived a hobbit.
         
303 modifier disambiguates between numbering sequences that use letters. In many languages there are two commonly used numbering sequences that use letters. One numbering sequence assigns numeric values to letters in alphabetic sequence, and the other assigns numeric values to each letter in some other manner traditional in that language. In English, these would correspond to the numbering sequences specified by the format tokens
declare %public function r:random-sequence($length as xs:integer) as xs:double* {
  r:random-sequence($length, fn:random-number-generator())
};

declare %private function r:random-sequence($length as xs:integer, 
                                            $G as map(xs:string, item())) {
  if ($length eq 0)
  then ()
  else ($G?number, r:random-sequence($length - 1, $G?next()))
};

r:random-sequence(200);
            
39 and
let $para := 
In a hole in the ground there lived a hobbit.
         
274. In some languages, the first member of each sequence is the same, and so the format token alone would be ambiguous. In the absence of the
declare %public function r:random-sequence($length as xs:integer) as xs:double* {
  r:random-sequence($length, fn:random-number-generator())
};

declare %private function r:random-sequence($length as xs:integer, 
                                            $G as map(xs:string, item())) {
  if ($length eq 0)
  then ()
  else ($G?number, r:random-sequence($length - 1, $G?next()))
};

r:random-sequence(200);
            
39 or
let $para := 
In a hole in the ground there lived a hobbit.
         
303 modifier, the default is ·implementation-defined·.

Error Conditions

A dynamic error is raised [err:FODF1310] if the format token is invalid, that is, if it violates any mandatory rules (indicated by an emphasized must or required keyword in the above rules). For example, the error is raised if the primary format token contains a digit but does not match the required regular expression.

Notes

  1. Note the careful distinction between conditions that are errors and conditions where fallback occurs. The principle is that an error in the syntax of the format picture will be reported by all processors, while a construct that is recognized by some implementations but not others will never result in an error, but will instead cause a fallback representation of the integer to be used.

  2. The following notes apply when a decimal-digit-pattern is used:

    1. If grouping-separator-signs appear at regular intervals within the format token, then the sequence is extrapolated to the left, so grouping separators will be used in the formatted number at every multiple of N. For example, if the format token is

      let $para := 
      In a hole in the ground there lived a hobbit.
               
      315 then the number one million will be formatted as
      let $para := 
      In a hole in the ground there lived a hobbit.
               
      316, while the number fifteen will be formatted as
      let $para := 
      In a hole in the ground there lived a hobbit.
               
      317.

    2. The only purpose of optional-digit-signs is to mark the position of grouping-separator-signs. For example, if the format token is

      let $para := 
      In a hole in the ground there lived a hobbit.
               
      318 then the number one million will be formatted as
      let $para := 
      In a hole in the ground there lived a hobbit.
               
      316, while the number fifteen will be formatted as
      let $para := 
      In a hole in the ground there lived a hobbit.
               
      222. A grouping separator is included in the formatted number only if there is a digit to its left, which will only be the case if either (a) the number is large enough to require that digit, or (b) the number of mandatory-digit-signs in the format token requires insignificant leading zeros to be present.

    3. Grouping separators are not designed for effects such as formatting a US telephone number as

      let $para := 
      In a hole in the ground there lived a hobbit.
               
      321. In general they are not suitable for such purposes because (a) only single characters are allowed, and (b) they cannot appear at the beginning or end of the number.

    4. Numbers will never be truncated. Given the decimal-digit-pattern

      let $para := 
      In a hole in the ground there lived a hobbit.
               
      259, the number three hundred will be output as
      let $para := 
      In a hole in the ground there lived a hobbit.
               
      323, despite the absence of any optional-digit-sign.

  3. The following notes apply when ordinal numbering is selected using the

    let $para := 
    In a hole in the ground there lived a hobbit.
             
    292 modifier.

    In some languages, the form of numbers (especially ordinal numbers) varies depending on the grammatical context: they may have different genders and may decline with the noun that they qualify. In such cases the string appearing in parentheses after the letter

    let $para := 
    In a hole in the ground there lived a hobbit.
             
    300 or
    let $para := 
    In a hole in the ground there lived a hobbit.
             
    292 may be used to indicate the variation of the cardinal or ordinal number required.

    The way in which the variation is indicated will depend on the conventions of the language.

    For inflected languages that vary the ending of the word, the approach recommended in the previous version of this specification was to indicate the required ending, preceded by a hyphen: for example in German, appropriate values might be

    let $para := 
    In a hole in the ground there lived a hobbit.
             
    327,
    let $para := 
    In a hole in the ground there lived a hobbit.
             
    328,
    let $para := 
    In a hole in the ground there lived a hobbit.
             
    329,
    let $para := 
    In a hole in the ground there lived a hobbit.
             
    330.

    Another approach, which might usefully be adopted by an implementation based on the open-source ICU localization library [ICU], or any other library making use of the Unicode Common Locale Data Repository [Unicode CLDR], is to allow the value in parentheses to be the name of a registered numbering rule set for the language in question, conventionally prefixed with a percent sign: for example,

    let $para := 
    In a hole in the ground there lived a hobbit.
             
    331, or
    let $para := 
    In a hole in the ground there lived a hobbit.
             
    332.

Examples

The expression

let $para := 
In a hole in the ground there lived a hobbit.
         
333 returns
let $para := 
In a hole in the ground there lived a hobbit.
         
334.

let $para := 
In a hole in the ground there lived a hobbit.
         
335 might return
let $para := 
In a hole in the ground there lived a hobbit.
         
336

Ordinal numbering in Italian: The specification

let $para := 
In a hole in the ground there lived a hobbit.
         
337 with
let $para := 
In a hole in the ground there lived a hobbit.
         
242 equal to
let $para := 
In a hole in the ground there lived a hobbit.
         
339, if supported, should produce the sequence:

1º 2º 3º 4º ...

The specification

let $para := 
In a hole in the ground there lived a hobbit.
         
340 with
let $para := 
In a hole in the ground there lived a hobbit.
         
242 equal to
let $para := 
In a hole in the ground there lived a hobbit.
         
339, if supported, should produce the sequence:

Primo Secondo Terzo Quarto Quinto ...

The expression

let $para := 
In a hole in the ground there lived a hobbit.
         
343 returns
let $para := 
In a hole in the ground there lived a hobbit.
         
344.

let $para := 
In a hole in the ground there lived a hobbit.
         
345 might return
let $para := 
In a hole in the ground there lived a hobbit.
         
346

The expression

let $para := 
In a hole in the ground there lived a hobbit.
         
347 returns
let $para := 
In a hole in the ground there lived a hobbit.
         
348.

The expression

let $para := 
In a hole in the ground there lived a hobbit.
         
349 returns
let $para := 
In a hole in the ground there lived a hobbit.
         
350.

The expression

let $para := 
In a hole in the ground there lived a hobbit.
         
351 returns
let $para := 
In a hole in the ground there lived a hobbit.
         
352.

4.7 Formatting numbers

This section defines a function for formatting decimal and floating point numbers.

FunctionMeaning
let $para := 
In a hole in the ground there lived a hobbit.
         
353Returns a string containing a number formatted according to a given picture string, taking account of decimal formats specified in the static context.

Note:

This function can be used to format any numeric quantity, including an integer. For integers, however, the

let $para := 
In a hole in the ground there lived a hobbit.
         
225 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.

4.7.1 Defining a decimal format

Decimal formats are defined in the static context, and the way they are defined is therefore outside the scope of this specification. XSLT and XQuery both provide custom syntax for creating a decimal format.

The static context provides a set of decimal formats. One of the decimal formats is unnamed, the others (if any) are identified by a QName. There is always an unnamed decimal format available, but its contents are ·implementation-defined·.

Each decimal format provides a set of named properties, described in the following table:

NameTypeUsage (non-normative)
let $para := 
In a hole in the ground there lived a hobbit.
         
355A single ·character·Defines the character used to represent the decimal point (typically ".") both in the picture string and in the formatted number.
let $para := 
In a hole in the ground there lived a hobbit.
         
356A single ·character·Defines the character used to separate groups of digits (typically ",") both in the picture string and in the formatted number.
let $para := 
In a hole in the ground there lived a hobbit.
         
357A single ·character·Defines the character used to separate the mantissa from the exponent in scientific notation (typically "e") both in the picture string and in the formatted number.
let $para := 
In a hole in the ground there lived a hobbit.
         
358A ·string·Defines the string used to represent the value positive or negative infinity in the formatted number (typically "Infinity")
let $para := 
In a hole in the ground there lived a hobbit.
         
359A single ·character·Defines the character used as a minus sign in the formatted number if there is no subpicture for formatting negative numbers (typically "-", x2D)
fn:abs($N * $arg2) le fn:abs($arg1) 
               and fn:compare($N * $arg2, 0) eq fn:compare($arg1, 0).
90A ·string·Defines the string used to represent the value
fn:abs($N * $arg2) le fn:abs($arg1) 
               and fn:compare($N * $arg2, 0) eq fn:compare($arg1, 0).
90 in the formatted number
let $para := 
In a hole in the ground there lived a hobbit.
         
362A single ·character·Defines the character used as a percent sign (typically "%") both in the picture string and in the formatted number
let $para := 
In a hole in the ground there lived a hobbit.
         
363A single ·character·Defines the character used as a per-mille sign (typically "‰", x2030) both in the picture string and in the formatted number
let $para := 
In a hole in the ground there lived a hobbit.
         
364A single ·character·, which must be a character in Unicode category Nd with decimal digit value 0 (zero)Defines the characters used in the picture string to represent a mandatory digit: for example, if the zero-digit is "0" then any of the digits "0" to "9" may be used (interchangeably) in the picture string to represent a mandatory digit, and in the formatted number the characters "0" to "9" will be used to represent the digits zero to nine.
let $para := 
In a hole in the ground there lived a hobbit.
         
365A single ·character·Defines the character used in the picture string to represent an optional digit (typically "#")
let $para := 
In a hole in the ground there lived a hobbit.
         
366A single ·character·Defines the character used in the picture string to separate the positive and negative subpictures (typically ";")

Note:

A phrase such as "The minus-signXP31 character" is to be read as "the character assigned to the minus-signXP31 property in the relevant decimal format within the static context".

[Definition] The decimal digit family of a decimal format is the sequence of ten digits with consecutive Unicode ·codepoints· starting with the character that is the value of the zero-digitXP31 property.

[Definition] The optional digit character is the character that is the value of the digitXP31 property.

For any named or unnamed decimal format, the properties representing characters used in a ·picture string· must have distinct values. These properties are decimal-separatorXP31 , grouping-separatorXP31, exponent-separatorXP31, percentXP31, per-milleXP31, digitXP31, and pattern-separatorXP31. Furthermore, none of these properties may be equal to any ·character· in the ·decimal digit family·.

4.7.2 fn:format-number

Summary

Returns a string containing a number formatted according to a given picture string, taking account of decimal formats specified in the static context.

Signatures

let $para := 
In a hole in the ground there lived a hobbit.
         
353(
fn:abs($N * $arg2) le fn:abs($arg1) 
               and fn:compare($N * $arg2, 0) eq fn:compare($arg1, 0).
44
let $para := 
In a hole in the ground there lived a hobbit.
         
71
let $C := 'http://www.w3.org/2013/collation/UCA?strength=primary'
93,
let $para := 
In a hole in the ground there lived a hobbit.
         
230
let $para := 
In a hole in the ground there lived a hobbit.
         
71
let $para := 
In a hole in the ground there lived a hobbit.
         
10)
let $para := 
In a hole in the ground there lived a hobbit.
         
71
let $para := 
In a hole in the ground there lived a hobbit.
         
10

let $para := 
In a hole in the ground there lived a hobbit.
         
353(
fn:abs($N * $arg2) le fn:abs($arg1) 
               and fn:compare($N * $arg2, 0) eq fn:compare($arg1, 0).
44
let $para := 
In a hole in the ground there lived a hobbit.
         
71
let $C := 'http://www.w3.org/2013/collation/UCA?strength=primary'
93,
let $para := 
In a hole in the ground there lived a hobbit.
         
230
let $para := 
In a hole in the ground there lived a hobbit.
         
71
let $para := 
In a hole in the ground there lived a hobbit.
         
10,
let $para := 
In a hole in the ground there lived a hobbit.
         
383
let $para := 
In a hole in the ground there lived a hobbit.
         
71
let $para := 
In a hole in the ground there lived a hobbit.
         
244)
let $para := 
In a hole in the ground there lived a hobbit.
         
71
let $para := 
In a hole in the ground there lived a hobbit.
         
10

Properties

The two-argument form of this function is ·deterministic·, ·context-independent·, and ·focus-independent·.

The three-argument form of this function is ·deterministic·, ·context-dependent·, and ·focus-independent·. It depends on decimal formats, and namespaces.

Rules

The effect of the two-argument form of the function is equivalent to calling the three-argument form with an empty sequence as the value of the third argument.

The function formats

fn:abs($N * $arg2) le fn:abs($arg1) 
               and fn:compare($N * $arg2, 0) eq fn:compare($arg1, 0).
44 as a string using the ·picture string· specified by the
let $para := 
In a hole in the ground there lived a hobbit.
         
230 argument and the decimal-format named by the
let $para := 
In a hole in the ground there lived a hobbit.
         
383 argument, or the unnamed decimal-format, if there is no
let $para := 
In a hole in the ground there lived a hobbit.
         
383 argument. The syntax of the picture string is described in 4.7.3 Syntax of the picture string.

The

fn:abs($N * $arg2) le fn:abs($arg1) 
               and fn:compare($N * $arg2, 0) eq fn:compare($arg1, 0).
44 argument may be of any numeric data type (
let $para := 
In a hole in the ground there lived a hobbit.
         
26,
let $para := 
In a hole in the ground there lived a hobbit.
         
83,
let $para := 
In a hole in the ground there lived a hobbit.
         
82, or their subtypes including
let $para := 
In a hole in the ground there lived a hobbit.
         
85). Note that if an
let $para := 
In a hole in the ground there lived a hobbit.
         
82 is supplied, it is not automatically promoted to an
let $para := 
In a hole in the ground there lived a hobbit.
         
26, as such promotion can involve a loss of precision.

If the supplied value of the

fn:abs($N * $arg2) le fn:abs($arg1) 
               and fn:compare($N * $arg2, 0) eq fn:compare($arg1, 0).
44 argument is an empty sequence, the function behaves as if the supplied value were the
let $para := 
In a hole in the ground there lived a hobbit.
         
26 value
fn:abs($N * $arg2) le fn:abs($arg1) 
               and fn:compare($N * $arg2, 0) eq fn:compare($arg1, 0).
90.

The value of

let $para := 
In a hole in the ground there lived a hobbit.
         
383, if present and non-empty, must be a string which after removal of leading and trailing whitespace is in the form of an
let $para := 
In a hole in the ground there lived a hobbit.
         
403 as defined in the XPath 3.0 grammar, that is one of the following:

  • A lexical QName, which is expanded using the statically known namespaces. The default namespace is not used (no prefix means no namespace).

  • A

    let $para := 
    In a hole in the ground there lived a hobbit.
             
    404 using the syntax
    let $para := 
    In a hole in the ground there lived a hobbit.
             
    405, where the URI can be zero-length to indicate a name in no namespace.

The decimal format that is used is the decimal format in the static context whose name matches

let $para := 
In a hole in the ground there lived a hobbit.
         
383 if supplied, or the unnamed decimal format in the static context otherwise.

The evaluation of the

let $para := 
In a hole in the ground there lived a hobbit.
         
353 function takes place in two phases, an analysis phase described in 4.7.4 Analyzing the picture string and a formatting phase described in 4.7.5 Formatting the number.

The analysis phase takes as its inputs the ·picture string· and the variables derived from the relevant decimal format in the static context, and produces as its output a number of variables with defined values. The formatting phase takes as its inputs the number to be formatted and the variables produced by the analysis phase, and produces as its output a string containing a formatted representation of the number.

The result of the function is the formatted string representation of the supplied number.

Error Conditions

A dynamic error is raised [err:FODF1280] if the name specified as the

let $para := 
In a hole in the ground there lived a hobbit.
         
383 argument is neither a valid lexical QName nor a valid
let $para := 
In a hole in the ground there lived a hobbit.
         
404, or if it uses a prefix that is not found in the statically known namespaces, or if the static context does not contain a declaration of a decimal-format with a matching expanded QName. If the processor is able to detect the error statically (for example, when the argument is supplied as a string literal), then the processor may optionally signal this as a static error.

Notes

A string is an ordered sequence of characters, and this specification uses terms such as "left" and "right", "preceding" and "following" in relation to this ordering, irrespective of the position of the characters when visually rendered on some output medium. Both in the picture string and in the result string, digits with higher significance (that is, representing higher powers of ten) always precede digits with lower significance, even when the rendered text flow is from right to left.

Examples

The following examples assume a default decimal format in which the chosen digits are the ASCII digits 0-9, the decimal separator is ".", the grouping separator is ",", the minus-sign is "-", and the percent-sign is "%".

The expression

let $para := 
In a hole in the ground there lived a hobbit.
         
410 returns
let $para := 
In a hole in the ground there lived a hobbit.
         
411.

The expression

let $para := 
In a hole in the ground there lived a hobbit.
         
412 returns
let $para := 
In a hole in the ground there lived a hobbit.
         
413.

The expression

let $para := 
In a hole in the ground there lived a hobbit.
         
414 returns
let $para := 
In a hole in the ground there lived a hobbit.
         
415.

The expression

let $para := 
In a hole in the ground there lived a hobbit.
         
416 returns
let $para := 
In a hole in the ground there lived a hobbit.
         
417.

The expression

let $para := 
In a hole in the ground there lived a hobbit.
         
418 returns
let $para := 
In a hole in the ground there lived a hobbit.
         
419.

The following example assumes the existence of a decimal format named 'ch' in which the grouping separator is

let $para := 
In a hole in the ground there lived a hobbit.
         
420 and the decimal separator is
let $para := 
In a hole in the ground there lived a hobbit.
         
421:

The expression

let $para := 
In a hole in the ground there lived a hobbit.
         
422 returns
let $para := 
In a hole in the ground there lived a hobbit.
         
423.

The following examples assume that the exponent separator is in decimal format 'fortran' is 'E':

The expression

let $para := 
In a hole in the ground there lived a hobbit.
         
424 returns
let $para := 
In a hole in the ground there lived a hobbit.
         
425.

The expression

let $para := 
In a hole in the ground there lived a hobbit.
         
426 returns
let $para := 
In a hole in the ground there lived a hobbit.
         
427.

The expression

let $para := 
In a hole in the ground there lived a hobbit.
         
428 returns
let $para := 
In a hole in the ground there lived a hobbit.
         
429.

The expression

let $para := 
In a hole in the ground there lived a hobbit.
         
430 returns
let $para := 
In a hole in the ground there lived a hobbit.
         
431.

4.7.3 Syntax of the picture string

Note:

This differs from the

let $para := 
In a hole in the ground there lived a hobbit.
         
432 function previously defined in XSLT 2.0 in that any digit can be used in the picture string to represent a mandatory digit: for example the picture strings '000', '001', and '999' are equivalent. The digits will all be from the same decimal digit family, specifically, the sequence of ten consecutive digits starting with the digit assigned to the zero-digit property. This change is to align
let $para := 
In a hole in the ground there lived a hobbit.
         
432 (which previously used '000') with
let $para := 
In a hole in the ground there lived a hobbit.
         
434 (which used '001').

[Definition] The formatting of a number is controlled by a picture string. The picture string is a sequence of ·characters·, in which the characters assigned to the properties decimal-separatorXP31 , exponent-separatorXP31, grouping-separatorXP31, and digitXP31, and pattern-separatorXP31 and the members of the ·decimal digit family·, are classified as active characters, and all other characters (including the values of the properties percentXP31 and per-milleXP31) are classified as passive characters.

A dynamic error is raised [err:FODF1310] if the ·picture string· does not conform to the following rules. Note that in these rules the words "preceded" and "followed" refer to characters anywhere in the string, they are not to be read as "immediately preceded" and "immediately followed".

  • A picture-string consists either of a sub-picture, or of two sub-pictures separated by the pattern-separatorXP31 character. A picture-string must not contain more than one instance of the pattern-separatorXP31 character. If the picture-string contains two sub-pictures, the first is used for positive and unsigned zero values and the second for negative values.

  • A sub-picture must not contain more than one instance of the decimal-separatorXP31 character.

  • A sub-picture must not contain more than one instance of the percentXP31 or per-milleXP31 characters, and it must not contain one of each.

  • The mantissa part of a sub-picture (defined below) must contain at least one character that is either an ·optional digit character· or a member of the ·decimal digit family·.

  • A sub-picture must not contain a passive character that is preceded by an active character and that is followed by another active character.

  • A sub-picture must not contain a grouping-separatorXP31 character that appears adjacent to a decimal-separatorXP31 character, or in the absence of a decimal-separatorXP31 character, at the end of the integer part.

  • A sub-picture must not contain two adjacent instances of the grouping-separatorXP31 character.

  • The integer part of a sub-picture (defined below) must not contain a member of the ·decimal digit family· that is followed by an instance of the ·optional digit character·. The fractional part of a sub-picture (defined below) must not contain an instance of the ·optional digit character· that is followed by a member of the ·decimal digit family·.

  • A character that matches the exponent-separatorXP31 property is treated as an exponent-separator-sign if it is both preceded and followed within the sub-picture by an active character. Otherwise, it is treated as a passive character. A sub-picture must not contain more than one character that is treated as an exponent-separator-sign.

  • A sub-picture that contains a percentXP31 or per-milleXP31 character must not contain a character treated as an exponent-separator-sign.

  • If a sub-picture contains a character treated as an exponent-separator-sign then this must be followed by one or more characters that are members of the ·decimal digit family·, and it must not be followed by any active character that is not a member of the ·decimal digit family·.

The mantissa part of the sub-picture is defined as the part that appears to the left of the exponent-separator-sign if there is one, or the entire sub-picture otherwise. The exponent part of the subpicture is defined as the part that appears to the right of the exponent-separator-sign; if there is no exponent-separator-sign then the exponent part is absent.

The integer part of the sub-picture is defined as the part that appears to the left of the decimal-separatorXP31 character if there is one, or the entire mantissa part otherwise.

The fractional part of the sub-picture is defined as that part of the mantissa part that appears to the right of the decimal-separatorXP31 character if there is one, or the part that appears to the right of the rightmost active character otherwise. The fractional part may be zero-length.

4.7.4 Analyzing the picture string

This phase of the algorithm analyzes the ·picture string· and the properties from the selected decimal format in the static context, and it has the effect of setting the values of various variables, which are used in the subsequent formatting phase. These variables are listed below. Each is shown with its initial setting and its datatype.

Several variables are associated with each sub-picture. If there are two sub-pictures, then these rules are applied to one sub-picture to obtain the values that apply to positive and unsigned zero numbers, and to the other to obtain the values that apply to negative numbers. If there is only one sub-picture, then the values for both cases are derived from this sub-picture.

The variables are as follows:

  • The integer-part-grouping-positions is a sequence of integers representing the positions of grouping separators within the integer part of the sub-picture. For each grouping-separatorXP31 character that appears within the integer part of the sub-picture, this sequence contains an integer that is equal to the total number of ·optional digit character· and ·decimal digit family· characters that appear within the integer part of the sub-picture and to the right of the grouping-separatorXP31 character.

    The grouping is defined to be regular if the following conditions apply:

    1. There is an least one grouping-separator in the integer part of the sub-picture.

    2. There is a positive integer G (the grouping size) such that the position of every grouping-separator in the integer part of the sub-picture is a positive integer multiple of G.

    3. Every position in the integer part of the sub-picture that is a positive integer multiple of G is occupied by a grouping-separator.

    If the grouping is regular, then the integer-part-grouping-positions sequence contains all integer multiples of G as far as necessary to accommodate the largest possible number.

  • The minimum-integer-part-size is an integer indicating the minimum number of digits that will appear to the left of the decimal-separator character. It is initially set to the number of ·decimal digit family· characters found in the integer part of the sub-picture, but may be adjusted as described below.

    Note:

    There is no maximum integer part size. All significant digits in the integer part of the number will be displayed, even if this exceeds the number of ·optional digit character· and ·decimal digit family· characters in the subpicture.

  • The scaling factor is a non-negative integer used to determine the scaling of the mantissa in exponential notation. It is set to the number of ·decimal digit family· characters found in the integer part of the sub-picture.

  • The prefix is set to contain all passive characters in the sub-picture to the left of the leftmost active character. If the picture string contains only one sub-picture, the prefix for the negative sub-picture is set by concatenating the minus-signXP31 character and the prefix for the positive sub-picture (if any), in that order.

  • The fractional-part-grouping-positions is a sequence of integers representing the positions of grouping separators within the fractional part of the sub-picture. For each grouping-separatorXP31 character that appears within the fractional part of the sub-picture, this sequence contains an integer that is equal to the total number of ·optional digit character· and ·decimal digit family· characters that appear within the fractional part of the sub-picture and to the left of the grouping-separatorXP31 character.

    Note:

    There is no need to extrapolate grouping positions on the fractional side, because the number of digits in the output will never exceed the number of ·optional digit character· and ·decimal digit family· characters in the fractional part of the sub-picture.

  • The minimum-fractional-part-size is set to the number of ·decimal digit family· characters found in the fractional part of the sub-picture.

  • The maximum-fractional-part-size is set to the total number of ·optional digit character· and ·decimal digit family· characters found in the fractional part of the sub-picture.

  • If the effect of the above rules is that minimum-integer-part-size and maximum-fractional-part-size are both zero, then an adjustment is applied as follows:

    • If an exponent separator is present then:

      • minimum-fractional-part-size is changed to 1 (one).

      • maximum-fractional-part-size is changed to 1 (one).

      Note:

      This has the effect that with the picture

      let $para := 
      In a hole in the ground there lived a hobbit.
               
      435, the value
      let $para := 
      In a hole in the ground there lived a hobbit.
               
      436 is formatted as
      let $para := 
      In a hole in the ground there lived a hobbit.
               
      437

    • Otherwise:

      • minimum-integer-part-size is changed to 1 (one).

      Note:

      This has the effect that with the picture

      let $para := 
      In a hole in the ground there lived a hobbit.
               
      438, the value
      let $para := 
      In a hole in the ground there lived a hobbit.
               
      439 is formatted as
      declare %public function r:random-sequence($length as xs:integer) as xs:double* {
        r:random-sequence($length, fn:random-number-generator())
      };
      
      declare %private function r:random-sequence($length as xs:integer, 
                                                  $G as map(xs:string, item())) {
        if ($length eq 0)
        then ()
        else ($G?number, r:random-sequence($length - 1, $G?next()))
      };
      
      r:random-sequence(200);
                  
      19

  • If all the following conditions are true:

    • An exponent separator is present

    • The minimum-integer-part-size is zero

    • There is at least one ·optional digit character· in the integer part of the sub-picture

    then the minimum-integer-part-size is changed to 1 (one).

    Note:

    This has the effect that with the picture

    let $para := 
    In a hole in the ground there lived a hobbit.
             
    441, the value
    let $para := 
    In a hole in the ground there lived a hobbit.
             
    442 is formatted as
    let $para := 
    In a hole in the ground there lived a hobbit.
             
    443, while with the picture
    let $para := 
    In a hole in the ground there lived a hobbit.
             
    444, it is formatted as
    let $para := 
    In a hole in the ground there lived a hobbit.
             
    437

  • If (after making the above adjustments) the minimum-integer-part-size and the minimum-fractional-part-size are both zero, then the minimum-fractional-part-size is set to 1 (one).

  • The minimum-exponent-size is set to the number of ·decimal digit family· characters found in the exponent part of the sub-picture if present, or zero otherwise.

    Note:

    The rules for the syntax of the picture string ensure that if an exponent separator is present, then the minimum-exponent-size will always be greater than zero.

  • The suffix is set to contain all passive characters to the right of the rightmost active character in the sub-picture.

Note:

If there is only one sub-picture, then all variables for positive numbers and negative numbers will be the same, except for prefix: the prefix for negative numbers will be preceded by the minus-signXP31 character.

4.7.5 Formatting the number

This section describes the second phase of processing of the

let $para := 
In a hole in the ground there lived a hobbit.
         
353 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
let $para := 
In a hole in the ground there lived a hobbit.
         
353 function.

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

  1. If the input number is NaN (not a number), the result is the value of the pattern separatorXP31 property (with no prefix or suffix).

  2. In the rules below, the positive sub-picture and its associated variables are used if the input number is positive, and the negative sub-picture and its associated variables are used if it is negative. For

    let $para := 
    In a hole in the ground there lived a hobbit.
             
    26 and
    let $para := 
    In a hole in the ground there lived a hobbit.
             
    83, negative zero is taken as negative, positive zero as positive. For
    let $para := 
    In a hole in the ground there lived a hobbit.
             
    82 and
    let $para := 
    In a hole in the ground there lived a hobbit.
             
    85, the positive sub-picture is used for zero.

  3. The adjusted number is determined as follows:

    • If the sub-picture contains a percentXP31 character, the adjusted number is the input number multiplied by 100.

    • If the sub-picture contains a per-milleXP31 character, the adjusted number is the input number multiplied by 1000.

    • Otherwise, the adjusted number is the input number.

    If the multiplication causes numeric overflow, no error occurs, and the adjusted number is positive or negative infinity as appropriate.

  4. If the adjusted number is positive or negative infinity, the result is the concatenation of the appropriate prefix, the value of the infinityXP31 property, and the appropriate suffix.

  5. If the minimum exponent size is non-zero, then the adjusted number is scaled to establish a mantissa and an integer exponent. The mantissa and exponent are chosen such that all the following conditions are true:

    • The primitive type of the mantissa is the same as the primitive type of the adjusted number (integer, decimal, float, or double).

    • The mantissa multiplied by ten to the power of the exponent is equal to the adjusted number.

    • The mantissa is less than 10N, and at least 10N-1, where N is the scaling factor.

    If the minimum exponent size is zero, then the mantissa is the adjusted number and there is no exponent.

  6. The mantissa is converted (if necessary) to an

    let $para := 
    In a hole in the ground there lived a hobbit.
             
    82 value, using an implementation of
    let $para := 
    In a hole in the ground there lived a hobbit.
             
    82 that imposes no limits on the
    let $para := 
    In a hole in the ground there lived a hobbit.
             
    454 or
    let $para := 
    In a hole in the ground there lived a hobbit.
             
    455 facets. If there are several such values that are numerically equal to the mantissa (bearing in mind that if the mantissa is an
    let $para := 
    In a hole in the ground there lived a hobbit.
             
    26 or
    let $para := 
    In a hole in the ground there lived a hobbit.
             
    83, the comparison will be done by converting the decimal value back to an
    let $para := 
    In a hole in the ground there lived a hobbit.
             
    26 or
    let $para := 
    In a hole in the ground there lived a hobbit.
             
    83), the one that is chosen should be one with the smallest possible number of digits not counting leading or trailing zeroes (whether significant or insignificant). For example, 1.0 is preferred to 0.9999999999, and 100000000 is preferred to 100000001. This value is then rounded so that it uses no more than
    let $para := 
    In a hole in the ground there lived a hobbit.
             
    460 digits in its fractional part. The rounded number is defined to be the result of converting the mantissa to an
    let $para := 
    In a hole in the ground there lived a hobbit.
             
    82 value, as described above, and then calling the function
    let $C := 'http://www.w3.org/2013/collation/UCA?strength=primary'
    83 with this converted number as the first argument and the
    let $para := 
    In a hole in the ground there lived a hobbit.
             
    460 as the second argument, again with no limits on the
    let $para := 
    In a hole in the ground there lived a hobbit.
             
    454 or
    let $para := 
    In a hole in the ground there lived a hobbit.
             
    455 in the result.

  7. The absolute value of the rounded number is converted to a string in decimal notation, using the digits in the ·decimal digit family· to represent the ten decimal digits, and the decimal-separatorXP31 character to separate the integer part and the fractional part. This string must always contain a decimal-separatorXP31, and it must contain no leading zeroes and no trailing zeroes. The value zero will at this stage be represented by a decimal-separatorXP31 on its own.

  8. If the number of digits to the left of the decimal-separatorXP31 character is less than minimum-integer-part-size, leading zero digitXP31 characters are added to pad out to that size.

  9. If the number of digits to the right of the decimal-separatorXP31 character is less than minimum-fractional-part-size, trailing zero digitXP31 characters are added to pad out to that size.

  10. For each integer N in the integer-part-grouping-positions list, a grouping-separatorXP31 character is inserted into the string immediately after that digit that appears in the integer part of the number and has N digits between it and the decimal-separatorXP31 character, if there is such a digit.

  11. For each integer N in the fractional-part-grouping-positions list, a grouping-separatorXP31 character is inserted into the string immediately before that digit that appears in the fractional part of the number and has N digits between it and the decimal-separatorXP31 character, if there is such a digit.

  12. If there is no decimal-separatorXP31 character in the sub-picture, or if there are no digits to the right of the decimal-separator character in the string, then the decimal-separator character is removed from the string (it will be the rightmost character in the string).

  13. If an exponent exists, then the string produced from the mantissa as described above is extended with the following, in order: (a) the exponent-separatorXP31 character; (b) if the exponent is negative, the minus-signXP31 character; (c) the value of the exponent represented as a decimal integer, extended if necessary with leading zeroes to make it up to the minimum exponent size, using digits taken from the ·decimal digit family·.

  14. The result of the function is the concatenation of the appropriate prefix, the string conversion of the number as obtained above, and the appropriate suffix.

4.8 Trigonometric and exponential functions

The functions in this section perform trigonometric and other mathematical calculations on

let $para := 
In a hole in the ground there lived a hobbit.
         
26 values. They are provided primarily for use in applications performing geometrical computation, for example when generating SVG graphics.

Functions are provided to support the six most commonly used trigonometric calculations: sine, cosine and tangent, and their inverses arc sine, arc cosine, and arc tangent. Other functions such as secant, cosecant, and cotangent are not provided because they are easily computed in terms of these six.

The functions in this section (with the exception of

let $para := 
In a hole in the ground there lived a hobbit.
         
467) are specified by reference to [IEEE 754-2008], where they appear as Recommended operations in section 9. IEEE defines these functions for a variety of floating point formats; this specification defines them only for
let $para := 
In a hole in the ground there lived a hobbit.
         
26 values. The IEEE specification applies with the following caveats:

  1. IEEE states that the preferred quantum is language-defined. In this specification, it is ·implementation-defined·.

  2. IEEE states that certain functions should raise the inexact exception if the result is inexact. In this specification, this exception if it occurs does not result in an error. Any diagnostic information is outside the scope of this specification.

  3. IEEE defines various rounding algorithms for inexact results, and states that the choice of rounding direction, and the mechanisms for influencing this choice, are language-defined. In this specification, the rounding direction and any mechanisms for influencing it are ·implementation-defined·.

  4. Certain operations (such as taking the square root of a negative number) are defined in IEEE to signal the invalid operation exception and return a quiet NaN. In this specification, such operations return

    fn:abs($N * $arg2) le fn:abs($arg1) 
                   and fn:compare($N * $arg2, 0) eq fn:compare($arg1, 0).
    90 and do not raise an error. The same policy applies to operations (such as taking the logarithm of zero) that raise a divide-by-zero exception. Any diagnostic information is outside the scope of this specification.

  5. Operations whose mathematical result is greater than the largest finite

    let $para := 
    In a hole in the ground there lived a hobbit.
             
    26 value are defined in IEEE to signal the overflow exception; operations whose mathematical result is closer to zero than the smallest non-zero
    let $para := 
    In a hole in the ground there lived a hobbit.
             
    26 value are similarly defined in IEEE to signal the underflow exception. The treatment of these exceptions in this specification is defined in 4.2 Arithmetic operators on numeric values.

FunctionMeaning
let $para := 
In a hole in the ground there lived a hobbit.
         
467Returns an approximation to the mathematical constant π.
let $para := 
In a hole in the ground there lived a hobbit.
         
473Returns the value of ex.
let $para := 
In a hole in the ground there lived a hobbit.
         
474Returns the value of
let $para := 
In a hole in the ground there lived a hobbit.
         
054x.
let $para := 
In a hole in the ground there lived a hobbit.
         
476Returns the natural logarithm of the argument.
let $para := 
In a hole in the ground there lived a hobbit.
         
477Returns the base-ten logarithm of the argument.
let $para := 
In a hole in the ground there lived a hobbit.
         
478Returns the result of raising the first argument to the power of the second.
let $para := 
In a hole in the ground there lived a hobbit.
         
479Returns the non-negative square root of the argument.
let $para := 
In a hole in the ground there lived a hobbit.
         
87Returns the sine of the argument. The argument is an angle in radians.
let $para := 
In a hole in the ground there lived a hobbit.
         
88Returns the cosine of the argument. The argument is an angle in radians.
let $para := 
In a hole in the ground there lived a hobbit.
         
482Returns the tangent of the argument. The argument is an angle in radians.
let $para := 
In a hole in the ground there lived a hobbit.
         
483Returns the arc sine of the argument.
let $para := 
In a hole in the ground there lived a hobbit.
         
484Returns the arc cosine of the argument.
let $para := 
In a hole in the ground there lived a hobbit.
         
485Returns the arc tangent of the argument.
let $para := 
In a hole in the ground there lived a hobbit.
         
486Returns the angle in radians subtended at the origin by the point on a plane with coordinates (x, y) and the positive x-axis.

4.8.1 math:pi

Summary

Returns an approximation to the mathematical constant π.

Signature

let $para := 
In a hole in the ground there lived a hobbit.
         
467()
let $para := 
In a hole in the ground there lived a hobbit.
         
71
let $para := 
In a hole in the ground there lived a hobbit.
         
26

Properties

This function is ·deterministic·, ·context-independent·, and ·focus-independent·.

Rules

This function returns the

let $para := 
In a hole in the ground there lived a hobbit.
         
26 value whose lexical representation is 3.141592653589793e0

Examples

The expression

let $para := 
In a hole in the ground there lived a hobbit.
         
491 returns
let $para := 
In a hole in the ground there lived a hobbit.
         
492.

The expression

let $para := 
In a hole in the ground there lived a hobbit.
         
493 converts an angle of 60 degrees to radians.

4.8.2 math:exp

Summary

Returns the value of ex.

Signature

let $para := 
In a hole in the ground there lived a hobbit.
         
473(
let $para := 
In a hole in the ground there lived a hobbit.
         
25
let $para := 
In a hole in the ground there lived a hobbit.
         
71
let $para := 
In a hole in the ground there lived a hobbit.
         
29)
let $para := 
In a hole in the ground there lived a hobbit.
         
71
let $para := 
In a hole in the ground there lived a hobbit.
         
29

Properties

This function is ·deterministic·, ·context-independent·, and ·focus-independent·.

Rules

If

let $para := 
In a hole in the ground there lived a hobbit.
         
25 is the empty sequence, the function returns the empty sequence.

Otherwise the result is the mathematical constant e raised to the power of

let $para := 
In a hole in the ground there lived a hobbit.
         
25, as defined in the [IEEE 754-2008] specification of the
let $para := 
In a hole in the ground there lived a hobbit.
         
502 function applied to 64-bit binary floating point values.

Notes

The treatment of overflow and underflow is defined in 4.2 Arithmetic operators on numeric values.

Examples

The expression

let $para := 
In a hole in the ground there lived a hobbit.
         
503 returns
let $para := 
In a hole in the ground there lived a hobbit.
         
96.

The expression

let $para := 
In a hole in the ground there lived a hobbit.
         
505 returns
let $para := 
In a hole in the ground there lived a hobbit.
         
506.

The expression

let $para := 
In a hole in the ground there lived a hobbit.
         
507 returns
let $para := 
In a hole in the ground there lived a hobbit.
         
508 (approximately).

The expression

let $para := 
In a hole in the ground there lived a hobbit.
         
509 returns
let $para := 
In a hole in the ground there lived a hobbit.
         
510.

The expression

let $para := 
In a hole in the ground there lived a hobbit.
         
511 returns
let $para := 
In a hole in the ground there lived a hobbit.
         
512.

The expression

let $para := 
In a hole in the ground there lived a hobbit.
         
513 returns
let $para := 
In a hole in the ground there lived a hobbit.
         
514.

The expression

let $para := 
In a hole in the ground there lived a hobbit.
         
515 returns
let $para := 
In a hole in the ground there lived a hobbit.
         
220.

The expression

let $para := 
In a hole in the ground there lived a hobbit.
         
517 returns
let $para := 
In a hole in the ground there lived a hobbit.
         
518.

The expression

let $para := 
In a hole in the ground there lived a hobbit.
         
519 returns
let $para := 
In a hole in the ground there lived a hobbit.
         
169.

4.8.3 math:exp10

Summary

Returns the value of

let $para := 
In a hole in the ground there lived a hobbit.
         
054x.

Signature

let $para := 
In a hole in the ground there lived a hobbit.
         
474(
let $para := 
In a hole in the ground there lived a hobbit.
         
25
let $para := 
In a hole in the ground there lived a hobbit.
         
71
let $para := 
In a hole in the ground there lived a hobbit.
         
29)
let $para := 
In a hole in the ground there lived a hobbit.
         
71
let $para := 
In a hole in the ground there lived a hobbit.
         
29

Properties

This function is ·deterministic·, ·context-independent·, and ·focus-independent·.

Rules

If

let $para := 
In a hole in the ground there lived a hobbit.
         
25 is the empty sequence, the function returns the empty sequence.

Otherwise the result is ten raised to the power of

let $para := 
In a hole in the ground there lived a hobbit.
         
25, as defined in the [IEEE 754-2008] specification of the
let $para := 
In a hole in the ground there lived a hobbit.
         
530 function applied to 64-bit binary floating point values.

Notes

The treatment of overflow and underflow is defined in 4.2 Arithmetic operators on numeric values.

Examples

The expression

let $para := 
In a hole in the ground there lived a hobbit.
         
531 returns
let $para := 
In a hole in the ground there lived a hobbit.
         
96.

The expression

let $para := 
In a hole in the ground there lived a hobbit.
         
533 returns
let $para := 
In a hole in the ground there lived a hobbit.
         
506.

The expression

let $para := 
In a hole in the ground there lived a hobbit.
         
535 returns
let $para := 
In a hole in the ground there lived a hobbit.
         
536.

The expression

let $para := 
In a hole in the ground there lived a hobbit.
         
537 returns
let $para := 
In a hole in the ground there lived a hobbit.
         
538.

The expression

let $para := 
In a hole in the ground there lived a hobbit.
         
539 returns
let $para := 
In a hole in the ground there lived a hobbit.
         
540.

The expression

let $para := 
In a hole in the ground there lived a hobbit.
         
541 returns
let $para := 
In a hole in the ground there lived a hobbit.
         
220.

The expression

let $para := 
In a hole in the ground there lived a hobbit.
         
543 returns
let $para := 
In a hole in the ground there lived a hobbit.
         
518.

The expression

let $para := 
In a hole in the ground there lived a hobbit.
         
545 returns
let $para := 
In a hole in the ground there lived a hobbit.
         
169.

4.8.4 math:log

Summary

Returns the natural logarithm of the argument.

Signature

let $para := 
In a hole in the ground there lived a hobbit.
         
476(
let $para := 
In a hole in the ground there lived a hobbit.
         
25
let $para := 
In a hole in the ground there lived a hobbit.
         
71
let $para := 
In a hole in the ground there lived a hobbit.
         
29)
let $para := 
In a hole in the ground there lived a hobbit.
         
71
let $para := 
In a hole in the ground there lived a hobbit.
         
29

Properties

This function is ·deterministic·, ·context-independent·, and ·focus-independent·.

Rules

If

let $para := 
In a hole in the ground there lived a hobbit.
         
25 is the empty sequence, the function returns the empty sequence.

Otherwise the result is the natural logarithm of

let $para := 
In a hole in the ground there lived a hobbit.
         
25, as defined in the [IEEE 754-2008] specification of the
let $para := 
In a hole in the ground there lived a hobbit.
         
555 function applied to 64-bit binary floating point values.

Notes

The treatment of

1º 2º 3º 4º ...
89 and
1º 2º 3º 4º ...
90 exceptions is defined in 4.2 Arithmetic operators on numeric values. The effect is that if the argument is zero, the result is
1º 2º 3º 4º ...
57, and if it is negative, the result is
fn:abs($N * $arg2) le fn:abs($arg1) 
               and fn:compare($N * $arg2, 0) eq fn:compare($arg1, 0).
90
.

Examples

The expression

let $para := 
In a hole in the ground there lived a hobbit.
         
560 returns
let $para := 
In a hole in the ground there lived a hobbit.
         
96.

The expression

let $para := 
In a hole in the ground there lived a hobbit.
         
562 returns
let $para := 
In a hole in the ground there lived a hobbit.
         
563.

The expression

let $para := 
In a hole in the ground there lived a hobbit.
         
564 returns
let $para := 
In a hole in the ground there lived a hobbit.
         
506.

The expression

let $para := 
In a hole in the ground there lived a hobbit.
         
566 returns
let $para := 
In a hole in the ground there lived a hobbit.
         
567.

The expression

let $para := 
In a hole in the ground there lived a hobbit.
         
568 returns
let $para := 
In a hole in the ground there lived a hobbit.
         
569.

The expression

let $para := 
In a hole in the ground there lived a hobbit.
         
570 returns
let $para := 
In a hole in the ground there lived a hobbit.
         
220.

The expression

let $para := 
In a hole in the ground there lived a hobbit.
         
572 returns
let $para := 
In a hole in the ground there lived a hobbit.
         
220.

The expression

let $para := 
In a hole in the ground there lived a hobbit.
         
574 returns
let $para := 
In a hole in the ground there lived a hobbit.
         
518.

The expression

let $para := 
In a hole in the ground there lived a hobbit.
         
576 returns
let $para := 
In a hole in the ground there lived a hobbit.
         
220.

4.8.5 math:log10

Summary

Returns the base-ten logarithm of the argument.

Signature

let $para := 
In a hole in the ground there lived a hobbit.
         
477(
let $para := 
In a hole in the ground there lived a hobbit.
         
25
let $para := 
In a hole in the ground there lived a hobbit.
         
71
let $para := 
In a hole in the ground there lived a hobbit.
         
29)
let $para := 
In a hole in the ground there lived a hobbit.
         
71
let $para := 
In a hole in the ground there lived a hobbit.
         
29

Properties

This function is ·deterministic·, ·context-independent·, and ·focus-independent·.

Rules

If

let $para := 
In a hole in the ground there lived a hobbit.
         
25 is the empty sequence, the function returns the empty sequence.

Otherwise the result is the base-10 logarithm of

let $para := 
In a hole in the ground there lived a hobbit.
         
25, as defined in the [IEEE 754-2008] specification of the
let $para := 
In a hole in the ground there lived a hobbit.
         
586 function applied to 64-bit binary floating point values.

Notes

The treatment of

1º 2º 3º 4º ...
89 and
1º 2º 3º 4º ...
90 exceptions is defined in 4.2 Arithmetic operators on numeric values. The effect is that if the argument is zero, the result is
1º 2º 3º 4º ...
57, and if it is negative, the result is
fn:abs($N * $arg2) le fn:abs($arg1) 
               and fn:compare($N * $arg2, 0) eq fn:compare($arg1, 0).
90
.

Examples

The expression

let $para := 
In a hole in the ground there lived a hobbit.
         
591 returns
let $para := 
In a hole in the ground there lived a hobbit.
         
96.

The expression

let $para := 
In a hole in the ground there lived a hobbit.
         
593 returns
let $para := 
In a hole in the ground there lived a hobbit.
         
563.

The expression

let $para := 
In a hole in the ground there lived a hobbit.
         
595 returns
let $para := 
In a hole in the ground there lived a hobbit.
         
596.

The expression

let $para := 
In a hole in the ground there lived a hobbit.
         
597 returns
let $para := 
In a hole in the ground there lived a hobbit.
         
598.

The expression

let $para := 
In a hole in the ground there lived a hobbit.
         
599 returns
let $para := 
In a hole in the ground there lived a hobbit.
         
600.

The expression

let $para := 
In a hole in the ground there lived a hobbit.
         
601 returns
let $para := 
In a hole in the ground there lived a hobbit.
         
220.

The expression

let $para := 
In a hole in the ground there lived a hobbit.
         
603 returns
let $para := 
In a hole in the ground there lived a hobbit.
         
220.

The expression

let $para := 
In a hole in the ground there lived a hobbit.
         
605 returns
let $para := 
In a hole in the ground there lived a hobbit.
         
518.

The expression

let $para := 
In a hole in the ground there lived a hobbit.
         
607 returns
let $para := 
In a hole in the ground there lived a hobbit.
         
220.

4.8.6 math:pow

Summary

Returns the result of raising the first argument to the power of the second.

Signature

let $para := 
In a hole in the ground there lived a hobbit.
         
478(
let $para := 
In a hole in the ground there lived a hobbit.
         
610
let $para := 
In a hole in the ground there lived a hobbit.
         
71
let $para := 
In a hole in the ground there lived a hobbit.
         
29,
let $para := 
In a hole in the ground there lived a hobbit.
         
613
let $para := 
In a hole in the ground there lived a hobbit.
         
71
let $para := 
In a hole in the ground there lived a hobbit.
         
72)
let $para := 
In a hole in the ground there lived a hobbit.
         
71
let $para := 
In a hole in the ground there lived a hobbit.
         
29

Properties

This function is ·deterministic·, ·context-independent·, and ·focus-independent·.

Rules

If

let $para := 
In a hole in the ground there lived a hobbit.
         
610 is the empty sequence, the function returns the empty sequence.

If

let $para := 
In a hole in the ground there lived a hobbit.
         
613 is an instance of
let $para := 
In a hole in the ground there lived a hobbit.
         
85, the result is
let $para := 
In a hole in the ground there lived a hobbit.
         
610 raised to the power of
let $para := 
In a hole in the ground there lived a hobbit.
         
613 as defined in the [IEEE 754-2008] specification of the
let $para := 
In a hole in the ground there lived a hobbit.
         
623 function applied to a 64-bit binary floating point value and an integer.

Otherwise

let $para := 
In a hole in the ground there lived a hobbit.
         
613 is converted to an
let $para := 
In a hole in the ground there lived a hobbit.
         
26 by numeric promotion, and the result is the value of
let $para := 
In a hole in the ground there lived a hobbit.
         
610 raised to the power of
let $para := 
In a hole in the ground there lived a hobbit.
         
613 as defined in the [IEEE 754-2008] specification of the
let $para := 
In a hole in the ground there lived a hobbit.
         
628 function applied to two 64-bit binary floating point values.

Notes

The treatment of the

1º 2º 3º 4º ...
89 and
1º 2º 3º 4º ...
90 exceptions is defined in 4.2 Arithmetic operators on numeric values. Some of the consequences are illustrated in the examples below.

Examples

The expression

let $para := 
In a hole in the ground there lived a hobbit.
         
631 returns
let $para := 
In a hole in the ground there lived a hobbit.
         
96.

The expression

let $para := 
In a hole in the ground there lived a hobbit.
         
633 returns
let $para := 
In a hole in the ground there lived a hobbit.
         
634.

The expression

let $para := 
In a hole in the ground there lived a hobbit.
         
635 returns
let $para := 
In a hole in the ground there lived a hobbit.
         
636.

The expression

let $para := 
In a hole in the ground there lived a hobbit.
         
637 returns
let $para := 
In a hole in the ground there lived a hobbit.
         
638.

The expression

let $para := 
In a hole in the ground there lived a hobbit.
         
639 returns
let $para := 
In a hole in the ground there lived a hobbit.
         
640.

The expression

let $para := 
In a hole in the ground there lived a hobbit.
         
641 returns
let $para := 
In a hole in the ground there lived a hobbit.
         
506.

The expression

let $para := 
In a hole in the ground there lived a hobbit.
         
643 returns
let $para := 
In a hole in the ground there lived a hobbit.
         
506.

The expression

let $para := 
In a hole in the ground there lived a hobbit.
         
645 returns
let $para := 
In a hole in the ground there lived a hobbit.
         
506.

The expression

let $para := 
In a hole in the ground there lived a hobbit.
         
647 returns
let $para := 
In a hole in the ground there lived a hobbit.
         
506.

The expression

let $para := 
In a hole in the ground there lived a hobbit.
         
649 returns
let $para := 
In a hole in the ground there lived a hobbit.
         
506.

The expression

let $para := 
In a hole in the ground there lived a hobbit.
         
651 returns
let $para := 
In a hole in the ground there lived a hobbit.
         
169.

The expression

let $para := 
In a hole in the ground there lived a hobbit.
         
653 returns
let $para := 
In a hole in the ground there lived a hobbit.
         
169.

The expression

let $para := 
In a hole in the ground there lived a hobbit.
         
655 returns
fn:abs($N * $arg2) le fn:abs($arg1) 
               and fn:compare($N * $arg2, 0) eq fn:compare($arg1, 0).
92.

The expression

let $para := 
In a hole in the ground there lived a hobbit.
         
657 returns
let $para := 
In a hole in the ground there lived a hobbit.
         
169.

The expression

let $para := 
In a hole in the ground there lived a hobbit.
         
659 returns
let $para := 
In a hole in the ground there lived a hobbit.
         
518.

The expression

let $para := 
In a hole in the ground there lived a hobbit.
         
661 returns
let $para := 
In a hole in the ground there lived a hobbit.
         
518.

The expression

let $para := 
In a hole in the ground there lived a hobbit.
         
663 returns
let $para := 
In a hole in the ground there lived a hobbit.
         
563.

The expression

let $para := 
In a hole in the ground there lived a hobbit.
         
665 returns
let $para := 
In a hole in the ground there lived a hobbit.
         
518.

The expression

let $para := 
In a hole in the ground there lived a hobbit.
         
667 returns
let $para := 
In a hole in the ground there lived a hobbit.
         
668.

The expression

let $para := 
In a hole in the ground there lived a hobbit.
         
669 returns
let $para := 
In a hole in the ground there lived a hobbit.
         
670.

The expression

let $para := 
In a hole in the ground there lived a hobbit.
         
671 returns
let $para := 
In a hole in the ground there lived a hobbit.
         
518.

The expression

let $para := 
In a hole in the ground there lived a hobbit.
         
673 returns
let $para := 
In a hole in the ground there lived a hobbit.
         
563. (Odd-valued whole numbers are treated specially).

The expression

let $para := 
In a hole in the ground there lived a hobbit.
         
675 returns
let $para := 
In a hole in the ground there lived a hobbit.
         
518.

The expression

let $para := 
In a hole in the ground there lived a hobbit.
         
677 returns
let $para := 
In a hole in the ground there lived a hobbit.
         
518.

The expression

let $para := 
In a hole in the ground there lived a hobbit.
         
679 returns
let $para := 
In a hole in the ground there lived a hobbit.
         
169.

The expression

let $para := 
In a hole in the ground there lived a hobbit.
         
681 returns
fn:abs($N * $arg2) le fn:abs($arg1) 
               and fn:compare($N * $arg2, 0) eq fn:compare($arg1, 0).
92. (Odd-valued whole numbers are treated specially).

The expression

let $para := 
In a hole in the ground there lived a hobbit.
         
683 returns
let $para := 
In a hole in the ground there lived a hobbit.
         
169.

The expression

let $para := 
In a hole in the ground there lived a hobbit.
         
685 returns
let $para := 
In a hole in the ground there lived a hobbit.
         
169.

The expression

let $para := 
In a hole in the ground there lived a hobbit.
         
687 returns
let $para := 
In a hole in the ground there lived a hobbit.
         
506.

The expression

let $para := 
In a hole in the ground there lived a hobbit.
         
689 returns
let $para := 
In a hole in the ground there lived a hobbit.
         
506.

The expression

let $para := 
In a hole in the ground there lived a hobbit.
         
691 returns
let $para := 
In a hole in the ground there lived a hobbit.
         
506.

The expression

let $para := 
In a hole in the ground there lived a hobbit.
         
693 returns
let $para := 
In a hole in the ground there lived a hobbit.
         
506.

The expression

let $para := 
In a hole in the ground there lived a hobbit.
         
695 returns
let $para := 
In a hole in the ground there lived a hobbit.
         
506.

The expression

let $para := 
In a hole in the ground there lived a hobbit.
         
697 returns
let $para := 
In a hole in the ground there lived a hobbit.
         
698.

The expression

let $para := 
In a hole in the ground there lived a hobbit.
         
699 returns
let $para := 
In a hole in the ground there lived a hobbit.
         
220.

4.8.7 math:sqrt

Summary

Returns the non-negative square root of the argument.

Signature

let $para := 
In a hole in the ground there lived a hobbit.
         
479(
let $para := 
In a hole in the ground there lived a hobbit.
         
25
let $para := 
In a hole in the ground there lived a hobbit.
         
71
let $para := 
In a hole in the ground there lived a hobbit.
         
29)
let $para := 
In a hole in the ground there lived a hobbit.
         
71
let $para := 
In a hole in the ground there lived a hobbit.
         
29

Properties

This function is ·deterministic·, ·context-independent·, and ·focus-independent·.

Rules

If

let $para := 
In a hole in the ground there lived a hobbit.
         
25 is the empty sequence, the function returns the empty sequence.

Otherwise the result is the mathematical non-negative square root of

let $para := 
In a hole in the ground there lived a hobbit.
         
25 as defined in the [IEEE 754-2008] specification of the
let $para := 
In a hole in the ground there lived a hobbit.
         
709 function applied to 64-bit binary floating point values.

Notes

The treatment of the

1º 2º 3º 4º ...
90 exception is defined in 4.2 Arithmetic operators on numeric values. The effect is that if the argument is less than zero, the result is
fn:abs($N * $arg2) le fn:abs($arg1) 
               and fn:compare($N * $arg2, 0) eq fn:compare($arg1, 0).
90.

If

let $para := 
In a hole in the ground there lived a hobbit.
         
25 is positive or negative zero, positive infinity, or
fn:abs($N * $arg2) le fn:abs($arg1) 
               and fn:compare($N * $arg2, 0) eq fn:compare($arg1, 0).
90, then the result is
let $para := 
In a hole in the ground there lived a hobbit.
         
25. (Negative zero is the only case where the result can have negative sign)

Examples

The expression

let $para := 
In a hole in the ground there lived a hobbit.
         
715 returns
let $para := 
In a hole in the ground there lived a hobbit.
         
96.

The expression

let $para := 
In a hole in the ground there lived a hobbit.
         
717 returns
let $para := 
In a hole in the ground there lived a hobbit.
         
169.

The expression

let $para := 
In a hole in the ground there lived a hobbit.
         
719 returns
fn:abs($N * $arg2) le fn:abs($arg1) 
               and fn:compare($N * $arg2, 0) eq fn:compare($arg1, 0).
92.

The expression

let $para := 
In a hole in the ground there lived a hobbit.
         
721 returns
let $para := 
In a hole in the ground there lived a hobbit.
         
722.

The expression

let $para := 
In a hole in the ground there lived a hobbit.
         
723 returns
let $para := 
In a hole in the ground there lived a hobbit.
         
724.

The expression

let $para := 
In a hole in the ground there lived a hobbit.
         
725 returns
let $para := 
In a hole in the ground there lived a hobbit.
         
220.

The expression

let $para := 
In a hole in the ground there lived a hobbit.
         
727 returns
let $para := 
In a hole in the ground there lived a hobbit.
         
220.

The expression

let $para := 
In a hole in the ground there lived a hobbit.
         
729 returns
let $para := 
In a hole in the ground there lived a hobbit.
         
518.

The expression

let $para := 
In a hole in the ground there lived a hobbit.
         
731 returns
let $para := 
In a hole in the ground there lived a hobbit.
         
220.

4.8.8 math:sin

Summary

Returns the sine of the argument. The argument is an angle in radians.

Signature

let $para := 
In a hole in the ground there lived a hobbit.
         
87(
let $para := 
In a hole in the ground there lived a hobbit.
         
734θ
let $para := 
In a hole in the ground there lived a hobbit.
         
71
let $para := 
In a hole in the ground there lived a hobbit.
         
29)
let $para := 
In a hole in the ground there lived a hobbit.
         
71
let $para := 
In a hole in the ground there lived a hobbit.
         
29

Properties

This function is ·deterministic·, ·context-independent·, and ·focus-independent·.

Rules

If

let $para := 
In a hole in the ground there lived a hobbit.
         
734θ is the empty sequence, the function returns the empty sequence.

Otherwise the result is the sine of

let $para := 
In a hole in the ground there lived a hobbit.
         
734θ (which is treated as an angle in radians) as defined in the [IEEE 754-2008] specification of the
let $para := 
In a hole in the ground there lived a hobbit.
         
741 function applied to 64-bit binary floating point values.

Notes

The treatment of the

1º 2º 3º 4º ...
90 and
let $para := 
In a hole in the ground there lived a hobbit.
         
743 exceptions is defined in 4.2 Arithmetic operators on numeric values.

If

let $para := 
In a hole in the ground there lived a hobbit.
         
734θ is positive or negative zero, the result is
let $para := 
In a hole in the ground there lived a hobbit.
         
734θ.

If

let $para := 
In a hole in the ground there lived a hobbit.
         
734θ is positive or negative infinity, or
fn:abs($N * $arg2) le fn:abs($arg1) 
               and fn:compare($N * $arg2, 0) eq fn:compare($arg1, 0).
90, then the result is
fn:abs($N * $arg2) le fn:abs($arg1) 
               and fn:compare($N * $arg2, 0) eq fn:compare($arg1, 0).
90.

Otherwise the result is always in the range -1.0e0 to +1.0e0

Examples

The expression

let $para := 
In a hole in the ground there lived a hobbit.
         
749 returns
let $para := 
In a hole in the ground there lived a hobbit.
         
96.

The expression

let $para := 
In a hole in the ground there lived a hobbit.
         
751 returns
let $para := 
In a hole in the ground there lived a hobbit.
         
169.

The expression

let $para := 
In a hole in the ground there lived a hobbit.
         
753 returns
fn:abs($N * $arg2) le fn:abs($arg1) 
               and fn:compare($N * $arg2, 0) eq fn:compare($arg1, 0).
92.

The expression

let $para := 
In a hole in the ground there lived a hobbit.
         
755 returns
let $para := 
In a hole in the ground there lived a hobbit.
         
506 (approximately).

The expression

let $para := 
In a hole in the ground there lived a hobbit.
         
757 returns
let $para := 
In a hole in the ground there lived a hobbit.
         
758 (approximately).

The expression

let $para := 
In a hole in the ground there lived a hobbit.
         
759 returns
let $para := 
In a hole in the ground there lived a hobbit.
         
169 (approximately).

The expression

let $para := 
In a hole in the ground there lived a hobbit.
         
761 returns
let $para := 
In a hole in the ground there lived a hobbit.
         
220.

The expression

let $para := 
In a hole in the ground there lived a hobbit.
         
763 returns
let $para := 
In a hole in the ground there lived a hobbit.
         
220.

The expression

let $para := 
In a hole in the ground there lived a hobbit.
         
765 returns
let $para := 
In a hole in the ground there lived a hobbit.
         
220.

4.8.9 math:cos

Summary

Returns the cosine of the argument. The argument is an angle in radians.

Signature

let $para := 
In a hole in the ground there lived a hobbit.
         
88(
let $para := 
In a hole in the ground there lived a hobbit.
         
734θ
let $para := 
In a hole in the ground there lived a hobbit.
         
71
let $para := 
In a hole in the ground there lived a hobbit.
         
29)
let $para := 
In a hole in the ground there lived a hobbit.
         
71
let $para := 
In a hole in the ground there lived a hobbit.
         
29

Properties

This function is ·deterministic·, ·context-independent·, and ·focus-independent·.

Rules

If

let $para := 
In a hole in the ground there lived a hobbit.
         
734θ is the empty sequence, the function returns the empty sequence.

If

let $para := 
In a hole in the ground there lived a hobbit.
         
734θ is positive or negative infinity, or
fn:abs($N * $arg2) le fn:abs($arg1) 
               and fn:compare($N * $arg2, 0) eq fn:compare($arg1, 0).
90, then the result is
fn:abs($N * $arg2) le fn:abs($arg1) 
               and fn:compare($N * $arg2, 0) eq fn:compare($arg1, 0).
90.

Otherwise the result is the cosine of

let $para := 
In a hole in the ground there lived a hobbit.
         
734θ (which is treated as an angle in radians) as defined in the [IEEE 754-2008] specification of the
let $para := 
In a hole in the ground there lived a hobbit.
         
778 function applied to 64-bit binary floating point values.

Notes

The treatment of the

1º 2º 3º 4º ...
90 exception is defined in 4.2 Arithmetic operators on numeric values.

If

let $para := 
In a hole in the ground there lived a hobbit.
         
734θ is positive or negative zero, the result is
let $para := 
In a hole in the ground there lived a hobbit.
         
734θ.

If

let $para := 
In a hole in the ground there lived a hobbit.
         
734θ is positive or negative infinity, or
fn:abs($N * $arg2) le fn:abs($arg1) 
               and fn:compare($N * $arg2, 0) eq fn:compare($arg1, 0).
90, then the result is
fn:abs($N * $arg2) le fn:abs($arg1) 
               and fn:compare($N * $arg2, 0) eq fn:compare($arg1, 0).
90.

Otherwise the result is always in the range -1.0e0 to +1.0e0

Examples

The expression

let $para := 
In a hole in the ground there lived a hobbit.
         
785 returns
let $para := 
In a hole in the ground there lived a hobbit.
         
96.

The expression

let $para := 
In a hole in the ground there lived a hobbit.
         
787 returns
let $para := 
In a hole in the ground there lived a hobbit.
         
506.

The expression

let $para := 
In a hole in the ground there lived a hobbit.
         
789 returns
let $para := 
In a hole in the ground there lived a hobbit.
         
506.

The expression

let $para := 
In a hole in the ground there lived a hobbit.
         
791 returns
let $para := 
In a hole in the ground there lived a hobbit.
         
169 (approximately).

The expression

let $para := 
In a hole in the ground there lived a hobbit.
         
793 returns
let $para := 
In a hole in the ground there lived a hobbit.
         
169 (approximately).

The expression

let $para := 
In a hole in the ground there lived a hobbit.
         
795 returns
let $para := 
In a hole in the ground there lived a hobbit.
         
758 (approximately).

The expression

let $para := 
In a hole in the ground there lived a hobbit.
         
797 returns
let $para := 
In a hole in the ground there lived a hobbit.
         
220.

The expression

let $para := 
In a hole in the ground there lived a hobbit.
         
799 returns
let $para := 
In a hole in the ground there lived a hobbit.
         
220.

The expression

let $para := 
In a hole in the ground there lived a hobbit.
         
801 returns
let $para := 
In a hole in the ground there lived a hobbit.
         
220.

4.8.10 math:tan

Summary

Returns the tangent of the argument. The argument is an angle in radians.

Signature

let $para := 
In a hole in the ground there lived a hobbit.
         
482(
let $para := 
In a hole in the ground there lived a hobbit.
         
734θ
let $para := 
In a hole in the ground there lived a hobbit.
         
71
let $para := 
In a hole in the ground there lived a hobbit.
         
29)
let $para := 
In a hole in the ground there lived a hobbit.
         
71
let $para := 
In a hole in the ground there lived a hobbit.
         
29

Properties

This function is ·deterministic·, ·context-independent·, and ·focus-independent·.

Rules

If

let $para := 
In a hole in the ground there lived a hobbit.
         
734θ is the empty sequence, the function returns the empty sequence.

Otherwise the result is the tangent of

let $para := 
In a hole in the ground there lived a hobbit.
         
734θ (which is treated as an angle in radians) as defined in the [IEEE 754-2008] specification of the
let $para := 
In a hole in the ground there lived a hobbit.
         
811 function applied to 64-bit binary floating point values.

Notes

The treatment of the

1º 2º 3º 4º ...
90 and
let $para := 
In a hole in the ground there lived a hobbit.
         
743 exceptions is defined in 4.2 Arithmetic operators on numeric values.

If

let $para := 
In a hole in the ground there lived a hobbit.
         
734θ is positive or negative infinity, or
fn:abs($N * $arg2) le fn:abs($arg1) 
               and fn:compare($N * $arg2, 0) eq fn:compare($arg1, 0).
90, then the result is
fn:abs($N * $arg2) le fn:abs($arg1) 
               and fn:compare($N * $arg2, 0) eq fn:compare($arg1, 0).
90.

Examples

The expression

let $para := 
In a hole in the ground there lived a hobbit.
         
817 returns
let $para := 
In a hole in the ground there lived a hobbit.
         
96.

The expression

let $para := 
In a hole in the ground there lived a hobbit.
         
819 returns
let $para := 
In a hole in the ground there lived a hobbit.
         
169.

The expression

let $para := 
In a hole in the ground there lived a hobbit.
         
821 returns
fn:abs($N * $arg2) le fn:abs($arg1) 
               and fn:compare($N * $arg2, 0) eq fn:compare($arg1, 0).
92.

The expression

let $para := 
In a hole in the ground there lived a hobbit.
         
823 returns
let $para := 
In a hole in the ground there lived a hobbit.
         
506 (approximately).

The expression

let $para := 
In a hole in the ground there lived a hobbit.
         
825 returns
let $para := 
In a hole in the ground there lived a hobbit.
         
758 (approximately).

The expression

let $para := 
In a hole in the ground there lived a hobbit.
         
827 returns
let $para := 
In a hole in the ground there lived a hobbit.
         
169 (approximately). (Mathematically, tan(π/2) is positive infinity. But because
let $para := 
In a hole in the ground there lived a hobbit.
         
829 returns an approximation, the result of
let $para := 
In a hole in the ground there lived a hobbit.
         
830 will be a large but finite number.)

The expression

let $para := 
In a hole in the ground there lived a hobbit.
         
831 returns
fn:abs($N * $arg2) le fn:abs($arg1) 
               and fn:compare($N * $arg2, 0) eq fn:compare($arg1, 0).
92 (approximately). (Mathematically, tan(-π/2) is negative infinity. But because
let $para := 
In a hole in the ground there lived a hobbit.
         
833 returns an approximation, the result of
let $para := 
In a hole in the ground there lived a hobbit.
         
834 will be a large but finite negative number.)

The expression

let $para := 
In a hole in the ground there lived a hobbit.
         
835 returns
let $para := 
In a hole in the ground there lived a hobbit.
         
169 (approximately).

The expression

let $para := 
In a hole in the ground there lived a hobbit.
         
837 returns
let $para := 
In a hole in the ground there lived a hobbit.
         
220.

The expression

let $para := 
In a hole in the ground there lived a hobbit.
         
839 returns
let $para := 
In a hole in the ground there lived a hobbit.
         
220.

The expression

let $para := 
In a hole in the ground there lived a hobbit.
         
841 returns
let $para := 
In a hole in the ground there lived a hobbit.
         
220.

4.8.11 math:asin

Summary

Returns the arc sine of the argument.

Signature

let $para := 
In a hole in the ground there lived a hobbit.
         
483(
let $para := 
In a hole in the ground there lived a hobbit.
         
25
let $para := 
In a hole in the ground there lived a hobbit.
         
71
let $para := 
In a hole in the ground there lived a hobbit.
         
29)
let $para := 
In a hole in the ground there lived a hobbit.
         
71
let $para := 
In a hole in the ground there lived a hobbit.
         
29

Properties

This function is ·deterministic·, ·context-independent·, and ·focus-independent·.

Rules

If

let $para := 
In a hole in the ground there lived a hobbit.
         
25 is the empty sequence, the function returns the empty sequence.

Otherwise the result is the arc sine of

let $para := 
In a hole in the ground there lived a hobbit.
         
25 as defined in the [IEEE 754-2008] specification of the
let $para := 
In a hole in the ground there lived a hobbit.
         
851 function applied to 64-bit binary floating point values. The result is in the range -π/2 to +π/2 radians.

Notes

The treatment of the

1º 2º 3º 4º ...
90 and
let $para := 
In a hole in the ground there lived a hobbit.
         
743 exceptions is defined in 4.2 Arithmetic operators on numeric values.

If

let $para := 
In a hole in the ground there lived a hobbit.
         
25 is positive or negative zero, the result is
let $para := 
In a hole in the ground there lived a hobbit.
         
25.

If

let $para := 
In a hole in the ground there lived a hobbit.
         
25 is
fn:abs($N * $arg2) le fn:abs($arg1) 
               and fn:compare($N * $arg2, 0) eq fn:compare($arg1, 0).
90, or if its absolute value is greater than one, then the result is
fn:abs($N * $arg2) le fn:abs($arg1) 
               and fn:compare($N * $arg2, 0) eq fn:compare($arg1, 0).
90.

In other cases the result is an

let $para := 
In a hole in the ground there lived a hobbit.
         
26 value representing an angle θ in radians in the range -π
let $para := 
In a hole in the ground there lived a hobbit.
         
860θ
let $para := 
In a hole in the ground there lived a hobbit.
         
861π
let $para := 
In a hole in the ground there lived a hobbit.
         
862.

Examples

The expression

let $para := 
In a hole in the ground there lived a hobbit.
         
863 returns
let $para := 
In a hole in the ground there lived a hobbit.
         
96.

The expression

let $para := 
In a hole in the ground there lived a hobbit.
         
865 returns
let $para := 
In a hole in the ground there lived a hobbit.
         
169.

The expression

let $para := 
In a hole in the ground there lived a hobbit.
         
867 returns
fn:abs($N * $arg2) le fn:abs($arg1) 
               and fn:compare($N * $arg2, 0) eq fn:compare($arg1, 0).
92.

The expression

let $para := 
In a hole in the ground there lived a hobbit.
         
869 returns
let $para := 
In a hole in the ground there lived a hobbit.
         
870 (approximately).

The expression

let $para := 
In a hole in the ground there lived a hobbit.
         
871 returns
let $para := 
In a hole in the ground there lived a hobbit.
         
872 (approximately).

The expression

let $para := 
In a hole in the ground there lived a hobbit.
         
873 returns
let $para := 
In a hole in the ground there lived a hobbit.
         
220.

The expression

let $para := 
In a hole in the ground there lived a hobbit.
         
875 returns
let $para := 
In a hole in the ground there lived a hobbit.
         
220.

The expression

let $para := 
In a hole in the ground there lived a hobbit.
         
877 returns
let $para := 
In a hole in the ground there lived a hobbit.
         
220.

The expression

let $para := 
In a hole in the ground there lived a hobbit.
         
879 returns
let $para := 
In a hole in the ground there lived a hobbit.
         
220.

4.8.12 math:acos

Summary

Returns the arc cosine of the argument.

Signature

let $para := 
In a hole in the ground there lived a hobbit.
         
484(
let $para := 
In a hole in the ground there lived a hobbit.
         
25
let $para := 
In a hole in the ground there lived a hobbit.
         
71
let $para := 
In a hole in the ground there lived a hobbit.
         
29)
let $para := 
In a hole in the ground there lived a hobbit.
         
71
let $para := 
In a hole in the ground there lived a hobbit.
         
29

Properties

This function is ·deterministic·, ·context-independent·, and ·focus-independent·.

Rules

If

let $para := 
In a hole in the ground there lived a hobbit.
         
25 is the empty sequence, the function returns the empty sequence.

Otherwise the result is the arc cosine of

let $para := 
In a hole in the ground there lived a hobbit.
         
25, as defined in the [IEEE 754-2008] specification of the
let $para := 
In a hole in the ground there lived a hobbit.
         
889 function applied to 64-bit binary floating point values. The result is in the range zero to +π radians.

Notes

The treatment of the

1º 2º 3º 4º ...
90 exception is defined in 4.2 Arithmetic operators on numeric values.

If

let $para := 
In a hole in the ground there lived a hobbit.
         
25 is
fn:abs($N * $arg2) le fn:abs($arg1) 
               and fn:compare($N * $arg2, 0) eq fn:compare($arg1, 0).
90, or if its absolute value is greater than one, then the result is
fn:abs($N * $arg2) le fn:abs($arg1) 
               and fn:compare($N * $arg2, 0) eq fn:compare($arg1, 0).
90.

In other cases the result is an

let $para := 
In a hole in the ground there lived a hobbit.
         
26 value representing an angle θ in radians in the range
let $para := 
In a hole in the ground there lived a hobbit.
         
895θ
let $para := 
In a hole in the ground there lived a hobbit.
         
861π.

Examples

The expression

let $para := 
In a hole in the ground there lived a hobbit.
         
897 returns
let $para := 
In a hole in the ground there lived a hobbit.
         
96.

The expression

let $para := 
In a hole in the ground there lived a hobbit.
         
899 returns
let $para := 
In a hole in the ground there lived a hobbit.
         
870 (approximately).

The expression

let $para := 
In a hole in the ground there lived a hobbit.
         
901 returns
let $para := 
In a hole in the ground there lived a hobbit.
         
870 (approximately).

The expression

let $para := 
In a hole in the ground there lived a hobbit.
         
903 returns
let $para := 
In a hole in the ground there lived a hobbit.
         
169.

The expression

let $para := 
In a hole in the ground there lived a hobbit.
         
905 returns
let $para := 
In a hole in the ground there lived a hobbit.
         
906 (approximately).

The expression

let $para := 
In a hole in the ground there lived a hobbit.
         
907 returns
let $para := 
In a hole in the ground there lived a hobbit.
         
220.

The expression

let $para := 
In a hole in the ground there lived a hobbit.
         
909 returns
let $para := 
In a hole in the ground there lived a hobbit.
         
220.

The expression

let $para := 
In a hole in the ground there lived a hobbit.
         
911 returns
let $para := 
In a hole in the ground there lived a hobbit.
         
220.

The expression

let $para := 
In a hole in the ground there lived a hobbit.
         
913 returns
let $para := 
In a hole in the ground there lived a hobbit.
         
220.

4.8.13 math:atan

Summary

Returns the arc tangent of the argument.

Signature

let $para := 
In a hole in the ground there lived a hobbit.
         
485(
let $para := 
In a hole in the ground there lived a hobbit.
         
25
let $para := 
In a hole in the ground there lived a hobbit.
         
71
let $para := 
In a hole in the ground there lived a hobbit.
         
29)
let $para := 
In a hole in the ground there lived a hobbit.
         
71
let $para := 
In a hole in the ground there lived a hobbit.
         
29

Properties

This function is ·deterministic·, ·context-independent·, and ·focus-independent·.

Rules

If

let $para := 
In a hole in the ground there lived a hobbit.
         
25 is the empty sequence, the function returns the empty sequence.

Otherwise the result is the arc tangent of

let $para := 
In a hole in the ground there lived a hobbit.
         
25, as defined in the [IEEE 754-2008] specification of the
let $para := 
In a hole in the ground there lived a hobbit.
         
923 function applied to 64-bit binary floating point values. The result is in the range -π/2 to +π/2 radians.

Notes

The treatment of the

let $para := 
In a hole in the ground there lived a hobbit.
         
743 exception is defined in 4.2 Arithmetic operators on numeric values.

If

let $para := 
In a hole in the ground there lived a hobbit.
         
25 is positive or negative zero, the result is
let $para := 
In a hole in the ground there lived a hobbit.
         
25.

If

let $para := 
In a hole in the ground there lived a hobbit.
         
25 is
fn:abs($N * $arg2) le fn:abs($arg1) 
               and fn:compare($N * $arg2, 0) eq fn:compare($arg1, 0).
90 then the result is
fn:abs($N * $arg2) le fn:abs($arg1) 
               and fn:compare($N * $arg2, 0) eq fn:compare($arg1, 0).
90.

In other cases the result is an

let $para := 
In a hole in the ground there lived a hobbit.
         
26 value representing an angle θ in radians in the range -π
let $para := 
In a hole in the ground there lived a hobbit.
         
860θ
let $para := 
In a hole in the ground there lived a hobbit.
         
861π
let $para := 
In a hole in the ground there lived a hobbit.
         
862.

Examples

The expression

let $para := 
In a hole in the ground there lived a hobbit.
         
934 returns
let $para := 
In a hole in the ground there lived a hobbit.
         
96.

The expression

let $para := 
In a hole in the ground there lived a hobbit.
         
936 returns
let $para := 
In a hole in the ground there lived a hobbit.
         
169.

The expression

let $para := 
In a hole in the ground there lived a hobbit.
         
938 returns
fn:abs($N * $arg2) le fn:abs($arg1) 
               and fn:compare($N * $arg2, 0) eq fn:compare($arg1, 0).
92.

The expression

let $para := 
In a hole in the ground there lived a hobbit.
         
940 returns
let $para := 
In a hole in the ground there lived a hobbit.
         
941 (approximately).

The expression

let $para := 
In a hole in the ground there lived a hobbit.
         
942 returns
let $para := 
In a hole in the ground there lived a hobbit.
         
943 (approximately).

The expression

let $para := 
In a hole in the ground there lived a hobbit.
         
944 returns
let $para := 
In a hole in the ground there lived a hobbit.
         
220.

The expression

let $para := 
In a hole in the ground there lived a hobbit.
         
946 returns
let $para := 
In a hole in the ground there lived a hobbit.
         
870 (approximately).

The expression

let $para := 
In a hole in the ground there lived a hobbit.
         
948 returns
let $para := 
In a hole in the ground there lived a hobbit.
         
872 (approximately).

4.8.14 math:atan2

Summary

Returns the angle in radians subtended at the origin by the point on a plane with coordinates (x, y) and the positive x-axis.

Signature

let $para := 
In a hole in the ground there lived a hobbit.
         
486(
let $para := 
In a hole in the ground there lived a hobbit.
         
613
let $para := 
In a hole in the ground there lived a hobbit.
         
71
let $para := 
In a hole in the ground there lived a hobbit.
         
26,
let $para := 
In a hole in the ground there lived a hobbit.
         
610
let $para := 
In a hole in the ground there lived a hobbit.
         
71
let $para := 
In a hole in the ground there lived a hobbit.
         
26)
let $para := 
In a hole in the ground there lived a hobbit.
         
71
let $para := 
In a hole in the ground there lived a hobbit.
         
26

Properties

This function is ·deterministic·, ·context-independent·, and ·focus-independent·.

Rules

The result is the value of

let $para := 
In a hole in the ground there lived a hobbit.
         
959 as defined in the [IEEE 754-2008] specification of the
let $para := 
In a hole in the ground there lived a hobbit.
         
960 function applied to 64-bit binary floating point values. The result is in the range -π to +π radians.

Notes

The treatment of the

let $para := 
In a hole in the ground there lived a hobbit.
         
743 exception is defined in 4.2 Arithmetic operators on numeric values.

If either argument is

fn:abs($N * $arg2) le fn:abs($arg1) 
               and fn:compare($N * $arg2, 0) eq fn:compare($arg1, 0).
90 then the result is
fn:abs($N * $arg2) le fn:abs($arg1) 
               and fn:compare($N * $arg2, 0) eq fn:compare($arg1, 0).
90.

If

let $para := 
In a hole in the ground there lived a hobbit.
         
613 is positive and
let $para := 
In a hole in the ground there lived a hobbit.
         
610 is positive and finite, then (subject to rules for overflow, underflow and approximation) the value of
let $para := 
In a hole in the ground there lived a hobbit.
         
966 is
let $para := 
In a hole in the ground there lived a hobbit.
         
967.

If

let $para := 
In a hole in the ground there lived a hobbit.
         
613 is positive and
let $para := 
In a hole in the ground there lived a hobbit.
         
610 is negative and finite, then (subject to the same caveats) the value of
let $para := 
In a hole in the ground there lived a hobbit.
         
966 is π
let $para := 
In a hole in the ground there lived a hobbit.
         
971.

Some results for special values of the arguments are shown in the examples below.

Examples

The expression

let $para := 
In a hole in the ground there lived a hobbit.
         
972 returns
let $para := 
In a hole in the ground there lived a hobbit.
         
169.

The expression

let $para := 
In a hole in the ground there lived a hobbit.
         
974 returns
fn:abs($N * $arg2) le fn:abs($arg1) 
               and fn:compare($N * $arg2, 0) eq fn:compare($arg1, 0).
92.

The expression

let $para := 
In a hole in the ground there lived a hobbit.
         
976 returns
let $para := 
In a hole in the ground there lived a hobbit.
         
906.

The expression

let $para := 
In a hole in the ground there lived a hobbit.
         
978 returns
let $para := 
In a hole in the ground there lived a hobbit.
         
979.

The expression

let $para := 
In a hole in the ground there lived a hobbit.
         
980 returns
let $para := 
In a hole in the ground there lived a hobbit.
         
872.

The expression

let $para := 
In a hole in the ground there lived a hobbit.
         
982 returns
let $para := 
In a hole in the ground there lived a hobbit.
         
870.

The expression

let $para := 
In a hole in the ground there lived a hobbit.
         
984 returns
let $para := 
In a hole in the ground there lived a hobbit.
         
979.

The expression

let $para := 
In a hole in the ground there lived a hobbit.
         
986 returns
let $para := 
In a hole in the ground there lived a hobbit.
         
906.

The expression

let $para := 
In a hole in the ground there lived a hobbit.
         
988 returns
fn:abs($N * $arg2) le fn:abs($arg1) 
               and fn:compare($N * $arg2, 0) eq fn:compare($arg1, 0).
92.

The expression

let $para := 
In a hole in the ground there lived a hobbit.
         
990 returns
let $para := 
In a hole in the ground there lived a hobbit.
         
991.

4.9 Random Numbers

FunctionMeaning
let $para := 
In a hole in the ground there lived a hobbit.
         
992Returns a random number generator, which can be used to generate sequences of random numbers.

4.9.1 fn:random-number-generator

Summary

Returns a random number generator, which can be used to generate sequences of random numbers.

Signatures

let $para := 
In a hole in the ground there lived a hobbit.
         
992()
let $para := 
In a hole in the ground there lived a hobbit.
         
71
let $para := 
In a hole in the ground there lived a hobbit.
         
995

let $para := 
In a hole in the ground there lived a hobbit.
         
992(
let $para := 
In a hole in the ground there lived a hobbit.
         
997
let $para := 
In a hole in the ground there lived a hobbit.
         
71
let $para := 
In a hole in the ground there lived a hobbit.
         
196)
let $para := 
In a hole in the ground there lived a hobbit.
         
71
let $para := 
In a hole in the ground there lived a hobbit.
         
995

Properties

This function is ·deterministic·, ·context-independent·, ·focus-independent·, and ·higher-order·.

Rules

The function returns a random number generator. A random number generator is represented as a map containing three entries. The keys of each entry are strings:

  1. The entry with key

    let $para := 
    In a hole in the ground there lived a hobbit.
             
    002 holds a random number; it is an
    let $para := 
    In a hole in the ground there lived a hobbit.
             
    26 greater than or equal to zero (0.0e0), and less than one (1.0e0).

  2. The entry with key

    let $para := 
    In a hole in the ground there lived a hobbit.
             
    004 is a zero-arity function that can be called to return another random number generator.

    The properties of this function are as follows:

    • name: absent

    • parameter names: ()

    • signature:

      let $para := 
      In a hole in the ground there lived a hobbit.
               
      005

    • non-local variable bindings: none

    • implementation: implementation-dependent

  3. The entry with key

    let $para := 
    In a hole in the ground there lived a hobbit.
             
    006 is a function with arity 1 (one), which takes an arbitrary sequence as its argument, and returns a random permutation of that sequence.

    The properties of this function are as follows:

    • name: absent

    • parameter names: ("arg")

    • signature:

      let $para := 
      In a hole in the ground there lived a hobbit.
               
      007

    • non-local variable bindings: none

    • implementation: implementation-dependent

Calling the

let $para := 
In a hole in the ground there lived a hobbit.
         
992 function with no arguments is equivalent to calling the single-argument form of the function with an implementation-dependent seed.

Calling the

let $para := 
In a hole in the ground there lived a hobbit.
         
992 function with an empty sequence as the value of
let $para := 
In a hole in the ground there lived a hobbit.
         
997 is equivalent to calling the single-argument form of the function with an implementation-dependent seed.

If a

let $para := 
In a hole in the ground there lived a hobbit.
         
997 is supplied, it may be an atomic value of any type.

Both forms of the function are ·deterministic·: calling the function twice with the same arguments, within a single ·execution scope·, produces the same results.

The value of the

let $para := 
In a hole in the ground there lived a hobbit.
         
012 entry should be such that all eligible
let $para := 
In a hole in the ground there lived a hobbit.
         
26 values are equally likely to be chosen.

The function returned in the

let $para := 
In a hole in the ground there lived a hobbit.
         
014 entry should be such that all permutations of the supplied sequence are equally likely to be chosen.

The map returned by the

let $para := 
In a hole in the ground there lived a hobbit.
         
992 function may contain additional entries beyond those specified here, but it must match the type
let $para := 
In a hole in the ground there lived a hobbit.
         
995. The meaning of any additional entries is ·implementation-defined·. To avoid conflict with any future version of this specification, the keys of any such entries should start with an underscore character.

Notes

It is not meaningful to ask whether the functions returned in the

let $para := 
In a hole in the ground there lived a hobbit.
         
017 and
let $para := 
In a hole in the ground there lived a hobbit.
         
014 functions resulting from two separate calls with the same seed are "the same function", but the functions must be equivalent in the sense that calling them produces the same sequence of random numbers.

The repeatability of the results of function calls in different execution scopes is outside the scope of this specification. It is recommended that when the same seed is provided explicitly, the same random number sequence should be delivered even in different execution scopes; while if no seed is provided, the processor should choose a seed that is likely to be different from one execution scope to another. (The same effect can be achieved explicitly by using

let $para := 
In a hole in the ground there lived a hobbit.
         
019 as a seed.)

The specification does not place strong conformance requirements on the actual randomness of the result; this is left to the implementation. It is desirable, for example, when generating a sequence of random numbers that the sequence should not get into a repeating loop; but the specification does not attempt to dictate this.

Examples

The following example returns a random permutation of the integers in the range 1 to 100:

let $para := 
In a hole in the ground there lived a hobbit.
         
020

The following example returns a 10% sample of the items in an input sequence

let $para := 
In a hole in the ground there lived a hobbit.
         
021, chosen at random:
let $para := 
In a hole in the ground there lived a hobbit.
         
022

The following code defines a function that can be called to produce a random sequence of

let $para := 
In a hole in the ground there lived a hobbit.
         
26 values in the range zero to one, of specified length:

declare %public function r:random-sequence($length as xs:integer) as xs:double* {
  r:random-sequence($length, fn:random-number-generator())
};

declare %private function r:random-sequence($length as xs:integer, 
                                            $G as map(xs:string, item())) {
  if ($length eq 0)
  then ()
  else ($G?number, r:random-sequence($length - 1, $G?next()))
};

r:random-sequence(200);
            

5 Functions on strings

This section specifies functions and operators on the [XML Schema Part 2: Datatypes Second Edition]

let $para := 
In a hole in the ground there lived a hobbit.
         
10 datatype and the datatypes derived from it.

5.1 String types

The operators described in this section are defined on the following types. Each type whose name is indented is derived from the type whose name appears nearest above with one less level of indentation.

xs:string     xs:normalizedString    xs:token   xs:language  xs:NMTOKEN  xs:Name  xs:NCName xs:IDxs:IDREFxs:ENTITY

They also apply to user-defined types derived by restriction from the above types.

5.2 Functions to assemble and disassemble strings

FunctionMeaning
let $para := 
In a hole in the ground there lived a hobbit.
         
025Returns an
let $para := 
In a hole in the ground there lived a hobbit.
         
10 whose characters have supplied ·codepoints·.
let $para := 
In a hole in the ground there lived a hobbit.
         
027Returns the sequence of ·codepoints· that constitute an
let $para := 
In a hole in the ground there lived a hobbit.
         
10 value.

5.2.1 fn:codepoints-to-string

Summary

Returns an

let $para := 
In a hole in the ground there lived a hobbit.
         
10 whose characters have supplied ·codepoints·.

Signature

let $para := 
In a hole in the ground there lived a hobbit.
         
025(
let $para := 
In a hole in the ground there lived a hobbit.
         
25
let $para := 
In a hole in the ground there lived a hobbit.
         
71
let $para := 
In a hole in the ground there lived a hobbit.
         
033)
let $para := 
In a hole in the ground there lived a hobbit.
         
71
let $para := 
In a hole in the ground there lived a hobbit.
         
10

Properties

This function is ·deterministic·, ·context-independent·, and ·focus-independent·.

Rules

The function returns the string made up from the ·characters· whose Unicode ·codepoints· are supplied in

let $para := 
In a hole in the ground there lived a hobbit.
         
25. This will be the zero-length string if
let $para := 
In a hole in the ground there lived a hobbit.
         
25 is the empty sequence.

Error Conditions

A dynamic error is raised [err:FOCH0001] if any of the codepoints in

let $para := 
In a hole in the ground there lived a hobbit.
         
25 is not a permitted XML character.

Examples

The expression

let $para := 
In a hole in the ground there lived a hobbit.
         
039 returns
let $para := 
In a hole in the ground there lived a hobbit.
         
040.

The expression

let $para := 
In a hole in the ground there lived a hobbit.
         
041 returns
let $para := 
In a hole in the ground there lived a hobbit.
         
042.

The expression

let $para := 
In a hole in the ground there lived a hobbit.
         
043 returns
let $para := 
In a hole in the ground there lived a hobbit.
         
044.

The expression

let $para := 
In a hole in the ground there lived a hobbit.
         
045 raises error
let $para := 
In a hole in the ground there lived a hobbit.
         
046.

5.2.2 fn:string-to-codepoints

Summary

Returns the sequence of ·codepoints· that constitute an

let $para := 
In a hole in the ground there lived a hobbit.
         
10 value.

Signature

let $para := 
In a hole in the ground there lived a hobbit.
         
027(
let $para := 
In a hole in the ground there lived a hobbit.
         
25
let $para := 
In a hole in the ground there lived a hobbit.
         
71
let $para := 
In a hole in the ground there lived a hobbit.
         
244)
let $para := 
In a hole in the ground there lived a hobbit.
         
71
let $para := 
In a hole in the ground there lived a hobbit.
         
033

Properties

This function is ·deterministic·, ·context-independent·, and ·focus-independent·.

Rules

The function returns a sequence of integers, each integer being the Unicode ·codepoint· of the corresponding ·character· in

let $para := 
In a hole in the ground there lived a hobbit.
         
25.

If

let $para := 
In a hole in the ground there lived a hobbit.
         
25 is a zero-length string or the empty sequence, the function returns the empty sequence.

Examples

The expression

let $para := 
In a hole in the ground there lived a hobbit.
         
056 returns
let $para := 
In a hole in the ground there lived a hobbit.
         
057.

5.3 Comparison of strings

FunctionMeaning
let $para := 
In a hole in the ground there lived a hobbit.
         
058Returns -1, 0, or 1, depending on whether
let $para := 
In a hole in the ground there lived a hobbit.
         
059 collates before, equal to, or after
let $para := 
In a hole in the ground there lived a hobbit.
         
060 according to the rules of a selected collation.
let $para := 
In a hole in the ground there lived a hobbit.
         
061Returns true if two strings are equal, considered codepoint-by-codepoint.
let $para := 
In a hole in the ground there lived a hobbit.
         
062Given a string value and a collation, generates an internal value called a collation key, with the property that the matching and ordering of collation keys reflects the matching and ordering of strings under the specified collation.
let $para := 
In a hole in the ground there lived a hobbit.
         
063Determines whether or not any of the supplied strings, when tokenized at whitespace boundaries, contains the supplied token, under the rules of the supplied collation.

5.3.1 Collations

A collation is a specification of the manner in which ·strings· are compared and, by extension, ordered. When values whose type is

let $para := 
In a hole in the ground there lived a hobbit.
         
10 or a type derived from
let $para := 
In a hole in the ground there lived a hobbit.
         
10 are compared (or, equivalently, sorted), the comparisons are inherently performed according to some collation (even if that collation is defined entirely on codepoint values). The [Character Model for the World Wide Web 1.0: Fundamentals] observes that some applications may require different comparison and ordering behaviors than other applications. Similarly, some users having particular linguistic expectations may require different behaviors than other users. Consequently, the collation must be taken into account when comparing strings in any context. Several functions in this and the following section make use of a collation.

Collations can indicate that two different codepoints are, in fact, equal for comparison purposes (e.g., "v" and "w" are considered equivalent in some Swedish collations). Strings can be compared codepoint-by-codepoint or in a linguistically appropriate manner, as defined by the collation.

Some collations, especially those based on the Unicode Collation Algorithm (see [UTS #10]) can be "tailored" for various purposes. This document does not discuss such tailoring, nor does it provide a mechanism to perform tailoring. Instead, it assumes that the collation argument to the various functions below is a tailored and named collation.

The ·Unicode codepoint collation· is a collation available in every implementation, which sorts based on codepoint values. For further details see 5.3.2 The Unicode Codepoint Collation.

Collations may or may not perform Unicode normalization on strings before comparing them.

This specification assumes that collations are named and that the collation name may be provided as an argument to string functions. Functions that allow specification of a collation do so with an argument whose type is

let $para := 
In a hole in the ground there lived a hobbit.
         
10 but whose lexical form must conform to an
let $para := 
In a hole in the ground there lived a hobbit.
         
30. If the collation is specified using a relative URI reference, it is resolved relative to the value of the static base URI property from the static context. This specification also defines the manner in which a default collation is determined if the collation argument is not specified in calls of functions that use a collation but allow it to be omitted.

This specification does not define whether or not the collation URI is dereferenced. The collation URI may be an abstract identifier, or it may refer to an actual resource describing the collation. If it refers to a resource, this specification does not define the nature of that resource. One possible candidate is that the resource is a locale description expressed using the Locale Data Markup Language: see [UTS #35].

Functions such as

let $para := 
In a hole in the ground there lived a hobbit.
         
058 and
let $para := 
In a hole in the ground there lived a hobbit.
         
069 that compare
let $para := 
In a hole in the ground there lived a hobbit.
         
10 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 URI. For example, suppose there is a collation
let $para := 
In a hole in the ground there lived a hobbit.
         
071 that refers to a French collation that compares on the basis of base characters. Collations that use the same basic rules, but with higher strengths, for example, base characters and accents, or base characters, accents and case, would need to be given different names, say
let $para := 
In a hole in the ground there lived a hobbit.
         
072 and
let $para := 
In a hole in the ground there lived a hobbit.
         
073. Note that some specifications use the term collation to refer to an algorithm that can be parameterized, but in this specification, each possible parameterization is considered to be a distinct collation.

The XQuery/XPath static context includes a provision for a default collation that can be used for string comparisons and ordering operations. See the description of the static context in Section 2.1.1 Static Context XP31. If the default collation is not specified by the user or the system, the default collation is the ·Unicode codepoint collation·.

Note:

XML allows elements to specify the

let $para := 
In a hole in the ground there lived a hobbit.
         
297 attribute to indicate the language associated with the content of such an element. This specification does not use
let $para := 
In a hole in the ground there lived a hobbit.
         
297 to identify the default collation because using
let $para := 
In a hole in the ground there lived a hobbit.
         
297 does not produce desired effects when the two strings to be compared have different
let $para := 
In a hole in the ground there lived a hobbit.
         
297 values or when a string is multilingual.

5.3.2 The Unicode Codepoint Collation

[Definition] The collation URI

let $para := 
In a hole in the ground there lived a hobbit.
         
078 identifies a collation which must be recognized by every implementation: it is referred to as the Unicode codepoint collation (not to be confused with the Unicode collation algorithm).

The Unicode codepoint collation does not perform any normalization on the supplied strings.

The collation is defined as follows. Each of the two strings is converted to a sequence of integers using the

let $para := 
In a hole in the ground there lived a hobbit.
         
027 function. These two sequences
let $para := 
In a hole in the ground there lived a hobbit.
         
080 and
let $para := 
In a hole in the ground there lived a hobbit.
         
081 are then compared as follows:

  • If both sequences are empty, the strings are equal.

  • If one sequence is empty and the other is not, then the string corresponding to the empty sequence is less than the other string.

  • If the first integer in

    let $para := 
    In a hole in the ground there lived a hobbit.
             
    080 is less than the first integer in
    let $para := 
    In a hole in the ground there lived a hobbit.
             
    081, then the string corresponding to
    let $para := 
    In a hole in the ground there lived a hobbit.
             
    080 is less than the string corresponding to
    let $para := 
    In a hole in the ground there lived a hobbit.
             
    081.

  • If the first integer in

    let $para := 
    In a hole in the ground there lived a hobbit.
             
    080 is greater than the first integer in
    let $para := 
    In a hole in the ground there lived a hobbit.
             
    081, then the string corresponding to
    let $para := 
    In a hole in the ground there lived a hobbit.
             
    080 is greater than the string corresponding to
    let $para := 
    In a hole in the ground there lived a hobbit.
             
    081.

  • Otherwise (the first pair of integers are equal), the result is obtained by applying the same rules recursively to

    let $para := 
    In a hole in the ground there lived a hobbit.
             
    090 and
    let $para := 
    In a hole in the ground there lived a hobbit.
             
    091

Note:

While the Unicode codepoint collation does not produce results suitable for quality publishing of printed indexes or directories, it is adequate for many purposes where a restricted alphabet is used, such as sorting of vehicle registrations.

5.3.3 The Unicode Collation Algorithm

This specification defines a family of collation URIs representing tailorings of the Unicode Collation Algorithm (UCA) as defined in [UTS #10]. The parameters used for tailoring the UCA are based on the parameters defined in the Locale Data Markup Language (LDML), defined in [UTS #35].

This family of URIs use the scheme and path

let $para := 
In a hole in the ground there lived a hobbit.
         
092 followed by an optional query part. The query part, if present, consists of a question mark followed by a sequence of zero or more semicolon-separated parameters. Each parameter is a keyword-value pair, the keyword and value being separated by an equals sign.

All implementations must recognize URIs in this family in the

let $para := 
In a hole in the ground there lived a hobbit.
         
093 argument of functions that take a collation argument.

If the

let $para := 
In a hole in the ground there lived a hobbit.
         
094 parameter is present with the value
let $para := 
In a hole in the ground there lived a hobbit.
         
095, then the implementation must either use a collation that conforms with the rules in the Unicode specifications for the requested tailoring, or fail with a static or dynamic error indicating that it does not provide the collation (the error code should be the same as if the collation URI were not recognized). If the
let $para := 
In a hole in the ground there lived a hobbit.
         
094 parameter is omitted or takes the value
let $para := 
In a hole in the ground there lived a hobbit.
         
097, and if the collation URI is well-formed according to the rules in this section, then the implementation must accept the collation URI, and should use the available collation that most closely reflects the user's intentions. For example, if the collation URI requested is
let $para := 
In a hole in the ground there lived a hobbit.
         
098 and the implementation does not include a fully conformant version of the UCA tailored for Swedish, then it may choose to use a Swedish collation that is known to differ from the UCA definition, or one whose conformance has not been established. It might even, as a last resort, fall back to using codepoint collation.

If two query parameters use the same keyword then the last one wins. If a query parameter uses a keyword or value which is not defined in this specification then the meaning is ·implementation-defined·. If the implementation recognizes the meaning of the keyword and value then it should interpret it accordingly; if it does not recognize the keyword or value then if the

let $para := 
In a hole in the ground there lived a hobbit.
         
094 parameter is present with the value
let $para := 
In a hole in the ground there lived a hobbit.
         
095 it should reject the collation as unsupported, otherwise it should ignore the unrecognized parameter.

The following query parameters are defined. If any parameter is absent, the default is ·implementation-defined· except where otherwise stated. The meaning given for each parameter is non-normative; the normative specification is found in [UTS #35].

KeywordValuesMeaningfallbackyes | no (default yes)Determines whether the processor uses a fallback collation if a conformant collation is not available.langlanguage code: a string in the lexical space of
let $para := 
In a hole in the ground there lived a hobbit.
         
101
.The language whose collation conventions are to be used.versionstringThe version number of the UCA to be used.strength (default tertiary)primary | secondary | tertiary | quaternary | identical, or 1|2|3|4|5 as synonymsThe collation strength as defined in UCA. Primary strength takes only the base form of the character into account (so A=a=Ä=ä); secondary strength ignores case but considers accents and diacritics as significant (so A=a and Ä=ä but ä≠a); tertiary considers case as significant (A≠a≠Ä≠ä); quaternary considers spaces and punctuation that would otherwise be ignored (for example
let $para := 
In a hole in the ground there lived a hobbit.
         
102=
let $para := 
In a hole in the ground there lived a hobbit.
         
103).maxVariablespace | punct | symbol | currency (default punct)Indicates that all characters in the specified group and earlier groups are treated as "noise" characters to be handled as defined by the
let $para := 
In a hole in the ground there lived a hobbit.
         
104 parameter. For example,
let $para := 
In a hole in the ground there lived a hobbit.
         
105 indicates that characters classified as whitespace or punctuation get this treatment.alternatenon-ignorable | shifted | blanked (default non-ignorable)Controls the handling of characters such as spaces and hyphens; specifically, the "noise" characters in the groups selected by the
let $para := 
In a hole in the ground there lived a hobbit.
         
106 parameter. The value
let $para := 
In a hole in the ground there lived a hobbit.
         
107 indicates that such characters are treated as distinct at the primary level (so
let $para := 
In a hole in the ground there lived a hobbit.
         
108 sorts before
let $para := 
In a hole in the ground there lived a hobbit.
         
109);
let $para := 
In a hole in the ground there lived a hobbit.
         
110 indicates that they are used to differentiate two strings only at the
let $para := 
In a hole in the ground there lived a hobbit.
         
111 level, and
let $para := 
In a hole in the ground there lived a hobbit.
         
112 indicates that they are taken into account only at the
let $para := 
In a hole in the ground there lived a hobbit.
         
113 level.backwardsyes | no (default no)The value
let $para := 
In a hole in the ground there lived a hobbit.
         
114 indicates that the last accent in the string is the most significant.normalizationyes | no (default no)Indicates whether strings are converted to normalization form D.caseLevelyes | no (default no)When used with primary strength, setting
let $para := 
In a hole in the ground there lived a hobbit.
         
115 has the effect of ignoring accents while taking account of case.caseFirstupper | lowerIndicates whether upper-case precedes lower-case or vice versa.numericyes | no (default no)When
let $para := 
In a hole in the ground there lived a hobbit.
         
116 is specified, a sequence of consecutive digits is interpreted as a number, for example
let $para := 
In a hole in the ground there lived a hobbit.
         
117 sorts before
let $para := 
In a hole in the ground there lived a hobbit.
         
118.reordera comma-separated sequence of reorder codes, where a reorder code is one of
let $para := 
In a hole in the ground there lived a hobbit.
         
119,
let $para := 
In a hole in the ground there lived a hobbit.
         
120,
let $para := 
In a hole in the ground there lived a hobbit.
         
121,
let $para := 
In a hole in the ground there lived a hobbit.
         
122,
let $para := 
In a hole in the ground there lived a hobbit.
         
365, or a four-letter script code defined in [ISO 15924 Register], the register of scripts maintained by the Unicode Consortium in its capacity as registration authority for [ISO 15924].Determines the relative ordering of text in different scripts; for example the value
let $para := 
In a hole in the ground there lived a hobbit.
         
124 indicates that digits precede Greek letters, which precede Latin letters.

Note:

This list excludes parameters that are inconvenient to express in a URI, or that are applicable only to substring matching.

5.3.4 The HTML ASCII Case-Insensitive Collation

The collation URI

let $para := 
In a hole in the ground there lived a hobbit.
         
125 must be recognized by every implementation. It is used to refer to the HTML ASCII case-insensitive collation as defined in [HTML5: A vocabulary and associated APIs for HTML and XHTML] (section 2.5, Case sensitivity and string comparison). It is used, for example, when matching HTML
let $para := 
In a hole in the ground there lived a hobbit.
         
126 attribute values.

Note:

The definition of the collation is paraphrased here for convenience:

Comparing two strings in an ASCII case-insensitive manner means comparing them exactly, codepoint for codepoint, except that the characters in the range x41 to x5A (A-Z) and the corresponding characters in the range x61 to x7A (a-z) are considered to also match.

HTML5 defines the semantics of equality matching using this collation; it does not define rules for ordering. If the collation is used for ordering, the results are ·implementation-defined·. The collation supports collation units and can therefore be used with functions such as

let $para := 
In a hole in the ground there lived a hobbit.
         
127; each Unicode codepoint is a single collation unit.

5.3.5 Choosing a collation

Many functions have two signatures, where one signature includes a

let $para := 
In a hole in the ground there lived a hobbit.
         
128 argument and the other omits this argument.

The collation to use for these functions is determined by the following rules:

  1. If the function specifies an explicit collation, CollationA (e.g., if the optional collation argument is specified in a call of the

    let $para := 
    In a hole in the ground there lived a hobbit.
             
    058 function), then:

    • If CollationA is supported by the implementation, then CollationA is used.

    • Otherwise, a dynamic error is raised [err:FOCH0002].

  2. If no collation is explicitly specified for the function and the default collation in the XQuery/XPath static context is CollationB, then:

    • If CollationB is supported by the implementation, then CollationB is used.

    • Otherwise, a dynamic error is raised [err:FOCH0002].

Note:

Because the set of collations that are supported is ·implementation-defined·, an implementation has the option to support all collation URIs, in which case it will never raise this error.

If the value of the collation argument is a relative URI reference, it is resolved against the base-URI from the static context. If it is a relative URI reference and cannot be resolved, perhaps because the base-URI property in the static context is absent, a dynamic error is raised [err:FOCH0002].

Note:

There is no explicit requirement that the string used as a collation URI be a valid URI. Implementations will in many cases reject such strings on the grounds that do not identify a supported collation; they may also cause an error if they cannot be resolved against the static base URI.

5.3.6 fn:compare

Summary

Returns -1, 0, or 1, depending on whether

let $para := 
In a hole in the ground there lived a hobbit.
         
059 collates before, equal to, or after
let $para := 
In a hole in the ground there lived a hobbit.
         
060 according to the rules of a selected collation.

Signatures

let $para := 
In a hole in the ground there lived a hobbit.
         
058(
let $para := 
In a hole in the ground there lived a hobbit.
         
059
let $para := 
In a hole in the ground there lived a hobbit.
         
71
let $para := 
In a hole in the ground there lived a hobbit.
         
244,
let $para := 
In a hole in the ground there lived a hobbit.
         
060
let $para := 
In a hole in the ground there lived a hobbit.
         
71
let $para := 
In a hole in the ground there lived a hobbit.
         
244)
let $para := 
In a hole in the ground there lived a hobbit.
         
71
let $para := 
In a hole in the ground there lived a hobbit.
         
229

let $para := 
In a hole in the ground there lived a hobbit.
         
058(
let $para := 
In a hole in the ground there lived a hobbit.
         
059
let $para := 
In a hole in the ground there lived a hobbit.
         
71
let $para := 
In a hole in the ground there lived a hobbit.
         
244,
let $para := 
In a hole in the ground there lived a hobbit.
         
060
let $para := 
In a hole in the ground there lived a hobbit.
         
71
let $para := 
In a hole in the ground there lived a hobbit.
         
244,
let $para := 
In a hole in the ground there lived a hobbit.
         
128
let $para := 
In a hole in the ground there lived a hobbit.
         
71
let $para := 
In a hole in the ground there lived a hobbit.
         
10)
let $para := 
In a hole in the ground there lived a hobbit.
         
71
let $para := 
In a hole in the ground there lived a hobbit.
         
229

Properties

The two-argument form of this function is ·deterministic·, ·context-dependent·, and ·focus-independent·. It depends on collations.

The three-argument form of this function is ·deterministic·, ·context-dependent·, and ·focus-independent·. It depends on collations, and static base URI.

Rules

Returns -1, 0, or 1, depending on whether the value of the

let $para := 
In a hole in the ground there lived a hobbit.
         
059 is respectively less than, equal to, or greater than the value of
let $para := 
In a hole in the ground there lived a hobbit.
         
060, according to the rules of the collation that is used.

The collation used by this function is determined according to the rules in 5.3.5 Choosing a collation.

If either

let $para := 
In a hole in the ground there lived a hobbit.
         
059 or
let $para := 
In a hole in the ground there lived a hobbit.
         
060 is the empty sequence, the function returns the empty sequence.

This function, called with the first signature, defines the semantics of the "eq", "ne", "gt", "lt", "le" and "ge" operators on

let $para := 
In a hole in the ground there lived a hobbit.
         
10 values.

Examples

The expression

let $para := 
In a hole in the ground there lived a hobbit.
         
158 returns
declare %public function r:random-sequence($length as xs:integer) as xs:double* {
  r:random-sequence($length, fn:random-number-generator())
};

declare %private function r:random-sequence($length as xs:integer, 
                                            $G as map(xs:string, item())) {
  if ($length eq 0)
  then ()
  else ($G?number, r:random-sequence($length - 1, $G?next()))
};

r:random-sequence(200);
            
19.

The expression

let $para := 
In a hole in the ground there lived a hobbit.
         
160 returns
declare %public function r:random-sequence($length as xs:integer) as xs:double* {
  r:random-sequence($length, fn:random-number-generator())
};

declare %private function r:random-sequence($length as xs:integer, 
                                            $G as map(xs:string, item())) {
  if ($length eq 0)
  then ()
  else ($G?number, r:random-sequence($length - 1, $G?next()))
};

r:random-sequence(200);
            
19. (Assuming the default collation includes provisions that equate "ss" and the (German) character "ß" ("sharp-s"). Otherwise, the returned value depends on the semantics of the default collation.)

The expression

let $para := 
In a hole in the ground there lived a hobbit.
         
162 returns
declare %public function r:random-sequence($length as xs:integer) as xs:double* {
  r:random-sequence($length, fn:random-number-generator())
};

declare %private function r:random-sequence($length as xs:integer, 
                                            $G as map(xs:string, item())) {
  if ($length eq 0)
  then ()
  else ($G?number, r:random-sequence($length - 1, $G?next()))
};

r:random-sequence(200);
            
19. (The specified collation equates "ss" and the (German) character "ß" ("sharp-s").)

The expression

let $para := 
In a hole in the ground there lived a hobbit.
         
164 returns
declare %public function r:random-sequence($length as xs:integer) as xs:double* {
  r:random-sequence($length, fn:random-number-generator())
};

declare %private function r:random-sequence($length as xs:integer, 
                                            $G as map(xs:string, item())) {
  if ($length eq 0)
  then ()
  else ($G?number, r:random-sequence($length - 1, $G?next()))
};

r:random-sequence(200);
            
13. (Assuming the default collation includes provisions that treat differences between "ss" and the (German) character "ß" ("sharp-s") with less strength than the differences between the base characters, such as the final "n". ).

5.3.7 fn:codepoint-equal

Summary

Returns true if two strings are equal, considered codepoint-by-codepoint.

Signature

let $para := 
In a hole in the ground there lived a hobbit.
         
061(
let $para := 
In a hole in the ground there lived a hobbit.
         
059
let $para := 
In a hole in the ground there lived a hobbit.
         
71
let $para := 
In a hole in the ground there lived a hobbit.
         
244,
let $para := 
In a hole in the ground there lived a hobbit.
         
060
let $para := 
In a hole in the ground there lived a hobbit.
         
71
let $para := 
In a hole in the ground there lived a hobbit.
         
244)
let $para := 
In a hole in the ground there lived a hobbit.
         
71
op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
63

Properties

This function is ·deterministic·, ·context-independent·, and ·focus-independent·.

Rules

If either argument is the empty sequence, the function returns the empty sequence.

Otherwise, the function returns

op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
76 or
let $C := 'http://www.w3.org/2013/collation/UCA?strength=primary'
07 depending on whether the value of
let $para := 
In a hole in the ground there lived a hobbit.
         
059 is equal to the value of
let $para := 
In a hole in the ground there lived a hobbit.
         
060, according to the Unicode codepoint collation (
let $para := 
In a hole in the ground there lived a hobbit.
         
078).

Notes

This function allows

let $para := 
In a hole in the ground there lived a hobbit.
         
30 values to be compared without having to specify the Unicode codepoint collation.

Examples

The expression

let $para := 
In a hole in the ground there lived a hobbit.
         
181 returns
let $para := 
In a hole in the ground there lived a hobbit.
         
182.

The expression

let $para := 
In a hole in the ground there lived a hobbit.
         
183 returns
let $para := 
In a hole in the ground there lived a hobbit.
         
184.

The expression

let $para := 
In a hole in the ground there lived a hobbit.
         
185 returns
let $para := 
In a hole in the ground there lived a hobbit.
         
182.

The expression

let $para := 
In a hole in the ground there lived a hobbit.
         
187 returns
let $para := 
In a hole in the ground there lived a hobbit.
         
96.

The expression

let $para := 
In a hole in the ground there lived a hobbit.
         
189 returns
let $para := 
In a hole in the ground there lived a hobbit.
         
96.

5.3.8 fn:collation-key

Summary

Given a string value and a collation, generates an internal value called a collation key, with the property that the matching and ordering of collation keys reflects the matching and ordering of strings under the specified collation.

Signatures

let $para := 
In a hole in the ground there lived a hobbit.
         
062(
let $para := 
In a hole in the ground there lived a hobbit.
         
192
let $para := 
In a hole in the ground there lived a hobbit.
         
71
let $para := 
In a hole in the ground there lived a hobbit.
         
10)
let $para := 
In a hole in the ground there lived a hobbit.
         
71
let $para := 
In a hole in the ground there lived a hobbit.
         
196

let $para := 
In a hole in the ground there lived a hobbit.
         
062(
let $para := 
In a hole in the ground there lived a hobbit.
         
192
let $para := 
In a hole in the ground there lived a hobbit.
         
71
let $para := 
In a hole in the ground there lived a hobbit.
         
10,
let $para := 
In a hole in the ground there lived a hobbit.
         
128
let $para := 
In a hole in the ground there lived a hobbit.
         
71
let $para := 
In a hole in the ground there lived a hobbit.
         
10)
let $para := 
In a hole in the ground there lived a hobbit.
         
71
let $para := 
In a hole in the ground there lived a hobbit.
         
196

Properties

This function is ·deterministic·, ·context-dependent·, and ·focus-independent·. It depends on collations.

Rules

Calling the one-argument version of this function is equivalent to calling the two-argument version supplying the default collation as the second argument.

The function returns an ·implementation-dependent· value with the property that, for any two strings

let $para := 
In a hole in the ground there lived a hobbit.
         
206 and
let $para := 
In a hole in the ground there lived a hobbit.
         
207:

  • let $para := 
    In a hole in the ground there lived a hobbit.
             
    208 if and only if
    let $para := 
    In a hole in the ground there lived a hobbit.
             
    209

  • let $para := 
    In a hole in the ground there lived a hobbit.
             
    210 if and only if
    let $para := 
    In a hole in the ground there lived a hobbit.
             
    211

The collation used by this function is determined according to the rules in 5.3.5 Choosing a collation. Collation keys are defined as

let $para := 
In a hole in the ground there lived a hobbit.
         
196 values to ensure unambiguous and context-free comparison semantics.

An implementation is free to generate a collation key in any convenient way provided that it always generates the same collation key for two strings that are equal under the collation, and different collation keys for strings that are not equal. This holds only within a single ·execution scope·; an implementation is under no obligation to generate the same collation keys during a subsequent unrelated query or transformation.

It is possible to define collations that do not have the ability to generate collation keys. Supplying such a collation will cause the function to fail. The ability to generate collation keys is an ·implementation-defined· property of the collation.

Error Conditions

An error is raised [err:FOCH0004] if the specified collation does not support the generation of collation keys.

Notes

The function is provided primarily for use with maps. If a map is required where 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

let $para := 
In a hole in the ground there lived a hobbit.
         
213,
let $para := 
In a hole in the ground there lived a hobbit.
         
214,
let $para := 
In a hole in the ground there lived a hobbit.
         
215, or
let $para := 
In a hole in the ground there lived a hobbit.
         
216, 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 accents.

The result of the function is defined to be an

let $para := 
In a hole in the ground there lived a hobbit.
         
196 value. Binary values are chosen because they have unambiguous and context-free comparison semantics, because the value space is unbounded, and because the ordering rules are such that between any two values in the ordered value space, an arbitrary number of further values can be interpolated. The choice between
let $para := 
In a hole in the ground there lived a hobbit.
         
196 and
let $para := 
In a hole in the ground there lived a hobbit.
         
219 is arbitrary; the only operation that behaves differently between the two binary data types is conversion to/from a string, and this operation is not one that is normally required for effective use of collation keys.

For collations based on the Unicode Collation Algorithm, an algorithm for computing collation keys is provided in [UTS #10]. Implementations are not required to use this algorithm.

This specification does not mandate that collation keys should retain ordering. This is partly because the primary use case is for maps, where only equality comparisons are required, and partly to allow the use of binary data types (which are currently unordered types) for the result. The specification may be revised in a future release to specify that ordering is preserved.

The fact that collation keys are ordered can be exploited in XQuery, whose

let $para := 
In a hole in the ground there lived a hobbit.
         
220 clause does not allow the collation to be selected dynamically. This restriction can be circumvented by rewriting the clause
let $para := 
In a hole in the ground there lived a hobbit.
         
221 as
let $para := 
In a hole in the ground there lived a hobbit.
         
222, where
let $para := 
In a hole in the ground there lived a hobbit.
         
128 allows the collation to be chosen dynamically.

Note that

let $para := 
In a hole in the ground there lived a hobbit.
         
196 becomes an ordered type in XPath 3.1, making binary collation keys possible.

Examples

let $C := 'http://www.w3.org/2013/collation/UCA?strength=primary'

The expression

let $para := 
In a hole in the ground there lived a hobbit.
         
225 returns
let $para := 
In a hole in the ground there lived a hobbit.
         
226. (Given that the keys of the two entries are equal under the rules of the chosen collation, only one of the entries can appear in the result; the one that is chosen is the one from the last map in the input sequence.)

The expression

let $para := 
In a hole in the ground there lived a hobbit.
         
227 returns
declare %public function r:random-sequence($length as xs:integer) as xs:double* {
  r:random-sequence($length, fn:random-number-generator())
};

declare %private function r:random-sequence($length as xs:integer, 
                                            $G as map(xs:string, item())) {
  if ($length eq 0)
  then ()
  else ($G?number, r:random-sequence($length - 1, $G?next()))
};

r:random-sequence(200);
            
13. (The strings "A" and "a" have the same collation key under this collation.)

As the above examples illustrate, it is important that when the

let $para := 
In a hole in the ground there lived a hobbit.
         
229 function is used to add entries to a map, then it must also be used when retrieving entries from the map. This process can be made less error-prone by encapsulating the map within a function:
let $para := 
In a hole in the ground there lived a hobbit.
         
230.

5.3.9 fn:contains-token

Summary

Determines whether or not any of the supplied strings, when tokenized at whitespace boundaries, contains the supplied token, under the rules of the supplied collation.

Signatures

let $para := 
In a hole in the ground there lived a hobbit.
         
063(
let $para := 
In a hole in the ground there lived a hobbit.
         
232
let $para := 
In a hole in the ground there lived a hobbit.
         
71
let $para := 
In a hole in the ground there lived a hobbit.
         
234,
let $para := 
In a hole in the ground there lived a hobbit.
         
235
let $para := 
In a hole in the ground there lived a hobbit.
         
71
let $para := 
In a hole in the ground there lived a hobbit.
         
10)
let $para := 
In a hole in the ground there lived a hobbit.
         
71
op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
32

let $para := 
In a hole in the ground there lived a hobbit.
         
063(
let $para := 
In a hole in the ground there lived a hobbit.
         
232
let $para := 
In a hole in the ground there lived a hobbit.
         
71
let $para := 
In a hole in the ground there lived a hobbit.
         
234,
let $para := 
In a hole in the ground there lived a hobbit.
         
235
let $para := 
In a hole in the ground there lived a hobbit.
         
71
let $para := 
In a hole in the ground there lived a hobbit.
         
10,
let $para := 
In a hole in the ground there lived a hobbit.
         
128
let $para := 
In a hole in the ground there lived a hobbit.
         
71
let $para := 
In a hole in the ground there lived a hobbit.
         
10)
let $para := 
In a hole in the ground there lived a hobbit.
         
71
op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
32

Properties

The two-argument form of this function is ·deterministic·, ·context-dependent·, and ·focus-independent·. It depends on collations.

The three-argument form of this function is ·deterministic·, ·context-dependent·, and ·focus-independent·. It depends on collations, and static base URI.

Rules

If

let $para := 
In a hole in the ground there lived a hobbit.
         
232 is the empty sequence, the function returns
let $C := 'http://www.w3.org/2013/collation/UCA?strength=primary'
07.

Leading and trailing whitespace is trimmed from the supplied value of

let $para := 
In a hole in the ground there lived a hobbit.
         
235. If the trimmed value of
let $para := 
In a hole in the ground there lived a hobbit.
         
235 is a zero-length string, the function returns
let $C := 'http://www.w3.org/2013/collation/UCA?strength=primary'
07.

The collation used by this function is determined according to the rules in 5.3.5 Choosing a collation.

The function returns true if and only if there is string in

let $para := 
In a hole in the ground there lived a hobbit.
         
232 which, after tokenizing at whitespace boundaries, contains a token that is equal to the trimmed value of
let $para := 
In a hole in the ground there lived a hobbit.
         
235 under the rules of the selected collation.

That is, the function returns the value of the expression:

let $para := 
In a hole in the ground there lived a hobbit.
         
0

Notes

Interior whitespace within

let $para := 
In a hole in the ground there lived a hobbit.
         
235 will cause the function to return
let $C := 'http://www.w3.org/2013/collation/UCA?strength=primary'
07, unless such whitespace is ignored by the selected collation.

This function can be used for processing space-separated attribute values (for example, the XHTML and DITA class attribute), where one often needs to test for the presence of a single token in a space-separated list. The function is designed to work both when the attribute has been validated against an XSD list type, and when it appears as a single untyped string. It differs from the HTML 5 definition in that HTML 5 recognizes form feed (x0C) as a separator. To reproduce the HTML token matching behavior, the HTML ASCII case-insensitive collation should be used: see 5.3.4 The HTML ASCII Case-Insensitive Collation.

Examples

The expression

let $para := 
In a hole in the ground there lived a hobbit.
         
261 returns
let $para := 
In a hole in the ground there lived a hobbit.
         
182.

The expression

let $para := 
In a hole in the ground there lived a hobbit.
         
263 returns
let $para := 
In a hole in the ground there lived a hobbit.
         
182.

The expression

let $para := 
In a hole in the ground there lived a hobbit.
         
265 returns
let $para := 
In a hole in the ground there lived a hobbit.
         
184.

The expression

let $para := 
In a hole in the ground there lived a hobbit.
         
267 returns
let $para := 
In a hole in the ground there lived a hobbit.
         
182.

5.4 Functions on string values

The following functions are defined on values of type

let $para := 
In a hole in the ground there lived a hobbit.
         
10 and types derived from it.

FunctionMeaning
let $para := 
In a hole in the ground there lived a hobbit.
         
98Returns the concatenation of the string values of the arguments.
let $para := 
In a hole in the ground there lived a hobbit.
         
271Returns a string created by concatenating the items in a sequence, with a defined separator between adjacent items.
let $para := 
In a hole in the ground there lived a hobbit.
         
61Returns the portion of the value of
let $para := 
In a hole in the ground there lived a hobbit.
         
273 beginning at the position indicated by the value of
let $para := 
In a hole in the ground there lived a hobbit.
         
274 and continuing for the number of ·characters· indicated by the value of
let $para := 
In a hole in the ground there lived a hobbit.
         
275.
let $para := 
In a hole in the ground there lived a hobbit.
         
62Returns the number of ·characters· in a string.
let $para := 
In a hole in the ground there lived a hobbit.
         
215Returns the value of
let $para := 
In a hole in the ground there lived a hobbit.
         
25 with leading and trailing whitespace removed, and sequences of internal whitespace reduced to a single space character.
let $para := 
In a hole in the ground there lived a hobbit.
         
216Returns the value of
let $para := 
In a hole in the ground there lived a hobbit.
         
25 after applying Unicode normalization.
let $para := 
In a hole in the ground there lived a hobbit.
         
213Converts a string to upper case.
let $para := 
In a hole in the ground there lived a hobbit.
         
214Converts a string to lower case.
let $para := 
In a hole in the ground there lived a hobbit.
         
63Returns the value of
let $para := 
In a hole in the ground there lived a hobbit.
         
25 modified by replacing or removing individual characters.

Notes:

When the above operators and functions are applied to datatypes derived from

let $para := 
In a hole in the ground there lived a hobbit.
         
10, they are guaranteed to return values that are instances of
let $para := 
In a hole in the ground there lived a hobbit.
         
10, but the value might or might not be an instance of the particular subtype of
let $para := 
In a hole in the ground there lived a hobbit.
         
10 to which they were applied.

The strings returned by

let $para := 
In a hole in the ground there lived a hobbit.
         
98 and
let $para := 
In a hole in the ground there lived a hobbit.
         
271 are not guaranteed to be normalized. But see note in
let $para := 
In a hole in the ground there lived a hobbit.
         
98.

5.4.1 fn:concat

Summary

Returns the concatenation of the string values of the arguments.

Operator Mapping

The two-argument form of this function defines the semantics of the "||" operator.

Signature

let $para := 
In a hole in the ground there lived a hobbit.
         
98(
let $para := 
In a hole in the ground there lived a hobbit.
         
70
let $para := 
In a hole in the ground there lived a hobbit.
         
71
let $para := 
In a hole in the ground there lived a hobbit.
         
196,
let $para := 
In a hole in the ground there lived a hobbit.
         
73
let $para := 
In a hole in the ground there lived a hobbit.
         
71
let $para := 
In a hole in the ground there lived a hobbit.
         
196,...)
let $para := 
In a hole in the ground there lived a hobbit.
         
71
let $para := 
In a hole in the ground there lived a hobbit.
         
10

Properties

This function is ·deterministic·, ·context-independent·, and ·focus-independent·.

Rules

This function accepts two or more

let $para := 
In a hole in the ground there lived a hobbit.
         
34 arguments and casts each one to
let $para := 
In a hole in the ground there lived a hobbit.
         
10. The function returns the
let $para := 
In a hole in the ground there lived a hobbit.
         
10 that is the concatenation of the values of its arguments after conversion. If any argument is the empty sequence, that argument is treated as the zero-length string.

The

let $para := 
In a hole in the ground there lived a hobbit.
         
98 function is specified to allow two or more arguments, which are concatenated together. This is the only function specified in this document that allows a variable number of arguments. This capability is retained for compatibility with [XML Path Language (XPath) Version 1.0].

Notes

As mentioned in 5.1 String types Unicode normalization is not automatically applied to the result of

let $para := 
In a hole in the ground there lived a hobbit.
         
98. If a normalized result is required,
let $para := 
In a hole in the ground there lived a hobbit.
         
216 can be applied to the
let $para := 
In a hole in the ground there lived a hobbit.
         
10 returned by
let $para := 
In a hole in the ground there lived a hobbit.
         
98. The following XQuery:

let $para := 
In a hole in the ground there lived a hobbit.
         
1

where the "?" represents either the actual Unicode character COMBINING DIARESIS (Unicode codepoint U+0308) or "̈", will return:

"I plan to go to Mu?nchen in September"

where the "?" represents either the actual Unicode character COMBINING DIARESIS (Unicode codepoint U+0308) or "̈". It is worth noting that the returned value is not normalized in NFC; however, it is normalized in NFD.

However, the following XQuery:

let $para := 
In a hole in the ground there lived a hobbit.
         
2

where the "?" represents either the actual Unicode character COMBINING DIARESIS (Unicode codepoint U+0308) or "̈", will return:

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

This returned result is normalized in NFC.

Examples

The expression

let $para := 
In a hole in the ground there lived a hobbit.
         
308 returns
let $para := 
In a hole in the ground there lived a hobbit.
         
309.

The expression

let $para := 
In a hole in the ground there lived a hobbit.
         
310 returns
let $para := 
In a hole in the ground there lived a hobbit.
         
311.

The expression

let $para := 
In a hole in the ground there lived a hobbit.
         
312 returns
let $para := 
In a hole in the ground there lived a hobbit.
         
313.

The expression

let $para := 
In a hole in the ground there lived a hobbit.
         
314 returns
let $para := 
In a hole in the ground there lived a hobbit.
         
315.

The expression

let $para := 
In a hole in the ground there lived a hobbit.
         
316 returns
let $para := 
In a hole in the ground there lived a hobbit.
         
317.

The expression

let $para := 
In a hole in the ground there lived a hobbit.
         
318 returns
let $para := 
In a hole in the ground there lived a hobbit.
         
319.

5.4.2 fn:string-join

Summary

Returns a string created by concatenating the items in a sequence, with a defined separator between adjacent items.

Signatures

let $para := 
In a hole in the ground there lived a hobbit.
         
271(
let $para := 
In a hole in the ground there lived a hobbit.
         
70
let $para := 
In a hole in the ground there lived a hobbit.
         
71
op:operation(fenceHeight, xs:integer) => op:operation(xs:integer, xs:integer)
12)
let $para := 
In a hole in the ground there lived a hobbit.
         
71
let $para := 
In a hole in the ground there lived a hobbit.
         
10

let $para := 
In a hole in the ground there lived a hobbit.
         
271(
let $para := 
In a hole in the ground there lived a hobbit.
         
70
let $para := 
In a hole in the ground there lived a hobbit.
         
71
op:operation(fenceHeight, xs:integer) => op:operation(xs:integer, xs:integer)
12,
let $para := 
In a hole in the ground there lived a hobbit.
         
73
let $para := 
In a hole in the ground there lived a hobbit.
         
71
let $para := 
In a hole in the ground there lived a hobbit.
         
10)
let $para := 
In a hole in the ground there lived a hobbit.
         
71
let $para := 
In a hole in the ground there lived a hobbit.
         
10

Properties

This function is ·deterministic·, ·context-independent·, and ·focus-independent·.

Rules

The effect of calling the single-argument version of this function is the same as calling the two-argument version with

let $para := 
In a hole in the ground there lived a hobbit.
         
73 set to a zero-length string.

The function returns an

let $para := 
In a hole in the ground there lived a hobbit.
         
10 created by casting each item in the sequence
let $para := 
In a hole in the ground there lived a hobbit.
         
70 to an
let $para := 
In a hole in the ground there lived a hobbit.
         
10, and then concatenating the result strings in order,
using the value of
let $para := 
In a hole in the ground there lived a hobbit.
         
73 as a separator between adjacent strings. If the value of
let $para := 
In a hole in the ground there lived a hobbit.
         
73 is the zero-length string, then the members of
let $para := 
In a hole in the ground there lived a hobbit.
         
70 are concatenated without a separator.

Notes

If the value of

let $para := 
In a hole in the ground there lived a hobbit.
         
70 is the empty sequence, the function returns the zero-length string.

Examples

The expression

let $para := 
In a hole in the ground there lived a hobbit.
         
343 returns
let $para := 
In a hole in the ground there lived a hobbit.
         
344.

The expression

let $para := 
In a hole in the ground there lived a hobbit.
         
345 returns
let $para := 
In a hole in the ground there lived a hobbit.
         
346.

The expression

let $para := 
In a hole in the ground there lived a hobbit.
         
347 returns
let $para := 
In a hole in the ground there lived a hobbit.
         
348.

The expression

let $para := 
In a hole in the ground there lived a hobbit.
         
349 returns
let $para := 
In a hole in the ground there lived a hobbit.
         
044.

The expression

let $para := 
In a hole in the ground there lived a hobbit.
         
351 returns
let $para := 
In a hole in the ground there lived a hobbit.
         
352.

let $para := 
In a hole in the ground there lived a hobbit.
         
3

The expression

let $para := 
In a hole in the ground there lived a hobbit.
         
353 returns
let $para := 
In a hole in the ground there lived a hobbit.
         
354.

The expression

let $para := 
In a hole in the ground there lived a hobbit.
         
355 returns
let $para := 
In a hole in the ground there lived a hobbit.
         
356.

5.4.3 fn:substring

Summary

Returns the portion of the value of

let $para := 
In a hole in the ground there lived a hobbit.
         
273 beginning at the position indicated by the value of
let $para := 
In a hole in the ground there lived a hobbit.
         
274 and continuing for the number of ·characters· indicated by the value of
let $para := 
In a hole in the ground there lived a hobbit.
         
275.

Signatures

let $para := 
In a hole in the ground there lived a hobbit.
         
61(
let $para := 
In a hole in the ground there lived a hobbit.
         
273
let $para := 
In a hole in the ground there lived a hobbit.
         
71
let $para := 
In a hole in the ground there lived a hobbit.
         
244,
let $para := 
In a hole in the ground there lived a hobbit.
         
274
let $para := 
In a hole in the ground there lived a hobbit.
         
71
let $para := 
In a hole in the ground there lived a hobbit.
         
26)
let $para := 
In a hole in the ground there lived a hobbit.
         
71
let $para := 
In a hole in the ground there lived a hobbit.
         
10

let $para := 
In a hole in the ground there lived a hobbit.
         
61(
let $para := 
In a hole in the ground there lived a hobbit.
         
273
let $para := 
In a hole in the ground there lived a hobbit.
         
71
let $para := 
In a hole in the ground there lived a hobbit.
         
244,
let $para := 
In a hole in the ground there lived a hobbit.
         
274
let $para := 
In a hole in the ground there lived a hobbit.
         
71
let $para := 
In a hole in the ground there lived a hobbit.
         
26,
let $para := 
In a hole in the ground there lived a hobbit.
         
275
let $para := 
In a hole in the ground there lived a hobbit.
         
71
let $para := 
In a hole in the ground there lived a hobbit.
         
26)
let $para := 
In a hole in the ground there lived a hobbit.
         
71
let $para := 
In a hole in the ground there lived a hobbit.
         
10

Properties

This function is ·deterministic·, ·context-independent·, and ·focus-independent·.

Rules

If the value of

let $para := 
In a hole in the ground there lived a hobbit.
         
273 is the empty sequence, the function returns the zero-length string.

Otherwise, the function returns a string comprising those ·characters· of

let $para := 
In a hole in the ground there lived a hobbit.
         
273 whose index position (counting from one) is greater than or equal to the value of
let $para := 
In a hole in the ground there lived a hobbit.
         
274 (rounded to an integer), and (if
let $para := 
In a hole in the ground there lived a hobbit.
         
275 is specified) less than the sum of
let $para := 
In a hole in the ground there lived a hobbit.
         
274 and
let $para := 
In a hole in the ground there lived a hobbit.
         
275 (both rounded to integers).

The characters returned do not extend beyond

let $para := 
In a hole in the ground there lived a hobbit.
         
273. If
let $para := 
In a hole in the ground there lived a hobbit.
         
274 is zero or negative, only those characters in positions greater than zero are returned.

More specifically, the three argument version of the function returns the characters in

let $para := 
In a hole in the ground there lived a hobbit.
         
273 whose position
let $para := 
In a hole in the ground there lived a hobbit.
         
390 satisfies:

let $para := 
In a hole in the ground there lived a hobbit.
         
391

The two argument version of the function assumes that

let $para := 
In a hole in the ground there lived a hobbit.
         
275 is infinite and thus returns the ·characters· in
let $para := 
In a hole in the ground there lived a hobbit.
         
273 whose position
let $para := 
In a hole in the ground there lived a hobbit.
         
390 satisfies:

let $para := 
In a hole in the ground there lived a hobbit.
         
395

In the above computations, the rules for

let $C := 'http://www.w3.org/2013/collation/UCA?strength=primary'
11 and
let $C := 'http://www.w3.org/2013/collation/UCA?strength=primary'
15 apply.

Notes

The first character of a string is located at position 1, not position 0.

The second and third arguments allow

let $para := 
In a hole in the ground there lived a hobbit.
         
26 values (rather than requiring
let $para := 
In a hole in the ground there lived a hobbit.
         
85) in order to achieve compatibility with XPath 1.0.

A surrogate pair counts as one character, not two.

The consequences of supplying values such as

fn:abs($N * $arg2) le fn:abs($arg1) 
               and fn:compare($N * $arg2, 0) eq fn:compare($arg1, 0).
90 or positive or negative infinity for the
let $para := 
In a hole in the ground there lived a hobbit.
         
274 or
let $para := 
In a hole in the ground there lived a hobbit.
         
275 arguments follow from the above rules, and are not always intuitive.

Examples

The expression

let $para := 
In a hole in the ground there lived a hobbit.
         
403 returns
let $para := 
In a hole in the ground there lived a hobbit.
         
404. (Characters starting at position 6 to the end of
let $para := 
In a hole in the ground there lived a hobbit.
         
273 are selected.)

The expression

let $para := 
In a hole in the ground there lived a hobbit.
         
406 returns
let $para := 
In a hole in the ground there lived a hobbit.
         
407. (Characters at positions greater than or equal to 4 and less than 7 are selected.)

The expression

let $para := 
In a hole in the ground there lived a hobbit.
         
408 returns
let $para := 
In a hole in the ground there lived a hobbit.
         
409. (Characters at positions greater than or equal to 2 and less than 5 are selected.)

The expression

let $para := 
In a hole in the ground there lived a hobbit.
         
410 returns
let $para := 
In a hole in the ground there lived a hobbit.
         
411. (Characters at positions greater than or equal to 0 and less than 3 are selected. Since the first position is 1, these are the characters at positions 1 and 2.)

The expression

let $para := 
In a hole in the ground there lived a hobbit.
         
412 returns
let $para := 
In a hole in the ground there lived a hobbit.
         
044. (Characters at positions greater than or equal to 5 and less than 2 are selected.)

The expression

let $para := 
In a hole in the ground there lived a hobbit.
         
414 returns
let $para := 
In a hole in the ground there lived a hobbit.
         
415. (Characters at positions greater than or equal to -3 and less than 2 are selected. Since the first position is 1, this is the character at position 1.)

The expression

let $para := 
In a hole in the ground there lived a hobbit.
         
416 returns
let $para := 
In a hole in the ground there lived a hobbit.
         
044. (Since
let $para := 
In a hole in the ground there lived a hobbit.
         
418 returns
fn:abs($N * $arg2) le fn:abs($arg1) 
               and fn:compare($N * $arg2, 0) eq fn:compare($arg1, 0).
90, and
fn:abs($N * $arg2) le fn:abs($arg1) 
               and fn:compare($N * $arg2, 0) eq fn:compare($arg1, 0).
90 compared to any other number returns
let $C := 'http://www.w3.org/2013/collation/UCA?strength=primary'
07, no characters are selected.)

The expression

let $para := 
In a hole in the ground there lived a hobbit.
         
422 returns
let $para := 
In a hole in the ground there lived a hobbit.
         
044. (As above.)

The expression

let $para := 
In a hole in the ground there lived a hobbit.
         
424 returns
let $para := 
In a hole in the ground there lived a hobbit.
         
044.

The expression

let $para := 
In a hole in the ground there lived a hobbit.
         
426 returns
let $para := 
In a hole in the ground there lived a hobbit.
         
427. (Characters at positions greater than or equal to -42 and less than
1º 2º 3º 4º ...
56 are selected.)

The expression

let $para := 
In a hole in the ground there lived a hobbit.
         
429 returns
let $para := 
In a hole in the ground there lived a hobbit.
         
044. (Since the value of
let $para := 
In a hole in the ground there lived a hobbit.
         
431 is
fn:abs($N * $arg2) le fn:abs($arg1) 
               and fn:compare($N * $arg2, 0) eq fn:compare($arg1, 0).
90, no characters are selected.)

5.4.4 fn:string-length

Summary

Returns the number of ·characters· in a string.

Signatures

let $para := 
In a hole in the ground there lived a hobbit.
         
62()
let $para := 
In a hole in the ground there lived a hobbit.
         
71
let $para := 
In a hole in the ground there lived a hobbit.
         
85

let $para := 
In a hole in the ground there lived a hobbit.
         
62(
let $para := 
In a hole in the ground there lived a hobbit.
         
25
let $para := 
In a hole in the ground there lived a hobbit.
         
71
let $para := 
In a hole in the ground there lived a hobbit.
         
244)
let $para := 
In a hole in the ground there lived a hobbit.
         
71
let $para := 
In a hole in the ground there lived a hobbit.
         
85

Properties

The zero-argument form of this function is ·deterministic·, ·context-dependent·, and ·focus-dependent·.

The one-argument form of this function is ·deterministic·, ·context-independent·, and ·focus-independent·.

Rules

The function returns an

let $para := 
In a hole in the ground there lived a hobbit.
         
85 equal to the length in ·characters· of the value of
let $para := 
In a hole in the ground there lived a hobbit.
         
25.

Calling the zero-argument version of the function is equivalent to calling

let $para := 
In a hole in the ground there lived a hobbit.
         
444.

If the value of

let $para := 
In a hole in the ground there lived a hobbit.
         
25 is the empty sequence, the function returns the
let $para := 
In a hole in the ground there lived a hobbit.
         
85 value zero (0).

Error Conditions

If

let $para := 
In a hole in the ground there lived a hobbit.
         
25 is not specified and the context item is absentDM31, a dynamic error is raised: [err:XPDY0002]XP31.

Notes

Unlike some programming languages, a ·codepoint· greater than 65535 counts as one character, not two.

There are situations where

let $para := 
In a hole in the ground there lived a hobbit.
         
448 has a different effect from
let $para := 
In a hole in the ground there lived a hobbit.
         
449. For example, if the context item is an attribute node typed as an
let $para := 
In a hole in the ground there lived a hobbit.
         
85 with the string value
let $para := 
In a hole in the ground there lived a hobbit.
         
451, then
let $para := 
In a hole in the ground there lived a hobbit.
         
448 returns 6 (the length of the string value of the node), while
let $para := 
In a hole in the ground there lived a hobbit.
         
449 raises a type error (because the result of atomization is not an
let $para := 
In a hole in the ground there lived a hobbit.
         
10).

Examples

The expression

let $para := 
In a hole in the ground there lived a hobbit.
         
455 returns
let $para := 
In a hole in the ground there lived a hobbit.
         
456.

The expression

let $para := 
In a hole in the ground there lived a hobbit.
         
457 returns
declare %public function r:random-sequence($length as xs:integer) as xs:double* {
  r:random-sequence($length, fn:random-number-generator())
};

declare %private function r:random-sequence($length as xs:integer, 
                                            $G as map(xs:string, item())) {
  if ($length eq 0)
  then ()
  else ($G?number, r:random-sequence($length - 1, $G?next()))
};

r:random-sequence(200);
            
19.

5.4.5 fn:normalize-space

Summary

Returns the value of

let $para := 
In a hole in the ground there lived a hobbit.
         
25 with leading and trailing whitespace removed, and sequences of internal whitespace reduced to a single space character.

Signatures

let $para := 
In a hole in the ground there lived a hobbit.
         
215()
let $para := 
In a hole in the ground there lived a hobbit.
         
71
let $para := 
In a hole in the ground there lived a hobbit.
         
10

let $para := 
In a hole in the ground there lived a hobbit.
         
215(
let $para := 
In a hole in the ground there lived a hobbit.
         
25
let $para := 
In a hole in the ground there lived a hobbit.
         
71
let $para := 
In a hole in the ground there lived a hobbit.
         
244)
let $para := 
In a hole in the ground there lived a hobbit.
         
71
let $para := 
In a hole in the ground there lived a hobbit.
         
10

Properties

The zero-argument form of this function is ·deterministic·, ·context-dependent·, and ·focus-dependent·.

The one-argument form of this function is ·deterministic·, ·context-independent·, and ·focus-independent·.

Rules

If the value of

let $para := 
In a hole in the ground there lived a hobbit.
         
25 is the empty sequence, the function returns the zero-length string.

The function returns a string constructed by stripping leading and trailing whitespace from the value of

let $para := 
In a hole in the ground there lived a hobbit.
         
25, and replacing sequences of one or more adjacent whitespace characters with a single space,
let $para := 
In a hole in the ground there lived a hobbit.
         
471.

The whitespace characters are defined in the metasymbol S (Production 3) of [Extensible Markup Language (XML) 1.0 (Fifth Edition)].

If no argument is supplied, then

let $para := 
In a hole in the ground there lived a hobbit.
         
25 defaults to the string value (calculated using
let $para := 
In a hole in the ground there lived a hobbit.
         
78) of the context item (
let $para := 
In a hole in the ground there lived a hobbit.
         
19).

Error Conditions

If no argument is supplied and the context item is absentDM31 then a dynamic error is raised: [err:XPDY0002]XP31.

Notes

The definition of whitespace is unchanged in [Extensible Markup Language (XML) 1.1 Recommendation]. It is repeated here for convenience:

let $para := 
In a hole in the ground there lived a hobbit.
         
475

Examples

The expression

let $para := 
In a hole in the ground there lived a hobbit.
         
476 returns
let $para := 
In a hole in the ground there lived a hobbit.
         
477.

The expression

let $para := 
In a hole in the ground there lived a hobbit.
         
478 returns
let $para := 
In a hole in the ground there lived a hobbit.
         
044.

5.4.6 fn:normalize-unicode

Summary

Returns the value of

let $para := 
In a hole in the ground there lived a hobbit.
         
25 after applying Unicode normalization.

Signatures

let $para := 
In a hole in the ground there lived a hobbit.
         
216(
let $para := 
In a hole in the ground there lived a hobbit.
         
25
let $para := 
In a hole in the ground there lived a hobbit.
         
71
let $para := 
In a hole in the ground there lived a hobbit.
         
244)
let $para := 
In a hole in the ground there lived a hobbit.
         
71
let $para := 
In a hole in the ground there lived a hobbit.
         
10

let $para := 
In a hole in the ground there lived a hobbit.
         
216(
let $para := 
In a hole in the ground there lived a hobbit.
         
25
let $para := 
In a hole in the ground there lived a hobbit.
         
71
let $para := 
In a hole in the ground there lived a hobbit.
         
244,
let $para := 
In a hole in the ground there lived a hobbit.
         
491
let $para := 
In a hole in the ground there lived a hobbit.
         
71
let $para := 
In a hole in the ground there lived a hobbit.
         
10)
let $para := 
In a hole in the ground there lived a hobbit.
         
71
let $para := 
In a hole in the ground there lived a hobbit.
         
10

Properties

This function is ·deterministic·, ·context-independent·, and ·focus-independent·.

Rules

If the value of

let $para := 
In a hole in the ground there lived a hobbit.
         
25 is the empty sequence, the function returns the zero-length string.

If the single-argument version of the function is used, the result is the same as calling the two-argument version with

let $para := 
In a hole in the ground there lived a hobbit.
         
491 set to the string "NFC".

Otherwise, the function returns the value of

let $para := 
In a hole in the ground there lived a hobbit.
         
25 normalized according to the rules of the normalization form identified by the value of
let $para := 
In a hole in the ground there lived a hobbit.
         
491.

The effective value of

let $para := 
In a hole in the ground there lived a hobbit.
         
491 is the value of the expression
let $para := 
In a hole in the ground there lived a hobbit.
         
501.

  • If the effective value of

    let $para := 
    In a hole in the ground there lived a hobbit.
             
    491 is "NFC", then the function returns the value of
    let $para := 
    In a hole in the ground there lived a hobbit.
             
    25 converted to Unicode Normalization Form C (NFC).

  • If the effective value of

    let $para := 
    In a hole in the ground there lived a hobbit.
             
    491 is "NFD", then the function returns the value of
    let $para := 
    In a hole in the ground there lived a hobbit.
             
    25 converted to Unicode Normalization Form D (NFD).

  • If the effective value of

    let $para := 
    In a hole in the ground there lived a hobbit.
             
    491 is "NFKC", then the function returns the value of
    let $para := 
    In a hole in the ground there lived a hobbit.
             
    25 in Unicode Normalization Form KC (NFKC).

  • If the effective value of

    let $para := 
    In a hole in the ground there lived a hobbit.
             
    491 is "NFKD", then the function returns the value of
    let $para := 
    In a hole in the ground there lived a hobbit.
             
    25 converted to Unicode Normalization Form KD (NFKD).

  • If the effective value of

    let $para := 
    In a hole in the ground there lived a hobbit.
             
    491 is "FULLY-NORMALIZED", then the function returns the value of
    let $para := 
    In a hole in the ground there lived a hobbit.
             
    25 converted to fully normalized form.

  • If the effective value of

    let $para := 
    In a hole in the ground there lived a hobbit.
             
    491 is the zero-length string, no normalization is performed and
    let $para := 
    In a hole in the ground there lived a hobbit.
             
    25 is returned.

Normalization forms NFC, NFD, NFKC, and NFKD, and the algorithms to be used for converting a string to each of these forms, are defined in [UAX #15].

The motivation for normalization form FULLY-NORMALIZED is explained in [Character Model for the World Wide Web 1.0: Normalization]. However, as that specification did not progress beyond working draft status, the normative specification is as follows:

  • A string is fully-normalized if (a) it is in normalization form NFC as defined in [UAX #15], and (b) it does not start with a composing character.

  • A composing character is a character that is one or both of the following:

    • the second character in the canonical decomposition mapping of some character that is not listed in the Composition Exclusion Table defined in [UAX #15];

    • of non-zero canonical combining class (as defined in [The Unicode Standard]).

  • A string is converted to FULLY-NORMALIZED form as follows:

    • if the first character in the string is a composing character, prepend a single space (x20);

    • convert the resulting string to normalization form NFC.

Conforming implementations must support normalization form "NFC" and may support normalization forms "NFD", "NFKC", "NFKD", and "FULLY-NORMALIZED". They may also support other normalization forms with ·implementation-defined· semantics.

It is ·implementation-defined· which version of Unicode (and therefore, of the normalization algorithms and their underlying data) is supported by the implementation. See [UAX #15] for 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

let $para := 
In a hole in the ground there lived a hobbit.
         
216 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.

Error Conditions

A dynamic error is raised [err:FOCH0003] if the effective value of the

let $para := 
In a hole in the ground there lived a hobbit.
         
491 argument is not one of the values supported by the implementation.

5.4.7 fn:upper-case

Summary

Converts a string to upper case.

Signature

let $para := 
In a hole in the ground there lived a hobbit.
         
213(
let $para := 
In a hole in the ground there lived a hobbit.
         
25
let $para := 
In a hole in the ground there lived a hobbit.
         
71
let $para := 
In a hole in the ground there lived a hobbit.
         
244)
let $para := 
In a hole in the ground there lived a hobbit.
         
71
let $para := 
In a hole in the ground there lived a hobbit.
         
10

Properties

This function is ·deterministic·, ·context-independent·, and ·focus-independent·.

Rules

If the value of

let $para := 
In a hole in the ground there lived a hobbit.
         
25 is the empty sequence, the zero-length string is returned.

Otherwise, the function returns the value of

let $para := 
In a hole in the ground there lived a hobbit.
         
25 after translating every ·character· to its upper-case correspondent as defined in the appropriate case mappings section in the Unicode standard [The Unicode Standard]. For versions of Unicode beginning with the 2.1.8 update, only locale-insensitive case mappings should be applied. Beginning with version 3.2.0 (and likely future versions) of Unicode, precise mappings are described in default case operations, which are full case mappings in the absence of tailoring for particular languages and environments. Every lower-case character that does not have an upper-case correspondent, as well as every upper-case character, is included in the returned value in its original form.

Notes

Case mappings may change the length of a string. In general, the

let $para := 
In a hole in the ground there lived a hobbit.
         
213 and
let $para := 
In a hole in the ground there lived a hobbit.
         
214 functions are not inverses of each other:
let $para := 
In a hole in the ground there lived a hobbit.
         
526 is not guaranteed to return
let $para := 
In a hole in the ground there lived a hobbit.
         
25, nor is
let $para := 
In a hole in the ground there lived a hobbit.
         
528. The Latin small letter dotless i (as used in Turkish) is perhaps the most prominent lower-case letter which will not round-trip. The Latin capital letter i with dot above is the most prominent upper-case letter which will not round trip; there are others, such as Latin capital letter Sharp S (#1E9E) which was introduced in Unicode 5.1.

These functions may not always be linguistically appropriate (e.g. Turkish i without dot) or appropriate for the application (e.g. titlecase). In cases such as Turkish, a simple translation should be used first.

Because the function is not sensitive to locale, results will not always match user expectations. In Quebec, for example, the standard uppercase equivalent of "è" is "È", while in metropolitan France it is more commonly "E"; only one of these is supported by the functions as defined.

Many characters of class Ll lack uppercase equivalents in the Unicode case mapping tables; many characters of class Lu lack lowercase equivalents.

Examples

The expression

let $para := 
In a hole in the ground there lived a hobbit.
         
529 returns
let $para := 
In a hole in the ground there lived a hobbit.
         
530.

5.4.8 fn:lower-case

Summary

Converts a string to lower case.

Signature

let $para := 
In a hole in the ground there lived a hobbit.
         
214(
let $para := 
In a hole in the ground there lived a hobbit.
         
25
let $para := 
In a hole in the ground there lived a hobbit.
         
71
let $para := 
In a hole in the ground there lived a hobbit.
         
244)
let $para := 
In a hole in the ground there lived a hobbit.
         
71
let $para := 
In a hole in the ground there lived a hobbit.
         
10

Properties

This function is ·deterministic·, ·context-independent·, and ·focus-independent·.

Rules

If the value of

let $para := 
In a hole in the ground there lived a hobbit.
         
25 is the empty sequence, the zero-length string is returned.

Otherwise, the function returns the value of

let $para := 
In a hole in the ground there lived a hobbit.
         
25 after translating every ·character· to its lower-case correspondent as defined in the appropriate case mappings section in the Unicode standard [The Unicode Standard]. For versions of Unicode beginning with the 2.1.8 update, only locale-insensitive case mappings should be applied. Beginning with version 3.2.0 (and likely future versions) of Unicode, precise mappings are described in default case operations, which are full case mappings in the absence of tailoring for particular languages and environments. Every upper-case character that does not have a lower-case correspondent, as well as every lower-case character, is included in the returned value in its original form.

Notes

Case mappings may change the length of a string. In general, the

let $para := 
In a hole in the ground there lived a hobbit.
         
213 and
let $para := 
In a hole in the ground there lived a hobbit.
         
214 functions are not inverses of each other:
let $para := 
In a hole in the ground there lived a hobbit.
         
526 is not guaranteed to return
let $para := 
In a hole in the ground there lived a hobbit.
         
25, nor is
let $para := 
In a hole in the ground there lived a hobbit.
         
528. The Latin small letter dotless i (as used in Turkish) is perhaps the most prominent lower-case letter which will not round-trip. The Latin capital letter i with dot above is the most prominent upper-case letter which will not round trip; there are others, such as Latin capital letter Sharp S (#1E9E) which was introduced in Unicode 5.1.

These functions may not always be linguistically appropriate (e.g. Turkish i without dot) or appropriate for the application (e.g. titlecase). In cases such as Turkish, a simple translation should be used first.

Because the function is not sensitive to locale, results will not always match user expectations. In Quebec, for example, the standard uppercase equivalent of "è" is "È", while in metropolitan France it is more commonly "E"; only one of these is supported by the functions as defined.

Many characters of class Ll lack uppercase equivalents in the Unicode case mapping tables; many characters of class Lu lack lowercase equivalents.

Examples

The expression

let $para := 
In a hole in the ground there lived a hobbit.
         
544 returns
let $para := 
In a hole in the ground there lived a hobbit.
         
545.

5.4.9 fn:translate

Summary

Returns the value of

let $para := 
In a hole in the ground there lived a hobbit.
         
25 modified by replacing or removing individual characters.

Signature

let $para := 
In a hole in the ground there lived a hobbit.
         
63(
let $para := 
In a hole in the ground there lived a hobbit.
         
25
let $para := 
In a hole in the ground there lived a hobbit.
         
71
let $para := 
In a hole in the ground there lived a hobbit.
         
244,
let $para := 
In a hole in the ground there lived a hobbit.
         
551
let $para := 
In a hole in the ground there lived a hobbit.
         
71
let $para := 
In a hole in the ground there lived a hobbit.
         
10,
let $para := 
In a hole in the ground there lived a hobbit.
         
554
let $para := 
In a hole in the ground there lived a hobbit.
         
71
let $para := 
In a hole in the ground there lived a hobbit.
         
10)
let $para := 
In a hole in the ground there lived a hobbit.
         
71
let $para := 
In a hole in the ground there lived a hobbit.
         
10

Properties

This function is ·deterministic·, ·context-independent·, and ·focus-independent·.

Rules

If the value of

let $para := 
In a hole in the ground there lived a hobbit.
         
25 is the empty sequence, the function returns the zero-length string.

Otherwise, the function returns a result string constructed by processing each ·character· in the value of

let $para := 
In a hole in the ground there lived a hobbit.
         
25, in order, according to the following rules:

  1. If the character does not appear in the value of

    let $para := 
    In a hole in the ground there lived a hobbit.
             
    551 then it is added to the result string unchanged.

  2. If the character first appears in the value of

    let $para := 
    In a hole in the ground there lived a hobbit.
             
    551 at some position M, where the value of
    let $para := 
    In a hole in the ground there lived a hobbit.
             
    554 is M or more characters in length, then the character at position M in
    let $para := 
    In a hole in the ground there lived a hobbit.
             
    554 is added to the result string.

  3. If the character first appears in the value of

    let $para := 
    In a hole in the ground there lived a hobbit.
             
    551 at some position M, where the value of
    let $para := 
    In a hole in the ground there lived a hobbit.
             
    554 is less than M characters in length, then the character is omitted from the result string.

Notes

If

let $para := 
In a hole in the ground there lived a hobbit.
         
551 is the zero-length string then the function returns
let $para := 
In a hole in the ground there lived a hobbit.
         
25 unchanged.

If a character occurs more than once in

let $para := 
In a hole in the ground there lived a hobbit.
         
551, then the first occurrence determines the action taken.

If

let $para := 
In a hole in the ground there lived a hobbit.
         
554 is longer than
let $para := 
In a hole in the ground there lived a hobbit.
         
551, the excess characters are ignored.

Examples

The expression

let $para := 
In a hole in the ground there lived a hobbit.
         
572 returns
let $para := 
In a hole in the ground there lived a hobbit.
         
573.

The expression

let $para := 
In a hole in the ground there lived a hobbit.
         
574 returns
let $para := 
In a hole in the ground there lived a hobbit.
         
575.

The expression

let $para := 
In a hole in the ground there lived a hobbit.
         
576 returns
let $para := 
In a hole in the ground there lived a hobbit.
         
577.

5.5 Functions based on substring matching

The functions described in the section examine a string

let $para := 
In a hole in the ground there lived a hobbit.
         
70 to see whether it contains another string
let $para := 
In a hole in the ground there lived a hobbit.
         
73 as a substring. The result depends on whether
let $para := 
In a hole in the ground there lived a hobbit.
         
73 is a substring of
let $para := 
In a hole in the ground there lived a hobbit.
         
70, and if so, on the range of ·characters· in
let $para := 
In a hole in the ground there lived a hobbit.
         
70 which
let $para := 
In a hole in the ground there lived a hobbit.
         
73 matches.

When the ·Unicode codepoint collation· is used, this simply involves determining whether

let $para := 
In a hole in the ground there lived a hobbit.
         
70 contains a contiguous sequence of characters whose ·codepoints· are the same, one for one, with the codepoints of the characters in
let $para := 
In a hole in the ground there lived a hobbit.
         
73.

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

let $para := 
In a hole in the ground there lived a hobbit.
         
058, this is all that is required. For other functions, such as
let $para := 
In a hole in the ground there lived a hobbit.
         
127, 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 comparison of these units. ("collation unit" is equivalent to "collation element" as defined in [UTS #10].) The string
let $para := 
In a hole in the ground there lived a hobbit.
         
70 is then considered to contain
let $para := 
In a hole in the ground there lived a hobbit.
         
73 as a substring if the sequence of collation units corresponding to
let $para := 
In a hole in the ground there lived a hobbit.
         
73 is a subsequence of the sequence of the collation units corresponding to
let $para := 
In a hole in the ground there lived a hobbit.
         
70. The characters in
let $para := 
In a hole in the ground there lived a hobbit.
         
70 that match are the characters corresponding to these collation units.

This rule may occasionally lead to surprises. For example, consider a collation that treats "Jaeger" and "Jäger" as equal. It might do this by treating "ä" as representing two collation units, in which case the expression

let $para := 
In a hole in the ground there lived a hobbit.
         
593 will return
op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
76. Alternatively, a collation might treat "ae" as a single collation unit, in which case the expression
let $para := 
In a hole in the ground there lived a hobbit.
         
595 will return
let $C := 'http://www.w3.org/2013/collation/UCA?strength=primary'
07. The results of these functions thus depend strongly on the properties of the collation that is used.

In addition, collations may specify that some collation units should be ignored during matching. If hyphen is an ignored collation unit, then

let $para := 
In a hole in the ground there lived a hobbit.
         
597 will be true, and
let $para := 
In a hole in the ground there lived a hobbit.
         
598 will also be true.

In the definitions below, we refer to the terms match and minimal match as defined in definitions DS2 and DS4 of [UTS #10]. In applying these definitions:

  • C is the collation; that is, the value of the

    let $para := 
    In a hole in the ground there lived a hobbit.
             
    128 argument if specified, otherwise the default collation.

  • P is the (candidate) substring

    let $para := 
    In a hole in the ground there lived a hobbit.
             
    73

  • Q is the (candidate) containing string

    let $para := 
    In a hole in the ground there lived a hobbit.
             
    70

  • The boundary condition B is satisfied at the start and end of a string, and between any two characters that belong to different collation units ("collation elements" in the language of [UTS #10]). It is not satisfied between two characters that belong to the same collation unit.

It is possible to define collations that do not have the ability to decompose a string into units suitable for substring matching. An argument to a function defined in this section may be a URI that identifies a collation that is able to compare two strings, but that does not have the capability to split the string into collation units. Such a collation may cause the function to fail, or to give unexpected results or it may be rejected as an unsuitable argument. The ability to decompose strings into collation units is an ·implementation-defined· property of the collation.

FunctionMeaning
let $para := 
In a hole in the ground there lived a hobbit.
         
127Returns true if the string
let $para := 
In a hole in the ground there lived a hobbit.
         
70 contains
let $para := 
In a hole in the ground there lived a hobbit.
         
73 as a substring, taking collations into account.
let $para := 
In a hole in the ground there lived a hobbit.
         
605Returns true if the string
let $para := 
In a hole in the ground there lived a hobbit.
         
70 contains
let $para := 
In a hole in the ground there lived a hobbit.
         
73 as a leading substring, taking collations into account.
let $para := 
In a hole in the ground there lived a hobbit.
         
608Returns true if the string
let $para := 
In a hole in the ground there lived a hobbit.
         
70 contains
let $para := 
In a hole in the ground there lived a hobbit.
         
73 as a trailing substring, taking collations into account.
let $para := 
In a hole in the ground there lived a hobbit.
         
611Returns the part of
let $para := 
In a hole in the ground there lived a hobbit.
         
70 that precedes the first occurrence of
let $para := 
In a hole in the ground there lived a hobbit.
         
73, taking collations into account.
let $para := 
In a hole in the ground there lived a hobbit.
         
614Returns the part of
let $para := 
In a hole in the ground there lived a hobbit.
         
70 that follows the first occurrence of
let $para := 
In a hole in the ground there lived a hobbit.
         
73, taking collations into account.

5.5.1 fn:contains

Summary

Returns true if the string

let $para := 
In a hole in the ground there lived a hobbit.
         
70 contains
let $para := 
In a hole in the ground there lived a hobbit.
         
73 as a substring, taking collations into account.

Signatures

let $para := 
In a hole in the ground there lived a hobbit.
         
127(
let $para := 
In a hole in the ground there lived a hobbit.
         
70
let $para := 
In a hole in the ground there lived a hobbit.
         
71
let $para := 
In a hole in the ground there lived a hobbit.
         
244,
let $para := 
In a hole in the ground there lived a hobbit.
         
73
let $para := 
In a hole in the ground there lived a hobbit.
         
71
let $para := 
In a hole in the ground there lived a hobbit.
         
244)
let $para := 
In a hole in the ground there lived a hobbit.
         
71
op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
32

let $para := 
In a hole in the ground there lived a hobbit.
         
127(
let $para := 
In a hole in the ground there lived a hobbit.
         
70
let $para := 
In a hole in the ground there lived a hobbit.
         
71
let $para := 
In a hole in the ground there lived a hobbit.
         
244,
let $para := 
In a hole in the ground there lived a hobbit.
         
73
let $para := 
In a hole in the ground there lived a hobbit.
         
71
let $para := 
In a hole in the ground there lived a hobbit.
         
244,
let $para := 
In a hole in the ground there lived a hobbit.
         
128
let $para := 
In a hole in the ground there lived a hobbit.
         
71
let $para := 
In a hole in the ground there lived a hobbit.
         
10)
let $para := 
In a hole in the ground there lived a hobbit.
         
71
op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
32

Properties

The two-argument form of this function is ·deterministic·, ·context-dependent·, and ·focus-independent·. It depends on collations.

The three-argument form of this function is ·deterministic·, ·context-dependent·, and ·focus-independent·. It depends on collations, and static base URI.

Rules

If the value of

let $para := 
In a hole in the ground there lived a hobbit.
         
70 or
let $para := 
In a hole in the ground there lived a hobbit.
         
73 is the empty sequence, or contains only ignorable collation units, it is interpreted as the zero-length string.

If the value of

let $para := 
In a hole in the ground there lived a hobbit.
         
73 is the zero-length string, then the function returns
op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
76.

If the value of

let $para := 
In a hole in the ground there lived a hobbit.
         
70 is the zero-length string, the function returns
let $C := 'http://www.w3.org/2013/collation/UCA?strength=primary'
07.

The collation used by this function is determined according to the rules in 5.3.5 Choosing a collation.

The function returns an

op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
32 indicating whether or not the value of
let $para := 
In a hole in the ground there lived a hobbit.
         
70 contains (at the beginning, at the end, or anywhere within) at least one sequence of collation units that provides a minimal match to the collation units in the value of
let $para := 
In a hole in the ground there lived a hobbit.
         
73, according to the collation that is used.

Note:

Minimal match is defined in [UTS #10].

Error Conditions

A dynamic error may be raised [err:FOCH0004] if the specified collation does not support collation units.

Examples

The collation used in these examples,

let $para := 
In a hole in the ground there lived a hobbit.
         
649 is a collation in which both "-" and "*" are ignorable collation units.

"Ignorable collation unit" is equivalent to "ignorable collation element" in [UTS #10].

The expression

let $para := 
In a hole in the ground there lived a hobbit.
         
650 returns
let $para := 
In a hole in the ground there lived a hobbit.
         
182.

The expression

let $para := 
In a hole in the ground there lived a hobbit.
         
652 returns
let $para := 
In a hole in the ground there lived a hobbit.
         
184.

The expression

let $para := 
In a hole in the ground there lived a hobbit.
         
654 returns
let $para := 
In a hole in the ground there lived a hobbit.
         
182. (The first rule is applied, followed by the second rule.)

The expression

let $para := 
In a hole in the ground there lived a hobbit.
         
656 returns
let $para := 
In a hole in the ground there lived a hobbit.
         
182.

The expression

let $para := 
In a hole in the ground there lived a hobbit.
         
658 returns
let $para := 
In a hole in the ground there lived a hobbit.
         
182.

The expression

let $para := 
In a hole in the ground there lived a hobbit.
         
660 returns
let $para := 
In a hole in the ground there lived a hobbit.
         
182.

The expression

let $para := 
In a hole in the ground there lived a hobbit.
         
662 returns
let $para := 
In a hole in the ground there lived a hobbit.
         
182. (The second argument contains only ignorable collation units and is equivalent to the zero-length string.)

5.5.2 fn:starts-with

Summary

Returns true if the string

let $para := 
In a hole in the ground there lived a hobbit.
         
70 contains
let $para := 
In a hole in the ground there lived a hobbit.
         
73 as a leading substring, taking collations into account.

Signatures

let $para := 
In a hole in the ground there lived a hobbit.
         
605(
let $para := 
In a hole in the ground there lived a hobbit.
         
70
let $para := 
In a hole in the ground there lived a hobbit.
         
71
let $para := 
In a hole in the ground there lived a hobbit.
         
244,
let $para := 
In a hole in the ground there lived a hobbit.
         
73
let $para := 
In a hole in the ground there lived a hobbit.
         
71
let $para := 
In a hole in the ground there lived a hobbit.
         
244)
let $para := 
In a hole in the ground there lived a hobbit.
         
71
op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
32

let $para := 
In a hole in the ground there lived a hobbit.
         
605(
let $para := 
In a hole in the ground there lived a hobbit.
         
70
let $para := 
In a hole in the ground there lived a hobbit.
         
71
let $para := 
In a hole in the ground there lived a hobbit.
         
244,
let $para := 
In a hole in the ground there lived a hobbit.
         
73
let $para := 
In a hole in the ground there lived a hobbit.
         
71
let $para := 
In a hole in the ground there lived a hobbit.
         
244,
let $para := 
In a hole in the ground there lived a hobbit.
         
128
let $para := 
In a hole in the ground there lived a hobbit.
         
71
let $para := 
In a hole in the ground there lived a hobbit.
         
10)
let $para := 
In a hole in the ground there lived a hobbit.
         
71
op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
32

Properties

The two-argument form of this function is ·deterministic·, ·context-dependent·, and ·focus-independent·. It depends on collations.

The three-argument form of this function is ·deterministic·, ·context-dependent·, and ·focus-independent·. It depends on collations, and static base URI.

Rules

If the value of

let $para := 
In a hole in the ground there lived a hobbit.
         
70 or
let $para := 
In a hole in the ground there lived a hobbit.
         
73 is the empty sequence, or contains only ignorable collation units, it is interpreted as the zero-length string.

If the value of

let $para := 
In a hole in the ground there lived a hobbit.
         
73 is the zero-length string, then the function returns
op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
76. If the value of
let $para := 
In a hole in the ground there lived a hobbit.
         
70 is the zero-length string and the value of
let $para := 
In a hole in the ground there lived a hobbit.
         
73 is not the zero-length string, then the function returns
let $C := 'http://www.w3.org/2013/collation/UCA?strength=primary'
07.

The collation used by this function is determined according to the rules in 5.3.5 Choosing a collation.

The function returns an

op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
32 indicating whether or not the value of
let $para := 
In a hole in the ground there lived a hobbit.
         
70 starts with a sequence of collation units that provides a match to the collation units of
let $para := 
In a hole in the ground there lived a hobbit.
         
73 according to the collation that is used.

Note:

Match is defined in [UTS #10].

Error Conditions

A dynamic error may be raised [err:FOCH0004] if the specified collation does not support collation units.

Examples

The collation used in these examples,

let $para := 
In a hole in the ground there lived a hobbit.
         
649 is a collation in which both "-" and "*" are ignorable collation units.

"Ignorable collation unit" is equivalent to "ignorable collation element" in [UTS #10].

The expression

let $para := 
In a hole in the ground there lived a hobbit.
         
698 returns
let $para := 
In a hole in the ground there lived a hobbit.
         
182.

The expression

let $para := 
In a hole in the ground there lived a hobbit.
         
700 returns
let $para := 
In a hole in the ground there lived a hobbit.
         
184.

The expression

let $para := 
In a hole in the ground there lived a hobbit.
         
702 returns
let $para := 
In a hole in the ground there lived a hobbit.
         
182.

The expression

let $para := 
In a hole in the ground there lived a hobbit.
         
704 returns
let $para := 
In a hole in the ground there lived a hobbit.
         
182.

The expression

let $para := 
In a hole in the ground there lived a hobbit.
         
706 returns
let $para := 
In a hole in the ground there lived a hobbit.
         
182.

The expression

let $para := 
In a hole in the ground there lived a hobbit.
         
708 returns
let $para := 
In a hole in the ground there lived a hobbit.
         
182.

The expression

let $para := 
In a hole in the ground there lived a hobbit.
         
710 returns
let $para := 
In a hole in the ground there lived a hobbit.
         
182. (The second argument contains only ignorable collation units and is equivalent to the zero-length string.)

The expression

let $para := 
In a hole in the ground there lived a hobbit.
         
712 returns
let $para := 
In a hole in the ground there lived a hobbit.
         
182.

5.5.3 fn:ends-with

Summary

Returns true if the string

let $para := 
In a hole in the ground there lived a hobbit.
         
70 contains
let $para := 
In a hole in the ground there lived a hobbit.
         
73 as a trailing substring, taking collations into account.

Signatures

let $para := 
In a hole in the ground there lived a hobbit.
         
608(
let $para := 
In a hole in the ground there lived a hobbit.
         
70
let $para := 
In a hole in the ground there lived a hobbit.
         
71
let $para := 
In a hole in the ground there lived a hobbit.
         
244,
let $para := 
In a hole in the ground there lived a hobbit.
         
73
let $para := 
In a hole in the ground there lived a hobbit.
         
71
let $para := 
In a hole in the ground there lived a hobbit.
         
244)
let $para := 
In a hole in the ground there lived a hobbit.
         
71
op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
32

let $para := 
In a hole in the ground there lived a hobbit.
         
608(
let $para := 
In a hole in the ground there lived a hobbit.
         
70
let $para := 
In a hole in the ground there lived a hobbit.
         
71
let $para := 
In a hole in the ground there lived a hobbit.
         
244,
let $para := 
In a hole in the ground there lived a hobbit.
         
73
let $para := 
In a hole in the ground there lived a hobbit.
         
71
let $para := 
In a hole in the ground there lived a hobbit.
         
244,
let $para := 
In a hole in the ground there lived a hobbit.
         
128
let $para := 
In a hole in the ground there lived a hobbit.
         
71
let $para := 
In a hole in the ground there lived a hobbit.
         
10)
let $para := 
In a hole in the ground there lived a hobbit.
         
71
op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
32

Properties

The two-argument form of this function is ·deterministic·, ·context-dependent·, and ·focus-independent·. It depends on collations.

The three-argument form of this function is ·deterministic·, ·context-dependent·, and ·focus-independent·. It depends on collations, and static base URI.

Rules

If the value of

let $para := 
In a hole in the ground there lived a hobbit.
         
70 or
let $para := 
In a hole in the ground there lived a hobbit.
         
73 is the empty sequence, or contains only ignorable collation units, it is interpreted as the zero-length string.

If the value of

let $para := 
In a hole in the ground there lived a hobbit.
         
73 is the zero-length string, then the function returns
op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
76. If the value of
let $para := 
In a hole in the ground there lived a hobbit.
         
70 is the zero-length string and the value of
let $para := 
In a hole in the ground there lived a hobbit.
         
73 is not the zero-length string, then the function returns
let $C := 'http://www.w3.org/2013/collation/UCA?strength=primary'
07.

The collation used by this function is determined according to the rules in 5.3.5 Choosing a collation.

The function returns an

op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
32 indicating whether or not the value of
let $para := 
In a hole in the ground there lived a hobbit.
         
70 ends with a sequence of collation units that provides a match to the collation units of
let $para := 
In a hole in the ground there lived a hobbit.
         
73 according to the collation that is used.

Note:

Match is defined in [UTS #10].

Error Conditions

A dynamic error may be raised [err:FOCH0004] if the specified collation does not support collation units.

Examples

The collation used in these examples,

let $para := 
In a hole in the ground there lived a hobbit.
         
649 is a collation in which both "-" and "*" are ignorable collation units.

"Ignorable collation unit" is equivalent to "ignorable collation element" in [UTS #10].

The expression

let $para := 
In a hole in the ground there lived a hobbit.
         
748 returns
let $para := 
In a hole in the ground there lived a hobbit.
         
182.

The expression

let $para := 
In a hole in the ground there lived a hobbit.
         
750 returns
let $para := 
In a hole in the ground there lived a hobbit.
         
184.

The expression

let $para := 
In a hole in the ground there lived a hobbit.
         
752 returns
let $para := 
In a hole in the ground there lived a hobbit.
         
182.

The expression

let $para := 
In a hole in the ground there lived a hobbit.
         
754 returns
let $para := 
In a hole in the ground there lived a hobbit.
         
182.

The expression

let $para := 
In a hole in the ground there lived a hobbit.
         
756 returns
let $para := 
In a hole in the ground there lived a hobbit.
         
182.

The expression

let $para := 
In a hole in the ground there lived a hobbit.
         
756 returns
let $para := 
In a hole in the ground there lived a hobbit.
         
182.

The expression

let $para := 
In a hole in the ground there lived a hobbit.
         
760 returns
let $para := 
In a hole in the ground there lived a hobbit.
         
182. (The second argument contains only ignorable collation units and is equivalent to the zero-length string.)

The expression

let $para := 
In a hole in the ground there lived a hobbit.
         
762 returns
let $para := 
In a hole in the ground there lived a hobbit.
         
182.

5.5.4 fn:substring-before

Summary

Returns the part of

let $para := 
In a hole in the ground there lived a hobbit.
         
70 that precedes the first occurrence of
let $para := 
In a hole in the ground there lived a hobbit.
         
73, taking collations into account.

Signatures

let $para := 
In a hole in the ground there lived a hobbit.
         
611(
let $para := 
In a hole in the ground there lived a hobbit.
         
70
let $para := 
In a hole in the ground there lived a hobbit.
         
71
let $para := 
In a hole in the ground there lived a hobbit.
         
244,
let $para := 
In a hole in the ground there lived a hobbit.
         
73
let $para := 
In a hole in the ground there lived a hobbit.
         
71
let $para := 
In a hole in the ground there lived a hobbit.
         
244)
let $para := 
In a hole in the ground there lived a hobbit.
         
71
let $para := 
In a hole in the ground there lived a hobbit.
         
10

let $para := 
In a hole in the ground there lived a hobbit.
         
611(
let $para := 
In a hole in the ground there lived a hobbit.
         
70
let $para := 
In a hole in the ground there lived a hobbit.
         
71
let $para := 
In a hole in the ground there lived a hobbit.
         
244,
let $para := 
In a hole in the ground there lived a hobbit.
         
73
let $para := 
In a hole in the ground there lived a hobbit.
         
71
let $para := 
In a hole in the ground there lived a hobbit.
         
244,
let $para := 
In a hole in the ground there lived a hobbit.
         
128
let $para := 
In a hole in the ground there lived a hobbit.
         
71
let $para := 
In a hole in the ground there lived a hobbit.
         
10)
let $para := 
In a hole in the ground there lived a hobbit.
         
71
let $para := 
In a hole in the ground there lived a hobbit.
         
10

Properties

The two-argument form of this function is ·deterministic·, ·context-dependent·, and ·focus-independent·. It depends on collations.

The three-argument form of this function is ·deterministic·, ·context-dependent·, and ·focus-independent·. It depends on collations, and static base URI.

Rules

If the value of

let $para := 
In a hole in the ground there lived a hobbit.
         
70 or
let $para := 
In a hole in the ground there lived a hobbit.
         
73 is the empty sequence, or contains only ignorable collation units, it is interpreted as the zero-length string.

If the value of

let $para := 
In a hole in the ground there lived a hobbit.
         
73 is the zero-length string, then the function returns the zero-length string.

If the value of

let $para := 
In a hole in the ground there lived a hobbit.
         
70 does not contain a string that is equal to the value of
let $para := 
In a hole in the ground there lived a hobbit.
         
73, then the function returns the zero-length string.

The collation used by this function is determined according to the rules in 5.3.5 Choosing a collation.

The function returns the substring of the value of

let $para := 
In a hole in the ground there lived a hobbit.
         
70 that precedes in the value of
let $para := 
In a hole in the ground there lived a hobbit.
         
70 the first occurrence of a sequence of collation units that provides a minimal match to the collation units of
let $para := 
In a hole in the ground there lived a hobbit.
         
73 according to the collation that is used.

Note:

Minimal match is defined in [UTS #10].

Error Conditions

A dynamic error may be raised [err:FOCH0004] if the specified collation does not support collation units.

Examples

The collation used in these examples,

let $para := 
In a hole in the ground there lived a hobbit.
         
649 is a collation in which both "-" and "*" are ignorable collation units.

"Ignorable collation unit" is equivalent to "ignorable collation element" in [UTS #10].

The expression

let $para := 
In a hole in the ground there lived a hobbit.
         
796 returns
let $para := 
In a hole in the ground there lived a hobbit.
         
797.

The expression

let $para := 
In a hole in the ground there lived a hobbit.
         
798 returns
let $para := 
In a hole in the ground there lived a hobbit.
         
044.

The expression

let $para := 
In a hole in the ground there lived a hobbit.
         
800 returns
let $para := 
In a hole in the ground there lived a hobbit.
         
044.

The expression

let $para := 
In a hole in the ground there lived a hobbit.
         
802 returns
let $para := 
In a hole in the ground there lived a hobbit.
         
803.

The expression

let $para := 
In a hole in the ground there lived a hobbit.
         
804 returns
let $para := 
In a hole in the ground there lived a hobbit.
         
805.

The expression

let $para := 
In a hole in the ground there lived a hobbit.
         
806 returns
let $para := 
In a hole in the ground there lived a hobbit.
         
807.

The expression

let $para := 
In a hole in the ground there lived a hobbit.
         
808 returns
let $para := 
In a hole in the ground there lived a hobbit.
         
044. (The second argument contains only ignorable collation units and is equivalent to the zero-length string.)

5.5.5 fn:substring-after

Summary

Returns the part of

let $para := 
In a hole in the ground there lived a hobbit.
         
70 that follows the first occurrence of
let $para := 
In a hole in the ground there lived a hobbit.
         
73, taking collations into account.

Signatures

let $para := 
In a hole in the ground there lived a hobbit.
         
614(
let $para := 
In a hole in the ground there lived a hobbit.
         
70
let $para := 
In a hole in the ground there lived a hobbit.
         
71
let $para := 
In a hole in the ground there lived a hobbit.
         
244,
let $para := 
In a hole in the ground there lived a hobbit.
         
73
let $para := 
In a hole in the ground there lived a hobbit.
         
71
let $para := 
In a hole in the ground there lived a hobbit.
         
244)
let $para := 
In a hole in the ground there lived a hobbit.
         
71
let $para := 
In a hole in the ground there lived a hobbit.
         
10

let $para := 
In a hole in the ground there lived a hobbit.
         
614(
let $para := 
In a hole in the ground there lived a hobbit.
         
70
let $para := 
In a hole in the ground there lived a hobbit.
         
71
let $para := 
In a hole in the ground there lived a hobbit.
         
244,
let $para := 
In a hole in the ground there lived a hobbit.
         
73
let $para := 
In a hole in the ground there lived a hobbit.
         
71
let $para := 
In a hole in the ground there lived a hobbit.
         
244,
let $para := 
In a hole in the ground there lived a hobbit.
         
128
let $para := 
In a hole in the ground there lived a hobbit.
         
71
let $para := 
In a hole in the ground there lived a hobbit.
         
10)
let $para := 
In a hole in the ground there lived a hobbit.
         
71
let $para := 
In a hole in the ground there lived a hobbit.
         
10

Properties

The two-argument form of this function is ·deterministic·, ·context-dependent·, and ·focus-independent·. It depends on collations.

The three-argument form of this function is ·deterministic·, ·context-dependent·, and ·focus-independent·. It depends on collations, and static base URI.

Rules

If the value of

let $para := 
In a hole in the ground there lived a hobbit.
         
70 or
let $para := 
In a hole in the ground there lived a hobbit.
         
73 is the empty sequence, or contains only ignorable collation units, it is interpreted as the zero-length string.

If the value of

let $para := 
In a hole in the ground there lived a hobbit.
         
73 is the zero-length string, then the function returns the value of
let $para := 
In a hole in the ground there lived a hobbit.
         
70.

If the value of

let $para := 
In a hole in the ground there lived a hobbit.
         
70 does not contain a string that is equal to the value of
let $para := 
In a hole in the ground there lived a hobbit.
         
73, then the function returns the zero-length string.

The collation used by this function is determined according to the rules in 5.3.5 Choosing a collation.

The function returns the substring of the value of

let $para := 
In a hole in the ground there lived a hobbit.
         
70 that follows in the value of
let $para := 
In a hole in the ground there lived a hobbit.
         
70 the first occurrence of a sequence of collation units that provides a minimal match to the collation units of
let $para := 
In a hole in the ground there lived a hobbit.
         
73 according to the collation that is used.

Note:

Minimal match is defined in [UTS #10].

Error Conditions

A dynamic error may be raised [err:FOCH0004] if the specified collation does not support collation units.

Examples

The collation used in these examples,

let $para := 
In a hole in the ground there lived a hobbit.
         
649 is a collation in which both "-" and "*" are ignorable collation units.

"Ignorable collation unit" is equivalent to "ignorable collation element" in [UTS #10].

The expression

let $para := 
In a hole in the ground there lived a hobbit.
         
843 returns
let $para := 
In a hole in the ground there lived a hobbit.
         
844.

The expression

let $para := 
In a hole in the ground there lived a hobbit.
         
845 returns
let $para := 
In a hole in the ground there lived a hobbit.
         
044.

The expression

let $para := 
In a hole in the ground there lived a hobbit.
         
847 returns
let $para := 
In a hole in the ground there lived a hobbit.
         
044.

The expression

let $para := 
In a hole in the ground there lived a hobbit.
         
849 returns
let $para := 
In a hole in the ground there lived a hobbit.
         
850.

The expression

let $para := 
In a hole in the ground there lived a hobbit.
         
851 returns
let $para := 
In a hole in the ground there lived a hobbit.
         
852.

The expression

let $para := 
In a hole in the ground there lived a hobbit.
         
853 returns
let $para := 
In a hole in the ground there lived a hobbit.
         
854.

The expression

let $para := 
In a hole in the ground there lived a hobbit.
         
855 returns
let $para := 
In a hole in the ground there lived a hobbit.
         
856. (The second argument contains only ignorable collation units and is equivalent to the zero-length string.)

5.6 String functions that use regular expressions

The three functions described in this section make use of a regular expression syntax for pattern matching. This is described below.

FunctionMeaning
let $para := 
In a hole in the ground there lived a hobbit.
         
857Returns true if the supplied string matches a given regular expression.
let $para := 
In a hole in the ground there lived a hobbit.
         
858Returns a string produced from the input string by replacing any substrings that match a given regular expression with a supplied replacement string.
let $para := 
In a hole in the ground there lived a hobbit.
         
859Returns a sequence of strings constructed by splitting the input wherever a separator is found; the separator is any substring that matches a given regular expression.
op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
18Analyzes a string using a regular expression, returning an XML structure that identifies which parts of the input string matched or failed to match the regular expression, and in the case of matched substrings, which substrings matched each capturing group in the regular expression.

5.6.1 Regular expression syntax

The regular expression syntax used by these functions is defined in terms of the regular expression syntax specified in XML Schema (see [XML Schema Part 2: Datatypes Second Edition]), which in turn is based on the established conventions of languages such as Perl. However, because XML Schema uses regular expressions only for validity checking, it omits some facilities that are widely-used with languages such as Perl. This section, therefore, describes extensions to the XML Schema regular expressions syntax that reinstate these capabilities.

Note:

It is recommended that implementers consult [UTS #18] for information on using regular expression processing on Unicode characters.

The regular expression syntax and semantics are identical to those defined in [XML Schema Part 2: Datatypes Second Edition] with the additions described in the following sub-sections.

Note:

In [Schema 1.1 Part 2] there are no substantive technical changes to the syntax or semantics of regular expressions relative to XSD 1.0, but a number of errors and ambiguities have been resolved. For example, the rules for the interpretation of hyphens within square brackets in a regular expression have been clarified; and the semantics of regular expressions are no longer tied to a specific version of Unicode.

Implementers, even in cases where XSD 1.1 is not supported, are advised to consult the XSD 1.1 regular expression specification for guidance on how to handle cases where the XSD 1.0 specification is unclear or inconsistent.

5.6.1.1 Matching the Start and End of the String

Two meta-characters,

let $para := 
In a hole in the ground there lived a hobbit.
         
861 and
let $para := 
In a hole in the ground there lived a hobbit.
         
734 are added. By default, the meta-character
let $para := 
In a hole in the ground there lived a hobbit.
         
861 matches the start of the entire string, while
let $para := 
In a hole in the ground there lived a hobbit.
         
734 matches the end of the entire string. In multi-line mode,
let $para := 
In a hole in the ground there lived a hobbit.
         
861 matches the start of any line (that is, the start of the entire string, and the position immediately after a newline character), while
let $para := 
In a hole in the ground there lived a hobbit.
         
734 matches the end of any line (that is, the end of the entire string, and the position immediately before a newline character). Newline here means the character
let $para := 
In a hole in the ground there lived a hobbit.
         
867 only.

This means that the production in [XML Schema Part 2: Datatypes Second Edition]:

let $para := 
In a hole in the ground there lived a hobbit.
         
868

is modified to read:

let $para := 
In a hole in the ground there lived a hobbit.
         
869

The XSD 1.1 grammar for regular expressions uses the same production rule, but renumbered and renamed

let $para := 
In a hole in the ground there lived a hobbit.
         
870; it is affected in the same way.

The characters

let $para := 
In a hole in the ground there lived a hobbit.
         
871 and
let $para := 
In a hole in the ground there lived a hobbit.
         
872 correspond to "
let $para := 
In a hole in the ground there lived a hobbit.
         
873" and "
let $para := 
In a hole in the ground there lived a hobbit.
         
874" respectively.

Note:

The definition of Char (production [10]) in [XML Schema Part 2: Datatypes Second Edition] has a known error in which it omits the left brace ("{") and right brace ("}"). That error is corrected here.

The following production:

let $para := 
In a hole in the ground there lived a hobbit.
         
875

is modified to read:

let $para := 
In a hole in the ground there lived a hobbit.
         
876

Using XSD 1.1 as the baseline the equivalent is to change the production:

let $para := 
In a hole in the ground there lived a hobbit.
         
877

to read:

let $para := 
In a hole in the ground there lived a hobbit.
         
878

Single character escapes are extended to allow the

let $para := 
In a hole in the ground there lived a hobbit.
         
734 character to be escaped. The following production is changed:

let $para := 
In a hole in the ground there lived a hobbit.
         
880

to

let $para := 
In a hole in the ground there lived a hobbit.
         
881

(In the XSD 1.1 version of the regular expression grammar, the production rule for

let $para := 
In a hole in the ground there lived a hobbit.
         
882 is unchanged, but is renumbered [84])

5.6.1.2 Reluctant Quantifiers

Reluctant quantifiers are supported. They are indicated by a

let $para := 
In a hole in the ground there lived a hobbit.
         
11 following a quantifier. Specifically:

  • let $para := 
    In a hole in the ground there lived a hobbit.
             
    884 matches X, once or not at all

  • let $para := 
    In a hole in the ground there lived a hobbit.
             
    885 matches X, zero or more times

  • let $para := 
    In a hole in the ground there lived a hobbit.
             
    886 matches X, one or more times

  • let $para := 
    In a hole in the ground there lived a hobbit.
             
    887 matches X, exactly n times

  • let $para := 
    In a hole in the ground there lived a hobbit.
             
    888 matches X, at least n times

  • let $para := 
    In a hole in the ground there lived a hobbit.
             
    889 matches X, at least n times, but not more than m times

The effect of these quantifiers is that the regular expression matches the shortest possible substring consistent with the match as a whole succeeding. Without the

let $para := 
In a hole in the ground there lived a hobbit.
         
11 , the regular expression matches the longest possible substring.

To achieve this, the production in [XML Schema Part 2: Datatypes Second Edition]:

let $para := 
In a hole in the ground there lived a hobbit.
         
891

is changed to:

let $para := 
In a hole in the ground there lived a hobbit.
         
892

(In the XSD 1.1 version of the regular expression grammar, this rule is unchanged, but is renumbered [67])

Note:

Reluctant quantifiers have no effect on the results of the boolean

let $para := 
In a hole in the ground there lived a hobbit.
         
857 function, since this function is only interested in discovering whether a match exists, and not where it exists.

5.6.1.3 Captured Sub-Expressions

Sub-expressions (groups) within the regular expression are recognized. The regular expression syntax defined by [XML Schema Part 2: Datatypes Second Edition] 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

let $para := 
In a hole in the ground there lived a hobbit.
         
858 function) allow access to the parts of the input string that matched a sub-expression (called captured substrings).

[Definition] A left parenthesis is recognized as a capturing left parenthesis provided it is not immediately followed by

let $para := 
In a hole in the ground there lived a hobbit.
         
895 (see below), is not within a character group (square brackets), and is not escaped with a backslash. The sub-expression enclosed by a capturing left parenthesis and its matching right parenthesis is referred to as a capturing sub-expression.

More specifically, the ·capturing sub-expression· enclosed by the Nth capturing left parenthesis within the regular expression (determined by its character position in left-to-right order, and counting from one) is referred to as the Nth capturing sub-expression.

For example, in the regular expression

let $para := 
In a hole in the ground there lived a hobbit.
         
896, the string matched by the sub-expression
let $para := 
In a hole in the ground there lived a hobbit.
         
897 is capturing sub-expression 1, the string matched by
let $para := 
In a hole in the ground there lived a hobbit.
         
898 is capturing sub-expression 2, and the string matched by
let $para := 
In a hole in the ground there lived a hobbit.
         
899 is capturing sub-expression 3.

When, in the course of evaluating a regular expression, a particular substring of the input matches a capturing sub-expression, that substring becomes available as a captured substring. The string matched by the Nth capturing sub-expression is referred to as the Nth captured substring. By convention, the substring captured by the entire regular expression is treated as captured substring 0 (zero).

When a ·capturing sub-expression· is matched more than once (because it is within a construct that allows repetition), then only the last substring that it matched will be captured. Note that this rule is not sufficient in all cases to ensure an unambiguous result, especially in cases where (a) the regular expression contains nested repeating constructs, and/or (b) the repeating construct matches a zero-length string. In such cases it is implementation-dependent which substring is captured. For example given the regular expression

let $para := 
In a hole in the ground there lived a hobbit.
         
900 and the input string
let $para := 
In a hole in the ground there lived a hobbit.
         
901, an implementation might legitimately capture either
let $para := 
In a hole in the ground there lived a hobbit.
         
901 or a zero length string as the content of the captured subgroup.

Parentheses that are required to group terms within the regular expression, but which are not required for capturing of substrings, can be represented using the syntax

let $para := 
In a hole in the ground there lived a hobbit.
         
903. To achieve this, the production rule for
let $para := 
In a hole in the ground there lived a hobbit.
         
904 in [XML Schema Part 2: Datatypes Second Edition] is changed to replace the alternative:

let $para := 
In a hole in the ground there lived a hobbit.
         
905

with:

let $para := 
In a hole in the ground there lived a hobbit.
         
906

(For the new versions of the XSD 1.0 and XSD 1.1 production rules for

let $para := 
In a hole in the ground there lived a hobbit.
         
904, see below.)

In the absence of back-references (see below), the presence of the optional

let $para := 
In a hole in the ground there lived a hobbit.
         
895 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
let $para := 
In a hole in the ground there lived a hobbit.
         
858 and back-references) that number the capturing sub-expressions within a regular expression.

5.6.1.4 Back-References

Back-references are allowed outside a character class expression. A back-reference is an additional kind of atom. The construct

let $para := 
In a hole in the ground there lived a hobbit.
         
910 where
let $para := 
In a hole in the ground there lived a hobbit.
         
911 is a single digit is always recognized as a back-reference; if this is followed by further digits, these digits are taken to be part of the back-reference if and only if the resulting number NN is such that the back-reference is preceded by the opening parenthesis of the NNth capturing left parenthesis. The regular expression is invalid if a back-reference refers to a capturing sub-expression that does not exist or whose closing right parenthesis occurs after the back-reference.

A back-reference with number N matches a string that is the same as the value of the

let $para := 
In a hole in the ground there lived a hobbit.
         
911th captured substring.

For example, the regular expression

let $para := 
In a hole in the ground there lived a hobbit.
         
913 matches a sequence of characters delimited either by an apostrophe at the start and end, or by a quotation mark at the start and end.

If no string has been matched by the

let $para := 
In a hole in the ground there lived a hobbit.
         
911th capturing sub-expression, the back-reference is interpreted as matching a zero-length string.

Combining this change with the introduction of non-capturing groups (see above), back-references change the following production:

let $para := 
In a hole in the ground there lived a hobbit.
         
915

to

let $para := 
In a hole in the ground there lived a hobbit.
         
916

let $para := 
In a hole in the ground there lived a hobbit.
         
917

With respect to the XSD 1.1 version of the regular expression grammar, the effect is to change:

let $para := 
In a hole in the ground there lived a hobbit.
         
918

to

let $para := 
In a hole in the ground there lived a hobbit.
         
919

let $para := 
In a hole in the ground there lived a hobbit.
         
920

Note:

Within a character class expression,

let $para := 
In a hole in the ground there lived a hobbit.
         
921 followed by a digit is invalid. Some other regular expression languages interpret this as an octal character reference.

5.6.1.5 Unicode Block Names

A regular expression that uses a Unicode block name that is not defined in the version(s) of Unicode supported by the processor (for example

let $para := 
In a hole in the ground there lived a hobbit.
         
922) is deemed to be invalid [err:FORX0002].

Note:

XSD 1.0 does not say how this situation should be handled; XSD 1.1 says that it should be handled by treating all characters as matching.

5.6.2 Flags

All these functions provide an optional parameter,

let $para := 
In a hole in the ground there lived a hobbit.
         
923, to set options for the interpretation of the regular expression. The parameter accepts a
let $para := 
In a hole in the ground there lived a hobbit.
         
10, in which individual letters are used to set options. The presence of a letter within the string indicates that the option is on; its absence indicates that the option is off. Letters may appear in any order and may be repeated. If there are characters present that are not defined here as flags, then a dynamic error is raised [err:FORX0001].

The following options are defined:

  • let $para := 
    In a hole in the ground there lived a hobbit.
             
    925: If present, the match operates in "dot-all" mode. (Perl calls this the single-line mode.) If the
    let $para := 
    In a hole in the ground there lived a hobbit.
             
    925 flag is not specified, the meta-character
    let $para := 
    In a hole in the ground there lived a hobbit.
             
    19 matches any character except a newline (
    let $para := 
    In a hole in the ground there lived a hobbit.
             
    867) or carriage return (
    let $para := 
    In a hole in the ground there lived a hobbit.
             
    929) character. In dot-all mode, the meta-character
    let $para := 
    In a hole in the ground there lived a hobbit.
             
    19 matches any character whatsoever. Suppose the input contains "hello" and "world" on two lines. This will not be matched by the regular expression "hello.*world" unless dot-all mode is enabled.

  • let $para := 
    In a hole in the ground there lived a hobbit.
             
    931: If present, the match operates in multi-line mode. By default, the meta-character
    let $para := 
    In a hole in the ground there lived a hobbit.
             
    861 matches the start of the entire string, while $ matches the end of the entire string. In multi-line mode,
    let $para := 
    In a hole in the ground there lived a hobbit.
             
    861 matches the start of any line (that is, the start of the entire string, and the position immediately after a newline character other than a newline that appears as the last character in the string), while
    let $para := 
    In a hole in the ground there lived a hobbit.
             
    734 matches the end of any line (that is, the position immediately before a newline character, and the end of the entire string if there is no newline character at the end of the string). Newline here means the character
    let $para := 
    In a hole in the ground there lived a hobbit.
             
    867 only.

  • let $para := 
    In a hole in the ground there lived a hobbit.
             
    274: If present, the match operates in case-insensitive mode. The detailed rules are as follows. In these rules, a character C2 is considered to be a case-variant of another character C1 if the following XPath expression returns
    op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
    76 when the two characters are considered as strings of length one, and the ·Unicode codepoint collation· is used:

    let $para := 
    In a hole in the ground there lived a hobbit.
             
    938

    Note that the case-variants of a character under this definition are always single characters.

    1. When a normal character (

      let $para := 
      In a hole in the ground there lived a hobbit.
               
      939) is used as an atom, it represents the set containing that character and all its case-variants. For example, the regular expression "z" will match both "z" and "Z".

    2. A character range (production

      let $para := 
      In a hole in the ground there lived a hobbit.
               
      940 in the XSD 1.0 grammar, replaced by productions
      let $para := 
      In a hole in the ground there lived a hobbit.
               
      940 and
      let $para := 
      In a hole in the ground there lived a hobbit.
               
      942 in XSD 1.1) represents the set containing all the characters that it would match in the absence of the "
      let $para := 
      In a hole in the ground there lived a hobbit.
               
      274" flag, together with their case-variants. For example, the regular expression "[A-Z]" will match all the letters A-Z and all the letters a-z. It will also match certain other characters such as
      let $para := 
      In a hole in the ground there lived a hobbit.
               
      944 (KELVIN SIGN), since
      let $para := 
      In a hole in the ground there lived a hobbit.
               
      945 is "k".

      This rule applies also to a character range used in a character class subtraction (

      let $para := 
      In a hole in the ground there lived a hobbit.
               
      946): thus [A-Z-[IO]] will match characters such as "A", "B", "a", and "b", but will not match "I", "O", "i", or "o".

      The rule also applies to a character range used as part of a negative character group: thus [^Q] will match every character except "Q" and "q" (these being the only case-variants of "Q" in Unicode).

    3. A back-reference is compared using case-blind comparison: that is, each character must either be the same as the corresponding character of the previously matched string, or must be a case-variant of that character. For example, the strings "Mum", "mom", "Dad", and "DUD" all match the regular expression "([md])[aeiou]\1" when the "

      let $para := 
      In a hole in the ground there lived a hobbit.
               
      274" flag is used.

    4. All other constructs are unaffected by the "

      let $para := 
      In a hole in the ground there lived a hobbit.
               
      274" flag. For example, "\p{Lu}" continues to match upper-case letters only.

  • let $para := 
    In a hole in the ground there lived a hobbit.
             
    949: If present, whitespace characters (#x9, #xA, #xD and #x20) in the regular expression are removed prior to matching with one exception: whitespace characters within character class expressions (
    let $para := 
    In a hole in the ground there lived a hobbit.
             
    950) are not removed. This flag can be used, for example, to break up long regular expressions into readable lines.

    Examples:

    let $para := 
    In a hole in the ground there lived a hobbit.
             
    951 returns
    let $para := 
    In a hole in the ground there lived a hobbit.
             
    182

    let $para := 
    In a hole in the ground there lived a hobbit.
             
    953 returns
    let $para := 
    In a hole in the ground there lived a hobbit.
             
    184

    let $para := 
    In a hole in the ground there lived a hobbit.
             
    955 returns
    let $para := 
    In a hole in the ground there lived a hobbit.
             
    182

    let $para := 
    In a hole in the ground there lived a hobbit.
             
    957 returns
    let $para := 
    In a hole in the ground there lived a hobbit.
             
    184

  • let $para := 
    In a hole in the ground there lived a hobbit.
             
    959: if present, all characters in the regular expression are treated as representing themselves, not as metacharacters. In effect, every character that would normally have a special meaning in a regular expression is implicitly escaped by preceding it with a backslash.

    Furthermore, when this flag is present, the characters

    let $para := 
    In a hole in the ground there lived a hobbit.
             
    734 and
    let $para := 
    In a hole in the ground there lived a hobbit.
             
    921 have no special significance when used in the replacement string supplied to the
    let $para := 
    In a hole in the ground there lived a hobbit.
             
    858 function.

    This flag can be used in conjunction with the

    let $para := 
    In a hole in the ground there lived a hobbit.
             
    274 flag. If it is used together with the
    let $para := 
    In a hole in the ground there lived a hobbit.
             
    931,
    let $para := 
    In a hole in the ground there lived a hobbit.
             
    925, or
    let $para := 
    In a hole in the ground there lived a hobbit.
             
    949 flag, that flag has no effect.

    Examples:

    let $para := 
    In a hole in the ground there lived a hobbit.
             
    967 returns
    let $para := 
    In a hole in the ground there lived a hobbit.
             
    968

    let $para := 
    In a hole in the ground there lived a hobbit.
             
    969 returns
    let $para := 
    In a hole in the ground there lived a hobbit.
             
    970

    let $para := 
    In a hole in the ground there lived a hobbit.
             
    971 returns
    let $para := 
    In a hole in the ground there lived a hobbit.
             
    972

    let $para := 
    In a hole in the ground there lived a hobbit.
             
    973 returns
    let $para := 
    In a hole in the ground there lived a hobbit.
             
    184

    let $para := 
    In a hole in the ground there lived a hobbit.
             
    975 returns
    let $para := 
    In a hole in the ground there lived a hobbit.
             
    182

5.6.3 fn:matches

Summary

Returns true if the supplied string matches a given regular expression.

Signatures

let $para := 
In a hole in the ground there lived a hobbit.
         
857(
let $para := 
In a hole in the ground there lived a hobbit.
         
232
let $para := 
In a hole in the ground there lived a hobbit.
         
71
let $para := 
In a hole in the ground there lived a hobbit.
         
244,
let $para := 
In a hole in the ground there lived a hobbit.
         
981
let $para := 
In a hole in the ground there lived a hobbit.
         
71
let $para := 
In a hole in the ground there lived a hobbit.
         
10)
let $para := 
In a hole in the ground there lived a hobbit.
         
71
op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
32

let $para := 
In a hole in the ground there lived a hobbit.
         
857(
let $para := 
In a hole in the ground there lived a hobbit.
         
232
let $para := 
In a hole in the ground there lived a hobbit.
         
71
let $para := 
In a hole in the ground there lived a hobbit.
         
244,
let $para := 
In a hole in the ground there lived a hobbit.
         
981
let $para := 
In a hole in the ground there lived a hobbit.
         
71
let $para := 
In a hole in the ground there lived a hobbit.
         
10,
let $para := 
In a hole in the ground there lived a hobbit.
         
923
let $para := 
In a hole in the ground there lived a hobbit.
         
71
let $para := 
In a hole in the ground there lived a hobbit.
         
10)
let $para := 
In a hole in the ground there lived a hobbit.
         
71
op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
32

Properties

This function is ·deterministic·, ·context-independent·, and ·focus-independent·.

Rules

The effect of calling the first version of this function (omitting the argument

let $para := 
In a hole in the ground there lived a hobbit.
         
923) is the same as the effect of calling the second version with the
let $para := 
In a hole in the ground there lived a hobbit.
         
923 argument set to a zero-length string. Flags are defined in 5.6.2 Flags.

If

let $para := 
In a hole in the ground there lived a hobbit.
         
232 is the empty sequence, it is interpreted as the zero-length string.

The function returns

op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
76 if
let $para := 
In a hole in the ground there lived a hobbit.
         
232 or some substring of
let $para := 
In a hole in the ground there lived a hobbit.
         
232 matches the regular expression supplied as
let $para := 
In a hole in the ground there lived a hobbit.
         
981. Otherwise, the function returns
let $C := 'http://www.w3.org/2013/collation/UCA?strength=primary'
07. The matching rules are influenced by the value of
let $para := 
In a hole in the ground there lived a hobbit.
         
923 if present.

Error Conditions

A dynamic error is raised [err:FORX0002] if the value of

let $para := 
In a hole in the ground there lived a hobbit.
         
981 is invalid according to the rules described in 5.6.1 Regular expression syntax.

A dynamic error is raised [err:FORX0001] if the value of

let $para := 
In a hole in the ground there lived a hobbit.
         
923 is invalid according to the rules described in 5.6.2 Flags.

Notes

Unless the metacharacters

let $para := 
In a hole in the ground there lived a hobbit.
         
861 and
let $para := 
In a hole in the ground there lived a hobbit.
         
734 are used as anchors, the string is considered to match the pattern if any substring matches the pattern. But if anchors are used, the anchors must match the start/end of the string (in string mode), or the start/end of a line (in multi-line mode).

This is different from the behavior of patterns in [XML Schema Part 2: Datatypes Second Edition], where regular expressions are implicitly anchored.

Regular expression matching is defined on the basis of Unicode code points; it takes no account of collations.

Examples

The expression

op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
011 returns
let $para := 
In a hole in the ground there lived a hobbit.
         
182.

The expression

op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
013 returns
let $para := 
In a hole in the ground there lived a hobbit.
         
182.

The expression

op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
015 returns
let $para := 
In a hole in the ground there lived a hobbit.
         
184.

Given the source document:

let $para := 
In a hole in the ground there lived a hobbit.
         
4

the following function calls produce the following results, with the

op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
017 element as the context node:

The expression

op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
018 returns
let $para := 
In a hole in the ground there lived a hobbit.
         
184.

The expression

op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
020 returns
let $para := 
In a hole in the ground there lived a hobbit.
         
182.

The expression

op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
022 returns
let $para := 
In a hole in the ground there lived a hobbit.
         
182.

The expression

op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
024 returns
let $para := 
In a hole in the ground there lived a hobbit.
         
184.

The expression

op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
026 returns
let $para := 
In a hole in the ground there lived a hobbit.
         
182.

5.6.4 fn:replace

Summary

Returns a string produced from the input string by replacing any substrings that match a given regular expression with a supplied replacement string.

Signatures

let $para := 
In a hole in the ground there lived a hobbit.
         
858(
let $para := 
In a hole in the ground there lived a hobbit.
         
232
let $para := 
In a hole in the ground there lived a hobbit.
         
71
let $para := 
In a hole in the ground there lived a hobbit.
         
244,
let $para := 
In a hole in the ground there lived a hobbit.
         
981
let $para := 
In a hole in the ground there lived a hobbit.
         
71
let $para := 
In a hole in the ground there lived a hobbit.
         
10,
op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
035
let $para := 
In a hole in the ground there lived a hobbit.
         
71
let $para := 
In a hole in the ground there lived a hobbit.
         
10)
let $para := 
In a hole in the ground there lived a hobbit.
         
71
let $para := 
In a hole in the ground there lived a hobbit.
         
10

let $para := 
In a hole in the ground there lived a hobbit.
         
858(
let $para := 
In a hole in the ground there lived a hobbit.
         
232
let $para := 
In a hole in the ground there lived a hobbit.
         
71
let $para := 
In a hole in the ground there lived a hobbit.
         
244,
let $para := 
In a hole in the ground there lived a hobbit.
         
981
let $para := 
In a hole in the ground there lived a hobbit.
         
71
let $para := 
In a hole in the ground there lived a hobbit.
         
10,
op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
035
let $para := 
In a hole in the ground there lived a hobbit.
         
71
let $para := 
In a hole in the ground there lived a hobbit.
         
10,
let $para := 
In a hole in the ground there lived a hobbit.
         
923
let $para := 
In a hole in the ground there lived a hobbit.
         
71
let $para := 
In a hole in the ground there lived a hobbit.
         
10)
let $para := 
In a hole in the ground there lived a hobbit.
         
71
let $para := 
In a hole in the ground there lived a hobbit.
         
10

Properties

This function is ·deterministic·, ·context-independent·, and ·focus-independent·.

Rules

The effect of calling the first version of this function (omitting the argument

let $para := 
In a hole in the ground there lived a hobbit.
         
923) is the same as the effect of calling the second version with the
let $para := 
In a hole in the ground there lived a hobbit.
         
923 argument set to a zero-length string. Flags are defined in 5.6.2 Flags.

The

let $para := 
In a hole in the ground there lived a hobbit.
         
923 argument is interpreted in the same manner as for the
let $para := 
In a hole in the ground there lived a hobbit.
         
857 function.

If

let $para := 
In a hole in the ground there lived a hobbit.
         
232 is the empty sequence, it is interpreted as the zero-length string.

The function returns the

let $para := 
In a hole in the ground there lived a hobbit.
         
10 that is obtained by replacing each non-overlapping substring of
let $para := 
In a hole in the ground there lived a hobbit.
         
232 that matches the given
let $para := 
In a hole in the ground there lived a hobbit.
         
981 with an occurrence of the
op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
035 string.

If two overlapping substrings of

let $para := 
In a hole in the ground there lived a hobbit.
         
232 both match the
let $para := 
In a hole in the ground there lived a hobbit.
         
981, then only the first one (that is, the one whose first ·character· comes first in the
let $para := 
In a hole in the ground there lived a hobbit.
         
232 string) is replaced.

If the

let $para := 
In a hole in the ground there lived a hobbit.
         
959 flag is present, the replacement string is used as is.

Otherwise, within the

op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
035 string, a variable
Primo Secondo Terzo Quarto Quinto ...
98 may be used to refer to the substring captured by the Nth parenthesized sub-expression in the regular expression. For each match of the pattern, these variables are assigned the value of the content matched by the relevant sub-expression, and the modified replacement string is then substituted for the ·characters· in
let $para := 
In a hole in the ground there lived a hobbit.
         
232 that matched the pattern.
op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
071 refers to the substring captured by the regular expression as a whole.

More specifically, the rules are as follows, where

op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
072 is the number of parenthesized sub-expressions in the regular expression, and
let $para := 
In a hole in the ground there lived a hobbit.
         
911 is the decimal number formed by taking all the digits that consecutively follow the
let $para := 
In a hole in the ground there lived a hobbit.
         
734 character:

  1. If

    let $para := 
    In a hole in the ground there lived a hobbit.
             
    911=
    declare %public function r:random-sequence($length as xs:integer) as xs:double* {
      r:random-sequence($length, fn:random-number-generator())
    };
    
    declare %private function r:random-sequence($length as xs:integer, 
                                                $G as map(xs:string, item())) {
      if ($length eq 0)
      then ()
      else ($G?number, r:random-sequence($length - 1, $G?next()))
    };
    
    r:random-sequence(200);
                
    19, then the variable is replaced by the substring matched by the regular expression as a whole.

  2. If

    declare %public function r:random-sequence($length as xs:integer) as xs:double* {
      r:random-sequence($length, fn:random-number-generator())
    };
    
    declare %private function r:random-sequence($length as xs:integer, 
                                                $G as map(xs:string, item())) {
      if ($length eq 0)
      then ()
      else ($G?number, r:random-sequence($length - 1, $G?next()))
    };
    
    r:random-sequence(200);
                
    13<=
    let $para := 
    In a hole in the ground there lived a hobbit.
             
    911<=
    op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
    072, then the variable is replaced by the substring captured by the Nth parenthesized sub-expression. If the
    op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
    080 parenthesized sub-expression was not matched, then the variable is replaced by the zero-length string.

  3. If

    op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
    072<
    let $para := 
    In a hole in the ground there lived a hobbit.
             
    911<=
    op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
    083, then the variable is replaced by the zero-length string.

  4. Otherwise (if

    let $para := 
    In a hole in the ground there lived a hobbit.
             
    911>
    op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
    072 and
    let $para := 
    In a hole in the ground there lived a hobbit.
             
    911>
    op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
    083), the last digit of
    let $para := 
    In a hole in the ground there lived a hobbit.
             
    911 is taken to be a literal character to be included "as is" in the replacement string, and the rules are reapplied using the number
    let $para := 
    In a hole in the ground there lived a hobbit.
             
    911 formed by stripping off this last digit.

For example, if the replacement string is

op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
090 and there are 5 substrings, the result contains the value of the substring that matches the second sub-expression, followed by the digit
declare %public function r:random-sequence($length as xs:integer) as xs:double* {
  r:random-sequence($length, fn:random-number-generator())
};

declare %private function r:random-sequence($length as xs:integer, 
                                            $G as map(xs:string, item())) {
  if ($length eq 0)
  then ()
  else ($G?number, r:random-sequence($length - 1, $G?next()))
};

r:random-sequence(200);
            
07.

Unless the

let $para := 
In a hole in the ground there lived a hobbit.
         
959 flag is used, a literal
let $para := 
In a hole in the ground there lived a hobbit.
         
734 character within the replacement string must be written as
op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
094, and a literal
let $para := 
In a hole in the ground there lived a hobbit.
         
921 character must be written as
op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
096.

If two alternatives within the pattern both match at the same position in the

let $para := 
In a hole in the ground there lived a hobbit.
         
232, then the match that is chosen is the one matched by the first alternative. For example:

let $para := 
In a hole in the ground there lived a hobbit.
         
5

Error Conditions

A dynamic error is raised [err:FORX0002] if the value of

let $para := 
In a hole in the ground there lived a hobbit.
         
981 is invalid according to the rules described in section 5.6.1 Regular expression syntax.

A dynamic error is raised [err:FORX0001] if the value of

let $para := 
In a hole in the ground there lived a hobbit.
         
923 is invalid according to the rules described in section 5.6.2 Flags.

A dynamic error is raised [err:FORX0003] if the pattern matches a zero-length string, that is, if the expression

op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
100 returns
op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
76. It is not an error, however, if a captured substring is zero-length.

In the absence of the

let $para := 
In a hole in the ground there lived a hobbit.
         
959 flag, a dynamic error is raised [err:FORX0004] if the value of
op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
035 contains a dollar sign (
let $para := 
In a hole in the ground there lived a hobbit.
         
734) character that is not immediately followed by a digit
op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
105 and not immediately preceded by a backslash (
let $para := 
In a hole in the ground there lived a hobbit.
         
921).

In the absence of the

let $para := 
In a hole in the ground there lived a hobbit.
         
959 flag, a dynamic error is raised [err:FORX0004] if the value of
op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
035 contains a backslash (
let $para := 
In a hole in the ground there lived a hobbit.
         
921) character that is not part of a
op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
096 pair, unless it is immediately followed by a dollar sign (
let $para := 
In a hole in the ground there lived a hobbit.
         
734) character.

Notes

If the input string contains no substring that matches the regular expression, the result of the function is a single string identical to the input string.

Examples

The expression

op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
112 returns
op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
113.

The expression

op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
114 returns
op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
115.

The expression

op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
116 returns
op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
117.

The expression

op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
118 returns
op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
119.

The expression

op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
120 returns
op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
121.

The expression

op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
122 raises an error, because the pattern matches the zero-length string

The expression

op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
123 returns
op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
124.

The expression

op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
125 returns
op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
126.

The expression

op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
127 returns
op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
128. (The first
op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
129 is replaced.)

5.6.5 fn:tokenize

Summary

Returns a sequence of strings constructed by splitting the input wherever a separator is found; the separator is any substring that matches a given regular expression.

Signatures

let $para := 
In a hole in the ground there lived a hobbit.
         
859(
let $para := 
In a hole in the ground there lived a hobbit.
         
232
let $para := 
In a hole in the ground there lived a hobbit.
         
71
let $para := 
In a hole in the ground there lived a hobbit.
         
244)
let $para := 
In a hole in the ground there lived a hobbit.
         
71
let $para := 
In a hole in the ground there lived a hobbit.
         
234

let $para := 
In a hole in the ground there lived a hobbit.
         
859(
let $para := 
In a hole in the ground there lived a hobbit.
         
232
let $para := 
In a hole in the ground there lived a hobbit.
         
71
let $para := 
In a hole in the ground there lived a hobbit.
         
244,
let $para := 
In a hole in the ground there lived a hobbit.
         
981
let $para := 
In a hole in the ground there lived a hobbit.
         
71
let $para := 
In a hole in the ground there lived a hobbit.
         
10)
let $para := 
In a hole in the ground there lived a hobbit.
         
71
let $para := 
In a hole in the ground there lived a hobbit.
         
234

let $para := 
In a hole in the ground there lived a hobbit.
         
859(
let $para := 
In a hole in the ground there lived a hobbit.
         
232
let $para := 
In a hole in the ground there lived a hobbit.
         
71
let $para := 
In a hole in the ground there lived a hobbit.
         
244,
let $para := 
In a hole in the ground there lived a hobbit.
         
981
let $para := 
In a hole in the ground there lived a hobbit.
         
71
let $para := 
In a hole in the ground there lived a hobbit.
         
10,
let $para := 
In a hole in the ground there lived a hobbit.
         
923
let $para := 
In a hole in the ground there lived a hobbit.
         
71
let $para := 
In a hole in the ground there lived a hobbit.
         
10)
let $para := 
In a hole in the ground there lived a hobbit.
         
71
let $para := 
In a hole in the ground there lived a hobbit.
         
234

Properties

This function is ·deterministic·, ·context-independent·, and ·focus-independent·.

Rules

The one-argument form of this function splits the supplied string at whitespace boundaries. More specifically, calling

op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
157 is equivalent to calling
op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
158 where the second argument is a single space character (x20).

The effect of calling the two-argument form of this function (omitting the argument

let $para := 
In a hole in the ground there lived a hobbit.
         
923) is the same as the effect of calling the three-argument version with the
let $para := 
In a hole in the ground there lived a hobbit.
         
923 argument set to a zero-length string. Flags are defined in 5.6.2 Flags.

The following rules apply to the three-argument form of the function:

  • The

    let $para := 
    In a hole in the ground there lived a hobbit.
             
    923 argument is interpreted in the same way as for the
    let $para := 
    In a hole in the ground there lived a hobbit.
             
    857 function.

  • If

    let $para := 
    In a hole in the ground there lived a hobbit.
             
    232 is the empty sequence, or if
    let $para := 
    In a hole in the ground there lived a hobbit.
             
    232 is the zero-length string, the function returns the empty sequence.

  • The function returns a sequence of strings formed by breaking the

    let $para := 
    In a hole in the ground there lived a hobbit.
             
    232 string into a sequence of strings, treating any substring that matches
    let $para := 
    In a hole in the ground there lived a hobbit.
             
    981 as a separator. The separators themselves are not returned.

  • Except with the one-argument form of the function, if a separator occurs at the start of the

    let $para := 
    In a hole in the ground there lived a hobbit.
             
    232 string, the result sequence will start with a zero-length string. Similarly, zero-length strings will also occur in the result sequence if a separator occurs at the end of the
    let $para := 
    In a hole in the ground there lived a hobbit.
             
    232 string, or if two adjacent substrings match the supplied
    let $para := 
    In a hole in the ground there lived a hobbit.
             
    981.

  • If two alternatives within the supplied

    let $para := 
    In a hole in the ground there lived a hobbit.
             
    981 both match at the same position in the
    let $para := 
    In a hole in the ground there lived a hobbit.
             
    232 string, then the match that is chosen is the first. For example:

    let $para := 
    In a hole in the ground there lived a hobbit.
             
    6

Error Conditions

A dynamic error is raised [err:FORX0002] if the value of

let $para := 
In a hole in the ground there lived a hobbit.
         
981 is invalid according to the rules described in section 5.6.1 Regular expression syntax.

A dynamic error is raised [err:FORX0001] if the value of

let $para := 
In a hole in the ground there lived a hobbit.
         
923 is invalid according to the rules described in section 5.6.2 Flags.

A dynamic error is raised [err:FORX0003] if the supplied

let $para := 
In a hole in the ground there lived a hobbit.
         
981 matches a zero-length string, that is, if
op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
100 returns
op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
76.

Notes

If the input string is not zero length, and no separators are found in the input string, the result of the function is a single string identical to the input string.

The one-argument form of the function has a similar effect to the two-argument form with

op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
177 as the separator pattern, except that the one-argument 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

op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
18 function can be used instead.

The separator used by the one-argument form of the function is any sequence of tab (x09), newline (x0A), carriage return (x0D) or space (x20) characters. This is the same as the separator recognized by list-valued attributes as defined in XSD. It is not the same as the separator recognized by list-valued attributes in HTML5, which also treats form-feed (x0C) as whitespace. If it is necessary to treat form-feed as a separator, an explicit separator pattern should be used.

Examples

The expression

op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
179 returns
op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
180.

The expression

op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
181 returns
op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
182.

The expression

op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
183 returns
op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
184.

The expression

op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
185 returns
op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
186.

The expression

op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
187 returns
op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
188.

op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
189 raises the dynamic error [err:FORX0003].

The expression

op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
190 returns
op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
191.

5.6.6 fn:analyze-string

Summary

Analyzes a string using a regular expression, returning an XML structure that identifies which parts of the input string matched or failed to match the regular expression, and in the case of matched substrings, which substrings matched each capturing group in the regular expression.

Signatures

op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
18(
let $para := 
In a hole in the ground there lived a hobbit.
         
232
let $para := 
In a hole in the ground there lived a hobbit.
         
71
let $para := 
In a hole in the ground there lived a hobbit.
         
244,
let $para := 
In a hole in the ground there lived a hobbit.
         
981
let $para := 
In a hole in the ground there lived a hobbit.
         
71
let $para := 
In a hole in the ground there lived a hobbit.
         
10)
let $para := 
In a hole in the ground there lived a hobbit.
         
71
op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
200

op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
18(
let $para := 
In a hole in the ground there lived a hobbit.
         
232
let $para := 
In a hole in the ground there lived a hobbit.
         
71
let $para := 
In a hole in the ground there lived a hobbit.
         
244,
let $para := 
In a hole in the ground there lived a hobbit.
         
981
let $para := 
In a hole in the ground there lived a hobbit.
         
71
let $para := 
In a hole in the ground there lived a hobbit.
         
10,
let $para := 
In a hole in the ground there lived a hobbit.
         
923
let $para := 
In a hole in the ground there lived a hobbit.
         
71
let $para := 
In a hole in the ground there lived a hobbit.
         
10)
let $para := 
In a hole in the ground there lived a hobbit.
         
71
op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
200

Properties

This function is ·nondeterministic·, ·context-independent·, and ·focus-independent·.

Rules

The effect of calling the first version of this function (omitting the argument

let $para := 
In a hole in the ground there lived a hobbit.
         
923) is the same as the effect of calling the second version with the
let $para := 
In a hole in the ground there lived a hobbit.
         
923 argument set to a zero-length string. Flags are defined in 5.6.2 Flags.

The

let $para := 
In a hole in the ground there lived a hobbit.
         
923 argument is interpreted in the same way as for the
let $para := 
In a hole in the ground there lived a hobbit.
         
857 function.

If

let $para := 
In a hole in the ground there lived a hobbit.
         
232 is the empty sequence the function behaves as if
let $para := 
In a hole in the ground there lived a hobbit.
         
232 were the zero-length string. In this situation the result will be an element node with no children.

The function returns an element node whose local name is

op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
219. This element and all its descendant elements have the namespace URI
let $para := 
In a hole in the ground there lived a hobbit.
         
37. The namespace prefix is ·implementation-dependent·. The children of this element are a sequence of
op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
221 and
op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
222 elements. This sequence is formed by breaking the
let $para := 
In a hole in the ground there lived a hobbit.
         
232 string into a sequence of strings, returning any substring that matches
let $para := 
In a hole in the ground there lived a hobbit.
         
981 as the content of a
op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
225 element, and any intervening substring as the content of a
op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
226 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 the string. If several alternatives within the regular expression both match at the same position in the input string, then the match that is chosen is the first alternative that matches. For example, if the input string is

op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
227 and the regular expression is
op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
228, then the match that is chosen is
op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
229.

Having found the first match, the instruction proceeds to find the second and subsequent matches by repeating the search, starting at the first ·character· that was not included in the previous match.

The input string is thus partitioned into a sequence of substrings, some of which match the regular expression, others which do not match it. Each substring will contain at least one character. This sequence is represented in the result by the sequence of

op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
221 and
op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
222 children of the returned element node; the string value of the
op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
221 or
op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
222 element will be the corresponding substring of
let $para := 
In a hole in the ground there lived a hobbit.
         
232, and the string value of the returned element node will therefore be the same as
let $para := 
In a hole in the ground there lived a hobbit.
         
232.

The content of an

op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
222 element is always a single text node.

The content of a

op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
221 element, however, is in general a sequence of text nodes and
op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
238 element children. An
op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
238 element with a
op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
240 attribute having the integer value N identifies the substring captured by the Nth parenthesized sub-expression in the regular expression. For each capturing subexpression there will be at most one corresponding
op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
238 element in each
op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
221 element in the result.

If the function is called twice with the same arguments, it is ·implementation-dependent· whether the two calls return the same element node or distinct (but deep equal) element nodes. In this respect it is ·non-deterministic with respect to node identity·.

The base URI of the element nodes in the result is ·implementation-dependent·.

A schema is defined for the structure of the returned element: see C.1 Schema for the result of fn:analyze-string.

The result of the function will always be such that validation against this schema would succeed. However, it is ·implementation-defined· whether the result is typed or untyped, that is, whether the elements and attributes in the returned tree have type annotations that reflect the result of validating against this schema.

Error Conditions

A dynamic error is raised [err:FORX0002] if the value of

let $para := 
In a hole in the ground there lived a hobbit.
         
981 is invalid according to the rules described in section 5.6.1 Regular expression syntax.

A dynamic error is raised [err:FORX0001] if the value of

let $para := 
In a hole in the ground there lived a hobbit.
         
923 is invalid according to the rules described in section 5.6.2 Flags.

A dynamic error is raised [err:FORX0003] if the supplied

let $para := 
In a hole in the ground there lived a hobbit.
         
981 matches a zero-length string, that is, if
op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
100 returns
op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
76.

Notes

It is recommended that a processor that implements schema awareness should return typed nodes. 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

op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
18 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,

op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
219, in such a way that mixed content is permitted. In fact the element will only have element nodes (
op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
225 and
op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
226) as its children, never text nodes. Although this might have originally been an oversight, defining the
op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
219 element with
op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
253 allows it to be atomized, which is potentially useful (the atomized value will be the original input string), and the capability has therefore been retained for compatibility with the 3.0 version of this specification.

Examples

In the following examples, the result document is shown in serialized form, with whitespace between the element nodes. This whitespace is not actually present in the result.

The expression

op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
254 returns (with whitespace added for legibility):

let $para := 
In a hole in the ground there lived a hobbit.
         
7

The expression

op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
255 returns (with whitespace added for legibility):

let $para := 
In a hole in the ground there lived a hobbit.
         
8

The expression

op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
256 returns (with whitespace added for legibility):

let $para := 
In a hole in the ground there lived a hobbit.
         
9

6 Functions that manipulate URIs

This section specifies functions that manipulate URI values, either as instances of

let $para := 
In a hole in the ground there lived a hobbit.
         
30 or as strings.

FunctionMeaning
op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
258Resolves a relative IRI reference against an absolute IRI.
op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
259Encodes reserved characters in a string that is intended to be used in the path segment of a URI.
op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
260Converts a string containing an IRI into a URI according to the rules of [RFC 3987].
op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
261Escapes a URI in the same way that HTML user agents handle attribute values expected to contain URIs.

6.1 fn:resolve-uri

Summary

Resolves a relative IRI reference against an absolute IRI.

Signatures

op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
258(
op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
263
let $para := 
In a hole in the ground there lived a hobbit.
         
71
let $para := 
In a hole in the ground there lived a hobbit.
         
244)
let $para := 
In a hole in the ground there lived a hobbit.
         
71
op:operation(fenceHeight, xs:integer) => op:operation(xs:integer, xs:integer)
44

op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
258(
op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
263
let $para := 
In a hole in the ground there lived a hobbit.
         
71
let $para := 
In a hole in the ground there lived a hobbit.
         
244,
op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
272
let $para := 
In a hole in the ground there lived a hobbit.
         
71
let $para := 
In a hole in the ground there lived a hobbit.
         
10)
let $para := 
In a hole in the ground there lived a hobbit.
         
71
op:operation(fenceHeight, xs:integer) => op:operation(xs:integer, xs:integer)
44

Properties

The one-argument form of this function is ·deterministic·, ·context-dependent·, and ·focus-independent·. It depends on static base URI.

The two-argument form of this function is ·deterministic·, ·context-independent·, and ·focus-independent·.

Rules

The function is defined to operate on IRI references as defined in [RFC 3987], and the implementation must permit all arguments that are valid according to that specification. In addition, the implementation may accept some or all strings that conform to the rules for (absolute or relative) Legacy Extended IRI references as defined in [Legacy extended IRIs for XML resource identification]. For the purposes of this section, the terms IRI and IRI reference include these extensions, insofar as the implementation chooses to support them.

The following rules apply in order:

  1. If

    op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
    263 is the empty sequence, the function returns the empty sequence.

  2. If

    op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
    263 is an absolute IRI (as defined above), then it is returned unchanged.

  3. If the

    op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
    272 argument is not supplied, then:

    1. If the static base URI in the static context is not absent, it is used as the effective value of

      op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
      272.

    2. Otherwise, a dynamic error is raised: [err:FONS0005].

  4. The function resolves the relative IRI reference

    op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
    263 against the base IRI
    op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
    272 using the algorithm defined in [RFC 3986], adapted by treating any ·character· that would not be valid in an RFC3986 URI or relative reference in the same way that RFC3986 treats unreserved characters. No percent-encoding takes place.

Error Conditions

The first form of this function resolves

op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
263 against the value of the base-uri property from the static context. A dynamic error is raised [err:FONS0005] if the base-uri property is not initialized in the static context.

A dynamic error is raised [err:FORG0002] if

op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
263 is not a valid IRI according to the rules of RFC3987, extended with an implementation-defined subset of the extensions permitted in LEIRI, or if it is not a suitable relative reference to use as input to the RFC3986 resolution algorithm extended to handle additional unreserved characters.

A dynamic error is raised [err:FORG0002] if

op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
272 is not a valid IRI according to the rules of RFC3987, extended with an implementation-defined subset of the extensions permitted in LEIRI, or if it is not a suitable IRI to use as input to the chosen resolution algorithm (for example, if it is a relative IRI reference, if it is a non-hierarchic URI, or if it contains a fragment identifier).

A dynamic error is raised [err:FORG0009] if the chosen resolution algorithm fails for any other reason.

Notes

Resolving a URI does not dereference it. This is merely a syntactic operation on two ·strings·.

The algorithms in the cited RFCs include some variations that are optional or recommended rather than mandatory; they also describe some common practices that are not recommended, but which are permitted for backwards compatibility. Where the cited RFCs permit variations in behavior, so does this specification.

Throughout this family of specifications, the phrase "resolving a relative URI (or IRI) reference" should be understood as using the rules of this function, unless otherwise stated.

RFC3986 defines an algorithm for resolving relative references in the context of the URI syntax defined in that RFC. RFC3987 describes a modification to that algorithm to make it applicable to IRIs (specifically: additional characters permitted in an IRI are handled the same way that RFC3986 handles unreserved characters). The LEIRI specification does not explicitly define a resolution algorithm, but suggests that it should not be done by converting the LEIRI to a URI, and should not involve percent-encoding. This specification fills this gap by defining resolution for LEIRIs in the same way that RFC3987 defines resolution for IRIs, that is by specifying that additional characters are handled as unreserved characters.

6.2 fn:encode-for-uri

Summary

Encodes reserved characters in a string that is intended to be used in the path segment of a URI.

Signature

op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
259(
op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
287
let $para := 
In a hole in the ground there lived a hobbit.
         
71
let $para := 
In a hole in the ground there lived a hobbit.
         
244)
let $para := 
In a hole in the ground there lived a hobbit.
         
71
let $para := 
In a hole in the ground there lived a hobbit.
         
10

Properties

This function is ·deterministic·, ·context-independent·, and ·focus-independent·.

Rules

If

op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
287 is the empty sequence, the function returns the zero-length string.

This function applies the URI escaping rules defined in section 2 of [RFC 3986] to the

let $para := 
In a hole in the ground there lived a hobbit.
         
10 supplied as
op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
287. The effect of the function is to escape reserved characters. Each such character in the string is replaced with its percent-encoded form as described in [RFC 3986].

Since [RFC 3986] recommends that, for consistency, URI producers and normalizers should use uppercase hexadecimal digits for all percent-encodings, this function must always generate hexadecimal values using the upper-case letters A-F.

Notes

All characters are escaped except those identified as "unreserved" by [RFC 3986], that is the upper- and lower-case letters A-Z, the digits 0-9, HYPHEN-MINUS ("-"), LOW LINE ("_"), FULL STOP ".", and TILDE "~".

This function escapes URI delimiters and therefore cannot be used indiscriminately to encode "invalid" characters in a path segment.

This function is invertible but not idempotent. This is because a string containing a percent character will be modified by applying the function: for example

op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
295 becomes
op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
296, while
op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
296 becomes
op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
298.

Examples

The expression

op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
299 returns
op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
300. (This is probably not what the user intended because all of the delimiters have been encoded.)

The expression

op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
301 returns
op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
302.

The expression

op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
303 returns
op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
304.

6.3 fn:iri-to-uri

Summary

Converts a string containing an IRI into a URI according to the rules of [RFC 3987].

Signature

op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
260(
op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
306
let $para := 
In a hole in the ground there lived a hobbit.
         
71
let $para := 
In a hole in the ground there lived a hobbit.
         
244)
let $para := 
In a hole in the ground there lived a hobbit.
         
71
let $para := 
In a hole in the ground there lived a hobbit.
         
10

Properties

This function is ·deterministic·, ·context-independent·, and ·focus-independent·.

Rules

If

op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
306 is the empty sequence, the function returns the zero-length string.

Otherwise, the function converts the value of

op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
306 into a URI according to the rules given in Section 3.1 of [RFC 3987] by percent-encoding characters that are allowed in an IRI but not in a URI. If
op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
306 contains a character that is invalid in an IRI, such as the space character (see note below), the invalid character is replaced by its percent-encoded form as described in [RFC 3986] before the conversion is performed.

Since [RFC 3986] recommends that, for consistency, URI producers and normalizers should use uppercase hexadecimal digits for all percent-encodings, this function must always generate hexadecimal values using the upper-case letters A-F.

Notes

The function is idempotent but not invertible. Both the inputs

op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
314 and
op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
315 will be converted to the output
op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
315.

This function does not check whether

op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
306 is a valid IRI. It treats it as an ·string· and operates on the ·characters· in the string.

The following printable ASCII characters are invalid in an IRI: "<", ">", " " " (double quote), space, "{", "}", "|", "\", "^", and "`". Since these characters should not appear in an IRI, if they do appear in

op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
306 they will be percent-encoded. In addition, characters outside the range x20-x7E will be percent-encoded because they are invalid in a URI.

Since this function does not escape the PERCENT SIGN "%" and this character is not allowed in data within a URI, users wishing to convert character strings (such as file names) that include "%" to a URI should manually escape "%" by replacing it with "%25".

Examples

The expression

op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
319 returns
op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
320.

The expression

op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
321 returns
op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
302.

6.4 fn:escape-html-uri

Summary

Escapes a URI in the same way that HTML user agents handle attribute values expected to contain URIs.

Signature

op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
261(
op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
324
let $para := 
In a hole in the ground there lived a hobbit.
         
71
let $para := 
In a hole in the ground there lived a hobbit.
         
244)
let $para := 
In a hole in the ground there lived a hobbit.
         
71
let $para := 
In a hole in the ground there lived a hobbit.
         
10

Properties

This function is ·deterministic·, ·context-independent·, and ·focus-independent·.

Rules

If

op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
324 is the empty sequence, the function returns the zero-length string.

Otherwise, the function escapes all ·characters· except printable characters of the US-ASCII coded character set, specifically the ·codepoints· between 32 and 126 (decimal) inclusive. Each character in

op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
324 to be escaped is replaced by an escape sequence, which is formed by encoding the character as a sequence of octets in UTF-8, and then representing each of these octets in the form %HH, where HH is the hexadecimal representation of the octet. This function must always generate hexadecimal values using the upper-case letters A-F.

Notes

The behavior of this function corresponds to the recommended handling of non-ASCII characters in URI attribute values as described in [HTML 4.0] Appendix B.2.1.

Examples

The expression

op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
331 returns
op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
332.

The expression

op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
333 returns
op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
334.

7 Functions and operators on Boolean values

This section defines functions and operators on the

op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
32 datatype.

7.1 Boolean constant functions

Since no literals are defined in XPath to reference the constant boolean values true and false, two functions are provided for the purpose.

FunctionMeaning
op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
336Returns the
op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
32 value
op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
76.
op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
339Returns the
op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
32 value
let $C := 'http://www.w3.org/2013/collation/UCA?strength=primary'
07.

7.1.1 fn:true

Summary

Returns the

op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
32 value
op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
76.

Signature

op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
336()
let $para := 
In a hole in the ground there lived a hobbit.
         
71
op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
32

Properties

This function is ·deterministic·, ·context-independent·, and ·focus-independent·.

Rules

The result is equivalent to

op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
347.

Examples

The expression

op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
348 returns
op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
349.

7.1.2 fn:false

Summary

Returns the

op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
32 value
let $C := 'http://www.w3.org/2013/collation/UCA?strength=primary'
07.

Signature

op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
339()
let $para := 
In a hole in the ground there lived a hobbit.
         
71
op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
32

Properties

This function is ·deterministic·, ·context-independent·, and ·focus-independent·.

Rules

The result is equivalent to

op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
355.

Examples

The expression

op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
356 returns
op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
357.

7.2 Operators on Boolean values

The following functions define the semantics of operators on boolean values in [XQuery 3.1: An XML Query Language] and [XML Path Language (XPath) 3.1]:

FunctionMeaning
op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
358Returns
op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
76 if the two arguments are the same boolean value.
op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
360Returns true if the first argument is false and the second is true.
op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
361Returns true if the first argument is true and the second is false.

The ordering operators

op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
360 and
op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
361 are provided for application purposes and for compatibility with [XML Path Language (XPath) Version 1.0]. The [XML Schema Part 2: Datatypes Second Edition] datatype
op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
32 is not ordered.

7.2.1 op:boolean-equal

Summary

Returns

op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
76 if the two arguments are the same boolean value.

Operator Mapping

Defines the semantics of the "eq" operator when applied to two

op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
32 values.

Signature

op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
358(
op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
368
let $para := 
In a hole in the ground there lived a hobbit.
         
71
op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
32,
op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
371
let $para := 
In a hole in the ground there lived a hobbit.
         
71
op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
32)
let $para := 
In a hole in the ground there lived a hobbit.
         
71
op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
32

Rules

The function returns

op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
76 if both arguments are
op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
76 or if both arguments are
let $C := 'http://www.w3.org/2013/collation/UCA?strength=primary'
07. It returns
let $C := 'http://www.w3.org/2013/collation/UCA?strength=primary'
07 if one of the arguments is
op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
76 and the other argument is
let $C := 'http://www.w3.org/2013/collation/UCA?strength=primary'
07.

7.2.2 op:boolean-less-than

Summary

Returns true if the first argument is false and the second is true.

Operator Mapping

Defines the semantics of the "lt" operator when applied to two

op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
32 values. Also used in the definition of the "ge" operator.

Signature

op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
360(
let $para := 
In a hole in the ground there lived a hobbit.
         
70
let $para := 
In a hole in the ground there lived a hobbit.
         
71
op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
32,
let $para := 
In a hole in the ground there lived a hobbit.
         
73
let $para := 
In a hole in the ground there lived a hobbit.
         
71
op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
32)
let $para := 
In a hole in the ground there lived a hobbit.
         
71
op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
32

Rules

The function returns

op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
76 if
let $para := 
In a hole in the ground there lived a hobbit.
         
70 is
let $C := 'http://www.w3.org/2013/collation/UCA?strength=primary'
07 and
let $para := 
In a hole in the ground there lived a hobbit.
         
73 is
op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
76. Otherwise, it returns
let $C := 'http://www.w3.org/2013/collation/UCA?strength=primary'
07.

7.2.3 op:boolean-greater-than

Summary

Returns true if the first argument is true and the second is false.

Operator Mapping

Defines the semantics of the "gt" operator when applied to two

op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
32 values. Also used in the definition of the "le" operator.

Signature

op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
361(
let $para := 
In a hole in the ground there lived a hobbit.
         
70
let $para := 
In a hole in the ground there lived a hobbit.
         
71
op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
32,
let $para := 
In a hole in the ground there lived a hobbit.
         
73
let $para := 
In a hole in the ground there lived a hobbit.
         
71
op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
32)
let $para := 
In a hole in the ground there lived a hobbit.
         
71
op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
32

Rules

The function call

op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
408 is defined to return the same result as
op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
409

7.3 Functions on Boolean values

The following functions are defined on boolean values:

FunctionMeaning
op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
410Computes the effective boolean value of the sequence
let $para := 
In a hole in the ground there lived a hobbit.
         
25.
op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
412Returns
op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
76 if the effective boolean value of
let $para := 
In a hole in the ground there lived a hobbit.
         
25 is
let $C := 'http://www.w3.org/2013/collation/UCA?strength=primary'
07, or
let $C := 'http://www.w3.org/2013/collation/UCA?strength=primary'
07 if it is
op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
76.

7.3.1 fn:boolean

Summary

Computes the effective boolean value of the sequence

let $para := 
In a hole in the ground there lived a hobbit.
         
25.

Signature

op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
410(
let $para := 
In a hole in the ground there lived a hobbit.
         
25
let $para := 
In a hole in the ground there lived a hobbit.
         
71
op:operation(fenceHeight, xs:integer) => op:operation(xs:integer, xs:integer)
16)
let $para := 
In a hole in the ground there lived a hobbit.
         
71
op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
32

Rules

The function computes the effective boolean value of a sequence, defined according to the following rules. See also Section 2.4.3 Effective Boolean Value XP31.

  • If

    let $para := 
    In a hole in the ground there lived a hobbit.
             
    25 is the empty sequence,
    op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
    410 returns
    let $C := 'http://www.w3.org/2013/collation/UCA?strength=primary'
    07.

  • If

    let $para := 
    In a hole in the ground there lived a hobbit.
             
    25 is a sequence whose first item is a node,
    op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
    410 returns
    op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
    76.

  • If

    let $para := 
    In a hole in the ground there lived a hobbit.
             
    25 is a singleton value of type
    op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
    32 or a derived from
    op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
    32,
    op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
    410 returns
    let $para := 
    In a hole in the ground there lived a hobbit.
             
    25.

  • If

    let $para := 
    In a hole in the ground there lived a hobbit.
             
    25 is a singleton value of type
    let $para := 
    In a hole in the ground there lived a hobbit.
             
    10 or a type derived from
    let $para := 
    In a hole in the ground there lived a hobbit.
             
    10,
    let $para := 
    In a hole in the ground there lived a hobbit.
             
    30 or a type derived from
    let $para := 
    In a hole in the ground there lived a hobbit.
             
    30, or
    let $para := 
    In a hole in the ground there lived a hobbit.
             
    00,
    op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
    410 returns
    let $C := 'http://www.w3.org/2013/collation/UCA?strength=primary'
    07 if the operand value has zero length; otherwise it returns
    op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
    76.

  • If

    let $para := 
    In a hole in the ground there lived a hobbit.
             
    25 is a singleton value of any numeric type or a type derived from a numeric type,
    op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
    410 returns
    let $C := 'http://www.w3.org/2013/collation/UCA?strength=primary'
    07 if the operand value is
    fn:abs($N * $arg2) le fn:abs($arg1) 
                   and fn:compare($N * $arg2, 0) eq fn:compare($arg1, 0).
    90 or is numerically equal to zero; otherwise it returns
    op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
    76.

Error Conditions

In all cases other than those listed above,

op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
410 raises a type error [err:FORG0006].

Notes

The result of this function is not necessarily the same as

op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
451. For example,
op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
452 returns the value
op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
76 whereas
op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
454 (which can also be written
op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
455) returns
let $C := 'http://www.w3.org/2013/collation/UCA?strength=primary'
07.

Examples

let $para := 
In a hole in the ground there lived a hobbit.
         
0

op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
457 raises a type error [err:FORG0006].

The expression

op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
458 returns
let $para := 
In a hole in the ground there lived a hobbit.
         
182.

The expression

op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
460 returns
let $para := 
In a hole in the ground there lived a hobbit.
         
184.

The expression

op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
462 returns
let $para := 
In a hole in the ground there lived a hobbit.
         
184.

op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
464 raises a type error [err:FORG0006].

7.3.2 fn:not

Summary

Returns

op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
76 if the effective boolean value of
let $para := 
In a hole in the ground there lived a hobbit.
         
25 is
let $C := 'http://www.w3.org/2013/collation/UCA?strength=primary'
07, or
let $C := 'http://www.w3.org/2013/collation/UCA?strength=primary'
07 if it is
op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
76.

Signature

op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
412(
let $para := 
In a hole in the ground there lived a hobbit.
         
25
let $para := 
In a hole in the ground there lived a hobbit.
         
71
op:operation(fenceHeight, xs:integer) => op:operation(xs:integer, xs:integer)
16)
let $para := 
In a hole in the ground there lived a hobbit.
         
71
op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
32

Properties

This function is ·deterministic·, ·context-independent·, and ·focus-independent·.

Rules

The value of

let $para := 
In a hole in the ground there lived a hobbit.
         
25 is first reduced to an effective boolean value by applying the
op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
477 function. The function returns
op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
76 if the effective boolean value is
let $C := 'http://www.w3.org/2013/collation/UCA?strength=primary'
07, or
let $C := 'http://www.w3.org/2013/collation/UCA?strength=primary'
07 if the effective boolean value is
op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
76.

Examples

The expression

op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
482 returns
let $para := 
In a hole in the ground there lived a hobbit.
         
184.

The expression

op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
484 returns
let $para := 
In a hole in the ground there lived a hobbit.
         
182.

The expression

op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
486 returns
let $para := 
In a hole in the ground there lived a hobbit.
         
184.

op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
488 raises a type error [err:FORG0006].

8 Functions and operators on durations

Operators are defined on the following type:

  • xs:duration

and on the two defined subtypes (see 8.1 Two totally ordered subtypes of duration):

  • xs:yearMonthDuration

  • xs:dayTimeDuration

No ordering relation is defined on

op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
489 values. Two
op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
489 values may however be compared for equality.

Operations on durations (including equality comparison, casting to string, and extraction of components) all treat the duration as normalized. This means that the seconds and minutes components will always be less than 60, the hours component less than 24, and the months component less than 12. Thus, for example, a duration of 120 seconds always gives the same result as a duration of two minutes.

Conditions such as underflow and overflow may occur with arithmetic on durations: see 9.7.1 Limits and precision

Note:

This means that in practice, the information content of an

op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
489 value can be reduced to an
let $para := 
In a hole in the ground there lived a hobbit.
         
85 number of months, and an
let $para := 
In a hole in the ground there lived a hobbit.
         
82 number of seconds. For the two defined subtypes this is further simplified so that one of these two components is fixed at zero. Operations such as comparison of durations and arithmetic on durations can be expressed in terms of numeric operations applied to these two components.

8.1 Two totally ordered subtypes of duration

Two subtypes of

op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
489, namely
let $para := 
In a hole in the ground there lived a hobbit.
         
24 and
let $para := 
In a hole in the ground there lived a hobbit.
         
25, are defined in [Schema 1.1 Part 2]. These types must be available in the data model whether or not the implementation supports other aspects of XSD 1.1.

The significance of these subtypes is that arithmetic and ordering become well defined; this is not the case for

op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
489 values in general, because of the variable number of days in a month. For this reason, many of the functions and operators on durations require the arguments/operands to belong to these two subtypes.

8.2 Comparison operators on durations

FunctionMeaning
op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
498Returns true if
let $para := 
In a hole in the ground there lived a hobbit.
         
70 is a shorter duration than
let $para := 
In a hole in the ground there lived a hobbit.
         
73.
op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
501Returns true if
let $para := 
In a hole in the ground there lived a hobbit.
         
70 is a longer duration than
let $para := 
In a hole in the ground there lived a hobbit.
         
73.
op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
504Returns true if
let $para := 
In a hole in the ground there lived a hobbit.
         
70 is a shorter duration than
let $para := 
In a hole in the ground there lived a hobbit.
         
73.
op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
507Returns true if
let $para := 
In a hole in the ground there lived a hobbit.
         
70 is a longer duration than
let $para := 
In a hole in the ground there lived a hobbit.
         
73.
op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
510Returns true if
let $para := 
In a hole in the ground there lived a hobbit.
         
70 and
let $para := 
In a hole in the ground there lived a hobbit.
         
73 are durations of the same length.

The following comparison operators are defined on the [XML Schema Part 2: Datatypes Second Edition] duration datatypes. Each operator takes two operands of the same type and returns an

op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
32 result. As discussed in [XML Schema Part 2: Datatypes Second Edition], the order relation on
op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
489 is a partial order rather than a total order. For this reason, only equality is defined on
op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
489. A full complement of comparison and arithmetic functions are defined on the two subtypes of duration described in 8.1 Two totally ordered subtypes of duration which do have a total order.

8.2.1 op:yearMonthDuration-less-than

Summary

Returns true if

let $para := 
In a hole in the ground there lived a hobbit.
         
70 is a shorter duration than
let $para := 
In a hole in the ground there lived a hobbit.
         
73.

Operator Mapping

Defines the semantics of the "lt" operator when applied to two

let $para := 
In a hole in the ground there lived a hobbit.
         
24 values. Also used in the definition of the "ge" operator.

Signature

op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
498(
let $para := 
In a hole in the ground there lived a hobbit.
         
70
let $para := 
In a hole in the ground there lived a hobbit.
         
71
let $para := 
In a hole in the ground there lived a hobbit.
         
24,
let $para := 
In a hole in the ground there lived a hobbit.
         
73
let $para := 
In a hole in the ground there lived a hobbit.
         
71
let $para := 
In a hole in the ground there lived a hobbit.
         
24)
let $para := 
In a hole in the ground there lived a hobbit.
         
71
op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
32

Rules

If the number of months in the value of

let $para := 
In a hole in the ground there lived a hobbit.
         
70 is numerically less than the number of months in the value of
let $para := 
In a hole in the ground there lived a hobbit.
         
73, the function returns true.

Otherwise, the function returns false.

Notes

Either or both durations may be negative.

8.2.2 op:yearMonthDuration-greater-than

Summary

Returns true if

let $para := 
In a hole in the ground there lived a hobbit.
         
70 is a longer duration than
let $para := 
In a hole in the ground there lived a hobbit.
         
73.

Operator Mapping

Defines the semantics of the "gt" operator when applied to two

let $para := 
In a hole in the ground there lived a hobbit.
         
24 values. Also used in the definition of the "le" operator.

Signature

op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
501(
let $para := 
In a hole in the ground there lived a hobbit.
         
70
let $para := 
In a hole in the ground there lived a hobbit.
         
71
let $para := 
In a hole in the ground there lived a hobbit.
         
24,
let $para := 
In a hole in the ground there lived a hobbit.
         
73
let $para := 
In a hole in the ground there lived a hobbit.
         
71
let $para := 
In a hole in the ground there lived a hobbit.
         
24)
let $para := 
In a hole in the ground there lived a hobbit.
         
71
op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
32

Rules

The function call

op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
542 is defined to return the same result as
op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
543

8.2.3 op:dayTimeDuration-less-than

Summary

Returns true if

let $para := 
In a hole in the ground there lived a hobbit.
         
70 is a shorter duration than
let $para := 
In a hole in the ground there lived a hobbit.
         
73.

Operator Mapping

Defines the semantics of the "lt" operator when applied to two

let $para := 
In a hole in the ground there lived a hobbit.
         
25 values. Also used in the definition of the "ge" operator.

Signature

op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
504(
let $para := 
In a hole in the ground there lived a hobbit.
         
70
let $para := 
In a hole in the ground there lived a hobbit.
         
71
let $para := 
In a hole in the ground there lived a hobbit.
         
25,
let $para := 
In a hole in the ground there lived a hobbit.
         
73
let $para := 
In a hole in the ground there lived a hobbit.
         
71
let $para := 
In a hole in the ground there lived a hobbit.
         
25)
let $para := 
In a hole in the ground there lived a hobbit.
         
71
op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
32

Rules

If the number of seconds in the value of

let $para := 
In a hole in the ground there lived a hobbit.
         
70 is numerically less than the number of seconds in the value of
let $para := 
In a hole in the ground there lived a hobbit.
         
73, the function returns true.

Otherwise, the function returns false.

Notes

Either or both durations may be negative

8.2.4 op:dayTimeDuration-greater-than

Summary

Returns true if

let $para := 
In a hole in the ground there lived a hobbit.
         
70 is a longer duration than
let $para := 
In a hole in the ground there lived a hobbit.
         
73.

Operator Mapping

Defines the semantics of the "gt" operator when applied to two

let $para := 
In a hole in the ground there lived a hobbit.
         
25 values. Also used in the definition of the "le" operator.

Signature

op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
507(
let $para := 
In a hole in the ground there lived a hobbit.
         
70
let $para := 
In a hole in the ground there lived a hobbit.
         
71
let $para := 
In a hole in the ground there lived a hobbit.
         
25,
let $para := 
In a hole in the ground there lived a hobbit.
         
73
let $para := 
In a hole in the ground there lived a hobbit.
         
71
let $para := 
In a hole in the ground there lived a hobbit.
         
25)
let $para := 
In a hole in the ground there lived a hobbit.
         
71
op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
32

Rules

The function call

op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
570 is defined to return the same result as
op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
571

8.2.5 op:duration-equal

Summary

Returns true if

let $para := 
In a hole in the ground there lived a hobbit.
         
70 and
let $para := 
In a hole in the ground there lived a hobbit.
         
73 are durations of the same length.

Operator Mapping

Defines the semantics of the "eq" operators when applied to two

op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
489 values. Also used in the definition of the "ne" operator.

Signature

op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
510(
let $para := 
In a hole in the ground there lived a hobbit.
         
70
let $para := 
In a hole in the ground there lived a hobbit.
         
71
op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
489,
let $para := 
In a hole in the ground there lived a hobbit.
         
73
let $para := 
In a hole in the ground there lived a hobbit.
         
71
op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
489)
let $para := 
In a hole in the ground there lived a hobbit.
         
71
op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
32

Rules

If the

let $para := 
In a hole in the ground there lived a hobbit.
         
24 components of
let $para := 
In a hole in the ground there lived a hobbit.
         
70 and
let $para := 
In a hole in the ground there lived a hobbit.
         
73 are equal and the
let $para := 
In a hole in the ground there lived a hobbit.
         
25 components of
let $para := 
In a hole in the ground there lived a hobbit.
         
70 and
let $para := 
In a hole in the ground there lived a hobbit.
         
73 are equal, the function returns
op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
76.

Otherwise, the function returns false.

The semantics of this function are:

let $para := 
In a hole in the ground there lived a hobbit.
         
1

that is, the function returns

op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
76 if the months and seconds values of the two durations are equal.

Notes

Note that this function, like any other, may be applied to arguments that are derived from the types given in the function signature, including the two subtypes

let $para := 
In a hole in the ground there lived a hobbit.
         
25 and
let $para := 
In a hole in the ground there lived a hobbit.
         
24. With the exception of the zero-length duration, no instance of
let $para := 
In a hole in the ground there lived a hobbit.
         
25 can ever be equal to an instance of
let $para := 
In a hole in the ground there lived a hobbit.
         
24.

Examples

The expression

op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
596 returns
let $para := 
In a hole in the ground there lived a hobbit.
         
182.

The expression

op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
598 returns
let $para := 
In a hole in the ground there lived a hobbit.
         
182.

The expression

op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
600 returns
let $para := 
In a hole in the ground there lived a hobbit.
         
184.

The expression

op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
602 returns
let $para := 
In a hole in the ground there lived a hobbit.
         
182.

The expression

op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
604 returns
let $para := 
In a hole in the ground there lived a hobbit.
         
184.

The expression

op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
606 returns
let $para := 
In a hole in the ground there lived a hobbit.
         
182.

The expression

op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
608 returns
let $para := 
In a hole in the ground there lived a hobbit.
         
182.

The expression

op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
610 returns
let $para := 
In a hole in the ground there lived a hobbit.
         
182.

The expression

op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
612 returns
let $para := 
In a hole in the ground there lived a hobbit.
         
182.

8.3 Component extraction functions on durations

The duration datatype may be considered to be a composite datatypes in that it contains distinct properties or components. The extraction functions specified below extract a single component from a duration value. For

op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
489 and its subtypes, including the two subtypes
let $para := 
In a hole in the ground there lived a hobbit.
         
24 and
let $para := 
In a hole in the ground there lived a hobbit.
         
25, the components are normalized: this means that the seconds and minutes components will always be less than 60, the hours component less than 24, and the months component less than 12.

FunctionMeaning
op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
617Returns the number of years in a duration.
op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
618Returns the number of months in a duration.
op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
619Returns the number of days in a duration.
op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
620Returns the number of hours in a duration.
op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
621Returns the number of minutes in a duration.
op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
622Returns the number of seconds in a duration.

8.3.1 fn:years-from-duration

Summary

Returns the number of years in a duration.

Signature

op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
617(
let $para := 
In a hole in the ground there lived a hobbit.
         
25
let $para := 
In a hole in the ground there lived a hobbit.
         
71
op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
626)
let $para := 
In a hole in the ground there lived a hobbit.
         
71
let $para := 
In a hole in the ground there lived a hobbit.
         
229

Properties

This function is ·deterministic·, ·context-independent·, and ·focus-independent·.

Rules

If

let $para := 
In a hole in the ground there lived a hobbit.
         
25 is the empty sequence, the function returns the empty sequence.

Otherwise, the function returns an

let $para := 
In a hole in the ground there lived a hobbit.
         
85 representing the years component in the value of
let $para := 
In a hole in the ground there lived a hobbit.
         
25. Given that a duration is a
op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
632 tuple, the result is the value of
op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
633
.

If

let $para := 
In a hole in the ground there lived a hobbit.
         
25 is a negative duration then the result will be negative.

If

let $para := 
In a hole in the ground there lived a hobbit.
         
25 is an
let $para := 
In a hole in the ground there lived a hobbit.
         
25 the function returns 0.

Examples

The expression

op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
637 returns
op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
638.

The expression

op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
639 returns
declare %public function r:random-sequence($length as xs:integer) as xs:double* {
  r:random-sequence($length, fn:random-number-generator())
};

declare %private function r:random-sequence($length as xs:integer, 
                                            $G as map(xs:string, item())) {
  if ($length eq 0)
  then ()
  else ($G?number, r:random-sequence($length - 1, $G?next()))
};

r:random-sequence(200);
            
09.

The expression

op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
641 returns
declare %public function r:random-sequence($length as xs:integer) as xs:double* {
  r:random-sequence($length, fn:random-number-generator())
};

declare %private function r:random-sequence($length as xs:integer, 
                                            $G as map(xs:string, item())) {
  if ($length eq 0)
  then ()
  else ($G?number, r:random-sequence($length - 1, $G?next()))
};

r:random-sequence(200);
            
19.

8.3.2 fn:months-from-duration

Summary

Returns the number of months in a duration.

Signature

op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
618(
let $para := 
In a hole in the ground there lived a hobbit.
         
25
let $para := 
In a hole in the ground there lived a hobbit.
         
71
op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
626)
let $para := 
In a hole in the ground there lived a hobbit.
         
71
let $para := 
In a hole in the ground there lived a hobbit.
         
229

Properties

This function is ·deterministic·, ·context-independent·, and ·focus-independent·.

Rules

If

let $para := 
In a hole in the ground there lived a hobbit.
         
25 is the empty sequence, the function returns the empty sequence.

Otherwise, the function returns an

let $para := 
In a hole in the ground there lived a hobbit.
         
85 representing the months component in the value of
let $para := 
In a hole in the ground there lived a hobbit.
         
25. Given that a duration is a
op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
632 tuple, the result is the value of
op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
653
.

If

let $para := 
In a hole in the ground there lived a hobbit.
         
25 is a negative duration then the result will be negative.

If

let $para := 
In a hole in the ground there lived a hobbit.
         
25 is an
let $para := 
In a hole in the ground there lived a hobbit.
         
25 the function returns 0.

Examples

The expression

op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
657 returns
declare %public function r:random-sequence($length as xs:integer) as xs:double* {
  r:random-sequence($length, fn:random-number-generator())
};

declare %private function r:random-sequence($length as xs:integer, 
                                            $G as map(xs:string, item())) {
  if ($length eq 0)
  then ()
  else ($G?number, r:random-sequence($length - 1, $G?next()))
};

r:random-sequence(200);
            
07.

The expression

op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
659 returns
op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
660.

The expression

op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
661 returns
declare %public function r:random-sequence($length as xs:integer) as xs:double* {
  r:random-sequence($length, fn:random-number-generator())
};

declare %private function r:random-sequence($length as xs:integer, 
                                            $G as map(xs:string, item())) {
  if ($length eq 0)
  then ()
  else ($G?number, r:random-sequence($length - 1, $G?next()))
};

r:random-sequence(200);
            
19.

8.3.3 fn:days-from-duration

Summary

Returns the number of days in a duration.

Signature

op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
619(
let $para := 
In a hole in the ground there lived a hobbit.
         
25
let $para := 
In a hole in the ground there lived a hobbit.
         
71
op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
626)
let $para := 
In a hole in the ground there lived a hobbit.
         
71
let $para := 
In a hole in the ground there lived a hobbit.
         
229

Properties

This function is ·deterministic·, ·context-independent·, and ·focus-independent·.

Rules

If

let $para := 
In a hole in the ground there lived a hobbit.
         
25 is the empty sequence, the function returns the empty sequence.

Otherwise, the function returns an

let $para := 
In a hole in the ground there lived a hobbit.
         
85 representing the days component in the value of
let $para := 
In a hole in the ground there lived a hobbit.
         
25. Given that a duration is a
op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
632 tuple, the result is the value of
op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
673
.

If

let $para := 
In a hole in the ground there lived a hobbit.
         
25 is a negative duration then the result will be negative.

If

let $para := 
In a hole in the ground there lived a hobbit.
         
25 is an
let $para := 
In a hole in the ground there lived a hobbit.
         
24 the function returns 0.

Examples

The expression

op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
677 returns
declare %public function r:random-sequence($length as xs:integer) as xs:double* {
  r:random-sequence($length, fn:random-number-generator())
};

declare %private function r:random-sequence($length as xs:integer, 
                                            $G as map(xs:string, item())) {
  if ($length eq 0)
  then ()
  else ($G?number, r:random-sequence($length - 1, $G?next()))
};

r:random-sequence(200);
            
07.

The expression

op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
679 returns
declare %public function r:random-sequence($length as xs:integer) as xs:double* {
  r:random-sequence($length, fn:random-number-generator())
};

declare %private function r:random-sequence($length as xs:integer, 
                                            $G as map(xs:string, item())) {
  if ($length eq 0)
  then ()
  else ($G?number, r:random-sequence($length - 1, $G?next()))
};

r:random-sequence(200);
            
21.

The expression

op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
681 returns
declare %public function r:random-sequence($length as xs:integer) as xs:double* {
  r:random-sequence($length, fn:random-number-generator())
};

declare %private function r:random-sequence($length as xs:integer, 
                                            $G as map(xs:string, item())) {
  if ($length eq 0)
  then ()
  else ($G?number, r:random-sequence($length - 1, $G?next()))
};

r:random-sequence(200);
            
19.

8.3.4 fn:hours-from-duration

Summary

Returns the number of hours in a duration.

Signature

op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
620(
let $para := 
In a hole in the ground there lived a hobbit.
         
25
let $para := 
In a hole in the ground there lived a hobbit.
         
71
op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
626)
let $para := 
In a hole in the ground there lived a hobbit.
         
71
let $para := 
In a hole in the ground there lived a hobbit.
         
229

Properties

This function is ·deterministic·, ·context-independent·, and ·focus-independent·.

Rules

If

let $para := 
In a hole in the ground there lived a hobbit.
         
25 is the empty sequence, the function returns the empty sequence.

Otherwise, the function returns an

let $para := 
In a hole in the ground there lived a hobbit.
         
85 representing the hours component in the value of
let $para := 
In a hole in the ground there lived a hobbit.
         
25. Given that a duration is a
op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
632 tuple, the result is the value of
op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
693
.

If

let $para := 
In a hole in the ground there lived a hobbit.
         
25 is a negative duration then the result will be negative.

If

let $para := 
In a hole in the ground there lived a hobbit.
         
25 is an
let $para := 
In a hole in the ground there lived a hobbit.
         
24 the function returns 0.

Examples

The expression

op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
697 returns
let $para := 
In a hole in the ground there lived a hobbit.
         
054.

The expression

op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
699 returns
op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
700.

The expression

op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
701 returns
declare %public function r:random-sequence($length as xs:integer) as xs:double* {
  r:random-sequence($length, fn:random-number-generator())
};

declare %private function r:random-sequence($length as xs:integer, 
                                            $G as map(xs:string, item())) {
  if ($length eq 0)
  then ()
  else ($G?number, r:random-sequence($length - 1, $G?next()))
};

r:random-sequence(200);
            
07.

The expression

op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
703 returns
let $para := 
In a hole in the ground there lived a hobbit.
         
034.

8.3.5 fn:minutes-from-duration

Summary

Returns the number of minutes in a duration.

Signature

op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
621(
let $para := 
In a hole in the ground there lived a hobbit.
         
25
let $para := 
In a hole in the ground there lived a hobbit.
         
71
op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
626)
let $para := 
In a hole in the ground there lived a hobbit.
         
71
let $para := 
In a hole in the ground there lived a hobbit.
         
229

Properties

This function is ·deterministic·, ·context-independent·, and ·focus-independent·.

Rules

If

let $para := 
In a hole in the ground there lived a hobbit.
         
25 is the empty sequence, the function returns the empty sequence.

Otherwise, the function returns an

let $para := 
In a hole in the ground there lived a hobbit.
         
85 representing the minutes component in the value of
let $para := 
In a hole in the ground there lived a hobbit.
         
25. Given that a duration is a
op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
632 tuple, the result is the value of
op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
715
.

If

let $para := 
In a hole in the ground there lived a hobbit.
         
25 is a negative duration then the result will be negative.

If

let $para := 
In a hole in the ground there lived a hobbit.
         
25 is an
let $para := 
In a hole in the ground there lived a hobbit.
         
24 the function returns 0.

Examples

The expression

op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
719 returns
declare %public function r:random-sequence($length as xs:integer) as xs:double* {
  r:random-sequence($length, fn:random-number-generator())
};

declare %private function r:random-sequence($length as xs:integer, 
                                            $G as map(xs:string, item())) {
  if ($length eq 0)
  then ()
  else ($G?number, r:random-sequence($length - 1, $G?next()))
};

r:random-sequence(200);
            
19.

The expression

op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
721 returns
op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
722.

8.3.6 fn:seconds-from-duration

Summary

Returns the number of seconds in a duration.

Signature

op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
622(
let $para := 
In a hole in the ground there lived a hobbit.
         
25
let $para := 
In a hole in the ground there lived a hobbit.
         
71
op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
626)
let $para := 
In a hole in the ground there lived a hobbit.
         
71
op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
728

Properties

This function is ·deterministic·, ·context-independent·, and ·focus-independent·.

Rules

If

let $para := 
In a hole in the ground there lived a hobbit.
         
25 is the empty sequence, the function returns the empty sequence.

Otherwise, the function returns an

let $para := 
In a hole in the ground there lived a hobbit.
         
82 representing the seconds component in the value of
let $para := 
In a hole in the ground there lived a hobbit.
         
25. Given that a duration is a
op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
632 tuple, the result is the value of
op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
733 as an
let $para := 
In a hole in the ground there lived a hobbit.
         
82
.

If

let $para := 
In a hole in the ground there lived a hobbit.
         
25 is a negative duration then the result will be negative.

If

let $para := 
In a hole in the ground there lived a hobbit.
         
25 is an
let $para := 
In a hole in the ground there lived a hobbit.
         
24 the function returns 0.

Examples

The expression

op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
738 returns
op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
739.

The expression

op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
740 returns
op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
741.

8.4 Arithmetic operators on durations

FunctionMeaning
op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
742Returns the result of adding two
let $para := 
In a hole in the ground there lived a hobbit.
         
24 values.
op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
744Returns the result of subtracting one
let $para := 
In a hole in the ground there lived a hobbit.
         
24 value from another.
op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
746Returns the result of multiplying the value of
let $para := 
In a hole in the ground there lived a hobbit.
         
70 by
let $para := 
In a hole in the ground there lived a hobbit.
         
73. The result is rounded to the nearest month.
op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
749Returns the result of dividing the value of
let $para := 
In a hole in the ground there lived a hobbit.
         
70 by
let $para := 
In a hole in the ground there lived a hobbit.
         
73. The result is rounded to the nearest month.
op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
752Returns the ratio of two
let $para := 
In a hole in the ground there lived a hobbit.
         
24 values.
op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
754Returns the sum of two
let $para := 
In a hole in the ground there lived a hobbit.
         
25 values.
op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
756Returns the result of subtracting one
let $para := 
In a hole in the ground there lived a hobbit.
         
25 from another.
op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
758Returns the result of multiplying a
let $para := 
In a hole in the ground there lived a hobbit.
         
25 by a number.
op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
760Returns the result of multiplying a
let $para := 
In a hole in the ground there lived a hobbit.
         
25 by a number.
op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
762Returns the ratio of two
let $para := 
In a hole in the ground there lived a hobbit.
         
25 values, as a decimal number.

For operators that combine a duration and a date/time value, see 9.7 Arithmetic operators on durations, dates and times.

8.4.1 op:add-yearMonthDurations

Summary

Returns the result of adding two

let $para := 
In a hole in the ground there lived a hobbit.
         
24 values.

Operator Mapping

Defines the semantics of the "+" operator when applied to two

let $para := 
In a hole in the ground there lived a hobbit.
         
24 values.

Signature

op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
742(
let $para := 
In a hole in the ground there lived a hobbit.
         
70
let $para := 
In a hole in the ground there lived a hobbit.
         
71
let $para := 
In a hole in the ground there lived a hobbit.
         
24,
let $para := 
In a hole in the ground there lived a hobbit.
         
73
let $para := 
In a hole in the ground there lived a hobbit.
         
71
let $para := 
In a hole in the ground there lived a hobbit.
         
24)
let $para := 
In a hole in the ground there lived a hobbit.
         
71
let $para := 
In a hole in the ground there lived a hobbit.
         
24

Rules

The function returns the result of adding the value of

let $para := 
In a hole in the ground there lived a hobbit.
         
70 to the value of
let $para := 
In a hole in the ground there lived a hobbit.
         
73. The result will be an
let $para := 
In a hole in the ground there lived a hobbit.
         
24 whose length in months is equal to the length in months of
let $para := 
In a hole in the ground there lived a hobbit.
         
70 plus the length in months of
let $para := 
In a hole in the ground there lived a hobbit.
         
73.

For handling of overflow, see 9.7.1 Limits and precision.

Notes

Either duration (and therefore the result) may be negative.

Examples

The expression

op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
780 returns
op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
781.

8.4.2 op:subtract-yearMonthDurations

Summary

Returns the result of subtracting one

let $para := 
In a hole in the ground there lived a hobbit.
         
24 value from another.

Operator Mapping

Defines the semantics of the "-" operator when applied to two

let $para := 
In a hole in the ground there lived a hobbit.
         
24 values.

Signature

op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
744(
let $para := 
In a hole in the ground there lived a hobbit.
         
70
let $para := 
In a hole in the ground there lived a hobbit.
         
71
let $para := 
In a hole in the ground there lived a hobbit.
         
24,
let $para := 
In a hole in the ground there lived a hobbit.
         
73
let $para := 
In a hole in the ground there lived a hobbit.
         
71
let $para := 
In a hole in the ground there lived a hobbit.
         
24)
let $para := 
In a hole in the ground there lived a hobbit.
         
71
let $para := 
In a hole in the ground there lived a hobbit.
         
24

Rules

The function returns the result of subtracting the value of

let $para := 
In a hole in the ground there lived a hobbit.
         
73 from the value of
let $para := 
In a hole in the ground there lived a hobbit.
         
70. The result will be an
let $para := 
In a hole in the ground there lived a hobbit.
         
24 whose length in months is equal to the length in months of
let $para := 
In a hole in the ground there lived a hobbit.
         
70 minus the length in months of
let $para := 
In a hole in the ground there lived a hobbit.
         
73.

For handling of overflow, see 9.7.1 Limits and precision.

Notes

Either duration (and therefore the result) may be negative.

Examples

The expression

op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
798 returns
op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
799.

8.4.3 op:multiply-yearMonthDuration

Summary

Returns the result of multiplying the value of

let $para := 
In a hole in the ground there lived a hobbit.
         
70 by
let $para := 
In a hole in the ground there lived a hobbit.
         
73. The result is rounded to the nearest month.

Operator Mapping

Defines the semantics of the "*" operator when applied to an

let $para := 
In a hole in the ground there lived a hobbit.
         
24 and a numeric value.

Signature

op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
746(
let $para := 
In a hole in the ground there lived a hobbit.
         
70
let $para := 
In a hole in the ground there lived a hobbit.
         
71
let $para := 
In a hole in the ground there lived a hobbit.
         
24,
let $para := 
In a hole in the ground there lived a hobbit.
         
73
let $para := 
In a hole in the ground there lived a hobbit.
         
71
let $para := 
In a hole in the ground there lived a hobbit.
         
26)
let $para := 
In a hole in the ground there lived a hobbit.
         
71
let $para := 
In a hole in the ground there lived a hobbit.
         
24

Rules

The result is the

let $para := 
In a hole in the ground there lived a hobbit.
         
24 whose length in months is equal to the result of applying the
let $C := 'http://www.w3.org/2013/collation/UCA?strength=primary'
82 function to the value obtained by multiplying the length in months of
let $para := 
In a hole in the ground there lived a hobbit.
         
70 by the value of
let $para := 
In a hole in the ground there lived a hobbit.
         
73.

If

let $para := 
In a hole in the ground there lived a hobbit.
         
73 is positive or negative zero, the result is a zero-length duration. If
let $para := 
In a hole in the ground there lived a hobbit.
         
73 is positive or negative infinity, the result overflows and is handled as described in 9.7.1 Limits and precision.

For handling of overflow and underflow, see 9.7.1 Limits and precision.

Error Conditions

A dynamic error is raised [err:FOCA0005] if

let $para := 
In a hole in the ground there lived a hobbit.
         
73 is
fn:abs($N * $arg2) le fn:abs($arg1) 
               and fn:compare($N * $arg2, 0) eq fn:compare($arg1, 0).
90.

Notes

Either duration (and therefore the result) may be negative.

Examples

The expression

op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
820 returns
op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
821.

8.4.4 op:divide-yearMonthDuration

Summary

Returns the result of dividing the value of

let $para := 
In a hole in the ground there lived a hobbit.
         
70 by
let $para := 
In a hole in the ground there lived a hobbit.
         
73. The result is rounded to the nearest month.

Operator Mapping

Defines the semantics of the "div" operator when applied to an

let $para := 
In a hole in the ground there lived a hobbit.
         
24 and a numeric value.

Signature

op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
749(
let $para := 
In a hole in the ground there lived a hobbit.
         
70
let $para := 
In a hole in the ground there lived a hobbit.
         
71
let $para := 
In a hole in the ground there lived a hobbit.
         
24,
let $para := 
In a hole in the ground there lived a hobbit.
         
73
let $para := 
In a hole in the ground there lived a hobbit.
         
71
let $para := 
In a hole in the ground there lived a hobbit.
         
26)
let $para := 
In a hole in the ground there lived a hobbit.
         
71
let $para := 
In a hole in the ground there lived a hobbit.
         
24

Rules

The result is the

let $para := 
In a hole in the ground there lived a hobbit.
         
24 whose length in months is equal to the result of applying the
let $C := 'http://www.w3.org/2013/collation/UCA?strength=primary'
82 function to the value obtained by dividing the length in months of
let $para := 
In a hole in the ground there lived a hobbit.
         
70 by the value of
let $para := 
In a hole in the ground there lived a hobbit.
         
73.

If

let $para := 
In a hole in the ground there lived a hobbit.
         
73 is positive or negative infinity, the result is a zero-length duration. If
let $para := 
In a hole in the ground there lived a hobbit.
         
73 is positive or negative zero, the result overflows and is handled as described in 9.7.1 Limits and precision.

For handling of overflow and underflow, see 9.7.1 Limits and precision.

Error Conditions

A dynamic error is raised [err:FOCA0005] if

let $para := 
In a hole in the ground there lived a hobbit.
         
73 is
fn:abs($N * $arg2) le fn:abs($arg1) 
               and fn:compare($N * $arg2, 0) eq fn:compare($arg1, 0).
90.

Notes

Either operand (and therefore the result) may be negative.

Examples

The expression

op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
842 returns
op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
843.

8.4.5 op:divide-yearMonthDuration-by-yearMonthDuration

Summary

Returns the ratio of two

let $para := 
In a hole in the ground there lived a hobbit.
         
24 values.

Operator Mapping

Defines the semantics of the "div" operator when applied to two

let $para := 
In a hole in the ground there lived a hobbit.
         
24 values.

Signature

op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
752(
let $para := 
In a hole in the ground there lived a hobbit.
         
70
let $para := 
In a hole in the ground there lived a hobbit.
         
71
let $para := 
In a hole in the ground there lived a hobbit.
         
24,
let $para := 
In a hole in the ground there lived a hobbit.
         
73
let $para := 
In a hole in the ground there lived a hobbit.
         
71
let $para := 
In a hole in the ground there lived a hobbit.
         
24)
let $para := 
In a hole in the ground there lived a hobbit.
         
71
let $para := 
In a hole in the ground there lived a hobbit.
         
82

Rules

The function returns the result of dividing the length in months of

let $para := 
In a hole in the ground there lived a hobbit.
         
70 by the length in months of
let $para := 
In a hole in the ground there lived a hobbit.
         
73, according to the rules of the
fn:abs($N * $arg2) le fn:abs($arg1) 
               and fn:compare($N * $arg2, 0) eq fn:compare($arg1, 0).
99 function for integer operands.

For handling of overflow and underflow, see 9.7.1 Limits and precision.

Notes

Either duration (and therefore the result) may be negative.

Examples

The expression

op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
858 returns
op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
859.

The following example demonstrates how to calculate the length of an

let $para := 
In a hole in the ground there lived a hobbit.
         
24 value in months:

The expression

op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
861 returns
op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
862.

8.4.6 op:add-dayTimeDurations

Summary

Returns the sum of two

let $para := 
In a hole in the ground there lived a hobbit.
         
25 values.

Operator Mapping

Defines the semantics of the "+" operator when applied to two

let $para := 
In a hole in the ground there lived a hobbit.
         
25 values.

Signature

op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
754(
let $para := 
In a hole in the ground there lived a hobbit.
         
70
let $para := 
In a hole in the ground there lived a hobbit.
         
71
let $para := 
In a hole in the ground there lived a hobbit.
         
25,
let $para := 
In a hole in the ground there lived a hobbit.
         
73
let $para := 
In a hole in the ground there lived a hobbit.
         
71
let $para := 
In a hole in the ground there lived a hobbit.
         
25)
let $para := 
In a hole in the ground there lived a hobbit.
         
71
let $para := 
In a hole in the ground there lived a hobbit.
         
25

Rules

The function returns the result of adding the value of

let $para := 
In a hole in the ground there lived a hobbit.
         
70 to the value of
let $para := 
In a hole in the ground there lived a hobbit.
         
73. The result is the
let $para := 
In a hole in the ground there lived a hobbit.
         
25 whose length in seconds is equal to the sum of the length in seconds of the two input durations.

For handling of overflow, see 9.7.1 Limits and precision.

Notes

Either duration (and therefore the result) may be negative.

Examples

The expression

op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
877 returns
op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
878.

8.4.7 op:subtract-dayTimeDurations

Summary

Returns the result of subtracting one

let $para := 
In a hole in the ground there lived a hobbit.
         
25 from another.

Operator Mapping

Defines the semantics of the "-" operator when applied to two

let $para := 
In a hole in the ground there lived a hobbit.
         
25 values.

Signature

op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
756(
let $para := 
In a hole in the ground there lived a hobbit.
         
70
let $para := 
In a hole in the ground there lived a hobbit.
         
71
let $para := 
In a hole in the ground there lived a hobbit.
         
25,
let $para := 
In a hole in the ground there lived a hobbit.
         
73
let $para := 
In a hole in the ground there lived a hobbit.
         
71
let $para := 
In a hole in the ground there lived a hobbit.
         
25)
let $para := 
In a hole in the ground there lived a hobbit.
         
71
let $para := 
In a hole in the ground there lived a hobbit.
         
25

Rules

The function returns the result of subtracting the value of

let $para := 
In a hole in the ground there lived a hobbit.
         
73 from the value of
let $para := 
In a hole in the ground there lived a hobbit.
         
70. The result is the
let $para := 
In a hole in the ground there lived a hobbit.
         
25 whose length in seconds is equal to the length in seconds of
let $para := 
In a hole in the ground there lived a hobbit.
         
70 minus the length in seconds of
let $para := 
In a hole in the ground there lived a hobbit.
         
73.

For handling of overflow, see 9.7.1 Limits and precision.

Notes

Either duration (and therefore the result) may be negative.

Examples

The expression

op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
895 returns
op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
896.

8.4.8 op:multiply-dayTimeDuration

Summary

Returns the result of multiplying a

let $para := 
In a hole in the ground there lived a hobbit.
         
25 by a number.

Operator Mapping

Defines the semantics of the "*" operator when applied to an

let $para := 
In a hole in the ground there lived a hobbit.
         
25 and a numeric value.

Signature

op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
758(
let $para := 
In a hole in the ground there lived a hobbit.
         
70
let $para := 
In a hole in the ground there lived a hobbit.
         
71
let $para := 
In a hole in the ground there lived a hobbit.
         
25,
let $para := 
In a hole in the ground there lived a hobbit.
         
73
let $para := 
In a hole in the ground there lived a hobbit.
         
71
let $para := 
In a hole in the ground there lived a hobbit.
         
26)
let $para := 
In a hole in the ground there lived a hobbit.
         
71
let $para := 
In a hole in the ground there lived a hobbit.
         
25

Rules

The function returns the result of multiplying the value of

let $para := 
In a hole in the ground there lived a hobbit.
         
70 by
let $para := 
In a hole in the ground there lived a hobbit.
         
73. The result is the
let $para := 
In a hole in the ground there lived a hobbit.
         
25 whose length in seconds is equal to the length in seconds of
let $para := 
In a hole in the ground there lived a hobbit.
         
70 multiplied by the numeric value
let $para := 
In a hole in the ground there lived a hobbit.
         
73.

If

let $para := 
In a hole in the ground there lived a hobbit.
         
73 is positive or negative zero, the result is a zero-length duration. If
let $para := 
In a hole in the ground there lived a hobbit.
         
73 is positive or negative infinity, the result overflows and is handled as described in 9.1.1 Limits and precision.

For handling of overflow and underflow, see 9.7.1 Limits and precision.

Error Conditions

A dynamic error is raised [err:FOCA0005] if

let $para := 
In a hole in the ground there lived a hobbit.
         
73 is
fn:abs($N * $arg2) le fn:abs($arg1) 
               and fn:compare($N * $arg2, 0) eq fn:compare($arg1, 0).
90.

Notes

Either operand (and therefore the result) may be negative.

Examples

The expression

op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
917 returns
op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
918.

8.4.9 op:divide-dayTimeDuration

Summary

Returns the result of multiplying a

let $para := 
In a hole in the ground there lived a hobbit.
         
25 by a number.

Operator Mapping

Defines the semantics of the "div" operator when applied to two

let $para := 
In a hole in the ground there lived a hobbit.
         
25 values.

Signature

op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
760(
let $para := 
In a hole in the ground there lived a hobbit.
         
70
let $para := 
In a hole in the ground there lived a hobbit.
         
71
let $para := 
In a hole in the ground there lived a hobbit.
         
25,
let $para := 
In a hole in the ground there lived a hobbit.
         
73
let $para := 
In a hole in the ground there lived a hobbit.
         
71
let $para := 
In a hole in the ground there lived a hobbit.
         
26)
let $para := 
In a hole in the ground there lived a hobbit.
         
71
let $para := 
In a hole in the ground there lived a hobbit.
         
25

Rules

The function returns the result of dividing the value of

let $para := 
In a hole in the ground there lived a hobbit.
         
70 by
let $para := 
In a hole in the ground there lived a hobbit.
         
73. The result is the
let $para := 
In a hole in the ground there lived a hobbit.
         
25 whose length in seconds is equal to the length in seconds of
let $para := 
In a hole in the ground there lived a hobbit.
         
70 divided by the numeric value
let $para := 
In a hole in the ground there lived a hobbit.
         
73.

If

let $para := 
In a hole in the ground there lived a hobbit.
         
73 is positive or negative infinity, the result is a zero-length duration. If
let $para := 
In a hole in the ground there lived a hobbit.
         
73 is positive or negative zero, the result overflows and is handled as described in 9.1.1 Limits and precision.

For handling of overflow and underflow, see 9.7.1 Limits and precision.

Error Conditions

A dynamic error is raised [err:FOCA0005] if

let $para := 
In a hole in the ground there lived a hobbit.
         
73 is
fn:abs($N * $arg2) le fn:abs($arg1) 
               and fn:compare($N * $arg2, 0) eq fn:compare($arg1, 0).
90.

Notes

Either operand (and therefore the result) may be negative.

Examples

The expression

op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
939 returns
op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
940.

8.4.10 op:divide-dayTimeDuration-by-dayTimeDuration

Summary

Returns the ratio of two

let $para := 
In a hole in the ground there lived a hobbit.
         
25 values, as a decimal number.

Operator Mapping

Defines the semantics of the "div" operator when applied to two

let $para := 
In a hole in the ground there lived a hobbit.
         
25 values.

Signature

op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
762(
let $para := 
In a hole in the ground there lived a hobbit.
         
70
let $para := 
In a hole in the ground there lived a hobbit.
         
71
let $para := 
In a hole in the ground there lived a hobbit.
         
25,
let $para := 
In a hole in the ground there lived a hobbit.
         
73
let $para := 
In a hole in the ground there lived a hobbit.
         
71
let $para := 
In a hole in the ground there lived a hobbit.
         
25)
let $para := 
In a hole in the ground there lived a hobbit.
         
71
let $para := 
In a hole in the ground there lived a hobbit.
         
82

Rules

The function returns the result of dividing the value of

let $para := 
In a hole in the ground there lived a hobbit.
         
70 by
let $para := 
In a hole in the ground there lived a hobbit.
         
73. The result is the
let $para := 
In a hole in the ground there lived a hobbit.
         
25 whose length in seconds is equal to the length in seconds of
let $para := 
In a hole in the ground there lived a hobbit.
         
70 divided by the length in seconds of
let $para := 
In a hole in the ground there lived a hobbit.
         
73. The calculation is performed by applying
fn:abs($N * $arg2) le fn:abs($arg1) 
               and fn:compare($N * $arg2, 0) eq fn:compare($arg1, 0).
99 to the two
let $para := 
In a hole in the ground there lived a hobbit.
         
82 operands.

For handling of overflow and underflow, see 9.7.1 Limits and precision.

Notes

Either operand (and therefore the result) may be negative.

Examples

The expression

op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
959 returns
op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
960.

This examples shows how to determine the number of seconds in a duration.

The expression

op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
961 returns
op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
962.

9 Functions and operators on dates and times

This section defines operations on the [XML Schema Part 2: Datatypes Second Edition] date and time types.

See [Working With Timezones] for a disquisition on working with date and time values with and without timezones.

9.1 Date and time types

The operators described in this section are defined on the following date and time types:

  • let $para := 
    In a hole in the ground there lived a hobbit.
             
    29

  • op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
    964

  • op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
    965

  • op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
    966

  • op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
    967

  • op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
    968

  • op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
    969

  • op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
    970

The only operation defined on

op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
966,
op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
967,
op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
968,
op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
969 and
op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
970 values is equality comparison. For other types, further operations are provided, including component extraction, order comparisons, arithmetic, formatted display, and timezone adjustment.

9.1.1 Limits and precision

All minimally conforming processors must support positive year values with a minimum of 4 digits (i.e., YYYY) and a minimum fractional second precision of 1 millisecond or three digits (i.e., s.sss). However, conforming processors may set larger ·implementation-defined· limits on the maximum number of digits they support in these two situations. Processors may also choose to support the year 0000 and years with negative values. The results of operations on dates that cross the year 0000 are ·implementation-defined·.

A processor that limits the number of digits in date and time datatype representations may encounter overflow and underflow conditions when it tries to execute the functions in 9.7 Arithmetic operators on durations, dates and times. In these situations, the processor must return 00:00:00 in case of time underflow. It must raise a dynamic error [err:FODT0001] in case of overflow.

9.2 Date/time datatype values

As defined in Section 3.3.2 Dates and Times DM31,

let $para := 
In a hole in the ground there lived a hobbit.
         
29,
op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
964,
op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
965,
op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
966,
op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
967,
op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
968,
op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
969,
op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
970 values, referred to collectively as date/time values, are represented as seven components or properties:
op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
984,
op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
985,
op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
986,
op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
987,
op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
988,
op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
989 and
op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
990. The first five components are
let $para := 
In a hole in the ground there lived a hobbit.
         
85 values. The value of the
op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
989 component is an
let $para := 
In a hole in the ground there lived a hobbit.
         
82 and the value of the
op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
990 component is an
let $para := 
In a hole in the ground there lived a hobbit.
         
25. For all the primitive date/time datatypes, the
op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
990 property is optional and may or may not be present. Depending on the datatype, some of the remaining six properties must be present and some must be absentDM31. Absent, or missing, properties are represented by the empty sequence. This value is referred to as the local value in that the value retains its original timezone. Before comparing or subtracting
let $para := 
In a hole in the ground there lived a hobbit.
         
29 values, this local value must be translated or normalized to UTC.

For

op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
965,
op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
999 and
op:operation(fenceHeight, xs:integer) => op:operation(xs:integer, xs:integer)
000 are alternate lexical forms for the same value, whose canonical representation is
op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
999. For
let $para := 
In a hole in the ground there lived a hobbit.
         
29, a time component
op:operation(fenceHeight, xs:integer) => op:operation(xs:integer, xs:integer)
000 translates to
op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
999 of the following day.

9.2.1 Examples

  • An

    let $para := 
    In a hole in the ground there lived a hobbit.
             
    29 with lexical representation
    op:operation(fenceHeight, xs:integer) => op:operation(xs:integer, xs:integer)
    006 is represented in the datamodel by
    op:operation(fenceHeight, xs:integer) => op:operation(xs:integer, xs:integer)
    007.

  • An

    let $para := 
    In a hole in the ground there lived a hobbit.
             
    29 with lexical representation
    op:operation(fenceHeight, xs:integer) => op:operation(xs:integer, xs:integer)
    009 is represented by
    op:operation(fenceHeight, xs:integer) => op:operation(xs:integer, xs:integer)
    010.

  • An

    let $para := 
    In a hole in the ground there lived a hobbit.
             
    29 with lexical representation
    op:operation(fenceHeight, xs:integer) => op:operation(xs:integer, xs:integer)
    012 is represented by
    op:operation(fenceHeight, xs:integer) => op:operation(xs:integer, xs:integer)
    013.

  • An

    op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
    964 with lexical representation
    op:operation(fenceHeight, xs:integer) => op:operation(xs:integer, xs:integer)
    015 is represented by
    op:operation(fenceHeight, xs:integer) => op:operation(xs:integer, xs:integer)
    016.

  • An

    op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
    965 with lexical representation
    op:operation(fenceHeight, xs:integer) => op:operation(xs:integer, xs:integer)
    000 is represented by
    op:operation(fenceHeight, xs:integer) => op:operation(xs:integer, xs:integer)
    019.

9.3 Constructing a dateTime

A function is provided for constructing a

let $para := 
In a hole in the ground there lived a hobbit.
         
29 value from a
op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
964 value and a
op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
965 value.

FunctionMeaning
op:operation(fenceHeight, xs:integer) => op:operation(xs:integer, xs:integer)
023Returns an
let $para := 
In a hole in the ground there lived a hobbit.
         
29 value created by combining an
op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
964 and an
op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
965.

9.3.1 fn:dateTime

Summary

Returns an

let $para := 
In a hole in the ground there lived a hobbit.
         
29 value created by combining an
op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
964 and an
op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
965.

Signature

op:operation(fenceHeight, xs:integer) => op:operation(xs:integer, xs:integer)
023(
let $para := 
In a hole in the ground there lived a hobbit.
         
70
let $para := 
In a hole in the ground there lived a hobbit.
         
71
op:operation(fenceHeight, xs:integer) => op:operation(xs:integer, xs:integer)
033,
let $para := 
In a hole in the ground there lived a hobbit.
         
73
let $para := 
In a hole in the ground there lived a hobbit.
         
71
op:operation(fenceHeight, xs:integer) => op:operation(xs:integer, xs:integer)
036)
let $para := 
In a hole in the ground there lived a hobbit.
         
71
op:operation(fenceHeight, xs:integer) => op:operation(xs:integer, xs:integer)
038

Properties

This function is ·deterministic·, ·context-independent·, and ·focus-independent·.

Rules

If either

let $para := 
In a hole in the ground there lived a hobbit.
         
70 or
let $para := 
In a hole in the ground there lived a hobbit.
         
73 is the empty sequence the function returns the empty sequence.

Otherwise, the function returns an

let $para := 
In a hole in the ground there lived a hobbit.
         
29 whose date component is equal to
let $para := 
In a hole in the ground there lived a hobbit.
         
70 and whose time component is equal to
let $para := 
In a hole in the ground there lived a hobbit.
         
73.

The timezone of the result is computed as follows:

  • If neither argument has a timezone, the result has no timezone.

  • If exactly one of the arguments has a timezone, or if both arguments have the same timezone, the result has this timezone.

Error Conditions

A dynamic error is raised [err:FORG0008] if the two arguments both have timezones and the timezones are different.

Examples

The expression

op:operation(fenceHeight, xs:integer) => op:operation(xs:integer, xs:integer)
044 returns
op:operation(fenceHeight, xs:integer) => op:operation(xs:integer, xs:integer)
045.

The expression

op:operation(fenceHeight, xs:integer) => op:operation(xs:integer, xs:integer)
046 returns
op:operation(fenceHeight, xs:integer) => op:operation(xs:integer, xs:integer)
047. (This is because
op:operation(fenceHeight, xs:integer) => op:operation(xs:integer, xs:integer)
048 is an alternate lexical form for
op:operation(fenceHeight, xs:integer) => op:operation(xs:integer, xs:integer)
049).

9.4 Comparison operators on duration, date and time values

FunctionMeaning
op:operation(fenceHeight, xs:integer) => op:operation(xs:integer, xs:integer)
050Returns true if the two supplied
let $para := 
In a hole in the ground there lived a hobbit.
         
29 values refer to the same instant in time.
op:operation(fenceHeight, xs:integer) => op:operation(xs:integer, xs:integer)
052Returns
op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
76 if the first argument represents an earlier instant in time than the second argument.
op:operation(fenceHeight, xs:integer) => op:operation(xs:integer, xs:integer)
054Returns
op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
76 if the first argument represents a later instant in time than the second argument.
op:operation(fenceHeight, xs:integer) => op:operation(xs:integer, xs:integer)
056Returns
op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
76 if and only if the starting instants of the two supplied
op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
964 values are the same.
op:operation(fenceHeight, xs:integer) => op:operation(xs:integer, xs:integer)
059Returns
op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
76 if and only if the starting instant of
let $para := 
In a hole in the ground there lived a hobbit.
         
70 is less than the starting instant of
let $para := 
In a hole in the ground there lived a hobbit.
         
73. Returns
let $C := 'http://www.w3.org/2013/collation/UCA?strength=primary'
07 otherwise.
op:operation(fenceHeight, xs:integer) => op:operation(xs:integer, xs:integer)
064Returns
op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
76 if and only if the starting instant of
let $para := 
In a hole in the ground there lived a hobbit.
         
70 is greater than the starting instant of
let $para := 
In a hole in the ground there lived a hobbit.
         
73. Returns
let $C := 'http://www.w3.org/2013/collation/UCA?strength=primary'
07 otherwise.
op:operation(fenceHeight, xs:integer) => op:operation(xs:integer, xs:integer)
069Returns
op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
76 if the two
op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
965 values represent the same instant in time, when treated as being times on the same date, before adjusting the timezone.
op:operation(fenceHeight, xs:integer) => op:operation(xs:integer, xs:integer)
072Returns
op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
76 if the first
op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
965 value represents an earlier instant in time than the second, when both are treated as being times on the same date, before adjusting the timezone.
op:operation(fenceHeight, xs:integer) => op:operation(xs:integer, xs:integer)
075Returns
op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
76 if the first
op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
965 value represents a later instant in time than the second, when both are treated as being times on the same date, before adjusting the timezone.
op:operation(fenceHeight, xs:integer) => op:operation(xs:integer, xs:integer)
078Returns true if the two
op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
966 values have the same starting instant.
op:operation(fenceHeight, xs:integer) => op:operation(xs:integer, xs:integer)
080Returns true if the two
op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
967 values have the same starting instant.
op:operation(fenceHeight, xs:integer) => op:operation(xs:integer, xs:integer)
082Returns true if the two
op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
968 values have the same starting instant, when considered as days in the same year.
op:operation(fenceHeight, xs:integer) => op:operation(xs:integer, xs:integer)
084Returns true if the two
op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
969 values have the same starting instant, when considered as months in the same year.
op:operation(fenceHeight, xs:integer) => op:operation(xs:integer, xs:integer)
086Returns true if the two
op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
970 values have the same starting instant, when considered as days in the same month of the same year.

The following comparison operators are defined on the [XML Schema Part 2: Datatypes Second Edition] date/time datatypes. Each operator takes two operands of the same type and returns an

op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
32 result.

[XML Schema Part 2: Datatypes Second Edition] also states that the order relation on date and time datatypes is not a total order but a partial order because these datatypes may or may not have a timezone. This is handled as follows. If either operand to a comparison function on date or time values does not have an (explicit) timezone then, for the purpose of the operation, an implicit timezone, provided by the dynamic context Section C.2 Dynamic Context Components XP31, is assumed to be present as part of the value. This creates a total order for all date and time values.

An

let $para := 
In a hole in the ground there lived a hobbit.
         
29 can be considered to consist of seven components:
op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
984,
op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
985,
op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
986,
op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
987,
op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
988,
op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
989 and
op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
990. For
let $para := 
In a hole in the ground there lived a hobbit.
         
29 six components (
op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
984,
op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
985,
op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
986,
op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
987,
op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
988 and
op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
989) are required and
op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
990 is optional. For other date/time values, of the first six components, some are required and others must be absentDM31.
op:operation(fenceHeight, xs:integer) => op:operation(xs:integer, xs:integer)
105 is always optional. For example, for
op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
964, the
op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
984,
op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
985 and
op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
986 components are required and
op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
987,
op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
988 and
op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
989 components must be absent; for
op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
965 the
op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
987,
op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
988 and
op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
989 components are required and
op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
984,
op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
985 and
op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
986 are missing; for
op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
970,
op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
986 is required and
op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
984,
op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
985,
op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
987,
op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
988 and
op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
989 are missing.

Note:

In [Schema 1.1 Part 2], a new

op:operation(fenceHeight, xs:integer) => op:operation(xs:integer, xs:integer)
127 facet is available with values
op:operation(fenceHeight, xs:integer) => op:operation(xs:integer, xs:integer)
128,
op:operation(fenceHeight, xs:integer) => op:operation(xs:integer, xs:integer)
129, or
op:operation(fenceHeight, xs:integer) => op:operation(xs:integer, xs:integer)
130 to enable the timezone to be defined as mandatory or disallowed.

Values of the date/time datatypes

op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
965,
op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
968,
op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
969, and
op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
970, can be considered to represent a sequence of recurring time instants or time periods. An
op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
965 occurs every day. An
op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
969 occurs every year. Comparison operators on these datatypes compare the starting instants of equivalent occurrences in the recurring series. These
let $para := 
In a hole in the ground there lived a hobbit.
         
29 values are calculated as described below.

Comparison operators on

op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
964,
op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
966 and
op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
967 compare their starting instants. These
let $para := 
In a hole in the ground there lived a hobbit.
         
29 values are calculated as described below.

The starting instant of an occurrence of a date/time value is an

let $para := 
In a hole in the ground there lived a hobbit.
         
29 calculated by filling in the missing components of the local value from a reference
let $para := 
In a hole in the ground there lived a hobbit.
         
29. An example of a suitable reference
let $para := 
In a hole in the ground there lived a hobbit.
         
29 is
op:operation(fenceHeight, xs:integer) => op:operation(xs:integer, xs:integer)
145. Then, for example, the starting instant corresponding to the
op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
964 value
op:operation(fenceHeight, xs:integer) => op:operation(xs:integer, xs:integer)
147 is
op:operation(fenceHeight, xs:integer) => op:operation(xs:integer, xs:integer)
148; the starting instant corresponding to the
op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
965 value
op:operation(fenceHeight, xs:integer) => op:operation(xs:integer, xs:integer)
150 is
op:operation(fenceHeight, xs:integer) => op:operation(xs:integer, xs:integer)
151; and the starting instant corresponding to the
op:operation(fenceHeight, xs:integer) => op:operation(xs:integer, xs:integer)
152 value
op:operation(fenceHeight, xs:integer) => op:operation(xs:integer, xs:integer)
153 is
op:operation(fenceHeight, xs:integer) => op:operation(xs:integer, xs:integer)
154 (which explains why a leap year was chosen for the reference).

Note:

In the previous version of this specification, the reference date/time chosen was

op:operation(fenceHeight, xs:integer) => op:operation(xs:integer, xs:integer)
155. While this gives the same results, it produces a "starting instant" for a
op:operation(fenceHeight, xs:integer) => op:operation(xs:integer, xs:integer)
156 or
op:operation(fenceHeight, xs:integer) => op:operation(xs:integer, xs:integer)
152 that bears no relation to the ordinary meaning of the term, and it also required special handling of short months. The original choice was made to allow for leap seconds; but since leap seconds are not recognized in date/time arithmetic, this is not actually necessary.

If the

op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
965 value written as
op:operation(fenceHeight, xs:integer) => op:operation(xs:integer, xs:integer)
000 is to be compared, filling in the missing components gives
op:operation(fenceHeight, xs:integer) => op:operation(xs:integer, xs:integer)
145, because
op:operation(fenceHeight, xs:integer) => op:operation(xs:integer, xs:integer)
000 is an alternative representation of
op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
999 (the lexical value
op:operation(fenceHeight, xs:integer) => op:operation(xs:integer, xs:integer)
048 is converted to the time components {0,0,0} before the missing components are filled in). This has the consequence that when ordering
op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
965 values,
op:operation(fenceHeight, xs:integer) => op:operation(xs:integer, xs:integer)
000 is considered to be earlier than
op:operation(fenceHeight, xs:integer) => op:operation(xs:integer, xs:integer)
166. However, when ordering
let $para := 
In a hole in the ground there lived a hobbit.
         
29 values, a time component of
op:operation(fenceHeight, xs:integer) => op:operation(xs:integer, xs:integer)
000 is considered equivalent to
op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
999 on the following day.

Note that the reference

let $para := 
In a hole in the ground there lived a hobbit.
         
29 does not have a timezone. The
op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
990 component is never filled in from the reference
let $para := 
In a hole in the ground there lived a hobbit.
         
29. In some cases, if the date/time value does not have a timezone, the implicit timezone from the dynamic context is used as the timezone.

Note:

This specification uses the reference

op:operation(fenceHeight, xs:integer) => op:operation(xs:integer, xs:integer)
173 in the description of the comparison operators. Implementations may use other reference
let $para := 
In a hole in the ground there lived a hobbit.
         
29 values as long as they yield the same results. The reference
let $para := 
In a hole in the ground there lived a hobbit.
         
29 used must meet the following constraints: when it is used to supply components into
op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
968 values, the year must allow for February 29 and so must be a leap year; when it is used to supply missing components into
op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
970 values, the month must allow for 31 days. Different reference
let $para := 
In a hole in the ground there lived a hobbit.
         
29 values may be used for different operators.

9.4.1 op:dateTime-equal

Summary

Returns true if the two supplied

let $para := 
In a hole in the ground there lived a hobbit.
         
29 values refer to the same instant in time.

Operator Mapping

Defines the semantics of the "eq" operator when applied to two

let $para := 
In a hole in the ground there lived a hobbit.
         
29 values. Also used in the definition of the "ne", "le" and "ge" operators.

Signature

op:operation(fenceHeight, xs:integer) => op:operation(xs:integer, xs:integer)
050(
let $para := 
In a hole in the ground there lived a hobbit.
         
70
let $para := 
In a hole in the ground there lived a hobbit.
         
71
let $para := 
In a hole in the ground there lived a hobbit.
         
29,
let $para := 
In a hole in the ground there lived a hobbit.
         
73
let $para := 
In a hole in the ground there lived a hobbit.
         
71
let $para := 
In a hole in the ground there lived a hobbit.
         
29)
let $para := 
In a hole in the ground there lived a hobbit.
         
71
op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
32

Properties

This function is ·deterministic·, ·context-dependent·, and ·focus-independent·. It depends on implicit timezone.

Rules

If either

let $para := 
In a hole in the ground there lived a hobbit.
         
70 or
let $para := 
In a hole in the ground there lived a hobbit.
         
73 has no timezone component, the effective value of the argument is obtained by substituting the implicit timezone from the dynamic evaluation context.

The function then returns

op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
76 if and only if the effective value of
let $para := 
In a hole in the ground there lived a hobbit.
         
70 is equal to the effective value of
let $para := 
In a hole in the ground there lived a hobbit.
         
73 according to the algorithm defined in section 3.2.7.4 of [XML Schema Part 2: Datatypes Second Edition] "Order relation on dateTime" for
let $para := 
In a hole in the ground there lived a hobbit.
         
29 values with timezones. Otherwise the function returns
let $C := 'http://www.w3.org/2013/collation/UCA?strength=primary'
07.

Examples

Assume that the dynamic context provides an implicit timezone value of

op:operation(fenceHeight, xs:integer) => op:operation(xs:integer, xs:integer)
197

The expression

op:operation(fenceHeight, xs:integer) => op:operation(xs:integer, xs:integer)
198 returns
let $para := 
In a hole in the ground there lived a hobbit.
         
182.

The expression

op:operation(fenceHeight, xs:integer) => op:operation(xs:integer, xs:integer)
200 returns
let $para := 
In a hole in the ground there lived a hobbit.
         
182.

The expression

op:operation(fenceHeight, xs:integer) => op:operation(xs:integer, xs:integer)
202 returns
let $para := 
In a hole in the ground there lived a hobbit.
         
184.

The expression

op:operation(fenceHeight, xs:integer) => op:operation(xs:integer, xs:integer)
204 returns
let $para := 
In a hole in the ground there lived a hobbit.
         
182.

The expression

op:operation(fenceHeight, xs:integer) => op:operation(xs:integer, xs:integer)
206 returns
let $para := 
In a hole in the ground there lived a hobbit.
         
182.

The expression

op:operation(fenceHeight, xs:integer) => op:operation(xs:integer, xs:integer)
208 returns
let $para := 
In a hole in the ground there lived a hobbit.
         
182.

The expression

op:operation(fenceHeight, xs:integer) => op:operation(xs:integer, xs:integer)
210 returns
let $para := 
In a hole in the ground there lived a hobbit.
         
184.

9.4.2 op:dateTime-less-than

Summary

Returns

op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
76 if the first argument represents an earlier instant in time than the second argument.

Operator Mapping

Defines the semantics of the "lt" operator when applied to two

let $para := 
In a hole in the ground there lived a hobbit.
         
29 values. Also used in the definition of the "ge" operator.

Signature

op:operation(fenceHeight, xs:integer) => op:operation(xs:integer, xs:integer)
052(
let $para := 
In a hole in the ground there lived a hobbit.
         
70
let $para := 
In a hole in the ground there lived a hobbit.
         
71
let $para := 
In a hole in the ground there lived a hobbit.
         
29,
let $para := 
In a hole in the ground there lived a hobbit.
         
73
let $para := 
In a hole in the ground there lived a hobbit.
         
71
let $para := 
In a hole in the ground there lived a hobbit.
         
29)
let $para := 
In a hole in the ground there lived a hobbit.
         
71
op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
32

Properties

This function is ·deterministic·, ·context-dependent·, and ·focus-independent·. It depends on implicit timezone.

Rules

If either

let $para := 
In a hole in the ground there lived a hobbit.
         
70 or
let $para := 
In a hole in the ground there lived a hobbit.
         
73 has no timezone component, the effective value of the argument is obtained by substituting the implicit timezone from the dynamic evaluation context.

The function then returns

op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
76 if and only if the effective value of
let $para := 
In a hole in the ground there lived a hobbit.
         
70 is less than the effective value of
let $para := 
In a hole in the ground there lived a hobbit.
         
73 according to the algorithm defined in section 3.2.7.4 of [XML Schema Part 2: Datatypes Second Edition] "Order relation on dateTime" for
let $para := 
In a hole in the ground there lived a hobbit.
         
29 values with timezones. Otherwise the function returns
let $C := 'http://www.w3.org/2013/collation/UCA?strength=primary'
07.

9.4.3 op:dateTime-greater-than

Summary

Returns

op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
76 if the first argument represents a later instant in time than the second argument.

Operator Mapping

Defines the semantics of the "gt" operator when applied to two

let $para := 
In a hole in the ground there lived a hobbit.
         
29 values. Also used in the definition of the "le" operator.

Signature

op:operation(fenceHeight, xs:integer) => op:operation(xs:integer, xs:integer)
054(
let $para := 
In a hole in the ground there lived a hobbit.
         
70
let $para := 
In a hole in the ground there lived a hobbit.
         
71
let $para := 
In a hole in the ground there lived a hobbit.
         
29,
let $para := 
In a hole in the ground there lived a hobbit.
         
73
let $para := 
In a hole in the ground there lived a hobbit.
         
71
let $para := 
In a hole in the ground there lived a hobbit.
         
29)
let $para := 
In a hole in the ground there lived a hobbit.
         
71
op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
32

Properties

This function is ·deterministic·, ·context-dependent·, and ·focus-independent·. It depends on implicit timezone.

Rules

The function call

op:operation(fenceHeight, xs:integer) => op:operation(xs:integer, xs:integer)
241 is defined to return the same result as
op:operation(fenceHeight, xs:integer) => op:operation(xs:integer, xs:integer)
242

9.4.4 op:date-equal

Summary

Returns

op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
76 if and only if the starting instants of the two supplied
op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
964 values are the same.

Operator Mapping

Defines the semantics of the "eq" operator when applied to two

op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
964 values. Also used in the definition of the "ne", "le" and "ge" operators.

Signature

op:operation(fenceHeight, xs:integer) => op:operation(xs:integer, xs:integer)
056(
let $para := 
In a hole in the ground there lived a hobbit.
         
70
let $para := 
In a hole in the ground there lived a hobbit.
         
71
op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
964,
let $para := 
In a hole in the ground there lived a hobbit.
         
73
let $para := 
In a hole in the ground there lived a hobbit.
         
71
op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
964)
let $para := 
In a hole in the ground there lived a hobbit.
         
71
op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
32

Properties

This function is ·deterministic·, ·context-dependent·, and ·focus-independent·. It depends on implicit timezone.

Rules

The starting instant of an

op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
964 is the
let $para := 
In a hole in the ground there lived a hobbit.
         
29 at time
op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
999 on that date.

The function returns the result of the expression:

let $para := 
In a hole in the ground there lived a hobbit.
         
2

Examples

The expression

op:operation(fenceHeight, xs:integer) => op:operation(xs:integer, xs:integer)
258 returns
let $para := 
In a hole in the ground there lived a hobbit.
         
184. (The starting instants are
op:operation(fenceHeight, xs:integer) => op:operation(xs:integer, xs:integer)
260 and
op:operation(fenceHeight, xs:integer) => op:operation(xs:integer, xs:integer)
261. These are normalized to
op:operation(fenceHeight, xs:integer) => op:operation(xs:integer, xs:integer)
260 and
op:operation(fenceHeight, xs:integer) => op:operation(xs:integer, xs:integer)
263. ).

The expression

op:operation(fenceHeight, xs:integer) => op:operation(xs:integer, xs:integer)
264 returns
let $para := 
In a hole in the ground there lived a hobbit.
         
182.

9.4.5 op:date-less-than

Summary

Returns

op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
76 if and only if the starting instant of
let $para := 
In a hole in the ground there lived a hobbit.
         
70 is less than the starting instant of
let $para := 
In a hole in the ground there lived a hobbit.
         
73. Returns
let $C := 'http://www.w3.org/2013/collation/UCA?strength=primary'
07 otherwise.

Operator Mapping

Defines the semantics of the "lt" operator when applied to two

op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
964 values. Also used in the definition of the "ge" operator.

Signature

op:operation(fenceHeight, xs:integer) => op:operation(xs:integer, xs:integer)
059(
let $para := 
In a hole in the ground there lived a hobbit.
         
70
let $para := 
In a hole in the ground there lived a hobbit.
         
71
op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
964,
let $para := 
In a hole in the ground there lived a hobbit.
         
73
let $para := 
In a hole in the ground there lived a hobbit.
         
71
op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
964)
let $para := 
In a hole in the ground there lived a hobbit.
         
71
op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
32

Rules

The starting instant of an

op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
964 is the
let $para := 
In a hole in the ground there lived a hobbit.
         
29 at time
op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
999 on that date.

The function returns the result of the expression:

let $para := 
In a hole in the ground there lived a hobbit.
         
3

Examples

The expression

op:operation(fenceHeight, xs:integer) => op:operation(xs:integer, xs:integer)
283 returns
let $para := 
In a hole in the ground there lived a hobbit.
         
182.

The expression

op:operation(fenceHeight, xs:integer) => op:operation(xs:integer, xs:integer)
285 returns
let $para := 
In a hole in the ground there lived a hobbit.
         
184.

9.4.6 op:date-greater-than

Summary

Returns

op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
76 if and only if the starting instant of
let $para := 
In a hole in the ground there lived a hobbit.
         
70 is greater than the starting instant of
let $para := 
In a hole in the ground there lived a hobbit.
         
73. Returns
let $C := 'http://www.w3.org/2013/collation/UCA?strength=primary'
07 otherwise.

Operator Mapping

Defines the semantics of the "gt" operator when applied to two

op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
964 values. Also used in the definition of the "le" operator.

Signature

op:operation(fenceHeight, xs:integer) => op:operation(xs:integer, xs:integer)
064(
let $para := 
In a hole in the ground there lived a hobbit.
         
70
let $para := 
In a hole in the ground there lived a hobbit.
         
71
op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
964,
let $para := 
In a hole in the ground there lived a hobbit.
         
73
let $para := 
In a hole in the ground there lived a hobbit.
         
71
op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
964)
let $para := 
In a hole in the ground there lived a hobbit.
         
71
op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
32

Properties

This function is ·deterministic·, ·context-dependent·, and ·focus-independent·. It depends on implicit timezone.

Rules

The function call

op:operation(fenceHeight, xs:integer) => op:operation(xs:integer, xs:integer)
301 is defined to return the same result as
op:operation(fenceHeight, xs:integer) => op:operation(xs:integer, xs:integer)
302

Examples

The expression

op:operation(fenceHeight, xs:integer) => op:operation(xs:integer, xs:integer)
303 returns
let $para := 
In a hole in the ground there lived a hobbit.
         
182.

The expression

op:operation(fenceHeight, xs:integer) => op:operation(xs:integer, xs:integer)
305 returns
let $para := 
In a hole in the ground there lived a hobbit.
         
184.

9.4.7 op:time-equal

Summary

Returns

op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
76 if the two
op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
965 values represent the same instant in time, when treated as being times on the same date, before adjusting the timezone.

Operator Mapping

Defines the semantics of the "eq" operator when applied to two

op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
965 values. Also used in the definition of the "ne", "le" and "ge" operators.

Signature

op:operation(fenceHeight, xs:integer) => op:operation(xs:integer, xs:integer)
069(
let $para := 
In a hole in the ground there lived a hobbit.
         
70
let $para := 
In a hole in the ground there lived a hobbit.
         
71
op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
965,
let $para := 
In a hole in the ground there lived a hobbit.
         
73
let $para := 
In a hole in the ground there lived a hobbit.
         
71
op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
965)
let $para := 
In a hole in the ground there lived a hobbit.
         
71
op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
32

Properties

This function is ·deterministic·, ·context-dependent·, and ·focus-independent·. It depends on implicit timezone.

Rules

Each of the supplied

op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
965 values is expanded to an
let $para := 
In a hole in the ground there lived a hobbit.
         
29 value by associating the time with an arbitrary date. The function returns the result of comparing these two
let $para := 
In a hole in the ground there lived a hobbit.
         
29 values using
op:operation(fenceHeight, xs:integer) => op:operation(xs:integer, xs:integer)
050.

The result of the function is thus the same as the value of the expression:

let $para := 
In a hole in the ground there lived a hobbit.
         
4

Examples

Assume that the date components from the reference

let $para := 
In a hole in the ground there lived a hobbit.
         
29 correspond to
op:operation(fenceHeight, xs:integer) => op:operation(xs:integer, xs:integer)
324.

The expression

op:operation(fenceHeight, xs:integer) => op:operation(xs:integer, xs:integer)
325 returns
let $para := 
In a hole in the ground there lived a hobbit.
         
184. (The
let $para := 
In a hole in the ground there lived a hobbit.
         
29s calculated using the reference date components are
op:operation(fenceHeight, xs:integer) => op:operation(xs:integer, xs:integer)
328 and
op:operation(fenceHeight, xs:integer) => op:operation(xs:integer, xs:integer)
329. These normalize to
op:operation(fenceHeight, xs:integer) => op:operation(xs:integer, xs:integer)
330 and
op:operation(fenceHeight, xs:integer) => op:operation(xs:integer, xs:integer)
331. ).

The expression

op:operation(fenceHeight, xs:integer) => op:operation(xs:integer, xs:integer)
332 returns
let $para := 
In a hole in the ground there lived a hobbit.
         
182.

The expression

op:operation(fenceHeight, xs:integer) => op:operation(xs:integer, xs:integer)
334 returns
let $para := 
In a hole in the ground there lived a hobbit.
         
182. (This not the result one might expect. For
let $para := 
In a hole in the ground there lived a hobbit.
         
29 values, a time of
op:operation(fenceHeight, xs:integer) => op:operation(xs:integer, xs:integer)
000 is equivalent to
op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
999 on the following day. For
op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
965, the normalization from
op:operation(fenceHeight, xs:integer) => op:operation(xs:integer, xs:integer)
000 to
op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
999 happens before the
op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
965 is converted into an
let $para := 
In a hole in the ground there lived a hobbit.
         
29 for the purpose of the equality comparison. For
op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
965, any operation on
op:operation(fenceHeight, xs:integer) => op:operation(xs:integer, xs:integer)
000 produces the same result as the same operation on
op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
999 because these are two different lexical representations of the same value. ).

9.4.8 op:time-less-than

Summary

Returns

op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
76 if the first
op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
965 value represents an earlier instant in time than the second, when both are treated as being times on the same date, before adjusting the timezone.

Operator Mapping

Defines the semantics of the "lt" operator when applied to two

op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
965 values. Also used in the definition of the "ge" operator.

Signature

op:operation(fenceHeight, xs:integer) => op:operation(xs:integer, xs:integer)
072(
let $para := 
In a hole in the ground there lived a hobbit.
         
70
let $para := 
In a hole in the ground there lived a hobbit.
         
71
op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
965,
let $para := 
In a hole in the ground there lived a hobbit.
         
73
let $para := 
In a hole in the ground there lived a hobbit.
         
71
op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
965)
let $para := 
In a hole in the ground there lived a hobbit.
         
71
op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
32

Properties

This function is ·deterministic·, ·context-dependent·, and ·focus-independent·. It depends on implicit timezone.

Rules

Each of the supplied

op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
965 values is expanded to an
let $para := 
In a hole in the ground there lived a hobbit.
         
29 value by associating the time with an arbitrary date. The function returns the result of comparing these two
let $para := 
In a hole in the ground there lived a hobbit.
         
29 values using
op:operation(fenceHeight, xs:integer) => op:operation(xs:integer, xs:integer)
052.

The result of the function is thus the same as the value of the expression:

let $para := 
In a hole in the ground there lived a hobbit.
         
5

Examples

Assume that the dynamic context provides an implicit timezone value of

op:operation(fenceHeight, xs:integer) => op:operation(xs:integer, xs:integer)
197.

The expression

op:operation(fenceHeight, xs:integer) => op:operation(xs:integer, xs:integer)
364 returns
let $para := 
In a hole in the ground there lived a hobbit.
         
184.

The expression

op:operation(fenceHeight, xs:integer) => op:operation(xs:integer, xs:integer)
366 returns
let $para := 
In a hole in the ground there lived a hobbit.
         
182.

The expression

op:operation(fenceHeight, xs:integer) => op:operation(xs:integer, xs:integer)
368 returns
let $para := 
In a hole in the ground there lived a hobbit.
         
184.

9.4.9 op:time-greater-than

Summary

Returns

op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
76 if the first
op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
965 value represents a later instant in time than the second, when both are treated as being times on the same date, before adjusting the timezone.

Operator Mapping

Defines the semantics of the "gt" operator when applied to two

op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
965 values. Also used in the definition of the "le" operator.

Signature

op:operation(fenceHeight, xs:integer) => op:operation(xs:integer, xs:integer)
075(
let $para := 
In a hole in the ground there lived a hobbit.
         
70
let $para := 
In a hole in the ground there lived a hobbit.
         
71
op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
965,
let $para := 
In a hole in the ground there lived a hobbit.
         
73
let $para := 
In a hole in the ground there lived a hobbit.
         
71
op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
965)
let $para := 
In a hole in the ground there lived a hobbit.
         
71
op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
32

Properties

This function is ·deterministic·, ·context-dependent·, and ·focus-independent·. It depends on implicit timezone.

Rules

The function call

op:operation(fenceHeight, xs:integer) => op:operation(xs:integer, xs:integer)
382 is defined to return the same result as
op:operation(fenceHeight, xs:integer) => op:operation(xs:integer, xs:integer)
383

Examples

The expression

op:operation(fenceHeight, xs:integer) => op:operation(xs:integer, xs:integer)
384 returns
let $para := 
In a hole in the ground there lived a hobbit.
         
184.

9.4.10 op:gYearMonth-equal

Summary

Returns true if the two

op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
966 values have the same starting instant.

Operator Mapping

Defines the semantics of the "eq" operator when applied to two

op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
966 values. Also used in the definition of the "ne" operator.

Signature

op:operation(fenceHeight, xs:integer) => op:operation(xs:integer, xs:integer)
078(
let $para := 
In a hole in the ground there lived a hobbit.
         
70
let $para := 
In a hole in the ground there lived a hobbit.
         
71
op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
966,
let $para := 
In a hole in the ground there lived a hobbit.
         
73
let $para := 
In a hole in the ground there lived a hobbit.
         
71
op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
966)
let $para := 
In a hole in the ground there lived a hobbit.
         
71
op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
32

Properties

This function is ·deterministic·, ·context-dependent·, and ·focus-independent·. It depends on implicit timezone.

Rules

The starting instants of

let $para := 
In a hole in the ground there lived a hobbit.
         
70 and
let $para := 
In a hole in the ground there lived a hobbit.
         
73 are calculated by supplying the missing components of
let $para := 
In a hole in the ground there lived a hobbit.
         
70 and
let $para := 
In a hole in the ground there lived a hobbit.
         
73 from the
let $para := 
In a hole in the ground there lived a hobbit.
         
29 template
op:operation(fenceHeight, xs:integer) => op:operation(xs:integer, xs:integer)
402. The function returns the result of comparing these two starting instants using
op:operation(fenceHeight, xs:integer) => op:operation(xs:integer, xs:integer)
050.

Examples

Assume that the dynamic context provides an implicit timezone value of

op:operation(fenceHeight, xs:integer) => op:operation(xs:integer, xs:integer)
197.

op:operation(fenceHeight, xs:integer) => op:operation(xs:integer, xs:integer)
405 returns
let $para := 
In a hole in the ground there lived a hobbit.
         
184. The starting instants are
op:operation(fenceHeight, xs:integer) => op:operation(xs:integer, xs:integer)
407 and
op:operation(fenceHeight, xs:integer) => op:operation(xs:integer, xs:integer)
408, respectively.

op:operation(fenceHeight, xs:integer) => op:operation(xs:integer, xs:integer)
409 returns
let $para := 
In a hole in the ground there lived a hobbit.
         
184. The starting instants are
op:operation(fenceHeight, xs:integer) => op:operation(xs:integer, xs:integer)
411 and
op:operation(fenceHeight, xs:integer) => op:operation(xs:integer, xs:integer)
412, respectively.

9.4.11 op:gYear-equal

Summary

Returns true if the two

op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
967 values have the same starting instant.

Operator Mapping

Defines the semantics of the "eq" operator when applied to two

op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
967 values. Also used in the definition of the "ne" operator.

Signature

op:operation(fenceHeight, xs:integer) => op:operation(xs:integer, xs:integer)
080(
let $para := 
In a hole in the ground there lived a hobbit.
         
70
let $para := 
In a hole in the ground there lived a hobbit.
         
71
op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
967,
let $para := 
In a hole in the ground there lived a hobbit.
         
73
let $para := 
In a hole in the ground there lived a hobbit.
         
71
op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
967)
let $para := 
In a hole in the ground there lived a hobbit.
         
71
op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
32

Properties

This function is ·deterministic·, ·context-dependent·, and ·focus-independent·. It depends on implicit timezone.

Rules

The starting instants of

let $para := 
In a hole in the ground there lived a hobbit.
         
70 and
let $para := 
In a hole in the ground there lived a hobbit.
         
73 are calculated by supplying the missing components of
let $para := 
In a hole in the ground there lived a hobbit.
         
70 and
let $para := 
In a hole in the ground there lived a hobbit.
         
73 from the
let $para := 
In a hole in the ground there lived a hobbit.
         
29 template
op:operation(fenceHeight, xs:integer) => op:operation(xs:integer, xs:integer)
429. The function returns the result of comparing these two starting instants using
op:operation(fenceHeight, xs:integer) => op:operation(xs:integer, xs:integer)
050.

Examples

Assume that the dynamic context provides an implicit timezone value of

op:operation(fenceHeight, xs:integer) => op:operation(xs:integer, xs:integer)
197. Assume, also, that the
let $para := 
In a hole in the ground there lived a hobbit.
         
29 template is
op:operation(fenceHeight, xs:integer) => op:operation(xs:integer, xs:integer)
429.

op:operation(fenceHeight, xs:integer) => op:operation(xs:integer, xs:integer)
434 returns
let $para := 
In a hole in the ground there lived a hobbit.
         
184. The starting instants are
op:operation(fenceHeight, xs:integer) => op:operation(xs:integer, xs:integer)
436 and
op:operation(fenceHeight, xs:integer) => op:operation(xs:integer, xs:integer)
437, respectively, and normalize to
op:operation(fenceHeight, xs:integer) => op:operation(xs:integer, xs:integer)
438 and
op:operation(fenceHeight, xs:integer) => op:operation(xs:integer, xs:integer)
439.

The expression

op:operation(fenceHeight, xs:integer) => op:operation(xs:integer, xs:integer)
440 returns
let $para := 
In a hole in the ground there lived a hobbit.
         
182.

9.4.12 op:gMonthDay-equal

Summary

Returns true if the two

op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
968 values have the same starting instant, when considered as days in the same year.

Operator Mapping

Defines the semantics of the "eq" operator when applied to two

op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
968 values. Also used in the definition of the "ne" operator.

Signature

op:operation(fenceHeight, xs:integer) => op:operation(xs:integer, xs:integer)
082(
let $para := 
In a hole in the ground there lived a hobbit.
         
70
let $para := 
In a hole in the ground there lived a hobbit.
         
71
op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
968,
let $para := 
In a hole in the ground there lived a hobbit.
         
73
let $para := 
In a hole in the ground there lived a hobbit.
         
71
op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
968)
let $para := 
In a hole in the ground there lived a hobbit.
         
71
op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
32

Properties

This function is ·deterministic·, ·context-dependent·, and ·focus-independent·. It depends on implicit timezone.

Rules

The starting instants of

let $para := 
In a hole in the ground there lived a hobbit.
         
70 and
let $para := 
In a hole in the ground there lived a hobbit.
         
73 are calculated by supplying the missing components of
let $para := 
In a hole in the ground there lived a hobbit.
         
70 and
let $para := 
In a hole in the ground there lived a hobbit.
         
73 from the
let $para := 
In a hole in the ground there lived a hobbit.
         
29 template
op:operation(fenceHeight, xs:integer) => op:operation(xs:integer, xs:integer)
458 or an equivalent. The function returns the result of comparing these two starting instants using
op:operation(fenceHeight, xs:integer) => op:operation(xs:integer, xs:integer)
050.

Examples

Assume that the dynamic context provides an implicit timezone value of

op:operation(fenceHeight, xs:integer) => op:operation(xs:integer, xs:integer)
197. Assume for the purposes of illustration that the
let $para := 
In a hole in the ground there lived a hobbit.
         
29 template used is
op:operation(fenceHeight, xs:integer) => op:operation(xs:integer, xs:integer)
458 (this does not affect the result).

The expression

op:operation(fenceHeight, xs:integer) => op:operation(xs:integer, xs:integer)
463 returns
let $para := 
In a hole in the ground there lived a hobbit.
         
182. ( The starting instants are
op:operation(fenceHeight, xs:integer) => op:operation(xs:integer, xs:integer)
465 and
op:operation(fenceHeight, xs:integer) => op:operation(xs:integer, xs:integer)
466, respectively, and normalize to
op:operation(fenceHeight, xs:integer) => op:operation(xs:integer, xs:integer)
467 and
op:operation(fenceHeight, xs:integer) => op:operation(xs:integer, xs:integer)
467. ).

The expression

op:operation(fenceHeight, xs:integer) => op:operation(xs:integer, xs:integer)
469 returns
let $para := 
In a hole in the ground there lived a hobbit.
         
184.

9.4.13 op:gMonth-equal

Summary

Returns true if the two

op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
969 values have the same starting instant, when considered as months in the same year.

Operator Mapping

Defines the semantics of the "eq" operator when applied to two

op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
969 values. Also used in the definition of the "ne" operator.

Signature

op:operation(fenceHeight, xs:integer) => op:operation(xs:integer, xs:integer)
084(
let $para := 
In a hole in the ground there lived a hobbit.
         
70
let $para := 
In a hole in the ground there lived a hobbit.
         
71
op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
969,
let $para := 
In a hole in the ground there lived a hobbit.
         
73
let $para := 
In a hole in the ground there lived a hobbit.
         
71
op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
969)
let $para := 
In a hole in the ground there lived a hobbit.
         
71
op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
32

Properties

This function is ·deterministic·, ·context-dependent·, and ·focus-independent·. It depends on implicit timezone.

Rules

The starting instants of

let $para := 
In a hole in the ground there lived a hobbit.
         
70 and
let $para := 
In a hole in the ground there lived a hobbit.
         
73 are calculated by supplying the missing components of
let $para := 
In a hole in the ground there lived a hobbit.
         
70 and
let $para := 
In a hole in the ground there lived a hobbit.
         
73 from the
let $para := 
In a hole in the ground there lived a hobbit.
         
29 template
op:operation(fenceHeight, xs:integer) => op:operation(xs:integer, xs:integer)
487 or an equivalent. The function returns the result of comparing these two starting instants using
op:operation(fenceHeight, xs:integer) => op:operation(xs:integer, xs:integer)
050.

Examples

Assume that the dynamic context provides an implicit timezone value of

op:operation(fenceHeight, xs:integer) => op:operation(xs:integer, xs:integer)
197. Assume, also, that the
let $para := 
In a hole in the ground there lived a hobbit.
         
29 template chosen is
op:operation(fenceHeight, xs:integer) => op:operation(xs:integer, xs:integer)
487.

The expression

op:operation(fenceHeight, xs:integer) => op:operation(xs:integer, xs:integer)
492 returns
let $para := 
In a hole in the ground there lived a hobbit.
         
184. ( The starting instants are
op:operation(fenceHeight, xs:integer) => op:operation(xs:integer, xs:integer)
494 and
op:operation(fenceHeight, xs:integer) => op:operation(xs:integer, xs:integer)
495, respectively, and normalize to
op:operation(fenceHeight, xs:integer) => op:operation(xs:integer, xs:integer)
496 and
op:operation(fenceHeight, xs:integer) => op:operation(xs:integer, xs:integer)
497. ).

The expression

op:operation(fenceHeight, xs:integer) => op:operation(xs:integer, xs:integer)
498 returns
let $para := 
In a hole in the ground there lived a hobbit.
         
184.

9.4.14 op:gDay-equal

Summary

Returns true if the two

op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
970 values have the same starting instant, when considered as days in the same month of the same year.

Operator Mapping

Defines the semantics of the "eq" operator when applied to two

op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
970 values. Also used in the definition of the "ne" operator.

Signature

op:operation(fenceHeight, xs:integer) => op:operation(xs:integer, xs:integer)
086(
let $para := 
In a hole in the ground there lived a hobbit.
         
70
let $para := 
In a hole in the ground there lived a hobbit.
         
71
op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
970,
let $para := 
In a hole in the ground there lived a hobbit.
         
73
let $para := 
In a hole in the ground there lived a hobbit.
         
71
op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
970)
let $para := 
In a hole in the ground there lived a hobbit.
         
71
op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
32

Properties

This function is ·deterministic·, ·context-dependent·, and ·focus-independent·. It depends on implicit timezone.

Rules

The starting instants of

let $para := 
In a hole in the ground there lived a hobbit.
         
70 and
let $para := 
In a hole in the ground there lived a hobbit.
         
73 are calculated by supplying the missing components of
let $para := 
In a hole in the ground there lived a hobbit.
         
70 and
let $para := 
In a hole in the ground there lived a hobbit.
         
73 from the
let $para := 
In a hole in the ground there lived a hobbit.
         
29 template
op:operation(fenceHeight, xs:integer) => op:operation(xs:integer, xs:integer)
516 or an equivalent. The function returns the result of comparing these two starting instants using
op:operation(fenceHeight, xs:integer) => op:operation(xs:integer, xs:integer)
050.

Examples

Assume that the dynamic context provides an implicit timezone value of

op:operation(fenceHeight, xs:integer) => op:operation(xs:integer, xs:integer)
197. Assume, also, that the
let $para := 
In a hole in the ground there lived a hobbit.
         
29 template is
op:operation(fenceHeight, xs:integer) => op:operation(xs:integer, xs:integer)
516.

The expression

op:operation(fenceHeight, xs:integer) => op:operation(xs:integer, xs:integer)
521 returns
let $para := 
In a hole in the ground there lived a hobbit.
         
184. ( The starting instants are
op:operation(fenceHeight, xs:integer) => op:operation(xs:integer, xs:integer)
465 and
op:operation(fenceHeight, xs:integer) => op:operation(xs:integer, xs:integer)
524, respectively, and normalize to
op:operation(fenceHeight, xs:integer) => op:operation(xs:integer, xs:integer)
467 and
op:operation(fenceHeight, xs:integer) => op:operation(xs:integer, xs:integer)
526. ).

The expression

op:operation(fenceHeight, xs:integer) => op:operation(xs:integer, xs:integer)
527 returns
let $para := 
In a hole in the ground there lived a hobbit.
         
184.

9.5 Component extraction functions on dates and times

The date and time datatypes may be considered to be composite datatypes in that they contain distinct properties or components. The extraction functions specified below extract a single component from a date or time value. In all cases the local value (that is, the original value as written, without any timezone adjustment) is used.

Note:

A time written as

op:operation(fenceHeight, xs:integer) => op:operation(xs:integer, xs:integer)
000 is treated as
op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
999 on the following day.

FunctionMeaning
op:operation(fenceHeight, xs:integer) => op:operation(xs:integer, xs:integer)
531Returns the year component of an
let $para := 
In a hole in the ground there lived a hobbit.
         
29.
op:operation(fenceHeight, xs:integer) => op:operation(xs:integer, xs:integer)
533Returns the month component of an
let $para := 
In a hole in the ground there lived a hobbit.
         
29.
op:operation(fenceHeight, xs:integer) => op:operation(xs:integer, xs:integer)
535Returns the day component of an
let $para := 
In a hole in the ground there lived a hobbit.
         
29.
op:operation(fenceHeight, xs:integer) => op:operation(xs:integer, xs:integer)
537Returns the hours component of an
let $para := 
In a hole in the ground there lived a hobbit.
         
29.
op:operation(fenceHeight, xs:integer) => op:operation(xs:integer, xs:integer)
539Returns the minute component of an
let $para := 
In a hole in the ground there lived a hobbit.
         
29.
op:operation(fenceHeight, xs:integer) => op:operation(xs:integer, xs:integer)
541Returns the seconds component of an
let $para := 
In a hole in the ground there lived a hobbit.
         
29.
let $para := 
In a hole in the ground there lived a hobbit.
         
89Returns the timezone component of an
let $para := 
In a hole in the ground there lived a hobbit.
         
29.
op:operation(fenceHeight, xs:integer) => op:operation(xs:integer, xs:integer)
545Returns the year component of an
op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
964.
op:operation(fenceHeight, xs:integer) => op:operation(xs:integer, xs:integer)
547Returns the month component of an
op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
964.
op:operation(fenceHeight, xs:integer) => op:operation(xs:integer, xs:integer)
549Returns the day component of an
op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
964.
op:operation(fenceHeight, xs:integer) => op:operation(xs:integer, xs:integer)
551Returns the timezone component of an
op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
964.
op:operation(fenceHeight, xs:integer) => op:operation(xs:integer, xs:integer)
553Returns the hours component of an
op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
965.
op:operation(fenceHeight, xs:integer) => op:operation(xs:integer, xs:integer)
555Returns the minutes component of an
op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
965.
op:operation(fenceHeight, xs:integer) => op:operation(xs:integer, xs:integer)
557Returns the seconds component of an
op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
965.
op:operation(fenceHeight, xs:integer) => op:operation(xs:integer, xs:integer)
559Returns the timezone component of an
op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
965.

9.5.1 fn:year-from-dateTime

Summary

Returns the year component of an

let $para := 
In a hole in the ground there lived a hobbit.
         
29.

Signature

op:operation(fenceHeight, xs:integer) => op:operation(xs:integer, xs:integer)
531(
let $para := 
In a hole in the ground there lived a hobbit.
         
25
let $para := 
In a hole in the ground there lived a hobbit.
         
71
op:operation(fenceHeight, xs:integer) => op:operation(xs:integer, xs:integer)
038)
let $para := 
In a hole in the ground there lived a hobbit.
         
71
let $para := 
In a hole in the ground there lived a hobbit.
         
229

Properties

This function is ·deterministic·, ·context-independent·, and ·focus-independent·.

Rules

If

let $para := 
In a hole in the ground there lived a hobbit.
         
25 is the empty sequence, the function returns the empty sequence.

Otherwise, the function returns an

let $para := 
In a hole in the ground there lived a hobbit.
         
85 representing the year component in the local value of
let $para := 
In a hole in the ground there lived a hobbit.
         
25. The result may be negative.

Notes

Ignoring complications that arise with midnight on the last day of the year, the year returned is the same numeric value that appears in the lexical representation, which for negative years means the meaning may vary depending on whether XSD 1.0 or XSD 1.1 conventions are in use.

Examples

The expression

op:operation(fenceHeight, xs:integer) => op:operation(xs:integer, xs:integer)
571 returns
op:operation(fenceHeight, xs:integer) => op:operation(xs:integer, xs:integer)
572.

The expression

op:operation(fenceHeight, xs:integer) => op:operation(xs:integer, xs:integer)
573 returns
op:operation(fenceHeight, xs:integer) => op:operation(xs:integer, xs:integer)
572.

The expression

op:operation(fenceHeight, xs:integer) => op:operation(xs:integer, xs:integer)
575 returns
op:operation(fenceHeight, xs:integer) => op:operation(xs:integer, xs:integer)
572.

The expression

op:operation(fenceHeight, xs:integer) => op:operation(xs:integer, xs:integer)
577 returns
op:operation(fenceHeight, xs:integer) => op:operation(xs:integer, xs:integer)
578.

The expression

op:operation(fenceHeight, xs:integer) => op:operation(xs:integer, xs:integer)
579 returns
op:operation(fenceHeight, xs:integer) => op:operation(xs:integer, xs:integer)
580. (The result is the same whether XSD 1.0 or 1.1 is in use, despite the absence of a year 0 in the XSD 1.0 value space.)

9.5.2 fn:month-from-dateTime

Summary

Returns the month component of an

let $para := 
In a hole in the ground there lived a hobbit.
         
29.

Signature

op:operation(fenceHeight, xs:integer) => op:operation(xs:integer, xs:integer)
533(
let $para := 
In a hole in the ground there lived a hobbit.
         
25
let $para := 
In a hole in the ground there lived a hobbit.
         
71
op:operation(fenceHeight, xs:integer) => op:operation(xs:integer, xs:integer)
038)
let $para := 
In a hole in the ground there lived a hobbit.
         
71
let $para := 
In a hole in the ground there lived a hobbit.
         
229

Properties

This function is ·deterministic·, ·context-independent·, and ·focus-independent·.

Rules

If

let $para := 
In a hole in the ground there lived a hobbit.
         
25 is the empty sequence, the function returns the empty sequence.

Otherwise, the function returns an

let $para := 
In a hole in the ground there lived a hobbit.
         
85 between 1 and 12, both inclusive, representing the month component in the local value of
let $para := 
In a hole in the ground there lived a hobbit.
         
25.

Examples

The expression

op:operation(fenceHeight, xs:integer) => op:operation(xs:integer, xs:integer)
591 returns
declare %public function r:random-sequence($length as xs:integer) as xs:double* {
  r:random-sequence($length, fn:random-number-generator())
};

declare %private function r:random-sequence($length as xs:integer, 
                                            $G as map(xs:string, item())) {
  if ($length eq 0)
  then ()
  else ($G?number, r:random-sequence($length - 1, $G?next()))
};

r:random-sequence(200);
            
21.

The expression

op:operation(fenceHeight, xs:integer) => op:operation(xs:integer, xs:integer)
593 returns
op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
700.

The expression

op:operation(fenceHeight, xs:integer) => op:operation(xs:integer, xs:integer)
595 returns
declare %public function r:random-sequence($length as xs:integer) as xs:double* {
  r:random-sequence($length, fn:random-number-generator())
};

declare %private function r:random-sequence($length as xs:integer, 
                                            $G as map(xs:string, item())) {
  if ($length eq 0)
  then ()
  else ($G?number, r:random-sequence($length - 1, $G?next()))
};

r:random-sequence(200);
            
13.

9.5.3 fn:day-from-dateTime

Summary

Returns the day component of an

let $para := 
In a hole in the ground there lived a hobbit.
         
29.

Signature

op:operation(fenceHeight, xs:integer) => op:operation(xs:integer, xs:integer)
535(
let $para := 
In a hole in the ground there lived a hobbit.
         
25
let $para := 
In a hole in the ground there lived a hobbit.
         
71
op:operation(fenceHeight, xs:integer) => op:operation(xs:integer, xs:integer)
038)
let $para := 
In a hole in the ground there lived a hobbit.
         
71
let $para := 
In a hole in the ground there lived a hobbit.
         
229

Properties

This function is ·deterministic·, ·context-independent·, and ·focus-independent·.

Rules

If

let $para := 
In a hole in the ground there lived a hobbit.
         
25 is the empty sequence, the function returns the empty sequence.

Otherwise, the function returns an

let $para := 
In a hole in the ground there lived a hobbit.
         
85 between 1 and 31, both inclusive, representing the day component in the local value of
let $para := 
In a hole in the ground there lived a hobbit.
         
25.

Examples

The expression

op:operation(fenceHeight, xs:integer) => op:operation(xs:integer, xs:integer)
607 returns
op:operation(fenceHeight, xs:integer) => op:operation(xs:integer, xs:integer)
608.

The expression

op:operation(fenceHeight, xs:integer) => op:operation(xs:integer, xs:integer)
609 returns
op:operation(fenceHeight, xs:integer) => op:operation(xs:integer, xs:integer)
608.

The expression

op:operation(fenceHeight, xs:integer) => op:operation(xs:integer, xs:integer)
611 returns
declare %public function r:random-sequence($length as xs:integer) as xs:double* {
  r:random-sequence($length, fn:random-number-generator())
};

declare %private function r:random-sequence($length as xs:integer, 
                                            $G as map(xs:string, item())) {
  if ($length eq 0)
  then ()
  else ($G?number, r:random-sequence($length - 1, $G?next()))
};

r:random-sequence(200);
            
13.

9.5.4 fn:hours-from-dateTime

Summary

Returns the hours component of an

let $para := 
In a hole in the ground there lived a hobbit.
         
29.

Signature

op:operation(fenceHeight, xs:integer) => op:operation(xs:integer, xs:integer)
537(
let $para := 
In a hole in the ground there lived a hobbit.
         
25
let $para := 
In a hole in the ground there lived a hobbit.
         
71
op:operation(fenceHeight, xs:integer) => op:operation(xs:integer, xs:integer)
038)
let $para := 
In a hole in the ground there lived a hobbit.
         
71
let $para := 
In a hole in the ground there lived a hobbit.
         
229

Properties

This function is ·deterministic·, ·context-independent·, and ·focus-independent·.

Rules

If

let $para := 
In a hole in the ground there lived a hobbit.
         
25 is the empty sequence, the function returns the empty sequence.

Otherwise, the function returns an

let $para := 
In a hole in the ground there lived a hobbit.
         
85 between 0 and 23, both inclusive, representing the hours component in the local value of
let $para := 
In a hole in the ground there lived a hobbit.
         
25.

Examples

The expression

op:operation(fenceHeight, xs:integer) => op:operation(xs:integer, xs:integer)
623 returns
op:operation(fenceHeight, xs:integer) => op:operation(xs:integer, xs:integer)
624.

The expression

op:operation(fenceHeight, xs:integer) => op:operation(xs:integer, xs:integer)
625 returns
op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
638.

The expression

op:operation(fenceHeight, xs:integer) => op:operation(xs:integer, xs:integer)
627 returns
let $para := 
In a hole in the ground there lived a hobbit.
         
226.

The expression

op:operation(fenceHeight, xs:integer) => op:operation(xs:integer, xs:integer)
629 returns
op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
700.

The expression

op:operation(fenceHeight, xs:integer) => op:operation(xs:integer, xs:integer)
631 returns
declare %public function r:random-sequence($length as xs:integer) as xs:double* {
  r:random-sequence($length, fn:random-number-generator())
};

declare %private function r:random-sequence($length as xs:integer, 
                                            $G as map(xs:string, item())) {
  if ($length eq 0)
  then ()
  else ($G?number, r:random-sequence($length - 1, $G?next()))
};

r:random-sequence(200);
            
19.

9.5.5 fn:minutes-from-dateTime

Summary

Returns the minute component of an

let $para := 
In a hole in the ground there lived a hobbit.
         
29.

Signature

op:operation(fenceHeight, xs:integer) => op:operation(xs:integer, xs:integer)
539(
let $para := 
In a hole in the ground there lived a hobbit.
         
25
let $para := 
In a hole in the ground there lived a hobbit.
         
71
op:operation(fenceHeight, xs:integer) => op:operation(xs:integer, xs:integer)
038)
let $para := 
In a hole in the ground there lived a hobbit.
         
71
let $para := 
In a hole in the ground there lived a hobbit.
         
229

Properties

This function is ·deterministic·, ·context-independent·, and ·focus-independent·.

Rules

If

let $para := 
In a hole in the ground there lived a hobbit.
         
25 is the empty sequence, the function returns the empty sequence.

Otherwise, the function returns an

let $para := 
In a hole in the ground there lived a hobbit.
         
85 value between 0 and 59, both inclusive, representing the minute component in the local value of
let $para := 
In a hole in the ground there lived a hobbit.
         
25.

Examples

The expression

op:operation(fenceHeight, xs:integer) => op:operation(xs:integer, xs:integer)
643 returns
op:operation(fenceHeight, xs:integer) => op:operation(xs:integer, xs:integer)
644.

The expression

op:operation(fenceHeight, xs:integer) => op:operation(xs:integer, xs:integer)
645 returns
op:operation(fenceHeight, xs:integer) => op:operation(xs:integer, xs:integer)
646.

9.5.6 fn:seconds-from-dateTime

Summary

Returns the seconds component of an

let $para := 
In a hole in the ground there lived a hobbit.
         
29.

Signature

op:operation(fenceHeight, xs:integer) => op:operation(xs:integer, xs:integer)
541(
let $para := 
In a hole in the ground there lived a hobbit.
         
25
let $para := 
In a hole in the ground there lived a hobbit.
         
71
op:operation(fenceHeight, xs:integer) => op:operation(xs:integer, xs:integer)
038)
let $para := 
In a hole in the ground there lived a hobbit.
         
71
op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
728

Properties

This function is ·deterministic·, ·context-independent·, and ·focus-independent·.

Rules

If

let $para := 
In a hole in the ground there lived a hobbit.
         
25 is the empty sequence, the function returns the empty sequence.

Otherwise, the function returns an

let $para := 
In a hole in the ground there lived a hobbit.
         
82 value greater than or equal to zero and less than 60, representing the seconds and fractional seconds in the local value of
let $para := 
In a hole in the ground there lived a hobbit.
         
25.

Examples

The expression

op:operation(fenceHeight, xs:integer) => op:operation(xs:integer, xs:integer)
657 returns
declare %public function r:random-sequence($length as xs:integer) as xs:double* {
  r:random-sequence($length, fn:random-number-generator())
};

declare %private function r:random-sequence($length as xs:integer, 
                                            $G as map(xs:string, item())) {
  if ($length eq 0)
  then ()
  else ($G?number, r:random-sequence($length - 1, $G?next()))
};

r:random-sequence(200);
            
19.

9.5.7 fn:timezone-from-dateTime

Summary

Returns the timezone component of an

let $para := 
In a hole in the ground there lived a hobbit.
         
29.

Signature

let $para := 
In a hole in the ground there lived a hobbit.
         
89(
let $para := 
In a hole in the ground there lived a hobbit.
         
25
let $para := 
In a hole in the ground there lived a hobbit.
         
71
op:operation(fenceHeight, xs:integer) => op:operation(xs:integer, xs:integer)
038)
let $para := 
In a hole in the ground there lived a hobbit.
         
71
op:operation(fenceHeight, xs:integer) => op:operation(xs:integer, xs:integer)
665

Properties

This function is ·deterministic·, ·context-independent·, and ·focus-independent·.

Rules

If

let $para := 
In a hole in the ground there lived a hobbit.
         
25 is the empty sequence, the function returns the empty sequence.

Otherwise, the function returns the timezone component of

let $para := 
In a hole in the ground there lived a hobbit.
         
25, if any. If
let $para := 
In a hole in the ground there lived a hobbit.
         
25 has a timezone component, then the result is an
let $para := 
In a hole in the ground there lived a hobbit.
         
25 that indicates deviation from UTC; its value may range from +14:00 to -14:00 hours, both inclusive. If
let $para := 
In a hole in the ground there lived a hobbit.
         
25 has no timezone component, the result is the empty sequence.

Examples

The expression

op:operation(fenceHeight, xs:integer) => op:operation(xs:integer, xs:integer)
671 returns
op:operation(fenceHeight, xs:integer) => op:operation(xs:integer, xs:integer)
672.

The expression

op:operation(fenceHeight, xs:integer) => op:operation(xs:integer, xs:integer)
673 returns
op:operation(fenceHeight, xs:integer) => op:operation(xs:integer, xs:integer)
674.

The expression

op:operation(fenceHeight, xs:integer) => op:operation(xs:integer, xs:integer)
675 returns
let $para := 
In a hole in the ground there lived a hobbit.
         
96.

9.5.8 fn:year-from-date

Summary

Returns the year component of an

op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
964.

Signature

op:operation(fenceHeight, xs:integer) => op:operation(xs:integer, xs:integer)
545(
let $para := 
In a hole in the ground there lived a hobbit.
         
25
let $para := 
In a hole in the ground there lived a hobbit.
         
71
op:operation(fenceHeight, xs:integer) => op:operation(xs:integer, xs:integer)
033)
let $para := 
In a hole in the ground there lived a hobbit.
         
71
let $para := 
In a hole in the ground there lived a hobbit.
         
229

Properties

This function is ·deterministic·, ·context-independent·, and ·focus-independent·.

Rules

If

let $para := 
In a hole in the ground there lived a hobbit.
         
25 is the empty sequence, the function returns the empty sequence.

Otherwise, the function returns an

let $para := 
In a hole in the ground there lived a hobbit.
         
85 representing the year in the local value of
let $para := 
In a hole in the ground there lived a hobbit.
         
25. The value may be negative.

Notes

The year returned is the same numeric value that appears in the lexical representation, which for negative years means the meaning may vary depending on whether XSD 1.0 or XSD 1.1 conventions are in use.

Examples

The expression

op:operation(fenceHeight, xs:integer) => op:operation(xs:integer, xs:integer)
687 returns
op:operation(fenceHeight, xs:integer) => op:operation(xs:integer, xs:integer)
572.

The expression

op:operation(fenceHeight, xs:integer) => op:operation(xs:integer, xs:integer)
689 returns
op:operation(fenceHeight, xs:integer) => op:operation(xs:integer, xs:integer)
578.

The expression

op:operation(fenceHeight, xs:integer) => op:operation(xs:integer, xs:integer)
691 returns
op:operation(fenceHeight, xs:integer) => op:operation(xs:integer, xs:integer)
580. (The result is the same whether XSD 1.0 or 1.1 is in use, despite the absence of a year 0 in the XSD 1.0 value space.)

9.5.9 fn:month-from-date

Summary

Returns the month component of an

op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
964.

Signature

op:operation(fenceHeight, xs:integer) => op:operation(xs:integer, xs:integer)
547(
let $para := 
In a hole in the ground there lived a hobbit.
         
25
let $para := 
In a hole in the ground there lived a hobbit.
         
71
op:operation(fenceHeight, xs:integer) => op:operation(xs:integer, xs:integer)
033)
let $para := 
In a hole in the ground there lived a hobbit.
         
71
let $para := 
In a hole in the ground there lived a hobbit.
         
229

Properties

This function is ·deterministic·, ·context-independent·, and ·focus-independent·.

Rules

If

let $para := 
In a hole in the ground there lived a hobbit.
         
25 is the empty sequence, the function returns the empty sequence.

Otherwise, the function returns an

let $para := 
In a hole in the ground there lived a hobbit.
         
85 between 1 and 12, both inclusive, representing the month component in the local value of
let $para := 
In a hole in the ground there lived a hobbit.
         
25.

Examples

The expression

op:operation(fenceHeight, xs:integer) => op:operation(xs:integer, xs:integer)
703 returns
declare %public function r:random-sequence($length as xs:integer) as xs:double* {
  r:random-sequence($length, fn:random-number-generator())
};

declare %private function r:random-sequence($length as xs:integer, 
                                            $G as map(xs:string, item())) {
  if ($length eq 0)
  then ()
  else ($G?number, r:random-sequence($length - 1, $G?next()))
};

r:random-sequence(200);
            
21.

The expression

op:operation(fenceHeight, xs:integer) => op:operation(xs:integer, xs:integer)
705 returns
declare %public function r:random-sequence($length as xs:integer) as xs:double* {
  r:random-sequence($length, fn:random-number-generator())
};

declare %private function r:random-sequence($length as xs:integer, 
                                            $G as map(xs:string, item())) {
  if ($length eq 0)
  then ()
  else ($G?number, r:random-sequence($length - 1, $G?next()))
};

r:random-sequence(200);
            
13.

9.5.10 fn:day-from-date

Summary

Returns the day component of an

op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
964.

Signature

op:operation(fenceHeight, xs:integer) => op:operation(xs:integer, xs:integer)
549(
let $para := 
In a hole in the ground there lived a hobbit.
         
25
let $para := 
In a hole in the ground there lived a hobbit.
         
71
op:operation(fenceHeight, xs:integer) => op:operation(xs:integer, xs:integer)
033)
let $para := 
In a hole in the ground there lived a hobbit.
         
71
let $para := 
In a hole in the ground there lived a hobbit.
         
229

Properties

This function is ·deterministic·, ·context-independent·, and ·focus-independent·.

Rules

If

let $para := 
In a hole in the ground there lived a hobbit.
         
25 is the empty sequence, the function returns the empty sequence.

Otherwise, the function returns an

let $para := 
In a hole in the ground there lived a hobbit.
         
85 between 1 and 31, both inclusive, representing the day component in the localized value of
let $para := 
In a hole in the ground there lived a hobbit.
         
25.

Examples

The expression

op:operation(fenceHeight, xs:integer) => op:operation(xs:integer, xs:integer)
717 returns
op:operation(fenceHeight, xs:integer) => op:operation(xs:integer, xs:integer)
608.

The expression

op:operation(fenceHeight, xs:integer) => op:operation(xs:integer, xs:integer)
719 returns
declare %public function r:random-sequence($length as xs:integer) as xs:double* {
  r:random-sequence($length, fn:random-number-generator())
};

declare %private function r:random-sequence($length as xs:integer, 
                                            $G as map(xs:string, item())) {
  if ($length eq 0)
  then ()
  else ($G?number, r:random-sequence($length - 1, $G?next()))
};

r:random-sequence(200);
            
13.

9.5.11 fn:timezone-from-date

Summary

Returns the timezone component of an

op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
964.

Signature

op:operation(fenceHeight, xs:integer) => op:operation(xs:integer, xs:integer)
551(
let $para := 
In a hole in the ground there lived a hobbit.
         
25
let $para := 
In a hole in the ground there lived a hobbit.
         
71
op:operation(fenceHeight, xs:integer) => op:operation(xs:integer, xs:integer)
033)
let $para := 
In a hole in the ground there lived a hobbit.
         
71
op:operation(fenceHeight, xs:integer) => op:operation(xs:integer, xs:integer)
665

Properties

This function is ·deterministic·, ·context-independent·, and ·focus-independent·.

Rules

If

let $para := 
In a hole in the ground there lived a hobbit.
         
25 is the empty sequence, the function returns the empty sequence.

Otherwise, the function returns the timezone component of

let $para := 
In a hole in the ground there lived a hobbit.
         
25, if any. If
let $para := 
In a hole in the ground there lived a hobbit.
         
25 has a timezone component, then the result is an
let $para := 
In a hole in the ground there lived a hobbit.
         
25 that indicates deviation from UTC; its value may range from +14:00 to -14:00 hours, both inclusive. If
let $para := 
In a hole in the ground there lived a hobbit.
         
25 has no timezone component, the result is the empty sequence.

Examples

The expression

op:operation(fenceHeight, xs:integer) => op:operation(xs:integer, xs:integer)
733 returns
op:operation(fenceHeight, xs:integer) => op:operation(xs:integer, xs:integer)
672.

The expression

op:operation(fenceHeight, xs:integer) => op:operation(xs:integer, xs:integer)
735 returns
op:operation(fenceHeight, xs:integer) => op:operation(xs:integer, xs:integer)
674.

9.5.12 fn:hours-from-time

Summary

Returns the hours component of an

op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
965.

Signature

op:operation(fenceHeight, xs:integer) => op:operation(xs:integer, xs:integer)
553(
let $para := 
In a hole in the ground there lived a hobbit.
         
25
let $para := 
In a hole in the ground there lived a hobbit.
         
71
op:operation(fenceHeight, xs:integer) => op:operation(xs:integer, xs:integer)
036)
let $para := 
In a hole in the ground there lived a hobbit.
         
71
let $para := 
In a hole in the ground there lived a hobbit.
         
229

Properties

This function is ·deterministic·, ·context-independent·, and ·focus-independent·.

Rules

If

let $para := 
In a hole in the ground there lived a hobbit.
         
25 is the empty sequence, the function returns the empty sequence.

Otherwise, the function returns an

let $para := 
In a hole in the ground there lived a hobbit.
         
85 between 0 and 23, both inclusive, representing the value of the hours component in the local value of
let $para := 
In a hole in the ground there lived a hobbit.
         
25.

Examples

Assume that the dynamic context provides an implicit timezone value of

op:operation(fenceHeight, xs:integer) => op:operation(xs:integer, xs:integer)
197.

The expression

op:operation(fenceHeight, xs:integer) => op:operation(xs:integer, xs:integer)
748 returns
let $para := 
In a hole in the ground there lived a hobbit.
         
032.

The expression

op:operation(fenceHeight, xs:integer) => op:operation(xs:integer, xs:integer)
750 returns
op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
638.

The expression

op:operation(fenceHeight, xs:integer) => op:operation(xs:integer, xs:integer)
752 returns
declare %public function r:random-sequence($length as xs:integer) as xs:double* {
  r:random-sequence($length, fn:random-number-generator())
};

declare %private function r:random-sequence($length as xs:integer, 
                                            $G as map(xs:string, item())) {
  if ($length eq 0)
  then ()
  else ($G?number, r:random-sequence($length - 1, $G?next()))
};

r:random-sequence(200);
            
13.

The expression

op:operation(fenceHeight, xs:integer) => op:operation(xs:integer, xs:integer)
754 returns
op:operation(fenceHeight, xs:integer) => op:operation(xs:integer, xs:integer)
644.

The expression

op:operation(fenceHeight, xs:integer) => op:operation(xs:integer, xs:integer)
756 returns
declare %public function r:random-sequence($length as xs:integer) as xs:double* {
  r:random-sequence($length, fn:random-number-generator())
};

declare %private function r:random-sequence($length as xs:integer, 
                                            $G as map(xs:string, item())) {
  if ($length eq 0)
  then ()
  else ($G?number, r:random-sequence($length - 1, $G?next()))
};

r:random-sequence(200);
            
19.

9.5.13 fn:minutes-from-time

Summary

Returns the minutes component of an

op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
965.

Signature

op:operation(fenceHeight, xs:integer) => op:operation(xs:integer, xs:integer)
555(
let $para := 
In a hole in the ground there lived a hobbit.
         
25
let $para := 
In a hole in the ground there lived a hobbit.
         
71
op:operation(fenceHeight, xs:integer) => op:operation(xs:integer, xs:integer)
036)
let $para := 
In a hole in the ground there lived a hobbit.
         
71
let $para := 
In a hole in the ground there lived a hobbit.
         
229

Properties

This function is ·deterministic·, ·context-independent·, and ·focus-independent·.

Rules

If

let $para := 
In a hole in the ground there lived a hobbit.
         
25 is the empty sequence, the function returns the empty sequence.

Otherwise, the function returns an

let $para := 
In a hole in the ground there lived a hobbit.
         
85 value between 0 and 59, both inclusive, representing the value of the minutes component in the local value of
let $para := 
In a hole in the ground there lived a hobbit.
         
25.

Examples

The expression

op:operation(fenceHeight, xs:integer) => op:operation(xs:integer, xs:integer)
768 returns
declare %public function r:random-sequence($length as xs:integer) as xs:double* {
  r:random-sequence($length, fn:random-number-generator())
};

declare %private function r:random-sequence($length as xs:integer, 
                                            $G as map(xs:string, item())) {
  if ($length eq 0)
  then ()
  else ($G?number, r:random-sequence($length - 1, $G?next()))
};

r:random-sequence(200);
            
19.

9.5.14 fn:seconds-from-time

Summary

Returns the seconds component of an

op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
965.

Signature

op:operation(fenceHeight, xs:integer) => op:operation(xs:integer, xs:integer)
557(
let $para := 
In a hole in the ground there lived a hobbit.
         
25
let $para := 
In a hole in the ground there lived a hobbit.
         
71
op:operation(fenceHeight, xs:integer) => op:operation(xs:integer, xs:integer)
036)
let $para := 
In a hole in the ground there lived a hobbit.
         
71
op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
728

Properties

This function is ·deterministic·, ·context-independent·, and ·focus-independent·.

Rules

If

let $para := 
In a hole in the ground there lived a hobbit.
         
25 is the empty sequence, the function returns the empty sequence.

Otherwise, the function returns an

let $para := 
In a hole in the ground there lived a hobbit.
         
82 value greater than or equal to zero and less than 60, representing the seconds and fractional seconds in the local value of
let $para := 
In a hole in the ground there lived a hobbit.
         
25.

Examples

The expression

op:operation(fenceHeight, xs:integer) => op:operation(xs:integer, xs:integer)
780 returns
let $para := 
In a hole in the ground there lived a hobbit.
         
010.

9.5.15 fn:timezone-from-time

Summary

Returns the timezone component of an

op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
965.

Signature

op:operation(fenceHeight, xs:integer) => op:operation(xs:integer, xs:integer)
559(
let $para := 
In a hole in the ground there lived a hobbit.
         
25
let $para := 
In a hole in the ground there lived a hobbit.
         
71
op:operation(fenceHeight, xs:integer) => op:operation(xs:integer, xs:integer)
036)
let $para := 
In a hole in the ground there lived a hobbit.
         
71
op:operation(fenceHeight, xs:integer) => op:operation(xs:integer, xs:integer)
665

Properties

This function is ·deterministic·, ·context-independent·, and ·focus-independent·.

Rules

If

let $para := 
In a hole in the ground there lived a hobbit.
         
25 is the empty sequence, the function returns the empty sequence.

Otherwise, the function returns the timezone component of

let $para := 
In a hole in the ground there lived a hobbit.
         
25, if any. If
let $para := 
In a hole in the ground there lived a hobbit.
         
25 has a timezone component, then the result is an
let $para := 
In a hole in the ground there lived a hobbit.
         
25 that indicates deviation from UTC; its value may range from +14:00 to -14:00 hours, both inclusive. If
let $para := 
In a hole in the ground there lived a hobbit.
         
25 has no timezone component, the result is the empty sequence.

Examples

The expression

op:operation(fenceHeight, xs:integer) => op:operation(xs:integer, xs:integer)
794 returns
op:operation(fenceHeight, xs:integer) => op:operation(xs:integer, xs:integer)
672.

The expression

op:operation(fenceHeight, xs:integer) => op:operation(xs:integer, xs:integer)
796 returns
let $para := 
In a hole in the ground there lived a hobbit.
         
96.

9.6 Timezone adjustment functions on dates and time values

FunctionMeaning
let $para := 
In a hole in the ground there lived a hobbit.
         
86Adjusts an
let $para := 
In a hole in the ground there lived a hobbit.
         
29 value to a specific timezone, or to no timezone at all.
let $para := 
In a hole in the ground there lived a hobbit.
         
85Adjusts an
op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
964 value to a specific timezone, or to no timezone at all; the result is the date in the target timezone that contains the starting instant of the supplied date.
let $para := 
In a hole in the ground there lived a hobbit.
         
87Adjusts an
op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
965 value to a specific timezone, or to no timezone at all.

These functions adjust the timezone component of an

let $para := 
In a hole in the ground there lived a hobbit.
         
29,
op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
964 or
op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
965 value. The
op:operation(fenceHeight, xs:integer) => op:operation(xs:integer, xs:integer)
807 argument to these functions is defined as an
let $para := 
In a hole in the ground there lived a hobbit.
         
25 but must be a valid timezone value.

9.6.1 fn:adjust-dateTime-to-timezone

Summary

Adjusts an

let $para := 
In a hole in the ground there lived a hobbit.
         
29 value to a specific timezone, or to no timezone at all.

Signatures

let $para := 
In a hole in the ground there lived a hobbit.
         
86(
let $para := 
In a hole in the ground there lived a hobbit.
         
25
let $para := 
In a hole in the ground there lived a hobbit.
         
71
op:operation(fenceHeight, xs:integer) => op:operation(xs:integer, xs:integer)
038)
let $para := 
In a hole in the ground there lived a hobbit.
         
71
op:operation(fenceHeight, xs:integer) => op:operation(xs:integer, xs:integer)
038

let $para := 
In a hole in the ground there lived a hobbit.
         
86(
let $para := 
In a hole in the ground there lived a hobbit.
         
25
let $para := 
In a hole in the ground there lived a hobbit.
         
71
op:operation(fenceHeight, xs:integer) => op:operation(xs:integer, xs:integer)
038,
op:operation(fenceHeight, xs:integer) => op:operation(xs:integer, xs:integer)
807
let $para := 
In a hole in the ground there lived a hobbit.
         
71
op:operation(fenceHeight, xs:integer) => op:operation(xs:integer, xs:integer)
665)
let $para := 
In a hole in the ground there lived a hobbit.
         
71
op:operation(fenceHeight, xs:integer) => op:operation(xs:integer, xs:integer)
038

Properties

The one-argument form of this function is ·deterministic·, ·context-dependent·, and ·focus-independent·. It depends on implicit timezone.

The two-argument form of this function is ·deterministic·, ·context-independent·, and ·focus-independent·.

Rules

If

op:operation(fenceHeight, xs:integer) => op:operation(xs:integer, xs:integer)
807 is not specified, then the effective value of
op:operation(fenceHeight, xs:integer) => op:operation(xs:integer, xs:integer)
807 is the value of the implicit timezone in the dynamic context.

If

let $para := 
In a hole in the ground there lived a hobbit.
         
25 is the empty sequence, then the function returns the empty sequence.

If

let $para := 
In a hole in the ground there lived a hobbit.
         
25 does not have a timezone component and
op:operation(fenceHeight, xs:integer) => op:operation(xs:integer, xs:integer)
807 is the empty sequence, then the result is
let $para := 
In a hole in the ground there lived a hobbit.
         
25.

If

let $para := 
In a hole in the ground there lived a hobbit.
         
25 does not have a timezone component and
op:operation(fenceHeight, xs:integer) => op:operation(xs:integer, xs:integer)
807 is not the empty sequence, then the result is
let $para := 
In a hole in the ground there lived a hobbit.
         
25 with
op:operation(fenceHeight, xs:integer) => op:operation(xs:integer, xs:integer)
807 as the timezone component.

If

let $para := 
In a hole in the ground there lived a hobbit.
         
25 has a timezone component and
op:operation(fenceHeight, xs:integer) => op:operation(xs:integer, xs:integer)
807 is the empty sequence, then the result is the local value of
let $para := 
In a hole in the ground there lived a hobbit.
         
25 without its timezone component.

If

let $para := 
In a hole in the ground there lived a hobbit.
         
25 has a timezone component and
op:operation(fenceHeight, xs:integer) => op:operation(xs:integer, xs:integer)
807 is not the empty sequence, then the result is the
let $para := 
In a hole in the ground there lived a hobbit.
         
29 value that is equal to
let $para := 
In a hole in the ground there lived a hobbit.
         
25 and that has a timezone component equal to
op:operation(fenceHeight, xs:integer) => op:operation(xs:integer, xs:integer)
807.

Error Conditions

A dynamic error is raised [err:FODT0003] if

op:operation(fenceHeight, xs:integer) => op:operation(xs:integer, xs:integer)
807 is less than
op:operation(fenceHeight, xs:integer) => op:operation(xs:integer, xs:integer)
844 or greater than
op:operation(fenceHeight, xs:integer) => op:operation(xs:integer, xs:integer)
845 or is not an integral number of minutes.

Examples

Assume the dynamic context provides an implicit timezone of

op:operation(fenceHeight, xs:integer) => op:operation(xs:integer, xs:integer)
846.

let $para := 
In a hole in the ground there lived a hobbit.
         
6

The expression

op:operation(fenceHeight, xs:integer) => op:operation(xs:integer, xs:integer)
847 returns
op:operation(fenceHeight, xs:integer) => op:operation(xs:integer, xs:integer)
848.

The expression

op:operation(fenceHeight, xs:integer) => op:operation(xs:integer, xs:integer)
849 returns
op:operation(fenceHeight, xs:integer) => op:operation(xs:integer, xs:integer)
850.

The expression

op:operation(fenceHeight, xs:integer) => op:operation(xs:integer, xs:integer)
851 returns
op:operation(fenceHeight, xs:integer) => op:operation(xs:integer, xs:integer)
852.

The expression

op:operation(fenceHeight, xs:integer) => op:operation(xs:integer, xs:integer)
853 returns
op:operation(fenceHeight, xs:integer) => op:operation(xs:integer, xs:integer)
854.

The expression

op:operation(fenceHeight, xs:integer) => op:operation(xs:integer, xs:integer)
855 returns
op:operation(fenceHeight, xs:integer) => op:operation(xs:integer, xs:integer)
856.

The expression

op:operation(fenceHeight, xs:integer) => op:operation(xs:integer, xs:integer)
857 returns
op:operation(fenceHeight, xs:integer) => op:operation(xs:integer, xs:integer)
858.

The expression

op:operation(fenceHeight, xs:integer) => op:operation(xs:integer, xs:integer)
859 returns
op:operation(fenceHeight, xs:integer) => op:operation(xs:integer, xs:integer)
860.

The expression

op:operation(fenceHeight, xs:integer) => op:operation(xs:integer, xs:integer)
861 returns
op:operation(fenceHeight, xs:integer) => op:operation(xs:integer, xs:integer)
860.

9.6.2 fn:adjust-date-to-timezone

Summary

Adjusts an

op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
964 value to a specific timezone, or to no timezone at all; the result is the date in the target timezone that contains the starting instant of the supplied date.

Signatures

let $para := 
In a hole in the ground there lived a hobbit.
         
85(
let $para := 
In a hole in the ground there lived a hobbit.
         
25
let $para := 
In a hole in the ground there lived a hobbit.
         
71
op:operation(fenceHeight, xs:integer) => op:operation(xs:integer, xs:integer)
033)
let $para := 
In a hole in the ground there lived a hobbit.
         
71
op:operation(fenceHeight, xs:integer) => op:operation(xs:integer, xs:integer)
033

let $para := 
In a hole in the ground there lived a hobbit.
         
85(
let $para := 
In a hole in the ground there lived a hobbit.
         
25
let $para := 
In a hole in the ground there lived a hobbit.
         
71
op:operation(fenceHeight, xs:integer) => op:operation(xs:integer, xs:integer)
033,
op:operation(fenceHeight, xs:integer) => op:operation(xs:integer, xs:integer)
807
let $para := 
In a hole in the ground there lived a hobbit.
         
71
op:operation(fenceHeight, xs:integer) => op:operation(xs:integer, xs:integer)
665)
let $para := 
In a hole in the ground there lived a hobbit.
         
71
op:operation(fenceHeight, xs:integer) => op:operation(xs:integer, xs:integer)
033

Properties

The one-argument form of this function is ·deterministic·, ·context-dependent·, and ·focus-independent·. It depends on implicit timezone.

The two-argument form of this function is ·deterministic·, ·context-independent·, and ·focus-independent·.

Rules

If

op:operation(fenceHeight, xs:integer) => op:operation(xs:integer, xs:integer)
807 is not specified, then the effective value of
op:operation(fenceHeight, xs:integer) => op:operation(xs:integer, xs:integer)
807 is the value of the implicit timezone in the dynamic context.

If

let $para := 
In a hole in the ground there lived a hobbit.
         
25 is the empty sequence, then the function returns the empty sequence.

If

let $para := 
In a hole in the ground there lived a hobbit.
         
25 does not have a timezone component and
op:operation(fenceHeight, xs:integer) => op:operation(xs:integer, xs:integer)
807 is the empty sequence, then the result is the value of
let $para := 
In a hole in the ground there lived a hobbit.
         
25.

If

let $para := 
In a hole in the ground there lived a hobbit.
         
25 does not have a timezone component and
op:operation(fenceHeight, xs:integer) => op:operation(xs:integer, xs:integer)
807 is not the empty sequence, then the result is
let $para := 
In a hole in the ground there lived a hobbit.
         
25 with
op:operation(fenceHeight, xs:integer) => op:operation(xs:integer, xs:integer)
807 as the timezone component.

If

let $para := 
In a hole in the ground there lived a hobbit.
         
25 has a timezone component and
op:operation(fenceHeight, xs:integer) => op:operation(xs:integer, xs:integer)
807 is the empty sequence, then the result is the local value of
let $para := 
In a hole in the ground there lived a hobbit.
         
25 without its timezone component.

If

let $para := 
In a hole in the ground there lived a hobbit.
         
25 has a timezone component and
op:operation(fenceHeight, xs:integer) => op:operation(xs:integer, xs:integer)
807 is not the empty sequence, then the function returns the value of the expression:

  • Let

    op:operation(fenceHeight, xs:integer) => op:operation(xs:integer, xs:integer)
    894 be the value of
    op:operation(fenceHeight, xs:integer) => op:operation(xs:integer, xs:integer)
    895.

  • Let

    op:operation(fenceHeight, xs:integer) => op:operation(xs:integer, xs:integer)
    896 be the value of
    op:operation(fenceHeight, xs:integer) => op:operation(xs:integer, xs:integer)
    897

  • The function returns the value of

    op:operation(fenceHeight, xs:integer) => op:operation(xs:integer, xs:integer)
    898

Error Conditions

A dynamic error is raised [err:FODT0003] if

op:operation(fenceHeight, xs:integer) => op:operation(xs:integer, xs:integer)
807 is less than
op:operation(fenceHeight, xs:integer) => op:operation(xs:integer, xs:integer)
844 or greater than
op:operation(fenceHeight, xs:integer) => op:operation(xs:integer, xs:integer)
845 or is not an integral number of minutes.

Examples

Assume the dynamic context provides an implicit timezone of

op:operation(fenceHeight, xs:integer) => op:operation(xs:integer, xs:integer)
846.

let $para := 
In a hole in the ground there lived a hobbit.
         
6

The expression

op:operation(fenceHeight, xs:integer) => op:operation(xs:integer, xs:integer)
903 returns
op:operation(fenceHeight, xs:integer) => op:operation(xs:integer, xs:integer)
904.

The expression

op:operation(fenceHeight, xs:integer) => op:operation(xs:integer, xs:integer)
905 returns
op:operation(fenceHeight, xs:integer) => op:operation(xs:integer, xs:integer)
904. (
let $para := 
In a hole in the ground there lived a hobbit.
         
25 is converted to
op:operation(fenceHeight, xs:integer) => op:operation(xs:integer, xs:integer)
908. This is adjusted to the implicit timezone, giving
op:operation(fenceHeight, xs:integer) => op:operation(xs:integer, xs:integer)
909. ).

The expression

op:operation(fenceHeight, xs:integer) => op:operation(xs:integer, xs:integer)
910 returns
op:operation(fenceHeight, xs:integer) => op:operation(xs:integer, xs:integer)
911.

The expression

op:operation(fenceHeight, xs:integer) => op:operation(xs:integer, xs:integer)
912 returns
op:operation(fenceHeight, xs:integer) => op:operation(xs:integer, xs:integer)
913. (
let $para := 
In a hole in the ground there lived a hobbit.
         
25 is converted to the
op:operation(fenceHeight, xs:integer) => op:operation(xs:integer, xs:integer)
915. This is adjusted to the given timezone, giving
op:operation(fenceHeight, xs:integer) => op:operation(xs:integer, xs:integer)
916. ).

The expression

op:operation(fenceHeight, xs:integer) => op:operation(xs:integer, xs:integer)
917 returns
op:operation(fenceHeight, xs:integer) => op:operation(xs:integer, xs:integer)
918.

The expression

op:operation(fenceHeight, xs:integer) => op:operation(xs:integer, xs:integer)
919 returns
op:operation(fenceHeight, xs:integer) => op:operation(xs:integer, xs:integer)
918.

9.6.3 fn:adjust-time-to-timezone

Summary

Adjusts an

op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
965 value to a specific timezone, or to no timezone at all.

Signatures

let $para := 
In a hole in the ground there lived a hobbit.
         
87(
let $para := 
In a hole in the ground there lived a hobbit.
         
25
let $para := 
In a hole in the ground there lived a hobbit.
         
71
op:operation(fenceHeight, xs:integer) => op:operation(xs:integer, xs:integer)
036)
let $para := 
In a hole in the ground there lived a hobbit.
         
71
op:operation(fenceHeight, xs:integer) => op:operation(xs:integer, xs:integer)
036

let $para := 
In a hole in the ground there lived a hobbit.
         
87(
let $para := 
In a hole in the ground there lived a hobbit.
         
25
let $para := 
In a hole in the ground there lived a hobbit.
         
71
op:operation(fenceHeight, xs:integer) => op:operation(xs:integer, xs:integer)
036,
op:operation(fenceHeight, xs:integer) => op:operation(xs:integer, xs:integer)
807
let $para := 
In a hole in the ground there lived a hobbit.
         
71
op:operation(fenceHeight, xs:integer) => op:operation(xs:integer, xs:integer)
665)
let $para := 
In a hole in the ground there lived a hobbit.
         
71
op:operation(fenceHeight, xs:integer) => op:operation(xs:integer, xs:integer)
036

Properties

The one-argument form of this function is ·deterministic·, ·context-dependent·, and ·focus-independent·. It depends on implicit timezone.

The two-argument form of this function is ·deterministic·, ·context-independent·, and ·focus-independent·.

Rules

If

op:operation(fenceHeight, xs:integer) => op:operation(xs:integer, xs:integer)
807 is not specified, then the effective value of
op:operation(fenceHeight, xs:integer) => op:operation(xs:integer, xs:integer)
807 is the value of the implicit timezone in the dynamic context.

If

let $para := 
In a hole in the ground there lived a hobbit.
         
25 is the empty sequence, then the function returns the empty sequence.

If

let $para := 
In a hole in the ground there lived a hobbit.
         
25 does not have a timezone component and
op:operation(fenceHeight, xs:integer) => op:operation(xs:integer, xs:integer)
807 is the empty sequence, then the result is
let $para := 
In a hole in the ground there lived a hobbit.
         
25.

If

let $para := 
In a hole in the ground there lived a hobbit.
         
25 does not have a timezone component and
op:operation(fenceHeight, xs:integer) => op:operation(xs:integer, xs:integer)
807 is not the empty sequence, then the result is
let $para := 
In a hole in the ground there lived a hobbit.
         
25 with
op:operation(fenceHeight, xs:integer) => op:operation(xs:integer, xs:integer)
807 as the timezone component.

If

let $para := 
In a hole in the ground there lived a hobbit.
         
25 has a timezone component and
op:operation(fenceHeight, xs:integer) => op:operation(xs:integer, xs:integer)
807 is the empty sequence, then the result is the localized value of
let $para := 
In a hole in the ground there lived a hobbit.
         
25 without its timezone component.

If

let $para := 
In a hole in the ground there lived a hobbit.
         
25 has a timezone component and
op:operation(fenceHeight, xs:integer) => op:operation(xs:integer, xs:integer)
807 is not the empty sequence, then:

  • Let

    op:operation(fenceHeight, xs:integer) => op:operation(xs:integer, xs:integer)
    894 be the
    let $para := 
    In a hole in the ground there lived a hobbit.
             
    29 value
    op:operation(fenceHeight, xs:integer) => op:operation(xs:integer, xs:integer)
    954.

  • Let

    op:operation(fenceHeight, xs:integer) => op:operation(xs:integer, xs:integer)
    896 be the value of
    op:operation(fenceHeight, xs:integer) => op:operation(xs:integer, xs:integer)
    897

  • The function returns the

    op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
    965 value
    op:operation(fenceHeight, xs:integer) => op:operation(xs:integer, xs:integer)
    958.

Error Conditions

A dynamic error is raised [err:FODT0003] if

op:operation(fenceHeight, xs:integer) => op:operation(xs:integer, xs:integer)
807 is less than
op:operation(fenceHeight, xs:integer) => op:operation(xs:integer, xs:integer)
844 or greater than
op:operation(fenceHeight, xs:integer) => op:operation(xs:integer, xs:integer)
845 or if does not contain an integral number of minutes.

Examples

Assume the dynamic context provides an implicit timezone of

op:operation(fenceHeight, xs:integer) => op:operation(xs:integer, xs:integer)
846.

let $para := 
In a hole in the ground there lived a hobbit.
         
6

The expression

op:operation(fenceHeight, xs:integer) => op:operation(xs:integer, xs:integer)
963 returns
op:operation(fenceHeight, xs:integer) => op:operation(xs:integer, xs:integer)
964.

The expression

op:operation(fenceHeight, xs:integer) => op:operation(xs:integer, xs:integer)
965 returns
op:operation(fenceHeight, xs:integer) => op:operation(xs:integer, xs:integer)
966.

The expression

op:operation(fenceHeight, xs:integer) => op:operation(xs:integer, xs:integer)
967 returns
op:operation(fenceHeight, xs:integer) => op:operation(xs:integer, xs:integer)
968.

The expression

op:operation(fenceHeight, xs:integer) => op:operation(xs:integer, xs:integer)
969 returns
op:operation(fenceHeight, xs:integer) => op:operation(xs:integer, xs:integer)
970.

The expression

op:operation(fenceHeight, xs:integer) => op:operation(xs:integer, xs:integer)
971 returns
op:operation(fenceHeight, xs:integer) => op:operation(xs:integer, xs:integer)
972.

The expression

op:operation(fenceHeight, xs:integer) => op:operation(xs:integer, xs:integer)
973 returns
op:operation(fenceHeight, xs:integer) => op:operation(xs:integer, xs:integer)
972.

The expression

op:operation(fenceHeight, xs:integer) => op:operation(xs:integer, xs:integer)
975 returns
op:operation(fenceHeight, xs:integer) => op:operation(xs:integer, xs:integer)
976.

9.7 Arithmetic operators on durations, dates and times

These functions support adding or subtracting a duration value to or from an

let $para := 
In a hole in the ground there lived a hobbit.
         
29, an
op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
964 or an
op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
965 value. Appendix E of [XML Schema Part 2: Datatypes Second Edition] describes an algorithm for performing such operations.

FunctionMeaning
op:operation(fenceHeight, xs:integer) => op:operation(xs:integer, xs:integer)
980Returns an
let $para := 
In a hole in the ground there lived a hobbit.
         
25 representing the amount of elapsed time between the instants
op:operation(fenceHeight, xs:integer) => op:operation(xs:integer, xs:integer)
982 and
op:operation(fenceHeight, xs:integer) => op:operation(xs:integer, xs:integer)
983.
op:operation(fenceHeight, xs:integer) => op:operation(xs:integer, xs:integer)
984Returns the
let $para := 
In a hole in the ground there lived a hobbit.
         
25 that corresponds to the elapsed time between the starting instant of
let $para := 
In a hole in the ground there lived a hobbit.
         
73 and the starting instant of
let $para := 
In a hole in the ground there lived a hobbit.
         
73.
op:operation(fenceHeight, xs:integer) => op:operation(xs:integer, xs:integer)
988Returns the
let $para := 
In a hole in the ground there lived a hobbit.
         
25 that corresponds to the elapsed time between the values of
let $para := 
In a hole in the ground there lived a hobbit.
         
73 and
let $para := 
In a hole in the ground there lived a hobbit.
         
70 treated as times on the same date.
op:operation(fenceHeight, xs:integer) => op:operation(xs:integer, xs:integer)
992Returns the
let $para := 
In a hole in the ground there lived a hobbit.
         
29 that is a given duration after a specified
let $para := 
In a hole in the ground there lived a hobbit.
         
29 (or before, if the duration is negative).
op:operation(fenceHeight, xs:integer) => op:operation(xs:integer, xs:integer)
995Returns the
let $para := 
In a hole in the ground there lived a hobbit.
         
29 that is a given duration after a specified
let $para := 
In a hole in the ground there lived a hobbit.
         
29 (or before, if the duration is negative).
op:operation(fenceHeight, xs:integer) => op:operation(xs:integer, xs:integer)
998Returns the
let $para := 
In a hole in the ground there lived a hobbit.
         
29 that is a given duration before a specified
let $para := 
In a hole in the ground there lived a hobbit.
         
29 (or after, if the duration is negative).
fn:abs($N * $arg2) le fn:abs($arg1) 
               and fn:compare($N * $arg2, 0) eq fn:compare($arg1, 0).
001Returns the
let $para := 
In a hole in the ground there lived a hobbit.
         
29 that is a given duration before a specified
let $para := 
In a hole in the ground there lived a hobbit.
         
29 (or after, if the duration is negative).
fn:abs($N * $arg2) le fn:abs($arg1) 
               and fn:compare($N * $arg2, 0) eq fn:compare($arg1, 0).
004Returns the
op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
964 that is a given duration after a specified
op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
964 (or before, if the duration is negative).
fn:abs($N * $arg2) le fn:abs($arg1) 
               and fn:compare($N * $arg2, 0) eq fn:compare($arg1, 0).
007Returns the
op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
964 that is a given duration after a specified
op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
964 (or before, if the duration is negative).
fn:abs($N * $arg2) le fn:abs($arg1) 
               and fn:compare($N * $arg2, 0) eq fn:compare($arg1, 0).
010Returns the
op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
964 that is a given duration before a specified
op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
964 (or after, if the duration is negative).
fn:abs($N * $arg2) le fn:abs($arg1) 
               and fn:compare($N * $arg2, 0) eq fn:compare($arg1, 0).
013Returns the
op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
964 that is a given duration before a specified
op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
964 (or after, if the duration is negative).
fn:abs($N * $arg2) le fn:abs($arg1) 
               and fn:compare($N * $arg2, 0) eq fn:compare($arg1, 0).
016Returns the
op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
965 value that is a given duration after a specified
op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
965 (or before, if the duration is negative or causes wrap-around past midnight)
fn:abs($N * $arg2) le fn:abs($arg1) 
               and fn:compare($N * $arg2, 0) eq fn:compare($arg1, 0).
019Returns the
op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
965 value that is a given duration before a specified
op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
965 (or after, if the duration is negative or causes wrap-around past midnight)

9.7.1 Limits and precision

A processor that limits the number of digits in date and time datatype representations may encounter overflow and underflow conditions when it tries to execute the functions in this section. In these situations, the processor must return P0M or PT0S in case of duration underflow and 00:00:00 in case of time underflow. It must raise a dynamic error [err:FODT0001] in case of overflow.

The value spaces of the two totally ordered subtypes of

op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
489 described in 8.1 Two totally ordered subtypes of duration are
let $para := 
In a hole in the ground there lived a hobbit.
         
85 months for
let $para := 
In a hole in the ground there lived a hobbit.
         
24 and
let $para := 
In a hole in the ground there lived a hobbit.
         
82 seconds for
let $para := 
In a hole in the ground there lived a hobbit.
         
25. If a processor limits the number of digits allowed in the representation of
let $para := 
In a hole in the ground there lived a hobbit.
         
85 and
let $para := 
In a hole in the ground there lived a hobbit.
         
82 then overflow and underflow situations can arise when it tries to execute the functions in 8.4 Arithmetic operators on durations. In these situations the processor must return zero in case of numeric underflow and P0M or PT0S in case of duration underflow. It must raise a dynamic error [err:FODT0002] in case of overflow.

9.7.2 op:subtract-dateTimes

Summary

Returns an

let $para := 
In a hole in the ground there lived a hobbit.
         
25 representing the amount of elapsed time between the instants
op:operation(fenceHeight, xs:integer) => op:operation(xs:integer, xs:integer)
982 and
op:operation(fenceHeight, xs:integer) => op:operation(xs:integer, xs:integer)
983.

Operator Mapping

Defines the semantics of the "-" operator when applied to two

let $para := 
In a hole in the ground there lived a hobbit.
         
29 values.

Signature

op:operation(fenceHeight, xs:integer) => op:operation(xs:integer, xs:integer)
980(
let $para := 
In a hole in the ground there lived a hobbit.
         
70
let $para := 
In a hole in the ground there lived a hobbit.
         
71
let $para := 
In a hole in the ground there lived a hobbit.
         
29,
let $para := 
In a hole in the ground there lived a hobbit.
         
73
let $para := 
In a hole in the ground there lived a hobbit.
         
71
let $para := 
In a hole in the ground there lived a hobbit.
         
29)
let $para := 
In a hole in the ground there lived a hobbit.
         
71
let $para := 
In a hole in the ground there lived a hobbit.
         
25

Properties

This function is ·deterministic·, ·context-dependent·, and ·focus-independent·. It depends on implicit timezone.

Rules

If either

let $para := 
In a hole in the ground there lived a hobbit.
         
70 or
let $para := 
In a hole in the ground there lived a hobbit.
         
73 do not contain an explicit timezone then, for the purpose of the operation, the implicit timezone provided by the dynamic context (See Section C.2 Dynamic Context Components XP31.) is assumed to be present as part of the value.

The function returns the elapsed time between the date/time instant

op:operation(fenceHeight, xs:integer) => op:operation(xs:integer, xs:integer)
982 and the date/time instant
op:operation(fenceHeight, xs:integer) => op:operation(xs:integer, xs:integer)
983, computed according to the algorithm given in Appendix E of [XML Schema Part 2: Datatypes Second Edition], and expressed as a
let $para := 
In a hole in the ground there lived a hobbit.
         
25.

If the normalized value of

let $para := 
In a hole in the ground there lived a hobbit.
         
70 precedes in time the normalized value of
let $para := 
In a hole in the ground there lived a hobbit.
         
73, then the returned value is a negative duration.

Examples

Assume that the dynamic context provides an implicit timezone value of

op:operation(fenceHeight, xs:integer) => op:operation(xs:integer, xs:integer)
197.

The expression

fn:abs($N * $arg2) le fn:abs($arg1) 
               and fn:compare($N * $arg2, 0) eq fn:compare($arg1, 0).
050 returns
fn:abs($N * $arg2) le fn:abs($arg1) 
               and fn:compare($N * $arg2, 0) eq fn:compare($arg1, 0).
051.

9.7.3 op:subtract-dates

Summary

Returns the

let $para := 
In a hole in the ground there lived a hobbit.
         
25 that corresponds to the elapsed time between the starting instant of
let $para := 
In a hole in the ground there lived a hobbit.
         
73 and the starting instant of
let $para := 
In a hole in the ground there lived a hobbit.
         
73.

Operator Mapping

Defines the semantics of the "-" operator when applied to two

op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
964 values.

Signature

op:operation(fenceHeight, xs:integer) => op:operation(xs:integer, xs:integer)
984(
let $para := 
In a hole in the ground there lived a hobbit.
         
70
let $para := 
In a hole in the ground there lived a hobbit.
         
71
op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
964,
let $para := 
In a hole in the ground there lived a hobbit.
         
73
let $para := 
In a hole in the ground there lived a hobbit.
         
71
op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
964)
let $para := 
In a hole in the ground there lived a hobbit.
         
71
let $para := 
In a hole in the ground there lived a hobbit.
         
25

Properties

This function is ·deterministic·, ·context-dependent·, and ·focus-independent·. It depends on implicit timezone.

Rules

If either

let $para := 
In a hole in the ground there lived a hobbit.
         
70 or
let $para := 
In a hole in the ground there lived a hobbit.
         
73 do not contain an explicit timezone then, for the purpose of the operation, the implicit timezone provided by the dynamic context (See Section C.2 Dynamic Context Components XP31.) is assumed to be present as part of the value.

The starting instant of an

op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
964 is the
let $para := 
In a hole in the ground there lived a hobbit.
         
29 at
op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
999 on that date.

The function returns the result of subtracting the two starting instants using

op:operation(fenceHeight, xs:integer) => op:operation(xs:integer, xs:integer)
980.

If the starting instant of

let $para := 
In a hole in the ground there lived a hobbit.
         
70 precedes in time the starting instant of
let $para := 
In a hole in the ground there lived a hobbit.
         
73, then the returned value is a negative duration.

Examples

Assume that the dynamic context provides an implicit timezone value of

fn:abs($N * $arg2) le fn:abs($arg1) 
               and fn:compare($N * $arg2, 0) eq fn:compare($arg1, 0).
073.

The expression

fn:abs($N * $arg2) le fn:abs($arg1) 
               and fn:compare($N * $arg2, 0) eq fn:compare($arg1, 0).
074 returns
fn:abs($N * $arg2) le fn:abs($arg1) 
               and fn:compare($N * $arg2, 0) eq fn:compare($arg1, 0).
075. (The normalized values of the two starting instants are
fn:abs($N * $arg2) le fn:abs($arg1) 
               and fn:compare($N * $arg2, 0) eq fn:compare($arg1, 0).
076 and
fn:abs($N * $arg2) le fn:abs($arg1) 
               and fn:compare($N * $arg2, 0) eq fn:compare($arg1, 0).
077.)

Now assume that the dynamic context provides an implicit timezone value of

fn:abs($N * $arg2) le fn:abs($arg1) 
               and fn:compare($N * $arg2, 0) eq fn:compare($arg1, 0).
078.

The expression

fn:abs($N * $arg2) le fn:abs($arg1) 
               and fn:compare($N * $arg2, 0) eq fn:compare($arg1, 0).
079 returns
fn:abs($N * $arg2) le fn:abs($arg1) 
               and fn:compare($N * $arg2, 0) eq fn:compare($arg1, 0).
080. ( The normalized values of the two starting instants are
fn:abs($N * $arg2) le fn:abs($arg1) 
               and fn:compare($N * $arg2, 0) eq fn:compare($arg1, 0).
081 and
fn:abs($N * $arg2) le fn:abs($arg1) 
               and fn:compare($N * $arg2, 0) eq fn:compare($arg1, 0).
077.)

The expression

fn:abs($N * $arg2) le fn:abs($arg1) 
               and fn:compare($N * $arg2, 0) eq fn:compare($arg1, 0).
083 returns
fn:abs($N * $arg2) le fn:abs($arg1) 
               and fn:compare($N * $arg2, 0) eq fn:compare($arg1, 0).
084.

9.7.4 op:subtract-times

Summary

Returns the

let $para := 
In a hole in the ground there lived a hobbit.
         
25 that corresponds to the elapsed time between the values of
let $para := 
In a hole in the ground there lived a hobbit.
         
73 and
let $para := 
In a hole in the ground there lived a hobbit.
         
70 treated as times on the same date.

Operator Mapping

Defines the semantics of the "-" operator when applied to two

op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
965 values.

Signature

op:operation(fenceHeight, xs:integer) => op:operation(xs:integer, xs:integer)
988(
let $para := 
In a hole in the ground there lived a hobbit.
         
70
let $para := 
In a hole in the ground there lived a hobbit.
         
71
op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
965,
let $para := 
In a hole in the ground there lived a hobbit.
         
73
let $para := 
In a hole in the ground there lived a hobbit.
         
71
op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
965)
let $para := 
In a hole in the ground there lived a hobbit.
         
71
let $para := 
In a hole in the ground there lived a hobbit.
         
25

Properties

This function is ·deterministic·, ·context-dependent·, and ·focus-independent·. It depends on implicit timezone.

Rules

The function returns the result of the expression:

let $para := 
In a hole in the ground there lived a hobbit.
         
9

Notes

Any other reference date would work equally well.

Examples

Assume that the dynamic context provides an implicit timezone value of

op:operation(fenceHeight, xs:integer) => op:operation(xs:integer, xs:integer)
197. Assume, also, that the date components of the reference
let $para := 
In a hole in the ground there lived a hobbit.
         
29 correspond to
fn:abs($N * $arg2) le fn:abs($arg1) 
               and fn:compare($N * $arg2, 0) eq fn:compare($arg1, 0).
100.

The expression

fn:abs($N * $arg2) le fn:abs($arg1) 
               and fn:compare($N * $arg2, 0) eq fn:compare($arg1, 0).
101 returns
fn:abs($N * $arg2) le fn:abs($arg1) 
               and fn:compare($N * $arg2, 0) eq fn:compare($arg1, 0).
102. (This is obtained by subtracting from the
let $para := 
In a hole in the ground there lived a hobbit.
         
29 value
fn:abs($N * $arg2) le fn:abs($arg1) 
               and fn:compare($N * $arg2, 0) eq fn:compare($arg1, 0).
104 the
let $para := 
In a hole in the ground there lived a hobbit.
         
29 value
fn:abs($N * $arg2) le fn:abs($arg1) 
               and fn:compare($N * $arg2, 0) eq fn:compare($arg1, 0).
106.)

The expression

fn:abs($N * $arg2) le fn:abs($arg1) 
               and fn:compare($N * $arg2, 0) eq fn:compare($arg1, 0).
107 returns
op:operation(fenceHeight, xs:integer) => op:operation(xs:integer, xs:integer)
674. (The two
let $para := 
In a hole in the ground there lived a hobbit.
         
29 values are
fn:abs($N * $arg2) le fn:abs($arg1) 
               and fn:compare($N * $arg2, 0) eq fn:compare($arg1, 0).
110 and
fn:abs($N * $arg2) le fn:abs($arg1) 
               and fn:compare($N * $arg2, 0) eq fn:compare($arg1, 0).
111. These normalize to
fn:abs($N * $arg2) le fn:abs($arg1) 
               and fn:compare($N * $arg2, 0) eq fn:compare($arg1, 0).
112 and
fn:abs($N * $arg2) le fn:abs($arg1) 
               and fn:compare($N * $arg2, 0) eq fn:compare($arg1, 0).
112. ).

The expression

fn:abs($N * $arg2) le fn:abs($arg1) 
               and fn:compare($N * $arg2, 0) eq fn:compare($arg1, 0).
114 returns
fn:abs($N * $arg2) le fn:abs($arg1) 
               and fn:compare($N * $arg2, 0) eq fn:compare($arg1, 0).
115. (The two normalized
let $para := 
In a hole in the ground there lived a hobbit.
         
29 values are
fn:abs($N * $arg2) le fn:abs($arg1) 
               and fn:compare($N * $arg2, 0) eq fn:compare($arg1, 0).
117 and
fn:abs($N * $arg2) le fn:abs($arg1) 
               and fn:compare($N * $arg2, 0) eq fn:compare($arg1, 0).
118.)

The expression

fn:abs($N * $arg2) le fn:abs($arg1) 
               and fn:compare($N * $arg2, 0) eq fn:compare($arg1, 0).
119 returns
fn:abs($N * $arg2) le fn:abs($arg1) 
               and fn:compare($N * $arg2, 0) eq fn:compare($arg1, 0).
120. (The two normalized
let $para := 
In a hole in the ground there lived a hobbit.
         
29 values are
fn:abs($N * $arg2) le fn:abs($arg1) 
               and fn:compare($N * $arg2, 0) eq fn:compare($arg1, 0).
122 and
fn:abs($N * $arg2) le fn:abs($arg1) 
               and fn:compare($N * $arg2, 0) eq fn:compare($arg1, 0).
123.)

9.7.5 op:add-yearMonthDuration-to-dateTime

Summary

Returns the

let $para := 
In a hole in the ground there lived a hobbit.
         
29 that is a given duration after a specified
let $para := 
In a hole in the ground there lived a hobbit.
         
29 (or before, if the duration is negative).

Operator Mapping

Defines the semantics of the "+" operator when applied to an

let $para := 
In a hole in the ground there lived a hobbit.
         
29 and an
let $para := 
In a hole in the ground there lived a hobbit.
         
24 value.

Signature

op:operation(fenceHeight, xs:integer) => op:operation(xs:integer, xs:integer)
992(
let $para := 
In a hole in the ground there lived a hobbit.
         
70
let $para := 
In a hole in the ground there lived a hobbit.
         
71
let $para := 
In a hole in the ground there lived a hobbit.
         
29,
let $para := 
In a hole in the ground there lived a hobbit.
         
73
let $para := 
In a hole in the ground there lived a hobbit.
         
71
let $para := 
In a hole in the ground there lived a hobbit.
         
24)
let $para := 
In a hole in the ground there lived a hobbit.
         
71
let $para := 
In a hole in the ground there lived a hobbit.
         
29

Properties

This function is ·deterministic·, ·context-independent·, and ·focus-independent·.

Rules

The function returns the result of adding

let $para := 
In a hole in the ground there lived a hobbit.
         
73 to the value of
let $para := 
In a hole in the ground there lived a hobbit.
         
70 using the algorithm described in Appendix E of [XML Schema Part 2: Datatypes Second Edition], disregarding the rule about leap seconds. If
let $para := 
In a hole in the ground there lived a hobbit.
         
73 is negative, then the result
let $para := 
In a hole in the ground there lived a hobbit.
         
29 precedes
let $para := 
In a hole in the ground there lived a hobbit.
         
70.

The result has the same timezone as

let $para := 
In a hole in the ground there lived a hobbit.
         
70. If
let $para := 
In a hole in the ground there lived a hobbit.
         
70 has no timezone, the result has no timezone.

Examples

The expression

fn:abs($N * $arg2) le fn:abs($arg1) 
               and fn:compare($N * $arg2, 0) eq fn:compare($arg1, 0).
144 returns
fn:abs($N * $arg2) le fn:abs($arg1) 
               and fn:compare($N * $arg2, 0) eq fn:compare($arg1, 0).
145.

9.7.6 op:add-dayTimeDuration-to-dateTime

Summary

Returns the

let $para := 
In a hole in the ground there lived a hobbit.
         
29 that is a given duration after a specified
let $para := 
In a hole in the ground there lived a hobbit.
         
29 (or before, if the duration is negative).

Operator Mapping

Defines the semantics of the "+" operator when applied to an

let $para := 
In a hole in the ground there lived a hobbit.
         
29 and an
let $para := 
In a hole in the ground there lived a hobbit.
         
25 value.

Signature

op:operation(fenceHeight, xs:integer) => op:operation(xs:integer, xs:integer)
995(
let $para := 
In a hole in the ground there lived a hobbit.
         
70
let $para := 
In a hole in the ground there lived a hobbit.
         
71
let $para := 
In a hole in the ground there lived a hobbit.
         
29,
let $para := 
In a hole in the ground there lived a hobbit.
         
73
let $para := 
In a hole in the ground there lived a hobbit.
         
71
let $para := 
In a hole in the ground there lived a hobbit.
         
25)
let $para := 
In a hole in the ground there lived a hobbit.
         
71
let $para := 
In a hole in the ground there lived a hobbit.
         
29

Properties

This function is ·deterministic·, ·context-independent·, and ·focus-independent·.

Rules

The function returns the result of adding

let $para := 
In a hole in the ground there lived a hobbit.
         
73 to the value of
let $para := 
In a hole in the ground there lived a hobbit.
         
70 using the algorithm described in Appendix E of [XML Schema Part 2: Datatypes Second Edition], disregarding the rule about leap seconds. If
let $para := 
In a hole in the ground there lived a hobbit.
         
73 is negative, then the result
let $para := 
In a hole in the ground there lived a hobbit.
         
29 precedes
let $para := 
In a hole in the ground there lived a hobbit.
         
70.

The result has the same timezone as

let $para := 
In a hole in the ground there lived a hobbit.
         
70. If
let $para := 
In a hole in the ground there lived a hobbit.
         
70 has no timezone, the result has no timezone.

Examples

The expression

fn:abs($N * $arg2) le fn:abs($arg1) 
               and fn:compare($N * $arg2, 0) eq fn:compare($arg1, 0).
166 returns
fn:abs($N * $arg2) le fn:abs($arg1) 
               and fn:compare($N * $arg2, 0) eq fn:compare($arg1, 0).
167.

9.7.7 op:subtract-yearMonthDuration-from-dateTime

Summary

Returns the

let $para := 
In a hole in the ground there lived a hobbit.
         
29 that is a given duration before a specified
let $para := 
In a hole in the ground there lived a hobbit.
         
29 (or after, if the duration is negative).

Operator Mapping

Defines the semantics of the "-" operator when applied to an

let $para := 
In a hole in the ground there lived a hobbit.
         
29 and an
let $para := 
In a hole in the ground there lived a hobbit.
         
24 value.

Signature

op:operation(fenceHeight, xs:integer) => op:operation(xs:integer, xs:integer)
998(
let $para := 
In a hole in the ground there lived a hobbit.
         
70
let $para := 
In a hole in the ground there lived a hobbit.
         
71
let $para := 
In a hole in the ground there lived a hobbit.
         
29,
let $para := 
In a hole in the ground there lived a hobbit.
         
73
let $para := 
In a hole in the ground there lived a hobbit.
         
71
let $para := 
In a hole in the ground there lived a hobbit.
         
24)
let $para := 
In a hole in the ground there lived a hobbit.
         
71
let $para := 
In a hole in the ground there lived a hobbit.
         
29

Properties

This function is ·deterministic·, ·context-independent·, and ·focus-independent·.

Rules

The function returns the

let $para := 
In a hole in the ground there lived a hobbit.
         
29 computed by negating
let $para := 
In a hole in the ground there lived a hobbit.
         
73 and adding the result to the value of
let $para := 
In a hole in the ground there lived a hobbit.
         
70 using the function
op:operation(fenceHeight, xs:integer) => op:operation(xs:integer, xs:integer)
992.

Examples

The expression

fn:abs($N * $arg2) le fn:abs($arg1) 
               and fn:compare($N * $arg2, 0) eq fn:compare($arg1, 0).
185 returns
fn:abs($N * $arg2) le fn:abs($arg1) 
               and fn:compare($N * $arg2, 0) eq fn:compare($arg1, 0).
186.

9.7.8 op:subtract-dayTimeDuration-from-dateTime

Summary

Returns the

let $para := 
In a hole in the ground there lived a hobbit.
         
29 that is a given duration before a specified
let $para := 
In a hole in the ground there lived a hobbit.
         
29 (or after, if the duration is negative).

Operator Mapping

Defines the semantics of the "-" operator when applied to an

let $para := 
In a hole in the ground there lived a hobbit.
         
29 an and
let $para := 
In a hole in the ground there lived a hobbit.
         
25 values

Signature

fn:abs($N * $arg2) le fn:abs($arg1) 
               and fn:compare($N * $arg2, 0) eq fn:compare($arg1, 0).
001(
let $para := 
In a hole in the ground there lived a hobbit.
         
70
let $para := 
In a hole in the ground there lived a hobbit.
         
71
let $para := 
In a hole in the ground there lived a hobbit.
         
29,
let $para := 
In a hole in the ground there lived a hobbit.
         
73
let $para := 
In a hole in the ground there lived a hobbit.
         
71
let $para := 
In a hole in the ground there lived a hobbit.
         
25)
let $para := 
In a hole in the ground there lived a hobbit.
         
71
let $para := 
In a hole in the ground there lived a hobbit.
         
29

Rules

The function returns the

let $para := 
In a hole in the ground there lived a hobbit.
         
29 computed by negating
let $para := 
In a hole in the ground there lived a hobbit.
         
73 and adding the result to the value of
let $para := 
In a hole in the ground there lived a hobbit.
         
70 using the function
op:operation(fenceHeight, xs:integer) => op:operation(xs:integer, xs:integer)
995.

Examples

The expression

fn:abs($N * $arg2) le fn:abs($arg1) 
               and fn:compare($N * $arg2, 0) eq fn:compare($arg1, 0).
204 returns
fn:abs($N * $arg2) le fn:abs($arg1) 
               and fn:compare($N * $arg2, 0) eq fn:compare($arg1, 0).
205.

9.7.9 op:add-yearMonthDuration-to-date

Summary

Returns the

op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
964 that is a given duration after a specified
op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
964 (or before, if the duration is negative).

Operator Mapping

Defines the semantics of the "+" operator when applied to an

op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
964 and an
let $para := 
In a hole in the ground there lived a hobbit.
         
24 value.

Signature

fn:abs($N * $arg2) le fn:abs($arg1) 
               and fn:compare($N * $arg2, 0) eq fn:compare($arg1, 0).
004(
let $para := 
In a hole in the ground there lived a hobbit.
         
70
let $para := 
In a hole in the ground there lived a hobbit.
         
71
op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
964,
let $para := 
In a hole in the ground there lived a hobbit.
         
73
let $para := 
In a hole in the ground there lived a hobbit.
         
71
let $para := 
In a hole in the ground there lived a hobbit.
         
24)
let $para := 
In a hole in the ground there lived a hobbit.
         
71
op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
964

Properties

This function is ·deterministic·, ·context-independent·, and ·focus-independent·.

Rules

The function returns the result of casting

let $para := 
In a hole in the ground there lived a hobbit.
         
70 to an
let $para := 
In a hole in the ground there lived a hobbit.
         
29, adding
let $para := 
In a hole in the ground there lived a hobbit.
         
73 using the function
op:operation(fenceHeight, xs:integer) => op:operation(xs:integer, xs:integer)
992, and casting the result back to an
op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
964.

Examples

The expression

fn:abs($N * $arg2) le fn:abs($arg1) 
               and fn:compare($N * $arg2, 0) eq fn:compare($arg1, 0).
224 returns
fn:abs($N * $arg2) le fn:abs($arg1) 
               and fn:compare($N * $arg2, 0) eq fn:compare($arg1, 0).
225.

9.7.10 op:add-dayTimeDuration-to-date

Summary

Returns the

op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
964 that is a given duration after a specified
op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
964 (or before, if the duration is negative).

Operator Mapping

Defines the semantics of the "+" operator when applied to an

op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
964 and an
let $para := 
In a hole in the ground there lived a hobbit.
         
25 value.

Signature

fn:abs($N * $arg2) le fn:abs($arg1) 
               and fn:compare($N * $arg2, 0) eq fn:compare($arg1, 0).
007(
let $para := 
In a hole in the ground there lived a hobbit.
         
70
let $para := 
In a hole in the ground there lived a hobbit.
         
71
op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
964,
let $para := 
In a hole in the ground there lived a hobbit.
         
73
let $para := 
In a hole in the ground there lived a hobbit.
         
71
let $para := 
In a hole in the ground there lived a hobbit.
         
25)
let $para := 
In a hole in the ground there lived a hobbit.
         
71
op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
964

Properties

This function is ·deterministic·, ·context-independent·, and ·focus-independent·.

Rules

The function returns the result of casting

let $para := 
In a hole in the ground there lived a hobbit.
         
70 to an
let $para := 
In a hole in the ground there lived a hobbit.
         
29, adding
let $para := 
In a hole in the ground there lived a hobbit.
         
73 using the function
op:operation(fenceHeight, xs:integer) => op:operation(xs:integer, xs:integer)
995, and casting the result back to an
op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
964.

Examples

The expression

fn:abs($N * $arg2) le fn:abs($arg1) 
               and fn:compare($N * $arg2, 0) eq fn:compare($arg1, 0).
244 returns
fn:abs($N * $arg2) le fn:abs($arg1) 
               and fn:compare($N * $arg2, 0) eq fn:compare($arg1, 0).
245. ( The starting instant of the first argument is the
let $para := 
In a hole in the ground there lived a hobbit.
         
29 value
fn:abs($N * $arg2) le fn:abs($arg1) 
               and fn:compare($N * $arg2, 0) eq fn:compare($arg1, 0).
247. Adding the second argument to this gives the
let $para := 
In a hole in the ground there lived a hobbit.
         
29 value
fn:abs($N * $arg2) le fn:abs($arg1) 
               and fn:compare($N * $arg2, 0) eq fn:compare($arg1, 0).
249. The time components are then discarded. ).

9.7.11 op:subtract-yearMonthDuration-from-date

Summary

Returns the

op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
964 that is a given duration before a specified
op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
964 (or after, if the duration is negative).

Operator Mapping

Defines the semantics of the "-" operator when applied to an

op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
964 and an
let $para := 
In a hole in the ground there lived a hobbit.
         
24 value.

Signature

fn:abs($N * $arg2) le fn:abs($arg1) 
               and fn:compare($N * $arg2, 0) eq fn:compare($arg1, 0).
010(
let $para := 
In a hole in the ground there lived a hobbit.
         
70
let $para := 
In a hole in the ground there lived a hobbit.
         
71
op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
964,
let $para := 
In a hole in the ground there lived a hobbit.
         
73
let $para := 
In a hole in the ground there lived a hobbit.
         
71
let $para := 
In a hole in the ground there lived a hobbit.
         
24)
let $para := 
In a hole in the ground there lived a hobbit.
         
71
op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
964

Properties

This function is ·deterministic·, ·context-independent·, and ·focus-independent·.

Rules

Returns the

op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
964 computed by negating
let $para := 
In a hole in the ground there lived a hobbit.
         
73 and adding the result to
let $para := 
In a hole in the ground there lived a hobbit.
         
70 using the function
fn:abs($N * $arg2) le fn:abs($arg1) 
               and fn:compare($N * $arg2, 0) eq fn:compare($arg1, 0).
004.

Examples

The expression

fn:abs($N * $arg2) le fn:abs($arg1) 
               and fn:compare($N * $arg2, 0) eq fn:compare($arg1, 0).
267 returns
fn:abs($N * $arg2) le fn:abs($arg1) 
               and fn:compare($N * $arg2, 0) eq fn:compare($arg1, 0).
268.

The expression

fn:abs($N * $arg2) le fn:abs($arg1) 
               and fn:compare($N * $arg2, 0) eq fn:compare($arg1, 0).
269 returns
fn:abs($N * $arg2) le fn:abs($arg1) 
               and fn:compare($N * $arg2, 0) eq fn:compare($arg1, 0).
270.

The expression

fn:abs($N * $arg2) le fn:abs($arg1) 
               and fn:compare($N * $arg2, 0) eq fn:compare($arg1, 0).
271 returns
fn:abs($N * $arg2) le fn:abs($arg1) 
               and fn:compare($N * $arg2, 0) eq fn:compare($arg1, 0).
272.

9.7.12 op:subtract-dayTimeDuration-from-date

Summary

Returns the

op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
964 that is a given duration before a specified
op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
964 (or after, if the duration is negative).

Operator Mapping

Defines the semantics of the "-" operator when applied to an

op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
964 and an
let $para := 
In a hole in the ground there lived a hobbit.
         
25.

Signature

fn:abs($N * $arg2) le fn:abs($arg1) 
               and fn:compare($N * $arg2, 0) eq fn:compare($arg1, 0).
013(
let $para := 
In a hole in the ground there lived a hobbit.
         
70
let $para := 
In a hole in the ground there lived a hobbit.
         
71
op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
964,
let $para := 
In a hole in the ground there lived a hobbit.
         
73
let $para := 
In a hole in the ground there lived a hobbit.
         
71
let $para := 
In a hole in the ground there lived a hobbit.
         
25)
let $para := 
In a hole in the ground there lived a hobbit.
         
71
op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
964

Properties

This function is ·deterministic·, ·context-independent·, and ·focus-independent·.

Rules

Returns the

op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
964 computed by negating
let $para := 
In a hole in the ground there lived a hobbit.
         
73 and adding the result to
let $para := 
In a hole in the ground there lived a hobbit.
         
70 using the function
fn:abs($N * $arg2) le fn:abs($arg1) 
               and fn:compare($N * $arg2, 0) eq fn:compare($arg1, 0).
007.

Examples

The expression

fn:abs($N * $arg2) le fn:abs($arg1) 
               and fn:compare($N * $arg2, 0) eq fn:compare($arg1, 0).
290 returns
fn:abs($N * $arg2) le fn:abs($arg1) 
               and fn:compare($N * $arg2, 0) eq fn:compare($arg1, 0).
291.

9.7.13 op:add-dayTimeDuration-to-time

Summary

Returns the

op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
965 value that is a given duration after a specified
op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
965 (or before, if the duration is negative or causes wrap-around past midnight)

Operator Mapping

Defines the semantics of the "+" operator when applied to an

op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
965 and an
let $para := 
In a hole in the ground there lived a hobbit.
         
25 value.

Signature

fn:abs($N * $arg2) le fn:abs($arg1) 
               and fn:compare($N * $arg2, 0) eq fn:compare($arg1, 0).
016(
let $para := 
In a hole in the ground there lived a hobbit.
         
70
let $para := 
In a hole in the ground there lived a hobbit.
         
71
op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
965,
let $para := 
In a hole in the ground there lived a hobbit.
         
73
let $para := 
In a hole in the ground there lived a hobbit.
         
71
let $para := 
In a hole in the ground there lived a hobbit.
         
25)
let $para := 
In a hole in the ground there lived a hobbit.
         
71
op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
965

Rules

First, the days component in the canonical lexical representation of

let $para := 
In a hole in the ground there lived a hobbit.
         
73 is set to zero (0) and the value of the resulting
let $para := 
In a hole in the ground there lived a hobbit.
         
25 is calculated. Alternatively, the value of
let $para := 
In a hole in the ground there lived a hobbit.
         
73 modulus 86,400 is used as the second argument. This value is added to the value of
let $para := 
In a hole in the ground there lived a hobbit.
         
70 converted to an
let $para := 
In a hole in the ground there lived a hobbit.
         
29 using a reference date such as
op:operation(fenceHeight, xs:integer) => op:operation(xs:integer, xs:integer)
324, and the time component of the result is returned. Note that the
op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
965 returned may occur in a following or preceding day and may be less than
let $para := 
In a hole in the ground there lived a hobbit.
         
70.

The result has the same timezone as

let $para := 
In a hole in the ground there lived a hobbit.
         
70. If
let $para := 
In a hole in the ground there lived a hobbit.
         
70 has no timezone, the result has no timezone.

Examples

The expression

fn:abs($N * $arg2) le fn:abs($arg1) 
               and fn:compare($N * $arg2, 0) eq fn:compare($arg1, 0).
315 returns
fn:abs($N * $arg2) le fn:abs($arg1) 
               and fn:compare($N * $arg2, 0) eq fn:compare($arg1, 0).
316.

The expression

fn:abs($N * $arg2) le fn:abs($arg1) 
               and fn:compare($N * $arg2, 0) eq fn:compare($arg1, 0).
317 returns
fn:abs($N * $arg2) le fn:abs($arg1) 
               and fn:compare($N * $arg2, 0) eq fn:compare($arg1, 0).
318. (That is,
fn:abs($N * $arg2) le fn:abs($arg1) 
               and fn:compare($N * $arg2, 0) eq fn:compare($arg1, 0).
319).

9.7.14 op:subtract-dayTimeDuration-from-time

Summary

Returns the

op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
965 value that is a given duration before a specified
op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
965 (or after, if the duration is negative or causes wrap-around past midnight)

Operator Mapping

Defines the semantics of the "-" operator when applied to an

op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
965 and an
let $para := 
In a hole in the ground there lived a hobbit.
         
25 value.

Signature

fn:abs($N * $arg2) le fn:abs($arg1) 
               and fn:compare($N * $arg2, 0) eq fn:compare($arg1, 0).
019(
let $para := 
In a hole in the ground there lived a hobbit.
         
70
let $para := 
In a hole in the ground there lived a hobbit.
         
71
op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
965,
let $para := 
In a hole in the ground there lived a hobbit.
         
73
let $para := 
In a hole in the ground there lived a hobbit.
         
71
let $para := 
In a hole in the ground there lived a hobbit.
         
25)
let $para := 
In a hole in the ground there lived a hobbit.
         
71
op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
965

Properties

This function is ·deterministic·, ·context-independent·, and ·focus-independent·.

Rules

The function returns the result of negating

let $para := 
In a hole in the ground there lived a hobbit.
         
73 and adding the result to
let $para := 
In a hole in the ground there lived a hobbit.
         
70 using the function
fn:abs($N * $arg2) le fn:abs($arg1) 
               and fn:compare($N * $arg2, 0) eq fn:compare($arg1, 0).
016.

Examples

The expression

fn:abs($N * $arg2) le fn:abs($arg1) 
               and fn:compare($N * $arg2, 0) eq fn:compare($arg1, 0).
336 returns
fn:abs($N * $arg2) le fn:abs($arg1) 
               and fn:compare($N * $arg2, 0) eq fn:compare($arg1, 0).
337.

The expression

fn:abs($N * $arg2) le fn:abs($arg1) 
               and fn:compare($N * $arg2, 0) eq fn:compare($arg1, 0).
338 returns
fn:abs($N * $arg2) le fn:abs($arg1) 
               and fn:compare($N * $arg2, 0) eq fn:compare($arg1, 0).
339.

9.8 Formatting dates and times

FunctionMeaning
fn:abs($N * $arg2) le fn:abs($arg1) 
               and fn:compare($N * $arg2, 0) eq fn:compare($arg1, 0).
340Returns a string containing an
let $para := 
In a hole in the ground there lived a hobbit.
         
29 value formatted for display.
fn:abs($N * $arg2) le fn:abs($arg1) 
               and fn:compare($N * $arg2, 0) eq fn:compare($arg1, 0).
342Returns a string containing an
op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
964 value formatted for display.
fn:abs($N * $arg2) le fn:abs($arg1) 
               and fn:compare($N * $arg2, 0) eq fn:compare($arg1, 0).
344Returns a string containing an
op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
965 value formatted for display.

Three functions are provided to represent dates and times as a string, using the conventions of a selected calendar, language, and country. The signatures are presented first, followed by the rules which apply to each of the functions.

9.8.1 fn:format-dateTime

Summary

Returns a string containing an

let $para := 
In a hole in the ground there lived a hobbit.
         
29 value formatted for display.

Signatures

fn:abs($N * $arg2) le fn:abs($arg1) 
               and fn:compare($N * $arg2, 0) eq fn:compare($arg1, 0).
340(
fn:abs($N * $arg2) le fn:abs($arg1) 
               and fn:compare($N * $arg2, 0) eq fn:compare($arg1, 0).
44
let $para := 
In a hole in the ground there lived a hobbit.
         
71
op:operation(fenceHeight, xs:integer) => op:operation(xs:integer, xs:integer)
038,
let $para := 
In a hole in the ground there lived a hobbit.
         
230
let $para := 
In a hole in the ground there lived a hobbit.
         
71
let $para := 
In a hole in the ground there lived a hobbit.
         
10)
let $para := 
In a hole in the ground there lived a hobbit.
         
71
let $para := 
In a hole in the ground there lived a hobbit.
         
244

fn:abs($N * $arg2) le fn:abs($arg1) 
               and fn:compare($N * $arg2, 0) eq fn:compare($arg1, 0).
340(
fn:abs($N * $arg2) le fn:abs($arg1) 
               and fn:compare($N * $arg2, 0) eq fn:compare($arg1, 0).
44
let $para := 
In a hole in the ground there lived a hobbit.
         
71
op:operation(fenceHeight, xs:integer) => op:operation(xs:integer, xs:integer)
038,
let $para := 
In a hole in the ground there lived a hobbit.
         
230
let $para := 
In a hole in the ground there lived a hobbit.
         
71
let $para := 
In a hole in the ground there lived a hobbit.
         
10,
fn:abs($N * $arg2) le fn:abs($arg1) 
               and fn:compare($N * $arg2, 0) eq fn:compare($arg1, 0).
363
let $para := 
In a hole in the ground there lived a hobbit.
         
71
let $para := 
In a hole in the ground there lived a hobbit.
         
244,
fn:abs($N * $arg2) le fn:abs($arg1) 
               and fn:compare($N * $arg2, 0) eq fn:compare($arg1, 0).
366
let $para := 
In a hole in the ground there lived a hobbit.
         
71
let $para := 
In a hole in the ground there lived a hobbit.
         
244,
fn:abs($N * $arg2) le fn:abs($arg1) 
               and fn:compare($N * $arg2, 0) eq fn:compare($arg1, 0).
369
let $para := 
In a hole in the ground there lived a hobbit.
         
71
let $para := 
In a hole in the ground there lived a hobbit.
         
244)
let $para := 
In a hole in the ground there lived a hobbit.
         
71
let $para := 
In a hole in the ground there lived a hobbit.
         
244

Properties

The two-argument form of this function is ·deterministic·, ·context-dependent·, and ·focus-independent·. It depends on default calendar, and default language, and default place, and implicit timezone.

The five-argument form of this function is ·deterministic·, ·context-dependent·, and ·focus-independent·. It depends on implicit timezone, and namespaces.

Rules

See 9.8.4 The date/time formatting functions.

9.8.2 fn:format-date

Summary

Returns a string containing an

op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
964 value formatted for display.

Signatures

fn:abs($N * $arg2) le fn:abs($arg1) 
               and fn:compare($N * $arg2, 0) eq fn:compare($arg1, 0).
342(
fn:abs($N * $arg2) le fn:abs($arg1) 
               and fn:compare($N * $arg2, 0) eq fn:compare($arg1, 0).
44
let $para := 
In a hole in the ground there lived a hobbit.
         
71
op:operation(fenceHeight, xs:integer) => op:operation(xs:integer, xs:integer)
033,
let $para := 
In a hole in the ground there lived a hobbit.
         
230
let $para := 
In a hole in the ground there lived a hobbit.
         
71
let $para := 
In a hole in the ground there lived a hobbit.
         
10)
let $para := 
In a hole in the ground there lived a hobbit.
         
71
let $para := 
In a hole in the ground there lived a hobbit.
         
244

fn:abs($N * $arg2) le fn:abs($arg1) 
               and fn:compare($N * $arg2, 0) eq fn:compare($arg1, 0).
342(
fn:abs($N * $arg2) le fn:abs($arg1) 
               and fn:compare($N * $arg2, 0) eq fn:compare($arg1, 0).
44
let $para := 
In a hole in the ground there lived a hobbit.
         
71
op:operation(fenceHeight, xs:integer) => op:operation(xs:integer, xs:integer)
033,
let $para := 
In a hole in the ground there lived a hobbit.
         
230
let $para := 
In a hole in the ground there lived a hobbit.
         
71
let $para := 
In a hole in the ground there lived a hobbit.
         
10,
fn:abs($N * $arg2) le fn:abs($arg1) 
               and fn:compare($N * $arg2, 0) eq fn:compare($arg1, 0).
363
let $para := 
In a hole in the ground there lived a hobbit.
         
71
let $para := 
In a hole in the ground there lived a hobbit.
         
244,
fn:abs($N * $arg2) le fn:abs($arg1) 
               and fn:compare($N * $arg2, 0) eq fn:compare($arg1, 0).
366
let $para := 
In a hole in the ground there lived a hobbit.
         
71
let $para := 
In a hole in the ground there lived a hobbit.
         
244,
fn:abs($N * $arg2) le fn:abs($arg1) 
               and fn:compare($N * $arg2, 0) eq fn:compare($arg1, 0).
369
let $para := 
In a hole in the ground there lived a hobbit.
         
71
let $para := 
In a hole in the ground there lived a hobbit.
         
244)
let $para := 
In a hole in the ground there lived a hobbit.
         
71
let $para := 
In a hole in the ground there lived a hobbit.
         
244

Properties

The two-argument form of this function is ·deterministic·, ·context-dependent·, and ·focus-independent·. It depends on default calendar, and default language, and default place, and implicit timezone.

The five-argument form of this function is ·deterministic·, ·context-dependent·, and ·focus-independent·. It depends on implicit timezone, and namespaces.

Rules

See 9.8.4 The date/time formatting functions.

9.8.3 fn:format-time

Summary

Returns a string containing an

op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
965 value formatted for display.

Signatures

fn:abs($N * $arg2) le fn:abs($arg1) 
               and fn:compare($N * $arg2, 0) eq fn:compare($arg1, 0).
344(
fn:abs($N * $arg2) le fn:abs($arg1) 
               and fn:compare($N * $arg2, 0) eq fn:compare($arg1, 0).
44
let $para := 
In a hole in the ground there lived a hobbit.
         
71
op:operation(fenceHeight, xs:integer) => op:operation(xs:integer, xs:integer)
036,
let $para := 
In a hole in the ground there lived a hobbit.
         
230
let $para := 
In a hole in the ground there lived a hobbit.
         
71
let $para := 
In a hole in the ground there lived a hobbit.
         
10)
let $para := 
In a hole in the ground there lived a hobbit.
         
71
let $para := 
In a hole in the ground there lived a hobbit.
         
244

fn:abs($N * $arg2) le fn:abs($arg1) 
               and fn:compare($N * $arg2, 0) eq fn:compare($arg1, 0).
344(
fn:abs($N * $arg2) le fn:abs($arg1) 
               and fn:compare($N * $arg2, 0) eq fn:compare($arg1, 0).
44
let $para := 
In a hole in the ground there lived a hobbit.
         
71
op:operation(fenceHeight, xs:integer) => op:operation(xs:integer, xs:integer)
036,
let $para := 
In a hole in the ground there lived a hobbit.
         
230
let $para := 
In a hole in the ground there lived a hobbit.
         
71
let $para := 
In a hole in the ground there lived a hobbit.
         
10,
fn:abs($N * $arg2) le fn:abs($arg1) 
               and fn:compare($N * $arg2, 0) eq fn:compare($arg1, 0).
363
let $para := 
In a hole in the ground there lived a hobbit.
         
71
let $para := 
In a hole in the ground there lived a hobbit.
         
244,
fn:abs($N * $arg2) le fn:abs($arg1) 
               and fn:compare($N * $arg2, 0) eq fn:compare($arg1, 0).
366
let $para := 
In a hole in the ground there lived a hobbit.
         
71
let $para := 
In a hole in the ground there lived a hobbit.
         
244,
fn:abs($N * $arg2) le fn:abs($arg1) 
               and fn:compare($N * $arg2, 0) eq fn:compare($arg1, 0).
369
let $para := 
In a hole in the ground there lived a hobbit.
         
71
let $para := 
In a hole in the ground there lived a hobbit.
         
244)
let $para := 
In a hole in the ground there lived a hobbit.
         
71
let $para := 
In a hole in the ground there lived a hobbit.
         
244

Properties

The two-argument form of this function is ·deterministic·, ·context-dependent·, and ·focus-independent·. It depends on default calendar, and default language, and default place, and implicit timezone.

The five-argument form of this function is ·deterministic·, ·context-dependent·, and ·focus-independent·. It depends on implicit timezone, and namespaces.

Rules

See 9.8.4 The date/time formatting functions.

9.8.4 The date/time formatting functions

The

fn:abs($N * $arg2) le fn:abs($arg1) 
               and fn:compare($N * $arg2, 0) eq fn:compare($arg1, 0).
340,
fn:abs($N * $arg2) le fn:abs($arg1) 
               and fn:compare($N * $arg2, 0) eq fn:compare($arg1, 0).
342, and
fn:abs($N * $arg2) le fn:abs($arg1) 
               and fn:compare($N * $arg2, 0) eq fn:compare($arg1, 0).
344 functions format
fn:abs($N * $arg2) le fn:abs($arg1) 
               and fn:compare($N * $arg2, 0) eq fn:compare($arg1, 0).
44 as a string using the picture string specified by the
let $para := 
In a hole in the ground there lived a hobbit.
         
230 argument, the calendar specified by the
fn:abs($N * $arg2) le fn:abs($arg1) 
               and fn:compare($N * $arg2, 0) eq fn:compare($arg1, 0).
366 argument, the language specified by the
fn:abs($N * $arg2) le fn:abs($arg1) 
               and fn:compare($N * $arg2, 0) eq fn:compare($arg1, 0).
363 argument, and the country or other place name specified by the
fn:abs($N * $arg2) le fn:abs($arg1) 
               and fn:compare($N * $arg2, 0) eq fn:compare($arg1, 0).
369 argument. The result of the function is the formatted string representation of the supplied
let $para := 
In a hole in the ground there lived a hobbit.
         
29,
op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
964, or
op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
965 value.

[Definition] The three functions

fn:abs($N * $arg2) le fn:abs($arg1) 
               and fn:compare($N * $arg2, 0) eq fn:compare($arg1, 0).
340,
fn:abs($N * $arg2) le fn:abs($arg1) 
               and fn:compare($N * $arg2, 0) eq fn:compare($arg1, 0).
342, and
fn:abs($N * $arg2) le fn:abs($arg1) 
               and fn:compare($N * $arg2, 0) eq fn:compare($arg1, 0).
344 are referred to collectively as the date formatting functions.

If

fn:abs($N * $arg2) le fn:abs($arg1) 
               and fn:compare($N * $arg2, 0) eq fn:compare($arg1, 0).
44 is the empty sequence, the function returns the empty sequence.

Calling the two-argument form of each of the three functions is equivalent to calling the five-argument form with each of the last three arguments set to an empty sequence.

For details of the

fn:abs($N * $arg2) le fn:abs($arg1) 
               and fn:compare($N * $arg2, 0) eq fn:compare($arg1, 0).
363,
fn:abs($N * $arg2) le fn:abs($arg1) 
               and fn:compare($N * $arg2, 0) eq fn:compare($arg1, 0).
366, and
fn:abs($N * $arg2) le fn:abs($arg1) 
               and fn:compare($N * $arg2, 0) eq fn:compare($arg1, 0).
369 arguments, see 9.8.4.8 The language, calendar, and place arguments.

In general, the use of an invalid

let $para := 
In a hole in the ground there lived a hobbit.
         
230,
fn:abs($N * $arg2) le fn:abs($arg1) 
               and fn:compare($N * $arg2, 0) eq fn:compare($arg1, 0).
363,
fn:abs($N * $arg2) le fn:abs($arg1) 
               and fn:compare($N * $arg2, 0) eq fn:compare($arg1, 0).
366, or
fn:abs($N * $arg2) le fn:abs($arg1) 
               and fn:compare($N * $arg2, 0) eq fn:compare($arg1, 0).
369 argument results in a dynamic error [err:FOFD1340]. By contrast, use of an option in any of these arguments that is valid but not supported by the implementation is not an error, and in these cases the implementation is required to output the value in a fallback representation. More detailed rules are given below.

9.8.4.1 The picture string

The picture consists of a sequence of variable markers and literal substrings. A substring enclosed in square brackets is interpreted as a variable marker; substrings not enclosed in square brackets are taken as literal substrings. The literal substrings are optional and if present are rendered unchanged, including any whitespace. If an opening or closing square bracket is required within a literal substring, it must be doubled. The variable markers are replaced in the result by strings representing aspects of the date and/or time to be formatted. These are described in detail below.

A variable marker consists of a component specifier followed optionally by one or two presentation modifiers and/or optionally by a width modifier. Whitespace within a variable marker is ignored.

The variable marker may be separated into its components by applying the following rules:

  1. The component specifier is always present and is always a single letter.

  2. The width modifier may be recognized by the presence of a comma.

  3. The substring between the component specifier and the comma (if present) or the end of the string (if there is no comma) contains the first and second presentation modifiers, both of which are optional. If this substring contains a single character, this is interpreted as the first presentation modifier. If it contains more than one character, the last character is examined: if it is valid as a second presentation modifier then it is treated as such, and the preceding part of the substring constitutes the first presentation modifier. Otherwise, the second presentation modifier is presumed absent and the whole substring is interpreted as the first presentation modifier.

The component specifier indicates the component of the date or time that is required, and takes the following values:

SpecifierMeaningDefault Presentation ModifierYyear (absolute value)1Mmonth in year1Dday in month1dday in year1Fday of weeknWweek in year1wweek in month1Hhour in day (24 hours)1hhour in half-day (12 hours)1Pam/pm markernmminute in hour01ssecond in minute01ffractional seconds1Ztimezone01:01ztimezone (same as Z, but modified where appropriate to include a prefix as a time offset using GMT, for example GMT+1 or GMT-05:00. For this component there is a fixed prefix of
fn:abs($N * $arg2) le fn:abs($arg1) 
               and fn:compare($N * $arg2, 0) eq fn:compare($arg1, 0).
452, or a localized variation thereof for the chosen language, and the remainder of the value is formatted as for specifier
fn:abs($N * $arg2) le fn:abs($arg1) 
               and fn:compare($N * $arg2, 0) eq fn:compare($arg1, 0).
073.01:01Ccalendar: the name or abbreviation of a calendar namenEera: the name of a baseline for the numbering of years, for example the reign of a monarchn

A dynamic error is reported [err:FOFD1340] if the syntax of the picture is incorrect.

A dynamic error is reported [err:FOFD1350] if a component specifier within the picture refers to components that are not available in the given type of

fn:abs($N * $arg2) le fn:abs($arg1) 
               and fn:compare($N * $arg2, 0) eq fn:compare($arg1, 0).
44, for example if the picture supplied to the
fn:abs($N * $arg2) le fn:abs($arg1) 
               and fn:compare($N * $arg2, 0) eq fn:compare($arg1, 0).
344 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.

The first presentation modifier indicates the style in which the value of a component is to be represented. Its value may be either:

  • any format token permitted as a primary format token in the second argument of the

    let $para := 
    In a hole in the ground there lived a hobbit.
             
    225 function, indicating that the value of the component is to be output numerically using the specified number format (for example,
    declare %public function r:random-sequence($length as xs:integer) as xs:double* {
      r:random-sequence($length, fn:random-number-generator())
    };
    
    declare %private function r:random-sequence($length as xs:integer, 
                                                $G as map(xs:string, item())) {
      if ($length eq 0)
      then ()
      else ($G?number, r:random-sequence($length - 1, $G?next()))
    };
    
    r:random-sequence(200);
                
    13,
    let $para := 
    In a hole in the ground there lived a hobbit.
             
    259,
    let $para := 
    In a hole in the ground there lived a hobbit.
             
    274,
    let $para := 
    In a hole in the ground there lived a hobbit.
             
    276,
    let $para := 
    In a hole in the ground there lived a hobbit.
             
    278,
    let $para := 
    In a hole in the ground there lived a hobbit.
             
    280, or
    let $para := 
    In a hole in the ground there lived a hobbit.
             
    282) or

  • the format token

    fn:abs($N * $arg2) le fn:abs($arg1) 
                   and fn:compare($N * $arg2, 0) eq fn:compare($arg1, 0).
    464,
    let $para := 
    In a hole in the ground there lived a hobbit.
             
    911, or
    fn:abs($N * $arg2) le fn:abs($arg1) 
                   and fn:compare($N * $arg2, 0) eq fn:compare($arg1, 0).
    466, indicating that the value of the component is to be output by name, in lower-case, upper-case, or title-case respectively. Components that can be output by name include (but are not limited to) months, days of the week, timezones, and eras. If the processor cannot output these components by name for the chosen calendar and language then it must use an ·implementation-defined· fallback representation.

If a comma is to be used as a grouping separator within the format token, then there must be a width specifier. More specifically: if a variable marker contains one or more commas, then the last comma is treated as introducing the width modifier, and all others are treated as grouping separators. So

fn:abs($N * $arg2) le fn:abs($arg1) 
               and fn:compare($N * $arg2, 0) eq fn:compare($arg1, 0).
467 will output the year as
fn:abs($N * $arg2) le fn:abs($arg1) 
               and fn:compare($N * $arg2, 0) eq fn:compare($arg1, 0).
468.

It is not possible to use a closing square bracket as a grouping separator within the format token.

If the implementation does not support the use of the requested format token, it must use the default presentation modifier for that component.

If the first presentation modifier is present, then it may optionally be followed by a second presentation modifier as follows:

ModifierMeaningeither
declare %public function r:random-sequence($length as xs:integer) as xs:double* {
  r:random-sequence($length, fn:random-number-generator())
};

declare %private function r:random-sequence($length as xs:integer, 
                                            $G as map(xs:string, item())) {
  if ($length eq 0)
  then ()
  else ($G?number, r:random-sequence($length - 1, $G?next()))
};

r:random-sequence(200);
            
39 or
let $para := 
In a hole in the ground there lived a hobbit.
         
303indicates alphabetic or traditional numbering respectively, the default being ·implementation-defined·. This has the same meaning as in the second argument of
let $para := 
In a hole in the ground there lived a hobbit.
         
225.either
let $para := 
In a hole in the ground there lived a hobbit.
         
300 or
let $para := 
In a hole in the ground there lived a hobbit.
         
292indicates cardinal or ordinal numbering respectively, for example
fn:abs($N * $arg2) le fn:abs($arg1) 
               and fn:compare($N * $arg2, 0) eq fn:compare($arg1, 0).
474 or
fn:abs($N * $arg2) le fn:abs($arg1) 
               and fn:compare($N * $arg2, 0) eq fn:compare($arg1, 0).
475 for a cardinal number, or
fn:abs($N * $arg2) le fn:abs($arg1) 
               and fn:compare($N * $arg2, 0) eq fn:compare($arg1, 0).
476,
fn:abs($N * $arg2) le fn:abs($arg1) 
               and fn:compare($N * $arg2, 0) eq fn:compare($arg1, 0).
477, or
fn:abs($N * $arg2) le fn:abs($arg1) 
               and fn:compare($N * $arg2, 0) eq fn:compare($arg1, 0).
478 for an ordinal number. This has the same meaning as in the second argument of
let $para := 
In a hole in the ground there lived a hobbit.
         
225. 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).

Note:

Although the formatting rules are expressed in terms of the rules for format tokens in

let $para := 
In a hole in the ground there lived a hobbit.
         
225, 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 (
fn:abs($N * $arg2) le fn:abs($arg1) 
               and fn:compare($N * $arg2, 0) eq fn:compare($arg1, 0).
481) for the first day of the month, and cardinal numbers (
fn:abs($N * $arg2) le fn:abs($arg1) 
               and fn:compare($N * $arg2, 0) eq fn:compare($arg1, 0).
482) for the remaining days. A processor may therefore use this convention to number days of the month, ignoring the presence or absence of the ordinal presentation modifier.

9.8.4.2 The Width Modifier

Whether or not a presentation modifier is included, a width modifier may be supplied. This indicates the number of characters to be included in the representation of the value.

The width modifier, if present, is introduced by a comma. It takes the form:

fn:abs($N * $arg2) le fn:abs($arg1) 
               and fn:compare($N * $arg2, 0) eq fn:compare($arg1, 0).
483

where

fn:abs($N * $arg2) le fn:abs($arg1) 
               and fn:compare($N * $arg2, 0) eq fn:compare($arg1, 0).
484 is either an unsigned integer indicating the minimum number of characters to be output, or
let $para := 
In a hole in the ground there lived a hobbit.
         
68 indicating that there is no explicit minimum, and
fn:abs($N * $arg2) le fn:abs($arg1) 
               and fn:compare($N * $arg2, 0) eq fn:compare($arg1, 0).
486 is either an unsigned integer indicating the maximum number of characters to be output, or
let $para := 
In a hole in the ground there lived a hobbit.
         
68 indicating that there is no explicit maximum; if
fn:abs($N * $arg2) le fn:abs($arg1) 
               and fn:compare($N * $arg2, 0) eq fn:compare($arg1, 0).
486 is omitted then
let $para := 
In a hole in the ground there lived a hobbit.
         
68 is assumed.

A dynamic error ([err:FOFD1340]) is raised if

fn:abs($N * $arg2) le fn:abs($arg1) 
               and fn:compare($N * $arg2, 0) eq fn:compare($arg1, 0).
484 is present and less than one, or if
fn:abs($N * $arg2) le fn:abs($arg1) 
               and fn:compare($N * $arg2, 0) eq fn:compare($arg1, 0).
486 is present and less than one or less than
fn:abs($N * $arg2) le fn:abs($arg1) 
               and fn:compare($N * $arg2, 0) eq fn:compare($arg1, 0).
484.

A format token containing more than one digit, such as

let $para := 
In a hole in the ground there lived a hobbit.
         
254 or
fn:abs($N * $arg2) le fn:abs($arg1) 
               and fn:compare($N * $arg2, 0) eq fn:compare($arg1, 0).
494, sets the minimum and maximum width to the number of digits appearing in the format token; if a width modifier is also present, then the width modifier takes precedence.

9.8.4.3 Formatting Integer-Valued Date/Time Components

The rules in this section apply to the majority of integer-valued components: specifically

fn:abs($N * $arg2) le fn:abs($arg1) 
               and fn:compare($N * $arg2, 0) eq fn:compare($arg1, 0).
495.

In the rules below, the term decimal digit pattern has the meaning given in 4.6.1 fn:format-integer.

  1. If the first presentation modifier takes the form of a decimal digit pattern:

    1. If there is no width modifier, then the value is formatted according to the rules of the

      fn:abs($N * $arg2) le fn:abs($arg1) 
                     and fn:compare($N * $arg2, 0) eq fn:compare($arg1, 0).
      496 function.

    2. If there is a width modifier, then the first presentation modifier is adjusted as follows:

      1. If the decimal digit pattern includes a grouping separator, the output is implementation-defined (but this is not an error).

        Note:

        Use of a width modifier together with grouping separators is inadvisable for this reason. It is never necessary to use a width modifier with a decimal digit pattern, since the same effect can be achieved by use of optional digit signs.

      2. Otherwise, the number of mandatory-digit-sign characters in the presentation modifier is increased if necessary. This is done first by replacing optional-digit-signs with mandatory-digit-signs, starting from the right, and then prepending mandatory-digit-signs to the presentation modifier, until the number of mandatory-digit-signs is equal to the minimum width. Any mandatory-digit-signs that are added by this process must use the same decimal digit family as existing mandatory-digit-signs in the presentation modifier if there are any, or ASCII digits otherwise.

      3. The maximum width, if specified, is ignored.

      4. The output is then as defined using the

        fn:abs($N * $arg2) le fn:abs($arg1) 
                       and fn:compare($N * $arg2, 0) eq fn:compare($arg1, 0).
        496 function with this adjusted decimal digit pattern.

  2. If the first presentation modifiers is one of

    let $para := 
    In a hole in the ground there lived a hobbit.
             
    911,
    fn:abs($N * $arg2) le fn:abs($arg1) 
                   and fn:compare($N * $arg2, 0) eq fn:compare($arg1, 0).
    464, or
    fn:abs($N * $arg2) le fn:abs($arg1) 
                   and fn:compare($N * $arg2, 0) eq fn:compare($arg1, 0).
    466:

    1. Let FN be the full name of the component, that is, the form of the name that would be used in the absence of any width modifier.

    2. If FN is shorter than the minimum width, then it is padded by appending spaces to the end of the name.

    3. If FN is longer than the maximum width, then it is abbreviated, either by choosing a conventional abbreviation that fits within the maximum width (for example, "Wednesday" might be abbreviated to "Weds"), or by removing characters from the end of FN until it fits within the maximum width.

  3. For other presentation modifiers:

    1. Any adjustment of the value to fit within the requested width range is implementation-defined.

    2. The value should not be truncated if this results in output that will not be meaningful to users (for example, there is no sensible way to truncate Roman numerals).

    3. If shorter than the minimum width, the value should be padded to the minimum width, either by appending spaces, or in some other way appropriate to the numbering scheme.

9.8.4.4 Formatting the Year Component

The rules for the year component (Y) are the same as those in 9.8.4.3 Formatting Integer-Valued Date/Time Components, except that the value of the year as output is the value of the year component of the supplied value modulo ten to the power N where N is determined as follows:

  1. If the width modifier is present and defines a finite maximum width, then that maximum width.

  2. Otherwise, if the first presentation modifier takes the form of a decimal-digit-pattern, then:

    1. Let W be the number of optional-digit-signs and mandatory-digit-signs in that decimal-digit-pattern.

    2. If W is 2 or more, then W.

  3. Otherwise, N is infinity (that is, the year is output in full).

9.8.4.5 Formatting Fractional Seconds

The output for the fractional seconds component (

fn:abs($N * $arg2) le fn:abs($arg1) 
               and fn:compare($N * $arg2, 0) eq fn:compare($arg1, 0).
501) is equivalent to the result of the following algorithm:

  1. If the first presentation modifier contains no Unicode digit, then the output is implementation-defined.

  2. Otherwise, the value of the fractional seconds is output as follows:

    1. If there is no width modifier and the first presentation modifier comprises in its entirety a single mandatory-digit-sign (for example the default

      declare %public function r:random-sequence($length as xs:integer) as xs:double* {
        r:random-sequence($length, fn:random-number-generator())
      };
      
      declare %private function r:random-sequence($length as xs:integer, 
                                                  $G as map(xs:string, item())) {
        if ($length eq 0)
        then ()
        else ($G?number, r:random-sequence($length - 1, $G?next()))
      };
      
      r:random-sequence(200);
                  
      13), then the presentation modifier is extended on the right with as many optional-digit-signs as are needed to accommodate the actual fractional seconds precision encountered in the value to be formatted.

    2. If there is a width modifier, then the first presentation modifier is adjusted as follows:

      1. If a minimum width is specified, and if this exceeds the number of mandatory-digit-sign characters in the first presentation modifier, then the first presentation modifier is adjusted. This is done first by replacing optional-digit-signs with mandatory-digit-signs, starting from the left, and then appending mandatory-digit-signs to the presentation modifier, until the number of mandatory-digit-signs is equal to the minimum width. Any mandatory-digit-signs that are added by this process must use the same decimal digit family as existing mandatory-digit-signs in the presentation modifier.

      2. If a maximum width is specified, the first presentation modifier is extended on the right with as many optional-digit-signs as are needed to ensure that the number of mandatory-digit-signs and optional-digit-signs is at least equal to the maximum width.

    3. The sequence of characters in the (adjusted) first presentation modifier is reversed (for example,

      fn:abs($N * $arg2) le fn:abs($arg1) 
                     and fn:compare($N * $arg2, 0) eq fn:compare($arg1, 0).
      503 becomes
      fn:abs($N * $arg2) le fn:abs($arg1) 
                     and fn:compare($N * $arg2, 0) eq fn:compare($arg1, 0).
      504). If the result is not a valid decimal digit pattern, then the output is ·implementation-defined·.

    4. The sequence of digits in the conventional decimal representation of the fractional seconds component is reversed, with insignificant zeroes removed, and the result is treated as an integer. For example, if the seconds value is

      fn:abs($N * $arg2) le fn:abs($arg1) 
                     and fn:compare($N * $arg2, 0) eq fn:compare($arg1, 0).
      505, the reversed fractional seconds value is
      fn:abs($N * $arg2) le fn:abs($arg1) 
                     and fn:compare($N * $arg2, 0) eq fn:compare($arg1, 0).
      506.

    5. The reversed fractional seconds value is formatted using the reversed decimal digit pattern according to the rules of the

      let $para := 
      In a hole in the ground there lived a hobbit.
               
      225 function. Given the examples above, the result is
      fn:abs($N * $arg2) le fn:abs($arg1) 
                     and fn:compare($N * $arg2, 0) eq fn:compare($arg1, 0).
      508

    6. The resulting string is reversed. In our example, the result is

      fn:abs($N * $arg2) le fn:abs($arg1) 
                     and fn:compare($N * $arg2, 0) eq fn:compare($arg1, 0).
      509.

    7. If the result contains more digits than the number of mandatory-digit-signs and optional-digit-signs in the decimal digit pattern, then excess digits are removed from the right hand end (that is, the value is truncated towards zero rather than being rounded). Any grouping separator that immediately precedes a removed digit is also removed.

Note:

The reason for presenting the algorithm in this way is that it enables maximum re-use of the rules defined for

let $para := 
In a hole in the ground there lived a hobbit.
         
225. 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.

Note:

A format token consisting of a single digit, such as

declare %public function r:random-sequence($length as xs:integer) as xs:double* {
  r:random-sequence($length, fn:random-number-generator())
};

declare %private function r:random-sequence($length as xs:integer, 
                                            $G as map(xs:string, item())) {
  if ($length eq 0)
  then ()
  else ($G?number, r:random-sequence($length - 1, $G?next()))
};

r:random-sequence(200);
            
13, does not constrain the number of digits in the output. In the case of fractional seconds in particular,
fn:abs($N * $arg2) le fn:abs($arg1) 
               and fn:compare($N * $arg2, 0) eq fn:compare($arg1, 0).
512 requests three decimal digits,
fn:abs($N * $arg2) le fn:abs($arg1) 
               and fn:compare($N * $arg2, 0) eq fn:compare($arg1, 0).
513 requests two digits, but
fn:abs($N * $arg2) le fn:abs($arg1) 
               and fn:compare($N * $arg2, 0) eq fn:compare($arg1, 0).
514 will retain all digits in the supplied date/time value (the maximum number of digits is implementation-defined). If exactly one digit is required, this can be achieved using the component specifier
fn:abs($N * $arg2) le fn:abs($arg1) 
               and fn:compare($N * $arg2, 0) eq fn:compare($arg1, 0).
515.

9.8.4.6 Formatting timezones

Special rules apply to the formatting of timezones. When the component specifiers

fn:abs($N * $arg2) le fn:abs($arg1) 
               and fn:compare($N * $arg2, 0) eq fn:compare($arg1, 0).
073 or
fn:abs($N * $arg2) le fn:abs($arg1) 
               and fn:compare($N * $arg2, 0) eq fn:compare($arg1, 0).
517 are used, the rules in this section override any rules given elsewhere in the case of discrepancies.

If the date/time value to be formatted does not include a timezone offset, then the timezone component specifier is generally ignored (results in no output). The exception is where military timezones are used (format ZZ) in which case the string "J" is output, indicating local time.

  • When the component specifier is

    fn:abs($N * $arg2) le fn:abs($arg1) 
                   and fn:compare($N * $arg2, 0) eq fn:compare($arg1, 0).
    517, the output is the same as for component specifier
    fn:abs($N * $arg2) le fn:abs($arg1) 
                   and fn:compare($N * $arg2, 0) eq fn:compare($arg1, 0).
    073, except that it is prefixed by the characters
    fn:abs($N * $arg2) le fn:abs($arg1) 
                   and fn:compare($N * $arg2, 0) eq fn:compare($arg1, 0).
    452 or some localized equivalent. The prefix is omitted, however, in cases where the timezone is identified by name rather than by a numeric offset from UTC.

  • If the first presentation modifier is numeric and comprises one or two digits with no grouping-separator (for example

    declare %public function r:random-sequence($length as xs:integer) as xs:double* {
      r:random-sequence($length, fn:random-number-generator())
    };
    
    declare %private function r:random-sequence($length as xs:integer, 
                                                $G as map(xs:string, item())) {
      if ($length eq 0)
      then ()
      else ($G?number, r:random-sequence($length - 1, $G?next()))
    };
    
    r:random-sequence(200);
                
    13 or
    let $para := 
    In a hole in the ground there lived a hobbit.
             
    259), then the timezone is formatted as a displacement from UTC in hours, preceded by a plus or minus sign: for example
    fn:abs($N * $arg2) le fn:abs($arg1) 
                   and fn:compare($N * $arg2, 0) eq fn:compare($arg1, 0).
    523 or
    fn:abs($N * $arg2) le fn:abs($arg1) 
                   and fn:compare($N * $arg2, 0) eq fn:compare($arg1, 0).
    524. If the actual timezone offset is not an integral number of hours, then the minutes part of the offset is appended, separated by a colon: for example
    fn:abs($N * $arg2) le fn:abs($arg1) 
                   and fn:compare($N * $arg2, 0) eq fn:compare($arg1, 0).
    525 or
    fn:abs($N * $arg2) le fn:abs($arg1) 
                   and fn:compare($N * $arg2, 0) eq fn:compare($arg1, 0).
    526.

  • If the first presentation modifier is numeric with a grouping-separator (for example

    fn:abs($N * $arg2) le fn:abs($arg1) 
                   and fn:compare($N * $arg2, 0) eq fn:compare($arg1, 0).
    527 or
    fn:abs($N * $arg2) le fn:abs($arg1) 
                   and fn:compare($N * $arg2, 0) eq fn:compare($arg1, 0).
    528), then the timezone offset is output in hours and minutes, separated by the grouping separator, even if the number of minutes is zero: for example
    fn:abs($N * $arg2) le fn:abs($arg1) 
                   and fn:compare($N * $arg2, 0) eq fn:compare($arg1, 0).
    529 or
    fn:abs($N * $arg2) le fn:abs($arg1) 
                   and fn:compare($N * $arg2, 0) eq fn:compare($arg1, 0).
    530.

  • If the first presentation modifier is numeric and comprises three or four digits with no grouping-separator, for example

    let $para := 
    In a hole in the ground there lived a hobbit.
             
    254 or
    fn:abs($N * $arg2) le fn:abs($arg1) 
                   and fn:compare($N * $arg2, 0) eq fn:compare($arg1, 0).
    532, then the timezone offset is shown in hours and minutes with no separator, for example
    fn:abs($N * $arg2) le fn:abs($arg1) 
                   and fn:compare($N * $arg2, 0) eq fn:compare($arg1, 0).
    533 or
    fn:abs($N * $arg2) le fn:abs($arg1) 
                   and fn:compare($N * $arg2, 0) eq fn:compare($arg1, 0).
    534.

  • If the first presentation modifier is numeric, in any of the above formats, and the second presentation modifier is

    let $para := 
    In a hole in the ground there lived a hobbit.
             
    303, then a zero timezone offset (that is, UTC) is output as
    fn:abs($N * $arg2) le fn:abs($arg1) 
                   and fn:compare($N * $arg2, 0) eq fn:compare($arg1, 0).
    073 instead of a signed numeric value. In this presentation modifier is absent or if the timezone offset is non-zero, then the displayed timezone offset is preceded by a "-" sign for negative offsets or a "+" sign for non-negative offsets.

  • If the first presentation modifier is

    fn:abs($N * $arg2) le fn:abs($arg1) 
                   and fn:compare($N * $arg2, 0) eq fn:compare($arg1, 0).
    073, then the timezone is formatted as a military timezone letter, using the convention Z = +00:00, A = +01:00, B = +02:00, ..., M = +12:00, N = -01:00, O = -02:00, ... Y = -12:00. The letter J (meaning local time) is used in the case of a value that does not specify a timezone offset. Timezone offsets that have no representation in this system (for example Indian Standard Time, +05:30) are output as if the format
    fn:abs($N * $arg2) le fn:abs($arg1) 
                   and fn:compare($N * $arg2, 0) eq fn:compare($arg1, 0).
    538 had been requested.

  • If the first presentation modifier is

    let $para := 
    In a hole in the ground there lived a hobbit.
             
    911, then the timezone is output (where possible) as a timezone name, for example
    fn:abs($N * $arg2) le fn:abs($arg1) 
                   and fn:compare($N * $arg2, 0) eq fn:compare($arg1, 0).
    540 or
    fn:abs($N * $arg2) le fn:abs($arg1) 
                   and fn:compare($N * $arg2, 0) eq fn:compare($arg1, 0).
    541. The same timezone offset has different names in different places; it is therefore recommended that this option should be used only if a country code (see [ISO 3166-1]) or IANA timezone name (see [IANA Timezone Database]) is supplied in the
    fn:abs($N * $arg2) le fn:abs($arg1) 
                   and fn:compare($N * $arg2, 0) eq fn:compare($arg1, 0).
    369 argument. In the absence of this information, the implementation may apply a default, for example by using the timezone names that are conventional in North America. If no timezone name can be identified, the timezone offset is output using the fallback format
    fn:abs($N * $arg2) le fn:abs($arg1) 
                   and fn:compare($N * $arg2, 0) eq fn:compare($arg1, 0).
    543.

The following examples illustrate options for timezone formatting.

Variable marker
fn:abs($N * $arg2) le fn:abs($arg1) 
               and fn:compare($N * $arg2, 0) eq fn:compare($arg1, 0).
369Timezone offsets (with time = 12:00:00)  -10:00-05:00+00:00+05:30+13:00[Z]()-10:00-05:00+00:00+05:30+13:00[Z0]()-10-5+0+5:30+13[Z0:00]()-10:00-5:00+0:00+5:30+13:00[Z00:00]()-10:00-05:00+00:00+05:30+13:00[Z0000]()-1000-0500+0000+0530+1300[Z00:00t]()-10:00-05:00Z+05:30+13:00[z]()GMT‑10:00GMT‑05:00GMT+00:00GMT+05:30GMT+13:00[ZZ]()WRZ+05:30+13:00[ZN]"us"HSTESTGMTIST+13:00[H00]:[M00] [ZN]"America/New_York"06:00 EST12:00 EST07:00 EST01:30 EST18:00 EST

If a width specifier is present when formatting a timezone, then the representation as defined in this section is padded to the minimum width as described in 9.8.4.2 The Width Modifier, but it is never shortened.

9.8.4.7 Formatting Other Components

This section applies to the remaining components:

fn:abs($N * $arg2) le fn:abs($arg1) 
               and fn:compare($N * $arg2, 0) eq fn:compare($arg1, 0).
545 (am/pm marker),
fn:abs($N * $arg2) le fn:abs($arg1) 
               and fn:compare($N * $arg2, 0) eq fn:compare($arg1, 0).
546 (calendar), and
fn:abs($N * $arg2) le fn:abs($arg1) 
               and fn:compare($N * $arg2, 0) eq fn:compare($arg1, 0).
547 (era).

The output for these components is entirely ·implementation-defined·. The default presentation modifier for these components is

fn:abs($N * $arg2) le fn:abs($arg1) 
               and fn:compare($N * $arg2, 0) eq fn:compare($arg1, 0).
464, indicating that they are output as names (or conventional abbreviations), and the chosen names will in many cases depend on the chosen language: see 9.8.4.8 The language, calendar, and place arguments.

9.8.4.8 The language, calendar, and place arguments

The set of languages, calendars, and places that are supported in the ·date formatting functions· is ·implementation-defined·. When any of these arguments is omitted or is an empty sequence, an ·implementation-defined· default value is used.

If the fallback representation uses a different calendar from that requested, the output string must identify the calendar actually used, for example by prefixing the string with

fn:abs($N * $arg2) le fn:abs($arg1) 
               and fn:compare($N * $arg2, 0) eq fn:compare($arg1, 0).
549 (where X is the calendar actually used), localized as appropriate to the requested language. If the fallback representation uses a different language from that requested, the output string must identify the language actually used, for example by prefixing the string with
fn:abs($N * $arg2) le fn:abs($arg1) 
               and fn:compare($N * $arg2, 0) eq fn:compare($arg1, 0).
550 (where Y is the language actually used) localized in an implementation-dependent way. If a particular component of the value cannot be output in the requested format, it should be output in the default format for that component.

The

fn:abs($N * $arg2) le fn:abs($arg1) 
               and fn:compare($N * $arg2, 0) eq fn:compare($arg1, 0).
363 argument specifies the language to be used for the result string of the function. The value of the argument should be either the empty sequence or a value that would be valid for the
let $para := 
In a hole in the ground there lived a hobbit.
         
297 attribute (see [XML]). Note that this permits the identification of sublanguages based on country codes (from [ISO 3166-1]) as well as identification of dialects and of regions within a country.

If the

fn:abs($N * $arg2) le fn:abs($arg1) 
               and fn:compare($N * $arg2, 0) eq fn:compare($arg1, 0).
363 argument is omitted or is set to an empty sequence, or if it is set to an invalid value or a value that the implementation does not recognize, then the processor uses the default language defined in the dynamic context.

The language is used to select the appropriate language-dependent forms of:

  • names (for example, of months)

  • numbers expressed as words or as ordinals (

    fn:abs($N * $arg2) le fn:abs($arg1) 
                   and fn:compare($N * $arg2, 0) eq fn:compare($arg1, 0).
    554)

  • hour convention (0-23 vs 1-24, 0-11 vs 1-12)

  • first day of week, first week of year

Where appropriate this choice may also take into account the value of the

fn:abs($N * $arg2) le fn:abs($arg1) 
               and fn:compare($N * $arg2, 0) eq fn:compare($arg1, 0).
369 argument, though this should not be used to override the language or any sublanguage that is specified as part of the
fn:abs($N * $arg2) le fn:abs($arg1) 
               and fn:compare($N * $arg2, 0) eq fn:compare($arg1, 0).
556 argument.

The choice of the names and abbreviations used in any given language is ·implementation-defined·. For example, one implementation might abbreviate July as

fn:abs($N * $arg2) le fn:abs($arg1) 
               and fn:compare($N * $arg2, 0) eq fn:compare($arg1, 0).
557 while another uses
fn:abs($N * $arg2) le fn:abs($arg1) 
               and fn:compare($N * $arg2, 0) eq fn:compare($arg1, 0).
558. In German, one implementation might represent Saturday as
fn:abs($N * $arg2) le fn:abs($arg1) 
               and fn:compare($N * $arg2, 0) eq fn:compare($arg1, 0).
559 while another uses
fn:abs($N * $arg2) le fn:abs($arg1) 
               and fn:compare($N * $arg2, 0) eq fn:compare($arg1, 0).
560. Implementations may provide mechanisms allowing users to control such choices.

Where ordinal numbers are used, the selection of the correct representation of the ordinal (for example, the linguistic gender) may depend on the component being formatted and on its textual context in the picture string.

The

fn:abs($N * $arg2) le fn:abs($arg1) 
               and fn:compare($N * $arg2, 0) eq fn:compare($arg1, 0).
561 attribute specifies that the
fn:abs($N * $arg2) le fn:abs($arg1) 
               and fn:compare($N * $arg2, 0) eq fn:compare($arg1, 0).
562,
fn:abs($N * $arg2) le fn:abs($arg1) 
               and fn:compare($N * $arg2, 0) eq fn:compare($arg1, 0).
563, or
fn:abs($N * $arg2) le fn:abs($arg1) 
               and fn:compare($N * $arg2, 0) eq fn:compare($arg1, 0).
564 supplied in the
fn:abs($N * $arg2) le fn:abs($arg1) 
               and fn:compare($N * $arg2, 0) eq fn:compare($arg1, 0).
44 argument must be converted to a value in the specified calendar and then converted to a string using the conventions of that calendar.

The calendar value if present must be a valid

let $para := 
In a hole in the ground there lived a hobbit.
         
403 (dynamic error: [err:FOFD1340]). If it is a lexical
let $para := 
In a hole in the ground there lived a hobbit.
         
86 then it is expanded into an expanded QName using the statically known namespaces; if it has no prefix then it represents an expanded-QName in no namespace. If the expanded QName is in no namespace, then it must identify a calendar with a designator specified below (dynamic error: [err:FOFD1340]). If the expanded QName is in a namespace then it identifies the calendar in an ·implementation-defined· way.

If the

fn:abs($N * $arg2) le fn:abs($arg1) 
               and fn:compare($N * $arg2, 0) eq fn:compare($arg1, 0).
366 argument is omitted or is set to an empty sequence then the default calendar defined in the dynamic context is used.

Note:

The calendars listed below were known to be in use during the last hundred years. Many other calendars have been used in the past.

This specification does not define any of these calendars, nor the way that they map to the value space of the

op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
964 datatype in [XML Schema Part 2: Datatypes Second Edition]. There may be ambiguities when dates are recorded using different calendars. For example, the start of a new day is not simultaneous in different calendars, and may also vary geographically (for example, based on the time of sunrise or sunset). Translation of dates is therefore more reliable when the time of day is also known, and when the geographic location is known. When translating dates between one calendar and another, the processor may take account of the values of the
fn:abs($N * $arg2) le fn:abs($arg1) 
               and fn:compare($N * $arg2, 0) eq fn:compare($arg1, 0).
369 and/or
fn:abs($N * $arg2) le fn:abs($arg1) 
               and fn:compare($N * $arg2, 0) eq fn:compare($arg1, 0).
363 arguments, with the
fn:abs($N * $arg2) le fn:abs($arg1) 
               and fn:compare($N * $arg2, 0) eq fn:compare($arg1, 0).
369 argument taking precedence.

Information about some of these calendars, and algorithms for converting between them, may be found in [Calendrical Calculations].

DesignatorCalendarADAnno Domini (Christian Era)AHAnno Hegirae (Muhammedan Era)AMEMauludi Era (solar years since Mohammed's birth)AMAnno Mundi (Jewish Calendar)APAnno PersiciASAji Saka Era (Java)BEBuddhist EraCBCooch Behar EraCECommon EraCLChinese Lunar EraCSChula Sakarat EraEEEthiopian EraFEFasli EraISOISO 8601 calendarJEJapanese CalendarKEKhalsa Era (Sikh calendar)KYKali YugaMEMalabar EraMSMonarchic Solar EraNSNepal Samwat EraOSOld Style (Julian Calendar)RSRattanakosin (Bangkok) EraSESaka EraSHMohammedan Solar Era (Iran)SSSaka SamvatTETripurabda EraVEVikrama EraVSVikrama Samvat Era

At least one of the above calendars must be supported. It is ·implementation-defined· which calendars are supported.

The ISO 8601 calendar ([ISO 8601]), which is included in the above list and designated

fn:abs($N * $arg2) le fn:abs($arg1) 
               and fn:compare($N * $arg2, 0) eq fn:compare($arg1, 0).
573, is very similar to the Gregorian calendar designated
fn:abs($N * $arg2) le fn:abs($arg1) 
               and fn:compare($N * $arg2, 0) eq fn:compare($arg1, 0).
574, but it differs in several ways. The ISO calendar is intended to ensure that date and time formats can be read easily by other software, as well as being legible for human users. The ISO calendar prescribes the use of particular numbering conventions as defined in ISO 8601, rather than allowing these to be localized on a per-language basis. In particular it provides a numeric 'week date' format which identifies dates by year, week of the year, and day in the week; in the ISO calendar the days of the week are numbered from 1 (Monday) to 7 (Sunday), and week 1 in any calendar year is the week (from Monday to Sunday) that includes the first Thursday of that year. The numeric values of the components year, month, day, hour, minute, and second are the same in the ISO calendar as the values used in the lexical representation of the date and time as defined in [XML Schema Part 2: Datatypes Second Edition]. The era ("E" component) with this calendar is either a minus sign (for negative years) or a zero-length string (for positive years). For dates before 1 January, AD 1, year numbers in the ISO and AD calendars are off by one from each other: ISO year 0000 is 1 BC, -0001 is 2 BC, etc.

ISO 8601 does not define a numbering for weeks within a month. When the

let $para := 
In a hole in the ground there lived a hobbit.
         
278 component is used, the convention to be adopted is that each Monday-to-Sunday week is considered to fall within a particular month if its Thursday occurs in that month; the weeks that fall in a particular month under this definition are numbered starting from 1. Thus, for example, 29 January 2013 falls in week 5 because the Thursday of the week (31 January 2013) is the fifth Thursday in January, and 1 February 2013 is also in week 5 for the same reason.

Note:

The value space of the date and time datatypes, as defined in XML Schema, is based on absolute points in time. The lexical space of these datatypes defines a representation of these absolute points in time using the proleptic Gregorian calendar, that is, the modern Western calendar extrapolated into the past and the future; but the value space is calendar-neutral. The ·date formatting functions· produce a representation of this absolute point in time, but denoted in a possibly different calendar. So, for example, the date whose lexical representation in XML Schema is

fn:abs($N * $arg2) le fn:abs($arg1) 
               and fn:compare($N * $arg2, 0) eq fn:compare($arg1, 0).
576 (the day on which Pope Gregory XIII was born) might be formatted using the Old Style (Julian) calendar as
fn:abs($N * $arg2) le fn:abs($arg1) 
               and fn:compare($N * $arg2, 0) eq fn:compare($arg1, 0).
577. This reflects the fact that there was at that time a ten-day difference between the two calendars. It would be incorrect, and would produce incorrect results, to represent this date in an element or attribute of type
op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
964 as
fn:abs($N * $arg2) le fn:abs($arg1) 
               and fn:compare($N * $arg2, 0) eq fn:compare($arg1, 0).
579, even though this might reflect the way the date was recorded in contemporary documents.

When referring to years occurring in antiquity, modern historians generally use a numbering system in which there is no year zero (the year before 1 CE is thus 1 BCE). This is the convention that should be used when the requested calendar is OS (Julian) or AD (Gregorian). When the requested calendar is ISO, however, the conventions of ISO 8601 should be followed: here the year before +0001 is numbered zero. In [XML Schema Part 2: Datatypes Second Edition] (version 1.0), the value space for

op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
964 and
let $para := 
In a hole in the ground there lived a hobbit.
         
29 does not include a year zero: however, XSD 1.1 endorses the ISO 8601 convention. This means that the date on which Julius Caesar was assassinated has the ISO 8601 lexical representation -0043-03-13, but will be formatted as 15 March 44 BCE in the Julian calendar or 13 March 44 BCE in the Gregorian calendar (dependant on the chosen localization of the names of months and eras).

The intended use of the

fn:abs($N * $arg2) le fn:abs($arg1) 
               and fn:compare($N * $arg2, 0) eq fn:compare($arg1, 0).
369 argument is to identify the place where an event represented by the
fn:abs($N * $arg2) le fn:abs($arg1) 
               and fn:compare($N * $arg2, 0) eq fn:compare($arg1, 0).
562,
fn:abs($N * $arg2) le fn:abs($arg1) 
               and fn:compare($N * $arg2, 0) eq fn:compare($arg1, 0).
563, or
fn:abs($N * $arg2) le fn:abs($arg1) 
               and fn:compare($N * $arg2, 0) eq fn:compare($arg1, 0).
564 supplied in the
fn:abs($N * $arg2) le fn:abs($arg1) 
               and fn:compare($N * $arg2, 0) eq fn:compare($arg1, 0).
44 argument took place or will take place. If the
fn:abs($N * $arg2) le fn:abs($arg1) 
               and fn:compare($N * $arg2, 0) eq fn:compare($arg1, 0).
369 argument is omitted or is set to an empty sequence, then the default place defined in the dynamic context is used. If the value is supplied, and is not the empty sequence, then it should either be a country code or an IANA timezone name. If the value does not take this form, or if its value is not recognized by the implementation, then the default place defined in the dynamic context is used.

  • Country codes are defined in [ISO 3166-1]. Examples are "de" for Germany and "jp" for Japan. Implementations may also allow the use of codes representing subdivisions of a country from ISO 3166-2, or codes representing formerly used names of countries from ISO 3166-3

  • IANA timezone names are defined in the IANA timezone database [IANA Timezone Database]. Examples are "America/New_York" and "Europe/Rome".

This argument is not intended to identify the location of the user for whom the date or time is being formatted; that should be done by means of the

fn:abs($N * $arg2) le fn:abs($arg1) 
               and fn:compare($N * $arg2, 0) eq fn:compare($arg1, 0).
363 attribute. This information may be used to provide additional information when converting dates between calendars or when deciding how individual components of the date and time are to be formatted. For example, different countries using the Old Style (Julian) calendar started the new year on different days, and some countries used variants of the calendar that were out of synchronization as a result of differences in calculating leap years.

The geographical area identified by a country code is defined by the boundaries as they existed at the time of the date to be formatted, or the present-day boundaries for dates in the future.

If the

fn:abs($N * $arg2) le fn:abs($arg1) 
               and fn:compare($N * $arg2, 0) eq fn:compare($arg1, 0).
369 argument is supplied in the form of an IANA timezone name that is recognized by the implementation, then the date or time being formatted is adjusted to the timezone offset applicable in that timezone. For example, if the
let $para := 
In a hole in the ground there lived a hobbit.
         
29 value
fn:abs($N * $arg2) le fn:abs($arg1) 
               and fn:compare($N * $arg2, 0) eq fn:compare($arg1, 0).
591 is formatted with the
fn:abs($N * $arg2) le fn:abs($arg1) 
               and fn:compare($N * $arg2, 0) eq fn:compare($arg1, 0).
369 argument set to
fn:abs($N * $arg2) le fn:abs($arg1) 
               and fn:compare($N * $arg2, 0) eq fn:compare($arg1, 0).
593, then the output will be as if the value
fn:abs($N * $arg2) le fn:abs($arg1) 
               and fn:compare($N * $arg2, 0) eq fn:compare($arg1, 0).
594 had been supplied. This adjustment takes daylight savings time into account where possible; if the date in question falls during daylight savings time in New York, then it is adjusted to timezone offset
fn:abs($N * $arg2) le fn:abs($arg1) 
               and fn:compare($N * $arg2, 0) eq fn:compare($arg1, 0).
595 rather than
fn:abs($N * $arg2) le fn:abs($arg1) 
               and fn:compare($N * $arg2, 0) eq fn:compare($arg1, 0).
596. Adjustment using daylight savings time is only possible where the value includes a date, and where the date is within the range covered by the timezone database.

9.8.5 Examples of date and time formatting

The following examples show a selection of dates and times and the way they might be formatted. These examples assume the use of the Gregorian calendar as the default calendar.

Required OutputExpression
fn:abs($N * $arg2) le fn:abs($arg1) 
               and fn:compare($N * $arg2, 0) eq fn:compare($arg1, 0).
597
fn:abs($N * $arg2) le fn:abs($arg1) 
               and fn:compare($N * $arg2, 0) eq fn:compare($arg1, 0).
598
fn:abs($N * $arg2) le fn:abs($arg1) 
               and fn:compare($N * $arg2, 0) eq fn:compare($arg1, 0).
599
fn:abs($N * $arg2) le fn:abs($arg1) 
               and fn:compare($N * $arg2, 0) eq fn:compare($arg1, 0).
600
fn:abs($N * $arg2) le fn:abs($arg1) 
               and fn:compare($N * $arg2, 0) eq fn:compare($arg1, 0).
601
fn:abs($N * $arg2) le fn:abs($arg1) 
               and fn:compare($N * $arg2, 0) eq fn:compare($arg1, 0).
602
fn:abs($N * $arg2) le fn:abs($arg1) 
               and fn:compare($N * $arg2, 0) eq fn:compare($arg1, 0).
603
fn:abs($N * $arg2) le fn:abs($arg1) 
               and fn:compare($N * $arg2, 0) eq fn:compare($arg1, 0).
604
fn:abs($N * $arg2) le fn:abs($arg1) 
               and fn:compare($N * $arg2, 0) eq fn:compare($arg1, 0).
605
fn:abs($N * $arg2) le fn:abs($arg1) 
               and fn:compare($N * $arg2, 0) eq fn:compare($arg1, 0).
606
fn:abs($N * $arg2) le fn:abs($arg1) 
               and fn:compare($N * $arg2, 0) eq fn:compare($arg1, 0).
607
fn:abs($N * $arg2) le fn:abs($arg1) 
               and fn:compare($N * $arg2, 0) eq fn:compare($arg1, 0).
608
fn:abs($N * $arg2) le fn:abs($arg1) 
               and fn:compare($N * $arg2, 0) eq fn:compare($arg1, 0).
609
fn:abs($N * $arg2) le fn:abs($arg1) 
               and fn:compare($N * $arg2, 0) eq fn:compare($arg1, 0).
610
fn:abs($N * $arg2) le fn:abs($arg1) 
               and fn:compare($N * $arg2, 0) eq fn:compare($arg1, 0).
611
fn:abs($N * $arg2) le fn:abs($arg1) 
               and fn:compare($N * $arg2, 0) eq fn:compare($arg1, 0).
612
fn:abs($N * $arg2) le fn:abs($arg1) 
               and fn:compare($N * $arg2, 0) eq fn:compare($arg1, 0).
613
fn:abs($N * $arg2) le fn:abs($arg1) 
               and fn:compare($N * $arg2, 0) eq fn:compare($arg1, 0).
614
fn:abs($N * $arg2) le fn:abs($arg1) 
               and fn:compare($N * $arg2, 0) eq fn:compare($arg1, 0).
615
fn:abs($N * $arg2) le fn:abs($arg1) 
               and fn:compare($N * $arg2, 0) eq fn:compare($arg1, 0).
616
fn:abs($N * $arg2) le fn:abs($arg1) 
               and fn:compare($N * $arg2, 0) eq fn:compare($arg1, 0).
617
fn:abs($N * $arg2) le fn:abs($arg1) 
               and fn:compare($N * $arg2, 0) eq fn:compare($arg1, 0).
618
fn:abs($N * $arg2) le fn:abs($arg1) 
               and fn:compare($N * $arg2, 0) eq fn:compare($arg1, 0).
619
fn:abs($N * $arg2) le fn:abs($arg1) 
               and fn:compare($N * $arg2, 0) eq fn:compare($arg1, 0).
620
fn:abs($N * $arg2) le fn:abs($arg1) 
               and fn:compare($N * $arg2, 0) eq fn:compare($arg1, 0).
621
fn:abs($N * $arg2) le fn:abs($arg1) 
               and fn:compare($N * $arg2, 0) eq fn:compare($arg1, 0).
622
fn:abs($N * $arg2) le fn:abs($arg1) 
               and fn:compare($N * $arg2, 0) eq fn:compare($arg1, 0).
623
fn:abs($N * $arg2) le fn:abs($arg1) 
               and fn:compare($N * $arg2, 0) eq fn:compare($arg1, 0).
624
fn:abs($N * $arg2) le fn:abs($arg1) 
               and fn:compare($N * $arg2, 0) eq fn:compare($arg1, 0).
625
fn:abs($N * $arg2) le fn:abs($arg1) 
               and fn:compare($N * $arg2, 0) eq fn:compare($arg1, 0).
626
fn:abs($N * $arg2) le fn:abs($arg1) 
               and fn:compare($N * $arg2, 0) eq fn:compare($arg1, 0).
627
fn:abs($N * $arg2) le fn:abs($arg1) 
               and fn:compare($N * $arg2, 0) eq fn:compare($arg1, 0).
628
fn:abs($N * $arg2) le fn:abs($arg1) 
               and fn:compare($N * $arg2, 0) eq fn:compare($arg1, 0).
629
fn:abs($N * $arg2) le fn:abs($arg1) 
               and fn:compare($N * $arg2, 0) eq fn:compare($arg1, 0).
630
fn:abs($N * $arg2) le fn:abs($arg1) 
               and fn:compare($N * $arg2, 0) eq fn:compare($arg1, 0).
631
fn:abs($N * $arg2) le fn:abs($arg1) 
               and fn:compare($N * $arg2, 0) eq fn:compare($arg1, 0).
632
fn:abs($N * $arg2) le fn:abs($arg1) 
               and fn:compare($N * $arg2, 0) eq fn:compare($arg1, 0).
633
fn:abs($N * $arg2) le fn:abs($arg1) 
               and fn:compare($N * $arg2, 0) eq fn:compare($arg1, 0).
634
fn:abs($N * $arg2) le fn:abs($arg1) 
               and fn:compare($N * $arg2, 0) eq fn:compare($arg1, 0).
635
fn:abs($N * $arg2) le fn:abs($arg1) 
               and fn:compare($N * $arg2, 0) eq fn:compare($arg1, 0).
636
fn:abs($N * $arg2) le fn:abs($arg1) 
               and fn:compare($N * $arg2, 0) eq fn:compare($arg1, 0).
637
fn:abs($N * $arg2) le fn:abs($arg1) 
               and fn:compare($N * $arg2, 0) eq fn:compare($arg1, 0).
638
fn:abs($N * $arg2) le fn:abs($arg1) 
               and fn:compare($N * $arg2, 0) eq fn:compare($arg1, 0).
639
fn:abs($N * $arg2) le fn:abs($arg1) 
               and fn:compare($N * $arg2, 0) eq fn:compare($arg1, 0).
640

The following examples use calendars other than the Gregorian calendar.

DescriptionRequestResultIslamic
fn:abs($N * $arg2) le fn:abs($arg1) 
               and fn:compare($N * $arg2, 0) eq fn:compare($arg1, 0).
641٢٦ ﺸﻭّﺍﻝ ١٤٢٣Jewish (with Western numbering)
fn:abs($N * $arg2) le fn:abs($arg1) 
               and fn:compare($N * $arg2, 0) eq fn:compare($arg1, 0).
642‏26 טבת 5763Jewish (with traditional numbering)
fn:abs($N * $arg2) le fn:abs($arg1) 
               and fn:compare($N * $arg2, 0) eq fn:compare($arg1, 0).
643כ״ו טבת תשס״גJulian (Old Style)
fn:abs($N * $arg2) le fn:abs($arg1) 
               and fn:compare($N * $arg2, 0) eq fn:compare($arg1, 0).
64418 December 2002Thai
fn:abs($N * $arg2) le fn:abs($arg1) 
               and fn:compare($N * $arg2, 0) eq fn:compare($arg1, 0).
645๓๑ ธันวาคม ๒๕๔๕

9.9 Parsing dates and times

FunctionMeaning
fn:abs($N * $arg2) le fn:abs($arg1) 
               and fn:compare($N * $arg2, 0) eq fn:compare($arg1, 0).
646Parses a string containing the date and time in IETF format, returning the corresponding
let $para := 
In a hole in the ground there lived a hobbit.
         
29 value.

A function is provided to parse dates and times expressed using syntax that is commonly encountered in internet protocols.

9.9.1 fn:parse-ietf-date

Summary

Parses a string containing the date and time in IETF format, returning the corresponding

let $para := 
In a hole in the ground there lived a hobbit.
         
29 value.

Signature

fn:abs($N * $arg2) le fn:abs($arg1) 
               and fn:compare($N * $arg2, 0) eq fn:compare($arg1, 0).
646(
fn:abs($N * $arg2) le fn:abs($arg1) 
               and fn:compare($N * $arg2, 0) eq fn:compare($arg1, 0).
44
let $para := 
In a hole in the ground there lived a hobbit.
         
71
let $para := 
In a hole in the ground there lived a hobbit.
         
244)
let $para := 
In a hole in the ground there lived a hobbit.
         
71
op:operation(fenceHeight, xs:integer) => op:operation(xs:integer, xs:integer)
038

Properties

This function is ·deterministic·, ·context-independent·, and ·focus-independent·.

Rules

The function accepts a string matching the production

fn:abs($N * $arg2) le fn:abs($arg1) 
               and fn:compare($N * $arg2, 0) eq fn:compare($arg1, 0).
655 in the following grammar:

fn:abs($N * $arg2) le fn:abs($arg1) 
               and fn:compare($N * $arg2, 0) eq fn:compare($arg1, 0).
655
fn:abs($N * $arg2) le fn:abs($arg1) 
               and fn:compare($N * $arg2, 0) eq fn:compare($arg1, 0).
657
fn:abs($N * $arg2) le fn:abs($arg1) 
               and fn:compare($N * $arg2, 0) eq fn:compare($arg1, 0).
658
fn:abs($N * $arg2) le fn:abs($arg1) 
               and fn:compare($N * $arg2, 0) eq fn:compare($arg1, 0).
659
fn:abs($N * $arg2) le fn:abs($arg1) 
               and fn:compare($N * $arg2, 0) eq fn:compare($arg1, 0).
657
fn:abs($N * $arg2) le fn:abs($arg1) 
               and fn:compare($N * $arg2, 0) eq fn:compare($arg1, 0).
661
fn:abs($N * $arg2) le fn:abs($arg1) 
               and fn:compare($N * $arg2, 0) eq fn:compare($arg1, 0).
662
fn:abs($N * $arg2) le fn:abs($arg1) 
               and fn:compare($N * $arg2, 0) eq fn:compare($arg1, 0).
657
fn:abs($N * $arg2) le fn:abs($arg1) 
               and fn:compare($N * $arg2, 0) eq fn:compare($arg1, 0).
664
fn:abs($N * $arg2) le fn:abs($arg1) 
               and fn:compare($N * $arg2, 0) eq fn:compare($arg1, 0).
665
fn:abs($N * $arg2) le fn:abs($arg1) 
               and fn:compare($N * $arg2, 0) eq fn:compare($arg1, 0).
657
fn:abs($N * $arg2) le fn:abs($arg1) 
               and fn:compare($N * $arg2, 0) eq fn:compare($arg1, 0).
667
fn:abs($N * $arg2) le fn:abs($arg1) 
               and fn:compare($N * $arg2, 0) eq fn:compare($arg1, 0).
668
fn:abs($N * $arg2) le fn:abs($arg1) 
               and fn:compare($N * $arg2, 0) eq fn:compare($arg1, 0).
657
fn:abs($N * $arg2) le fn:abs($arg1) 
               and fn:compare($N * $arg2, 0) eq fn:compare($arg1, 0).
670
fn:abs($N * $arg2) le fn:abs($arg1) 
               and fn:compare($N * $arg2, 0) eq fn:compare($arg1, 0).
671
fn:abs($N * $arg2) le fn:abs($arg1) 
               and fn:compare($N * $arg2, 0) eq fn:compare($arg1, 0).
657
fn:abs($N * $arg2) le fn:abs($arg1) 
               and fn:compare($N * $arg2, 0) eq fn:compare($arg1, 0).
673
op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
984
fn:abs($N * $arg2) le fn:abs($arg1) 
               and fn:compare($N * $arg2, 0) eq fn:compare($arg1, 0).
657
fn:abs($N * $arg2) le fn:abs($arg1) 
               and fn:compare($N * $arg2, 0) eq fn:compare($arg1, 0).
676
let $para := 
In a hole in the ground there lived a hobbit.
         
365
fn:abs($N * $arg2) le fn:abs($arg1) 
               and fn:compare($N * $arg2, 0) eq fn:compare($arg1, 0).
657
fn:abs($N * $arg2) le fn:abs($arg1) 
               and fn:compare($N * $arg2, 0) eq fn:compare($arg1, 0).
679
fn:abs($N * $arg2) le fn:abs($arg1) 
               and fn:compare($N * $arg2, 0) eq fn:compare($arg1, 0).
680
fn:abs($N * $arg2) le fn:abs($arg1) 
               and fn:compare($N * $arg2, 0) eq fn:compare($arg1, 0).
657
fn:abs($N * $arg2) le fn:abs($arg1) 
               and fn:compare($N * $arg2, 0) eq fn:compare($arg1, 0).
682
fn:abs($N * $arg2) le fn:abs($arg1) 
               and fn:compare($N * $arg2, 0) eq fn:compare($arg1, 0).
564
fn:abs($N * $arg2) le fn:abs($arg1) 
               and fn:compare($N * $arg2, 0) eq fn:compare($arg1, 0).
657
fn:abs($N * $arg2) le fn:abs($arg1) 
               and fn:compare($N * $arg2, 0) eq fn:compare($arg1, 0).
685
fn:abs($N * $arg2) le fn:abs($arg1) 
               and fn:compare($N * $arg2, 0) eq fn:compare($arg1, 0).
686
fn:abs($N * $arg2) le fn:abs($arg1) 
               and fn:compare($N * $arg2, 0) eq fn:compare($arg1, 0).
657
fn:abs($N * $arg2) le fn:abs($arg1) 
               and fn:compare($N * $arg2, 0) eq fn:compare($arg1, 0).
673
fn:abs($N * $arg2) le fn:abs($arg1) 
               and fn:compare($N * $arg2, 0) eq fn:compare($arg1, 0).
689
fn:abs($N * $arg2) le fn:abs($arg1) 
               and fn:compare($N * $arg2, 0) eq fn:compare($arg1, 0).
657
fn:abs($N * $arg2) le fn:abs($arg1) 
               and fn:compare($N * $arg2, 0) eq fn:compare($arg1, 0).
691
fn:abs($N * $arg2) le fn:abs($arg1) 
               and fn:compare($N * $arg2, 0) eq fn:compare($arg1, 0).
692
fn:abs($N * $arg2) le fn:abs($arg1) 
               and fn:compare($N * $arg2, 0) eq fn:compare($arg1, 0).
657
fn:abs($N * $arg2) le fn:abs($arg1) 
               and fn:compare($N * $arg2, 0) eq fn:compare($arg1, 0).
694
op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
990
fn:abs($N * $arg2) le fn:abs($arg1) 
               and fn:compare($N * $arg2, 0) eq fn:compare($arg1, 0).
657
fn:abs($N * $arg2) le fn:abs($arg1) 
               and fn:compare($N * $arg2, 0) eq fn:compare($arg1, 0).
697
fn:abs($N * $arg2) le fn:abs($arg1) 
               and fn:compare($N * $arg2, 0) eq fn:compare($arg1, 0).
698
fn:abs($N * $arg2) le fn:abs($arg1) 
               and fn:compare($N * $arg2, 0) eq fn:compare($arg1, 0).
657
fn:abs($N * $arg2) le fn:abs($arg1) 
               and fn:compare($N * $arg2, 0) eq fn:compare($arg1, 0).
700
fn:abs($N * $arg2) le fn:abs($arg1) 
               and fn:compare($N * $arg2, 0) eq fn:compare($arg1, 0).
701
fn:abs($N * $arg2) le fn:abs($arg1) 
               and fn:compare($N * $arg2, 0) eq fn:compare($arg1, 0).
657
fn:abs($N * $arg2) le fn:abs($arg1) 
               and fn:compare($N * $arg2, 0) eq fn:compare($arg1, 0).
703
op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
072
fn:abs($N * $arg2) le fn:abs($arg1) 
               and fn:compare($N * $arg2, 0) eq fn:compare($arg1, 0).
657
fn:abs($N * $arg2) le fn:abs($arg1) 
               and fn:compare($N * $arg2, 0) eq fn:compare($arg1, 0).
706

The input is case-insensitive: upper-case and lower-case distinctions in the above grammar show the conventional usage, but otherwise have no significance.

If the input is an empty sequence, the result is an empty sequence.

The

fn:abs($N * $arg2) le fn:abs($arg1) 
               and fn:compare($N * $arg2, 0) eq fn:compare($arg1, 0).
659, if present, is ignored.

The

fn:abs($N * $arg2) le fn:abs($arg1) 
               and fn:compare($N * $arg2, 0) eq fn:compare($arg1, 0).
671,
fn:abs($N * $arg2) le fn:abs($arg1) 
               and fn:compare($N * $arg2, 0) eq fn:compare($arg1, 0).
680, and
op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
984 supply the day, month, and year of the resulting
let $para := 
In a hole in the ground there lived a hobbit.
         
29 value. A two-digit year must have 1900 added to it. A year such as 0070 is to be treated as given; negative years are not permitted.

The

fn:abs($N * $arg2) le fn:abs($arg1) 
               and fn:compare($N * $arg2, 0) eq fn:compare($arg1, 0).
686,
fn:abs($N * $arg2) le fn:abs($arg1) 
               and fn:compare($N * $arg2, 0) eq fn:compare($arg1, 0).
689, and
fn:abs($N * $arg2) le fn:abs($arg1) 
               and fn:compare($N * $arg2, 0) eq fn:compare($arg1, 0).
692 (including fractional seconds) values supply the corresponding components of the resulting
let $para := 
In a hole in the ground there lived a hobbit.
         
29 value; if the
fn:abs($N * $arg2) le fn:abs($arg1) 
               and fn:compare($N * $arg2, 0) eq fn:compare($arg1, 0).
692 value or the fractional seconds value is absent then zero is assumed.

If both a

fn:abs($N * $arg2) le fn:abs($arg1) 
               and fn:compare($N * $arg2, 0) eq fn:compare($arg1, 0).
701 and a
fn:abs($N * $arg2) le fn:abs($arg1) 
               and fn:compare($N * $arg2, 0) eq fn:compare($arg1, 0).
698 are supplied then the
fn:abs($N * $arg2) le fn:abs($arg1) 
               and fn:compare($N * $arg2, 0) eq fn:compare($arg1, 0).
698 is ignored.

If a

fn:abs($N * $arg2) le fn:abs($arg1) 
               and fn:compare($N * $arg2, 0) eq fn:compare($arg1, 0).
701 is supplied then this defines the hours and minutes parts of the timezone offset:

  • If it contains a colon, this separates the hours part from the minutes part.

  • Otherwise, the grammar allows a sequence of from one to four digits. These are interpreted as

    fn:abs($N * $arg2) le fn:abs($arg1) 
                   and fn:compare($N * $arg2, 0) eq fn:compare($arg1, 0).
    721,
    fn:abs($N * $arg2) le fn:abs($arg1) 
                   and fn:compare($N * $arg2, 0) eq fn:compare($arg1, 0).
    722,
    fn:abs($N * $arg2) le fn:abs($arg1) 
                   and fn:compare($N * $arg2, 0) eq fn:compare($arg1, 0).
    723, or
    fn:abs($N * $arg2) le fn:abs($arg1) 
                   and fn:compare($N * $arg2, 0) eq fn:compare($arg1, 0).
    724 respectively, where
    fn:abs($N * $arg2) le fn:abs($arg1) 
                   and fn:compare($N * $arg2, 0) eq fn:compare($arg1, 0).
    721 or
    fn:abs($N * $arg2) le fn:abs($arg1) 
                   and fn:compare($N * $arg2, 0) eq fn:compare($arg1, 0).
    722 is the hours part, and
    fn:abs($N * $arg2) le fn:abs($arg1) 
                   and fn:compare($N * $arg2, 0) eq fn:compare($arg1, 0).
    727 (if present) is the minutes part.

  • If the minutes part is absent it defaults to
    let $para := 
    In a hole in the ground there lived a hobbit.
             
    260.

If a

fn:abs($N * $arg2) le fn:abs($arg1) 
               and fn:compare($N * $arg2, 0) eq fn:compare($arg1, 0).
698 is supplied with no
fn:abs($N * $arg2) le fn:abs($arg1) 
               and fn:compare($N * $arg2, 0) eq fn:compare($arg1, 0).
701 then it is translated to a timezone offset as follows:

tznameOffsetUT, UTC, GMT00:00EST-05:00EDT-04:00CST-06:00CDT-05:00MST-07:00MDT-06:00PST-08:00PDT-07:00

If neither a

fn:abs($N * $arg2) le fn:abs($arg1) 
               and fn:compare($N * $arg2, 0) eq fn:compare($arg1, 0).
701 nor
fn:abs($N * $arg2) le fn:abs($arg1) 
               and fn:compare($N * $arg2, 0) eq fn:compare($arg1, 0).
698 is supplied, a timezone offset of
fn:abs($N * $arg2) le fn:abs($arg1) 
               and fn:compare($N * $arg2, 0) eq fn:compare($arg1, 0).
733 is assumed.

Error Conditions

A dynamic error is raised [err:FORG0010] if the input does not match the grammar, or if the resulting date/time value is invalid (for example, 31 February).

Notes

The

fn:abs($N * $arg2) le fn:abs($arg1) 
               and fn:compare($N * $arg2, 0) eq fn:compare($arg1, 0).
734 function attempts to interpret its input as a date in any of the three formats specified by HTTP [RFC 2616].

These formats are used widely on the Internet to represent timestamps, and were specified in:

  • [RFC 822] (electronic mail), extended in [RFC 1123] to allow four-digit years;
  • [RFC 850] (Usenet Messages), obsoleted by [RFC 1036];
  • POSIX
    fn:abs($N * $arg2) le fn:abs($arg1) 
                   and fn:compare($N * $arg2, 0) eq fn:compare($arg1, 0).
    735 format

[RFC 2616] (HTTP) officially uses a subset of those three formats restricted to GMT.

The grammar for this function is slightly more liberal than the RFCs (reflecting the internet tradition of being liberal in what is accepted). For example the function:

  1. Accepts a single-digit value where appropriate in place of a two-digit value with a leading zero (so "Wed 1 Jun" is acceptable in place of "Wed 01 Jun", and the timezone offset "-5:00" is equivalent to "-05:00")

  2. Accepts one or more whitespace characters (x20, x09, x0A, x0D) wherever a single space is required, and allows whitespace to be omitted where it is not required for parsing

  3. Accepts and ignores whitespace characters (x20, x09, x0A, x0D) at the start or end of the string.

In new protocols IETF recommends the format of [RFC 3339] which is based on a profile of ISO 8601 similar to that already used in XPath and XSD, but the "approximate" [RFC 822] format described here is very widely used.

An [RFC 1123] date can be generated approximately using

fn:abs($N * $arg2) le fn:abs($arg1) 
               and fn:compare($N * $arg2, 0) eq fn:compare($arg1, 0).
340 with a picture string of
fn:abs($N * $arg2) le fn:abs($arg1) 
               and fn:compare($N * $arg2, 0) eq fn:compare($arg1, 0).
737.

Examples

The expression

fn:abs($N * $arg2) le fn:abs($arg1) 
               and fn:compare($N * $arg2, 0) eq fn:compare($arg1, 0).
738 returns
fn:abs($N * $arg2) le fn:abs($arg1) 
               and fn:compare($N * $arg2, 0) eq fn:compare($arg1, 0).
739.

The expression

fn:abs($N * $arg2) le fn:abs($arg1) 
               and fn:compare($N * $arg2, 0) eq fn:compare($arg1, 0).
740 returns
fn:abs($N * $arg2) le fn:abs($arg1) 
               and fn:compare($N * $arg2, 0) eq fn:compare($arg1, 0).
739.

The expression

fn:abs($N * $arg2) le fn:abs($arg1) 
               and fn:compare($N * $arg2, 0) eq fn:compare($arg1, 0).
742 returns
fn:abs($N * $arg2) le fn:abs($arg1) 
               and fn:compare($N * $arg2, 0) eq fn:compare($arg1, 0).
743.

The expression

fn:abs($N * $arg2) le fn:abs($arg1) 
               and fn:compare($N * $arg2, 0) eq fn:compare($arg1, 0).
744 returns
fn:abs($N * $arg2) le fn:abs($arg1) 
               and fn:compare($N * $arg2, 0) eq fn:compare($arg1, 0).
745.

The expression

fn:abs($N * $arg2) le fn:abs($arg1) 
               and fn:compare($N * $arg2, 0) eq fn:compare($arg1, 0).
746 returns
fn:abs($N * $arg2) le fn:abs($arg1) 
               and fn:compare($N * $arg2, 0) eq fn:compare($arg1, 0).
747.

10.1 Functions to create a QName

In addition to the

let $para := 
In a hole in the ground there lived a hobbit.
         
36 constructor function, QName values can be constructed by combining a namespace URI, prefix, and local name, or by resolving a lexical QName against the in-scope namespaces of an element node. This section defines these functions. Leading and trailing whitespace, if present, is stripped from string arguments before the result is constructed.

FunctionMeaning
fn:abs($N * $arg2) le fn:abs($arg1) 
               and fn:compare($N * $arg2, 0) eq fn:compare($arg1, 0).
749Returns an
let $para := 
In a hole in the ground there lived a hobbit.
         
36 value (that is, an expanded-QName) by taking an
let $para := 
In a hole in the ground there lived a hobbit.
         
10 that has the lexical form of an
let $para := 
In a hole in the ground there lived a hobbit.
         
36 (a string in the form "prefix:local-name" or "local-name") and resolving it using the in-scope namespaces for a given element.
fn:abs($N * $arg2) le fn:abs($arg1) 
               and fn:compare($N * $arg2, 0) eq fn:compare($arg1, 0).
753Returns an
let $para := 
In a hole in the ground there lived a hobbit.
         
36 value formed using a supplied namespace URI and lexical QName.

10.1.1 fn:resolve-QName

Summary

Returns an

let $para := 
In a hole in the ground there lived a hobbit.
         
36 value (that is, an expanded-QName) by taking an
let $para := 
In a hole in the ground there lived a hobbit.
         
10 that has the lexical form of an
let $para := 
In a hole in the ground there lived a hobbit.
         
36 (a string in the form "prefix:local-name" or "local-name") and resolving it using the in-scope namespaces for a given element.

Signature

fn:abs($N * $arg2) le fn:abs($arg1) 
               and fn:compare($N * $arg2, 0) eq fn:compare($arg1, 0).
749(
fn:abs($N * $arg2) le fn:abs($arg1) 
               and fn:compare($N * $arg2, 0) eq fn:compare($arg1, 0).
759
let $para := 
In a hole in the ground there lived a hobbit.
         
71
let $para := 
In a hole in the ground there lived a hobbit.
         
244,
fn:abs($N * $arg2) le fn:abs($arg1) 
               and fn:compare($N * $arg2, 0) eq fn:compare($arg1, 0).
762
let $para := 
In a hole in the ground there lived a hobbit.
         
71
fn:abs($N * $arg2) le fn:abs($arg1) 
               and fn:compare($N * $arg2, 0) eq fn:compare($arg1, 0).
764)
let $para := 
In a hole in the ground there lived a hobbit.
         
71
op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
47

Properties

This function is ·deterministic·, ·context-independent·, and ·focus-independent·.

Rules

If

fn:abs($N * $arg2) le fn:abs($arg1) 
               and fn:compare($N * $arg2, 0) eq fn:compare($arg1, 0).
759 is the empty sequence, returns the empty sequence.

More specifically, the function searches the namespace bindings of

fn:abs($N * $arg2) le fn:abs($arg1) 
               and fn:compare($N * $arg2, 0) eq fn:compare($arg1, 0).
762 for a binding whose name matches the prefix of
fn:abs($N * $arg2) le fn:abs($arg1) 
               and fn:compare($N * $arg2, 0) eq fn:compare($arg1, 0).
759, or the zero-length string if it has no prefix, and returns an expanded-QName whose local name is taken from the supplied
fn:abs($N * $arg2) le fn:abs($arg1) 
               and fn:compare($N * $arg2, 0) eq fn:compare($arg1, 0).
759, and whose namespace URI is taken from the string value of the namespace binding.

If the

fn:abs($N * $arg2) le fn:abs($arg1) 
               and fn:compare($N * $arg2, 0) eq fn:compare($arg1, 0).
759 has no prefix, and there is no namespace binding for
fn:abs($N * $arg2) le fn:abs($arg1) 
               and fn:compare($N * $arg2, 0) eq fn:compare($arg1, 0).
762 corresponding to the default (unnamed) namespace, then the resulting expanded-QName has no namespace part.

The prefix (or absence of a prefix) in the supplied

fn:abs($N * $arg2) le fn:abs($arg1) 
               and fn:compare($N * $arg2, 0) eq fn:compare($arg1, 0).
759 argument is retained in the returned expanded-QName, as described in Section 2.1 Terminology DM31.

Error Conditions

A dynamic error is raised [err:FOCA0002] if

fn:abs($N * $arg2) le fn:abs($arg1) 
               and fn:compare($N * $arg2, 0) eq fn:compare($arg1, 0).
759 does not have the correct lexical form for an instance of
let $para := 
In a hole in the ground there lived a hobbit.
         
36.

A dynamic error is raised [err:FONS0004] if

fn:abs($N * $arg2) le fn:abs($arg1) 
               and fn:compare($N * $arg2, 0) eq fn:compare($arg1, 0).
759 has a prefix and there is no namespace binding for
fn:abs($N * $arg2) le fn:abs($arg1) 
               and fn:compare($N * $arg2, 0) eq fn:compare($arg1, 0).
762 that matches this prefix.

Notes

Sometimes the requirement is to construct an

let $para := 
In a hole in the ground there lived a hobbit.
         
36 without using the default namespace. This can be achieved by writing:

op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
0

If the requirement is to construct an

let $para := 
In a hole in the ground there lived a hobbit.
         
36 using the namespaces in the static context, then the
let $para := 
In a hole in the ground there lived a hobbit.
         
36 constructor should be used.

Examples

Assume that the element bound to

fn:abs($N * $arg2) le fn:abs($arg1) 
               and fn:compare($N * $arg2, 0) eq fn:compare($arg1, 0).
762 has a single namespace binding bound to the prefix
fn:abs($N * $arg2) le fn:abs($arg1) 
               and fn:compare($N * $arg2, 0) eq fn:compare($arg1, 0).
782.

fn:abs($N * $arg2) le fn:abs($arg1) 
               and fn:compare($N * $arg2, 0) eq fn:compare($arg1, 0).
783 returns a QName with local name "hello" that is in no namespace.

fn:abs($N * $arg2) le fn:abs($arg1) 
               and fn:compare($N * $arg2, 0) eq fn:compare($arg1, 0).
784 returns an
let $para := 
In a hole in the ground there lived a hobbit.
         
36 whose namespace URI is specified by the namespace binding corresponding to the prefix "eg" and whose local name is "myFunc".

10.1.2 fn:QName

Summary

Returns an

let $para := 
In a hole in the ground there lived a hobbit.
         
36 value formed using a supplied namespace URI and lexical QName.

Signature

fn:abs($N * $arg2) le fn:abs($arg1) 
               and fn:compare($N * $arg2, 0) eq fn:compare($arg1, 0).
753(
fn:abs($N * $arg2) le fn:abs($arg1) 
               and fn:compare($N * $arg2, 0) eq fn:compare($arg1, 0).
788
let $para := 
In a hole in the ground there lived a hobbit.
         
71
let $para := 
In a hole in the ground there lived a hobbit.
         
244,
fn:abs($N * $arg2) le fn:abs($arg1) 
               and fn:compare($N * $arg2, 0) eq fn:compare($arg1, 0).
791
let $para := 
In a hole in the ground there lived a hobbit.
         
71
let $para := 
In a hole in the ground there lived a hobbit.
         
10)
let $para := 
In a hole in the ground there lived a hobbit.
         
71
let $para := 
In a hole in the ground there lived a hobbit.
         
36

Properties

This function is ·deterministic·, ·context-independent·, and ·focus-independent·.

Rules

The namespace URI in the returned QName is taken from

fn:abs($N * $arg2) le fn:abs($arg1) 
               and fn:compare($N * $arg2, 0) eq fn:compare($arg1, 0).
788. If
fn:abs($N * $arg2) le fn:abs($arg1) 
               and fn:compare($N * $arg2, 0) eq fn:compare($arg1, 0).
788 is the zero-length string or the empty sequence, it represents "no namespace".

The prefix (or absence of a prefix) in

fn:abs($N * $arg2) le fn:abs($arg1) 
               and fn:compare($N * $arg2, 0) eq fn:compare($arg1, 0).
791 is retained in the returned
let $para := 
In a hole in the ground there lived a hobbit.
         
36 value.

The local name in the result is taken from the local part of

fn:abs($N * $arg2) le fn:abs($arg1) 
               and fn:compare($N * $arg2, 0) eq fn:compare($arg1, 0).
791.

Error Conditions

A dynamic error is raised [err:FOCA0002] if

fn:abs($N * $arg2) le fn:abs($arg1) 
               and fn:compare($N * $arg2, 0) eq fn:compare($arg1, 0).
791 does not have the correct lexical form for an instance of
let $para := 
In a hole in the ground there lived a hobbit.
         
36.

A dynamic error is raised [err:FOCA0002] if

fn:abs($N * $arg2) le fn:abs($arg1) 
               and fn:compare($N * $arg2, 0) eq fn:compare($arg1, 0).
788 is the zero-length string or the empty sequence, and the value of
fn:abs($N * $arg2) le fn:abs($arg1) 
               and fn:compare($N * $arg2, 0) eq fn:compare($arg1, 0).
791 contains a colon (
fn:abs($N * $arg2) le fn:abs($arg1) 
               and fn:compare($N * $arg2, 0) eq fn:compare($arg1, 0).
805).

A dynamic error may be raised [err:FOCA0002] if

fn:abs($N * $arg2) le fn:abs($arg1) 
               and fn:compare($N * $arg2, 0) eq fn:compare($arg1, 0).
788 is not a valid URI (XML Namespaces 1.0) or IRI (XML Namespaces 1.1).

Examples

fn:abs($N * $arg2) le fn:abs($arg1) 
               and fn:compare($N * $arg2, 0) eq fn:compare($arg1, 0).
807 returns an
let $para := 
In a hole in the ground there lived a hobbit.
         
36 with namespace URI = "http://www.example.com/example", local name = "person" and prefix = "".

fn:abs($N * $arg2) le fn:abs($arg1) 
               and fn:compare($N * $arg2, 0) eq fn:compare($arg1, 0).
809 returns an
let $para := 
In a hole in the ground there lived a hobbit.
         
36 with namespace URI = "http://www.example.com/example", local name = "person" and prefix = "ht".

This section specifies functions on QNames as defined in [XML Schema Part 2: Datatypes Second Edition].

FunctionMeaning
fn:abs($N * $arg2) le fn:abs($arg1) 
               and fn:compare($N * $arg2, 0) eq fn:compare($arg1, 0).
811Returns
op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
76 if two supplied QNames have the same namespace URI and the same local part.
fn:abs($N * $arg2) le fn:abs($arg1) 
               and fn:compare($N * $arg2, 0) eq fn:compare($arg1, 0).
813Returns the prefix component of the supplied QName.
fn:abs($N * $arg2) le fn:abs($arg1) 
               and fn:compare($N * $arg2, 0) eq fn:compare($arg1, 0).
814Returns the local part of the supplied QName.
fn:abs($N * $arg2) le fn:abs($arg1) 
               and fn:compare($N * $arg2, 0) eq fn:compare($arg1, 0).
815Returns the namespace URI part of the supplied QName.
fn:abs($N * $arg2) le fn:abs($arg1) 
               and fn:compare($N * $arg2, 0) eq fn:compare($arg1, 0).
816Returns the namespace URI of one of the in-scope namespaces for
fn:abs($N * $arg2) le fn:abs($arg1) 
               and fn:compare($N * $arg2, 0) eq fn:compare($arg1, 0).
762, identified by its namespace prefix.
fn:abs($N * $arg2) le fn:abs($arg1) 
               and fn:compare($N * $arg2, 0) eq fn:compare($arg1, 0).
818Returns the prefixes of the in-scope namespaces for an element node.

10.2.1 op:QName-equal

Summary

Returns

op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
76 if two supplied QNames have the same namespace URI and the same local part.

Operator Mapping

Defines the semantics of the "eq" and "ne" operators when applied to two values of type

let $para := 
In a hole in the ground there lived a hobbit.
         
36.

Signature

fn:abs($N * $arg2) le fn:abs($arg1) 
               and fn:compare($N * $arg2, 0) eq fn:compare($arg1, 0).
811(
let $para := 
In a hole in the ground there lived a hobbit.
         
70
let $para := 
In a hole in the ground there lived a hobbit.
         
71
let $para := 
In a hole in the ground there lived a hobbit.
         
36,
let $para := 
In a hole in the ground there lived a hobbit.
         
73
let $para := 
In a hole in the ground there lived a hobbit.
         
71
let $para := 
In a hole in the ground there lived a hobbit.
         
36)
let $para := 
In a hole in the ground there lived a hobbit.
         
71
op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
32

Properties

This function is ·deterministic·, ·context-independent·, and ·focus-independent·.

Rules

The function returns

op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
76 if the namespace URIs of
let $para := 
In a hole in the ground there lived a hobbit.
         
70 and
let $para := 
In a hole in the ground there lived a hobbit.
         
73 are equal and the local names of
let $para := 
In a hole in the ground there lived a hobbit.
         
70 and
let $para := 
In a hole in the ground there lived a hobbit.
         
73 are equal.

Otherwise, the function returns

let $C := 'http://www.w3.org/2013/collation/UCA?strength=primary'
07.

The namespace URI parts are considered equal if they are both absentDM31, or if they are both present and equal under the rules of the

let $para := 
In a hole in the ground there lived a hobbit.
         
061 function.

The local parts are also compared under the rules of the

let $para := 
In a hole in the ground there lived a hobbit.
         
061 function.

Notes

The prefix parts of

let $para := 
In a hole in the ground there lived a hobbit.
         
70 and
let $para := 
In a hole in the ground there lived a hobbit.
         
73, if any, are ignored.

10.2.2 fn:prefix-from-QName

Summary

Returns the prefix component of the supplied QName.

Signature

fn:abs($N * $arg2) le fn:abs($arg1) 
               and fn:compare($N * $arg2, 0) eq fn:compare($arg1, 0).
813(
let $para := 
In a hole in the ground there lived a hobbit.
         
25
let $para := 
In a hole in the ground there lived a hobbit.
         
71
op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
47)
let $para := 
In a hole in the ground there lived a hobbit.
         
71
fn:abs($N * $arg2) le fn:abs($arg1) 
               and fn:compare($N * $arg2, 0) eq fn:compare($arg1, 0).
845

Properties

This function is ·deterministic·, ·context-independent·, and ·focus-independent·.

Rules

If

let $para := 
In a hole in the ground there lived a hobbit.
         
25 is the empty sequence the function returns the empty sequence.

If

let $para := 
In a hole in the ground there lived a hobbit.
         
25 has no prefix component the function returns the empty sequence.

Otherwise, the function returns an

let $para := 
In a hole in the ground there lived a hobbit.
         
35 representing the prefix component of
let $para := 
In a hole in the ground there lived a hobbit.
         
25.

10.2.3 fn:local-name-from-QName

Summary

Returns the local part of the supplied QName.

Signature

fn:abs($N * $arg2) le fn:abs($arg1) 
               and fn:compare($N * $arg2, 0) eq fn:compare($arg1, 0).
814(
let $para := 
In a hole in the ground there lived a hobbit.
         
25
let $para := 
In a hole in the ground there lived a hobbit.
         
71
op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
47)
let $para := 
In a hole in the ground there lived a hobbit.
         
71
fn:abs($N * $arg2) le fn:abs($arg1) 
               and fn:compare($N * $arg2, 0) eq fn:compare($arg1, 0).
845

Properties

This function is ·deterministic·, ·context-independent·, and ·focus-independent·.

Rules

If

let $para := 
In a hole in the ground there lived a hobbit.
         
25 is the empty sequence the function returns the empty sequence.

Otherwise, the function returns an

let $para := 
In a hole in the ground there lived a hobbit.
         
35 representing the local part of
let $para := 
In a hole in the ground there lived a hobbit.
         
25.

Examples

The expression

fn:abs($N * $arg2) le fn:abs($arg1) 
               and fn:compare($N * $arg2, 0) eq fn:compare($arg1, 0).
859 returns
fn:abs($N * $arg2) le fn:abs($arg1) 
               and fn:compare($N * $arg2, 0) eq fn:compare($arg1, 0).
860.

10.2.4 fn:namespace-uri-from-QName

Summary

Returns the namespace URI part of the supplied QName.

Signature

fn:abs($N * $arg2) le fn:abs($arg1) 
               and fn:compare($N * $arg2, 0) eq fn:compare($arg1, 0).
815(
let $para := 
In a hole in the ground there lived a hobbit.
         
25
let $para := 
In a hole in the ground there lived a hobbit.
         
71
op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
47)
let $para := 
In a hole in the ground there lived a hobbit.
         
71
op:operation(fenceHeight, xs:integer) => op:operation(xs:integer, xs:integer)
44

Properties

This function is ·deterministic·, ·context-independent·, and ·focus-independent·.

Rules

If

let $para := 
In a hole in the ground there lived a hobbit.
         
25 is the empty sequence the function returns the empty sequence.

Otherwise, the function returns an

let $para := 
In a hole in the ground there lived a hobbit.
         
30 representing the namespace URI part of
let $para := 
In a hole in the ground there lived a hobbit.
         
25.

If

let $para := 
In a hole in the ground there lived a hobbit.
         
25 is in no namespace, the function returns the zero-length
let $para := 
In a hole in the ground there lived a hobbit.
         
30.

Examples

The expression

fn:abs($N * $arg2) le fn:abs($arg1) 
               and fn:compare($N * $arg2, 0) eq fn:compare($arg1, 0).
872 returns
fn:abs($N * $arg2) le fn:abs($arg1) 
               and fn:compare($N * $arg2, 0) eq fn:compare($arg1, 0).
873.

10.2.5 fn:namespace-uri-for-prefix

Summary

Returns the namespace URI of one of the in-scope namespaces for

fn:abs($N * $arg2) le fn:abs($arg1) 
               and fn:compare($N * $arg2, 0) eq fn:compare($arg1, 0).
762, identified by its namespace prefix.

Signature

fn:abs($N * $arg2) le fn:abs($arg1) 
               and fn:compare($N * $arg2, 0) eq fn:compare($arg1, 0).
816(
fn:abs($N * $arg2) le fn:abs($arg1) 
               and fn:compare($N * $arg2, 0) eq fn:compare($arg1, 0).
876
let $para := 
In a hole in the ground there lived a hobbit.
         
71
let $para := 
In a hole in the ground there lived a hobbit.
         
244,
fn:abs($N * $arg2) le fn:abs($arg1) 
               and fn:compare($N * $arg2, 0) eq fn:compare($arg1, 0).
762
let $para := 
In a hole in the ground there lived a hobbit.
         
71
fn:abs($N * $arg2) le fn:abs($arg1) 
               and fn:compare($N * $arg2, 0) eq fn:compare($arg1, 0).
764)
let $para := 
In a hole in the ground there lived a hobbit.
         
71
op:operation(fenceHeight, xs:integer) => op:operation(xs:integer, xs:integer)
44

Properties

This function is ·deterministic·, ·context-independent·, and ·focus-independent·.

Rules

If

fn:abs($N * $arg2) le fn:abs($arg1) 
               and fn:compare($N * $arg2, 0) eq fn:compare($arg1, 0).
762 has an in-scope namespace whose namespace prefix is equal to
fn:abs($N * $arg2) le fn:abs($arg1) 
               and fn:compare($N * $arg2, 0) eq fn:compare($arg1, 0).
876, the function returns the namespace URI of that namespace.

If

fn:abs($N * $arg2) le fn:abs($arg1) 
               and fn:compare($N * $arg2, 0) eq fn:compare($arg1, 0).
762 has no in-scope namespace whose namespace prefix is equal to
fn:abs($N * $arg2) le fn:abs($arg1) 
               and fn:compare($N * $arg2, 0) eq fn:compare($arg1, 0).
876, the function returns the empty sequence.

If

fn:abs($N * $arg2) le fn:abs($arg1) 
               and fn:compare($N * $arg2, 0) eq fn:compare($arg1, 0).
876 is the zero-length string or the empty sequence, then if
fn:abs($N * $arg2) le fn:abs($arg1) 
               and fn:compare($N * $arg2, 0) eq fn:compare($arg1, 0).
762 has a default namespace (that is, a namespace node with no name), the function returns the namespace URI of the default namespace. If
fn:abs($N * $arg2) le fn:abs($arg1) 
               and fn:compare($N * $arg2, 0) eq fn:compare($arg1, 0).
762 has no default namespace, the function returns the empty sequence.

Prefixes are equal only if their Unicode codepoints match exactly.

Examples

op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
1

The expression

fn:abs($N * $arg2) le fn:abs($arg1) 
               and fn:compare($N * $arg2, 0) eq fn:compare($arg1, 0).
891 returns
fn:abs($N * $arg2) le fn:abs($arg1) 
               and fn:compare($N * $arg2, 0) eq fn:compare($arg1, 0).
892.

The expression

fn:abs($N * $arg2) le fn:abs($arg1) 
               and fn:compare($N * $arg2, 0) eq fn:compare($arg1, 0).
893 returns
fn:abs($N * $arg2) le fn:abs($arg1) 
               and fn:compare($N * $arg2, 0) eq fn:compare($arg1, 0).
894.

The expression

fn:abs($N * $arg2) le fn:abs($arg1) 
               and fn:compare($N * $arg2, 0) eq fn:compare($arg1, 0).
895 returns
fn:abs($N * $arg2) le fn:abs($arg1) 
               and fn:compare($N * $arg2, 0) eq fn:compare($arg1, 0).
894.

The expression

fn:abs($N * $arg2) le fn:abs($arg1) 
               and fn:compare($N * $arg2, 0) eq fn:compare($arg1, 0).
897 returns
fn:abs($N * $arg2) le fn:abs($arg1) 
               and fn:compare($N * $arg2, 0) eq fn:compare($arg1, 0).
898.

The expression

fn:abs($N * $arg2) le fn:abs($arg1) 
               and fn:compare($N * $arg2, 0) eq fn:compare($arg1, 0).
897 returns
fn:abs($N * $arg2) le fn:abs($arg1) 
               and fn:compare($N * $arg2, 0) eq fn:compare($arg1, 0).
898.

10.2.6 fn:in-scope-prefixes

Summary

Returns the prefixes of the in-scope namespaces for an element node.

Signature

fn:abs($N * $arg2) le fn:abs($arg1) 
               and fn:compare($N * $arg2, 0) eq fn:compare($arg1, 0).
818(
fn:abs($N * $arg2) le fn:abs($arg1) 
               and fn:compare($N * $arg2, 0) eq fn:compare($arg1, 0).
762
let $para := 
In a hole in the ground there lived a hobbit.
         
71
fn:abs($N * $arg2) le fn:abs($arg1) 
               and fn:compare($N * $arg2, 0) eq fn:compare($arg1, 0).
764)
let $para := 
In a hole in the ground there lived a hobbit.
         
71
let $para := 
In a hole in the ground there lived a hobbit.
         
234

Properties

This function is ·nondeterministic-wrt-ordering·, ·context-independent·, and ·focus-independent·.

Rules

The function returns a sequence of strings representing the prefixes of the in-scope namespaces for

fn:abs($N * $arg2) le fn:abs($arg1) 
               and fn:compare($N * $arg2, 0) eq fn:compare($arg1, 0).
762.

For namespace bindings that have a prefix, the function returns the prefix as an

let $para := 
In a hole in the ground there lived a hobbit.
         
35. For the default namespace, which has no prefix, it returns the zero-length string.

The result sequence contains no duplicates.

The ordering of the result sequence is ·implementation-dependent·.

Notes

The XML namespace is in scope for every element, so the result will always include the string "xml".

11 Operators on base64Binary and hexBinary

11.1 Comparisons of base64Binary and hexBinary values

The following comparison operators on

let $para := 
In a hole in the ground there lived a hobbit.
         
196 and
let $para := 
In a hole in the ground there lived a hobbit.
         
219 values are defined. Comparisons take two operands of the same type; that is, both operands must be
let $para := 
In a hole in the ground there lived a hobbit.
         
196 or both operands may be
let $para := 
In a hole in the ground there lived a hobbit.
         
219. Each returns a boolean value.

A value of type

let $para := 
In a hole in the ground there lived a hobbit.
         
219 can be compared with a value of type
let $para := 
In a hole in the ground there lived a hobbit.
         
196 by casting one value to the other type. See 19.1.6 Casting to xs:base64Binary and xs:hexBinary.

FunctionMeaning
fn:abs($N * $arg2) le fn:abs($arg1) 
               and fn:compare($N * $arg2, 0) eq fn:compare($arg1, 0).
915Returns true if two
let $para := 
In a hole in the ground there lived a hobbit.
         
219 values contain the same octet sequence.
fn:abs($N * $arg2) le fn:abs($arg1) 
               and fn:compare($N * $arg2, 0) eq fn:compare($arg1, 0).
917Returns true if the first argument is less than the second.
fn:abs($N * $arg2) le fn:abs($arg1) 
               and fn:compare($N * $arg2, 0) eq fn:compare($arg1, 0).
918Returns true if the first argument is greater than the second.
fn:abs($N * $arg2) le fn:abs($arg1) 
               and fn:compare($N * $arg2, 0) eq fn:compare($arg1, 0).
919Returns true if two
let $para := 
In a hole in the ground there lived a hobbit.
         
196 values contain the same octet sequence.
fn:abs($N * $arg2) le fn:abs($arg1) 
               and fn:compare($N * $arg2, 0) eq fn:compare($arg1, 0).
921Returns true if the first argument is less than the second.
fn:abs($N * $arg2) le fn:abs($arg1) 
               and fn:compare($N * $arg2, 0) eq fn:compare($arg1, 0).
922Returns true if the first argument is greater than the second.

11.1.1 op:hexBinary-equal

Summary

Returns true if two

let $para := 
In a hole in the ground there lived a hobbit.
         
219 values contain the same octet sequence.

Operator Mapping

Defines the semantics of the "eq" and "ne" operators when applied to two

let $para := 
In a hole in the ground there lived a hobbit.
         
219 values.

Signature

fn:abs($N * $arg2) le fn:abs($arg1) 
               and fn:compare($N * $arg2, 0) eq fn:compare($arg1, 0).
915(
op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
368
let $para := 
In a hole in the ground there lived a hobbit.
         
71
let $para := 
In a hole in the ground there lived a hobbit.
         
219,
op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
371
let $para := 
In a hole in the ground there lived a hobbit.
         
71
let $para := 
In a hole in the ground there lived a hobbit.
         
219)
let $para := 
In a hole in the ground there lived a hobbit.
         
71
op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
32

Rules

The function returns

op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
76 if
op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
368 and
op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
371 are of the same length, measured in binary octets, and contain the same octets in the same order. Otherwise, it returns
let $C := 'http://www.w3.org/2013/collation/UCA?strength=primary'
07.

11.1.2 op:hexBinary-less-than

Summary

Returns true if the first argument is less than the second.

Operator Mapping

Defines the semantics of the "lt" operator when applied to two

let $para := 
In a hole in the ground there lived a hobbit.
         
219 values. Also used in the definition of the "ge" operator.

Signature

fn:abs($N * $arg2) le fn:abs($arg1) 
               and fn:compare($N * $arg2, 0) eq fn:compare($arg1, 0).
917(
let $para := 
In a hole in the ground there lived a hobbit.
         
70
let $para := 
In a hole in the ground there lived a hobbit.
         
71
let $para := 
In a hole in the ground there lived a hobbit.
         
219,
let $para := 
In a hole in the ground there lived a hobbit.
         
73
let $para := 
In a hole in the ground there lived a hobbit.
         
71
let $para := 
In a hole in the ground there lived a hobbit.
         
219)
let $para := 
In a hole in the ground there lived a hobbit.
         
71
op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
32

Rules

The function returns

op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
76 if any of the following conditions is true:

  1. let $para := 
    In a hole in the ground there lived a hobbit.
             
    70 is zero-length (contains no octets) and
    let $para := 
    In a hole in the ground there lived a hobbit.
             
    73 is not zero-length.

  2. Neither argument is zero-length, and the first octet of

    let $para := 
    In a hole in the ground there lived a hobbit.
             
    70 is less than the first octet of
    let $para := 
    In a hole in the ground there lived a hobbit.
             
    73, treating the value of the octet as an unsigned integer in the range 0 to 255.

  3. Neither argument is zero-length, the first octet of

    let $para := 
    In a hole in the ground there lived a hobbit.
             
    70 is equal to the first octet of
    let $para := 
    In a hole in the ground there lived a hobbit.
             
    73, and the
    let $para := 
    In a hole in the ground there lived a hobbit.
             
    219 value formed by taking all octets of
    op:operation(fenceHeight, xs:integer) => op:operation(xs:integer, xs:integer)
    983 after the first is less than the
    let $para := 
    In a hole in the ground there lived a hobbit.
             
    219 value formed by taking all octets of
    op:operation(fenceHeight, xs:integer) => op:operation(xs:integer, xs:integer)
    982 after the first.

Otherwise, the function returns

let $C := 'http://www.w3.org/2013/collation/UCA?strength=primary'
07.

11.1.3 op:hexBinary-greater-than

Summary

Returns true if the first argument is greater than the second.

Operator Mapping

Defines the semantics of the "gt" operator when applied to two

let $para := 
In a hole in the ground there lived a hobbit.
         
219 values. Also used in the definition of the "le" operator.

Signature

fn:abs($N * $arg2) le fn:abs($arg1) 
               and fn:compare($N * $arg2, 0) eq fn:compare($arg1, 0).
918(
let $para := 
In a hole in the ground there lived a hobbit.
         
70
let $para := 
In a hole in the ground there lived a hobbit.
         
71
let $para := 
In a hole in the ground there lived a hobbit.
         
219,
let $para := 
In a hole in the ground there lived a hobbit.
         
73
let $para := 
In a hole in the ground there lived a hobbit.
         
71
let $para := 
In a hole in the ground there lived a hobbit.
         
219)
let $para := 
In a hole in the ground there lived a hobbit.
         
71
op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
32

Rules

The function call

fn:abs($N * $arg2) le fn:abs($arg1) 
               and fn:compare($N * $arg2, 0) eq fn:compare($arg1, 0).
970 is defined to return the same result as
fn:abs($N * $arg2) le fn:abs($arg1) 
               and fn:compare($N * $arg2, 0) eq fn:compare($arg1, 0).
971

11.1.4 op:base64Binary-equal

Summary

Returns true if two

let $para := 
In a hole in the ground there lived a hobbit.
         
196 values contain the same octet sequence.

Operator Mapping

Defines the semantics of the "eq" and "ne" operators when applied to two

let $para := 
In a hole in the ground there lived a hobbit.
         
196 values.

Signature

fn:abs($N * $arg2) le fn:abs($arg1) 
               and fn:compare($N * $arg2, 0) eq fn:compare($arg1, 0).
919(
op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
368
let $para := 
In a hole in the ground there lived a hobbit.
         
71
let $para := 
In a hole in the ground there lived a hobbit.
         
196,
op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
371
let $para := 
In a hole in the ground there lived a hobbit.
         
71
let $para := 
In a hole in the ground there lived a hobbit.
         
196)
let $para := 
In a hole in the ground there lived a hobbit.
         
71
op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
32

Rules

The function returns

op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
76 if
op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
368 and
op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
371 are of the same length, measured in binary octets, and contain the same octets in the same order. Otherwise, it returns
let $C := 'http://www.w3.org/2013/collation/UCA?strength=primary'
07.

11.1.5 op:base64Binary-less-than

Summary

Returns true if the first argument is less than the second.

Operator Mapping

Defines the semantics of the "lt" operator when applied to two

let $para := 
In a hole in the ground there lived a hobbit.
         
196 values. Also used in the definition of the "ge" operator.

Signature

fn:abs($N * $arg2) le fn:abs($arg1) 
               and fn:compare($N * $arg2, 0) eq fn:compare($arg1, 0).
921(
let $para := 
In a hole in the ground there lived a hobbit.
         
70
let $para := 
In a hole in the ground there lived a hobbit.
         
71
let $para := 
In a hole in the ground there lived a hobbit.
         
196,
let $para := 
In a hole in the ground there lived a hobbit.
         
73
let $para := 
In a hole in the ground there lived a hobbit.
         
71
let $para := 
In a hole in the ground there lived a hobbit.
         
196)
let $para := 
In a hole in the ground there lived a hobbit.
         
71
op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
32

Rules

The function returns

op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
76 if any of the following conditions is true:

  1. let $para := 
    In a hole in the ground there lived a hobbit.
             
    70 is zero-length (contains no octets) and
    let $para := 
    In a hole in the ground there lived a hobbit.
             
    73 is not zero-length.

  2. Neither argument is zero-length, and the first octet of

    let $para := 
    In a hole in the ground there lived a hobbit.
             
    70 is less than the first octet of
    let $para := 
    In a hole in the ground there lived a hobbit.
             
    73, treating the value of the octet as an unsigned integer in the range 0 to 255.

  3. Neither argument is zero-length, the first octet of

    let $para := 
    In a hole in the ground there lived a hobbit.
             
    70 is equal to the first octet of
    let $para := 
    In a hole in the ground there lived a hobbit.
             
    73, and the
    let $para := 
    In a hole in the ground there lived a hobbit.
             
    196 value formed by taking all octets of
    op:operation(fenceHeight, xs:integer) => op:operation(xs:integer, xs:integer)
    983 after the first is less than the
    let $para := 
    In a hole in the ground there lived a hobbit.
             
    196 value formed by taking all octets of
    op:operation(fenceHeight, xs:integer) => op:operation(xs:integer, xs:integer)
    982 after the first.

Otherwise, the function returns

let $C := 'http://www.w3.org/2013/collation/UCA?strength=primary'
07.

11.1.6 op:base64Binary-greater-than

Summary

Returns true if the first argument is greater than the second.

Operator Mapping

Defines the semantics of the "gt" operator when applied to two

let $para := 
In a hole in the ground there lived a hobbit.
         
196 values. Also used in the definition of the "le" operator.

Signature

fn:abs($N * $arg2) le fn:abs($arg1) 
               and fn:compare($N * $arg2, 0) eq fn:compare($arg1, 0).
922(
let $para := 
In a hole in the ground there lived a hobbit.
         
70
let $para := 
In a hole in the ground there lived a hobbit.
         
71
let $para := 
In a hole in the ground there lived a hobbit.
         
196,
let $para := 
In a hole in the ground there lived a hobbit.
         
73
let $para := 
In a hole in the ground there lived a hobbit.
         
71
let $para := 
In a hole in the ground there lived a hobbit.
         
196)
let $para := 
In a hole in the ground there lived a hobbit.
         
71
op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
32

Rules

The function call

1º 2º 3º 4º ...
019 is defined to return the same result as
1º 2º 3º 4º ...
020

12 Operators on NOTATION

This section specifies operators that take

1º 2º 3º 4º ...
021 values as arguments.

FunctionMeaning
1º 2º 3º 4º ...
022Returns
op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
76 if the two
1º 2º 3º 4º ...
021 values have the same namespace URI and the same local part.

12.1 op:NOTATION-equal

Summary

Returns

op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
76 if the two
1º 2º 3º 4º ...
021 values have the same namespace URI and the same local part.

Operator Mapping

Defines the semantics of the "eq" and "ne" operators when applied to two values of type

1º 2º 3º 4º ...
021.

Signature

1º 2º 3º 4º ...
022(
let $para := 
In a hole in the ground there lived a hobbit.
         
70
let $para := 
In a hole in the ground there lived a hobbit.
         
71
1º 2º 3º 4º ...
021,
let $para := 
In a hole in the ground there lived a hobbit.
         
73
let $para := 
In a hole in the ground there lived a hobbit.
         
71
1º 2º 3º 4º ...
021)
let $para := 
In a hole in the ground there lived a hobbit.
         
71
op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
32

Rules

The function returns

op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
76 if the namespace URIs of
let $para := 
In a hole in the ground there lived a hobbit.
         
70 and
let $para := 
In a hole in the ground there lived a hobbit.
         
73 are equal and the local names of
let $para := 
In a hole in the ground there lived a hobbit.
         
70 and
let $para := 
In a hole in the ground there lived a hobbit.
         
73 are equal.

Otherwise, the function returns

let $C := 'http://www.w3.org/2013/collation/UCA?strength=primary'
07.

The namespace URI parts are considered equal if they are both absentDM31, or if they are both present and equal under the rules of the

let $para := 
In a hole in the ground there lived a hobbit.
         
061 function.

The local parts are also compared under the rules of the

let $para := 
In a hole in the ground there lived a hobbit.
         
061 function.

Notes

The prefix parts of

let $para := 
In a hole in the ground there lived a hobbit.
         
70 and
let $para := 
In a hole in the ground there lived a hobbit.
         
73, if any, are ignored.

13 Functions and operators on nodes

This section specifies functions and operators on nodes. Nodes are formally defined in Section 6 Nodes DM31.

FunctionMeaning
let $para := 
In a hole in the ground there lived a hobbit.
         
38Returns the name of a node, as an
let $para := 
In a hole in the ground there lived a hobbit.
         
10 that is either the zero-length string, or has the lexical form of an
let $para := 
In a hole in the ground there lived a hobbit.
         
36.
1º 2º 3º 4º ...
050Returns the local part of the name of
let $para := 
In a hole in the ground there lived a hobbit.
         
25 as an
let $para := 
In a hole in the ground there lived a hobbit.
         
10 that is either the zero-length string, or has the lexical form of an
let $para := 
In a hole in the ground there lived a hobbit.
         
35.
1º 2º 3º 4º ...
054Returns the namespace URI part of the name of
let $para := 
In a hole in the ground there lived a hobbit.
         
25, as an
let $para := 
In a hole in the ground there lived a hobbit.
         
30 value.
1º 2º 3º 4º ...
057This function tests whether the language of
1º 2º 3º 4º ...
058, or the context item if the second argument is omitted, as specified by
let $para := 
In a hole in the ground there lived a hobbit.
         
297 attributes is the same as, or is a sublanguage of, the language specified by
1º 2º 3º 4º ...
060.
1º 2º 3º 4º ...
061Returns the root of the tree to which
let $para := 
In a hole in the ground there lived a hobbit.
         
25 belongs. This will usually, but not necessarily, be a document node.
1º 2º 3º 4º ...
063Returns a path expression that can be used to select the supplied node relative to the root of its containing document.
1º 2º 3º 4º ...
064Returns true if the supplied node has one or more child nodes (of any kind).
1º 2º 3º 4º ...
065Returns every node within the input sequence that is not an ancestor of another member of the input sequence; the nodes are returned in document order with duplicates eliminated.
1º 2º 3º 4º ...
066Returns every node within the input sequence that has no ancestor that is itself a member of the input sequence; the nodes are returned in document order with duplicates eliminated.

For the illustrative examples below assume an XQuery or transformation operating on a

1º 2º 3º 4º ...
067 document containing a number of
1º 2º 3º 4º ...
068 elements. Each line-item has child elements called
1º 2º 3º 4º ...
069,
1º 2º 3º 4º ...
070,
1º 2º 3º 4º ...
071, etc. whose content is different for each
1º 2º 3º 4º ...
068. Quantity has simple content of type
let $para := 
In a hole in the ground there lived a hobbit.
         
82. Further assume that variables
1º 2º 3º 4º ...
074,
1º 2º 3º 4º ...
075, etc. are each bound to single line-item element nodes in the document in sequence and that the value of the quantity child of the first line-item is
1º 2º 3º 4º ...
076.

op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
2

op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
3

op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
4

op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
5

13.1 fn:name

Summary

Returns the name of a node, as an

let $para := 
In a hole in the ground there lived a hobbit.
         
10 that is either the zero-length string, or has the lexical form of an
let $para := 
In a hole in the ground there lived a hobbit.
         
36.

Signatures

let $para := 
In a hole in the ground there lived a hobbit.
         
38()
let $para := 
In a hole in the ground there lived a hobbit.
         
71
let $para := 
In a hole in the ground there lived a hobbit.
         
10

let $para := 
In a hole in the ground there lived a hobbit.
         
38(
let $para := 
In a hole in the ground there lived a hobbit.
         
25
let $para := 
In a hole in the ground there lived a hobbit.
         
71
op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
51)
let $para := 
In a hole in the ground there lived a hobbit.
         
71
let $para := 
In a hole in the ground there lived a hobbit.
         
10

Properties

The zero-argument form of this function is ·deterministic·, ·context-dependent·, and ·focus-dependent·.

The one-argument form of this function is ·deterministic·, ·context-independent·, and ·focus-independent·.

Rules

If the argument is omitted, it defaults to the context item (

let $para := 
In a hole in the ground there lived a hobbit.
         
19). The behavior of the function if the argument is omitted is exactly the same as if the context item had been passed as the argument.

If the argument is supplied and is the empty sequence, the function returns the zero-length string.

If the node identified by

let $para := 
In a hole in the ground there lived a hobbit.
         
25 has no name (that is, if it is a document node, a comment, a text node, or a namespace node having no name), the function returns the zero-length string.

Otherwise, the function returns the value of the expression

1º 2º 3º 4º ...
090.

Error Conditions

The following errors may be raised when

let $para := 
In a hole in the ground there lived a hobbit.
         
25 is omitted:

  • If the context item is absentDM31, dynamic error [err:XPDY0002]XP31

  • If the context item is not a node, type error [err:XPTY0004]XP31.

Notes

Because the result depends on the choice of namespace prefixes in the source document, it is not good practice to use the result of this function for anything other than display purposes. For example, the test

1º 2º 3º 4º ...
092 will fail if the source document uses an unexpected namespace prefix. Such a test (assuming it relates to an element node) is better written as
1º 2º 3º 4º ...
093.

13.2 fn:local-name

Summary

Returns the local part of the name of

let $para := 
In a hole in the ground there lived a hobbit.
         
25 as an
let $para := 
In a hole in the ground there lived a hobbit.
         
10 that is either the zero-length string, or has the lexical form of an
let $para := 
In a hole in the ground there lived a hobbit.
         
35.

Signatures

1º 2º 3º 4º ...
050()
let $para := 
In a hole in the ground there lived a hobbit.
         
71
let $para := 
In a hole in the ground there lived a hobbit.
         
10

1º 2º 3º 4º ...
050(
let $para := 
In a hole in the ground there lived a hobbit.
         
25
let $para := 
In a hole in the ground there lived a hobbit.
         
71
op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
51)
let $para := 
In a hole in the ground there lived a hobbit.
         
71
let $para := 
In a hole in the ground there lived a hobbit.
         
10

Properties

The zero-argument form of this function is ·deterministic·, ·context-dependent·, and ·focus-dependent·.

The one-argument form of this function is ·deterministic·, ·context-independent·, and ·focus-independent·.

Rules

If the argument is omitted, it defaults to the context item (

let $para := 
In a hole in the ground there lived a hobbit.
         
19). The behavior of the function if the argument is omitted is exactly the same as if the context item had been passed as the argument.

If the argument is supplied and is the empty sequence, the function returns the zero-length string.

If the node identified by

let $para := 
In a hole in the ground there lived a hobbit.
         
25 has no name (that is, if it is a document node, a comment, a text node, or a namespace node having no name), the function returns the zero-length string.

Otherwise, the function returns the local part of the expanded-QName of the node identified by

let $para := 
In a hole in the ground there lived a hobbit.
         
25, as determined by the
op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
56 accessor defined in Section 5.10 node-name Accessor DM31). This will be an
let $para := 
In a hole in the ground there lived a hobbit.
         
10 whose lexical form is an
let $para := 
In a hole in the ground there lived a hobbit.
         
35.

Error Conditions

The following errors may be raised when

let $para := 
In a hole in the ground there lived a hobbit.
         
25 is omitted:

  • If the context item is absentDM31, dynamic error [err:XPDY0002]XP31

  • If the context item is not a node, type error [err:XPTY0004]XP31.

13.3 fn:namespace-uri

Summary

Returns the namespace URI part of the name of

let $para := 
In a hole in the ground there lived a hobbit.
         
25, as an
let $para := 
In a hole in the ground there lived a hobbit.
         
30 value.

Signatures

1º 2º 3º 4º ...
054()
let $para := 
In a hole in the ground there lived a hobbit.
         
71
let $para := 
In a hole in the ground there lived a hobbit.
         
30

1º 2º 3º 4º ...
054(
let $para := 
In a hole in the ground there lived a hobbit.
         
25
let $para := 
In a hole in the ground there lived a hobbit.
         
71
op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
51)
let $para := 
In a hole in the ground there lived a hobbit.
         
71
let $para := 
In a hole in the ground there lived a hobbit.
         
30

Properties

The zero-argument form of this function is ·deterministic·, ·context-dependent·, and ·focus-dependent·.

The one-argument form of this function is ·deterministic·, ·context-independent·, and ·focus-independent·.

Rules

If the argument is omitted, it defaults to the context node (

let $para := 
In a hole in the ground there lived a hobbit.
         
19). The behavior of the function if the argument is omitted is exactly the same as if the context item had been passed as the argument.

If the node identified by

let $para := 
In a hole in the ground there lived a hobbit.
         
25 is neither an element nor an attribute node, or if it is an element or attribute node whose expanded-QName (as determined by the
op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
56 accessor in the Section 5.10 node-name Accessor DM31) is in no namespace, then the function returns the zero-length
let $para := 
In a hole in the ground there lived a hobbit.
         
30 value.

Otherwise, the result will be the namespace URI part of the expanded-QName of the node identified by

let $para := 
In a hole in the ground there lived a hobbit.
         
25, as determined by the
op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
56 accessor defined in Section 5.10 node-name Accessor DM31), returned as an
let $para := 
In a hole in the ground there lived a hobbit.
         
30 value.

Error Conditions

The following errors may be raised when

let $para := 
In a hole in the ground there lived a hobbit.
         
25 is omitted:

  • If the context item is absentDM31, dynamic error [err:XPDY0002]XP31

  • If the context item is not a node, type error [err:XPTY0004]XP31.

13.4 fn:lang

Summary

This function tests whether the language of

1º 2º 3º 4º ...
058, or the context item if the second argument is omitted, as specified by
let $para := 
In a hole in the ground there lived a hobbit.
         
297 attributes is the same as, or is a sublanguage of, the language specified by
1º 2º 3º 4º ...
060.

Signatures

1º 2º 3º 4º ...
057(
1º 2º 3º 4º ...
060
let $para := 
In a hole in the ground there lived a hobbit.
         
71
let $para := 
In a hole in the ground there lived a hobbit.
         
244)
let $para := 
In a hole in the ground there lived a hobbit.
         
71
op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
32

1º 2º 3º 4º ...
057(
1º 2º 3º 4º ...
060
let $para := 
In a hole in the ground there lived a hobbit.
         
71
let $para := 
In a hole in the ground there lived a hobbit.
         
244,
1º 2º 3º 4º ...
058
let $para := 
In a hole in the ground there lived a hobbit.
         
71
1º 2º 3º 4º ...
147)
let $para := 
In a hole in the ground there lived a hobbit.
         
71
op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
32

Properties

The one-argument form of this function is ·deterministic·, ·context-dependent·, and ·focus-dependent·.

The two-argument form of this function is ·deterministic·, ·context-independent·, and ·focus-independent·.

Rules

The behavior of the function if the second argument is omitted is exactly the same as if the context item (

let $para := 
In a hole in the ground there lived a hobbit.
         
19) had been passed as the second argument.

The language of the argument

1º 2º 3º 4º ...
058, or the context item if the second argument is omitted, is determined by the value of the
let $para := 
In a hole in the ground there lived a hobbit.
         
297 attribute on the node, or, if the node has no such attribute, by the value of the
let $para := 
In a hole in the ground there lived a hobbit.
         
297 attribute on the nearest ancestor of the node that has an
let $para := 
In a hole in the ground there lived a hobbit.
         
297 attribute. If there is no such ancestor, then the function returns
let $C := 'http://www.w3.org/2013/collation/UCA?strength=primary'
07.

If

1º 2º 3º 4º ...
060 is the empty sequence it is interpreted as the zero-length string.

The relevant

let $para := 
In a hole in the ground there lived a hobbit.
         
297 attribute is determined by the value of the XPath expression:

op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
6

If this expression returns an empty sequence, the function returns

let $C := 'http://www.w3.org/2013/collation/UCA?strength=primary'
07.

Otherwise, the function returns

op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
76 if and only if, based on a caseless default match as specified in section 3.13 of [The Unicode Standard], either:

  1. 1º 2º 3º 4º ...
    060 is equal to the string-value of the relevant
    let $para := 
    In a hole in the ground there lived a hobbit.
             
    297 attribute, or

  2. 1º 2º 3º 4º ...
    060 is equal to some substring of the string-value of the relevant
    let $para := 
    In a hole in the ground there lived a hobbit.
             
    297 attribute that starts at the start of the string-value and ends immediately before a hyphen, "-" (the character "-" is HYPHEN-MINUS, #x002D).

Error Conditions

The following errors may be raised when

let $para := 
In a hole in the ground there lived a hobbit.
         
25 is omitted:

  • If the context item is absentDM31, dynamic error [err:XPDY0002]XP31

  • If the context item is not a node, type error [err:XPTY0004]XP31.

Examples

The expression

1º 2º 3º 4º ...
165 would return
op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
76 if the context node were any of the following four elements:

  • 1º 2º 3º 4º ...
    167

  • 1º 2º 3º 4º ...
    168

  • 1º 2º 3º 4º ...
    169

  • 1º 2º 3º 4º ...
    170

The expression

1º 2º 3º 4º ...
171 would return
let $C := 'http://www.w3.org/2013/collation/UCA?strength=primary'
07 if the context node were
1º 2º 3º 4º ...
169

13.5 fn:root

Summary

Returns the root of the tree to which

let $para := 
In a hole in the ground there lived a hobbit.
         
25 belongs. This will usually, but not necessarily, be a document node.

Signatures

1º 2º 3º 4º ...
061()
let $para := 
In a hole in the ground there lived a hobbit.
         
71
1º 2º 3º 4º ...
147

1º 2º 3º 4º ...
061(
let $para := 
In a hole in the ground there lived a hobbit.
         
25
let $para := 
In a hole in the ground there lived a hobbit.
         
71
op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
51)
let $para := 
In a hole in the ground there lived a hobbit.
         
71
op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
51

Properties

The zero-argument form of this function is ·deterministic·, ·context-dependent·, and ·focus-dependent·.

The one-argument form of this function is ·deterministic·, ·context-independent·, and ·focus-independent·.

Rules

If the function is called without an argument, the context item (

let $para := 
In a hole in the ground there lived a hobbit.
         
19) is used as the default argument. The behavior of the function if the argument is omitted is exactly the same as if the context item had been passed as the argument.

The function returns the value of the expression

1º 2º 3º 4º ...
185.

Error Conditions

The following errors may be raised when

let $para := 
In a hole in the ground there lived a hobbit.
         
25 is omitted:

  • If the context item is absentDM31, dynamic error [err:XPDY0002]XP31

  • If the context item is not a node, type error [err:XPTY0004]XP31.

Examples

These examples use some variables which could be defined in [XQuery 3.1: An XML Query Language] as:

op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
7

Or they could be defined in [XSL Transformations (XSLT) Version 3.0] as:

op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
8

1º 2º 3º 4º ...
187 returns the element node
1º 2º 3º 4º ...
188

1º 2º 3º 4º ...
189 returns the element node
1º 2º 3º 4º ...
190

1º 2º 3º 4º ...
191 returns the document node
1º 2º 3º 4º ...
192

1º 2º 3º 4º ...
193 returns the element node
1º 2º 3º 4º ...
190

The final three examples could be made type-safe by wrapping their operands with

1º 2º 3º 4º ...
195.

13.6 fn:path

Summary

Returns a path expression that can be used to select the supplied node relative to the root of its containing document.

Signatures

1º 2º 3º 4º ...
063()
let $para := 
In a hole in the ground there lived a hobbit.
         
71
let $para := 
In a hole in the ground there lived a hobbit.
         
244

1º 2º 3º 4º ...
063(
let $para := 
In a hole in the ground there lived a hobbit.
         
25
let $para := 
In a hole in the ground there lived a hobbit.
         
71
op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
51)
let $para := 
In a hole in the ground there lived a hobbit.
         
71
let $para := 
In a hole in the ground there lived a hobbit.
         
244

Properties

The one-argument form of this function is ·deterministic·, ·context-dependent·, and ·focus-dependent·.

The two-argument form of this function is ·deterministic·, ·context-independent·, and ·focus-independent·.

Rules

The behavior of the function if the argument is omitted is exactly the same as if the context item (

let $para := 
In a hole in the ground there lived a hobbit.
         
19) had been passed as the argument.

If

let $para := 
In a hole in the ground there lived a hobbit.
         
25 is the empty sequence, the function returns the empty sequence.

If

let $para := 
In a hole in the ground there lived a hobbit.
         
25 is a document node, the function returns the string
1º 2º 3º 4º ...
208.

Otherwise, the function returns a string that consists of a sequence of steps, one for each ancestor-or-self of

let $para := 
In a hole in the ground there lived a hobbit.
         
25 other than the root node. This string is prefixed by
1º 2º 3º 4º ...
210 if the root node is not a document node. Each step consists of the character
1º 2º 3º 4º ...
208 followed by a string whose form depends on the kind of node selected by that step, as follows:

  1. For an element node,

    1º 2º 3º 4º ...
    212, where
    1º 2º 3º 4º ...
    213 is the namespace URI of the node name or the empty string if the node is in no namespace,
    1º 2º 3º 4º ...
    214 is the local part of the node name, and
    1º 2º 3º 4º ...
    215 is an integer representing the position of the selected node among its like-named siblings.

  2. For an attribute node:

    1. if the node is in no namespace,

      1º 2º 3º 4º ...
      216, where
      1º 2º 3º 4º ...
      214 is the local part of the node name

    2. otherwise,

      1º 2º 3º 4º ...
      218, where
      1º 2º 3º 4º ...
      213 is the namespace URI of the node name, and
      1º 2º 3º 4º ...
      214 is the local part of the node name

  3. For a text node:

    1º 2º 3º 4º ...
    221 where
    1º 2º 3º 4º ...
    215 is an integer representing the position of the selected node among its text node siblings

  4. For a comment node:

    1º 2º 3º 4º ...
    223 where
    1º 2º 3º 4º ...
    215 is an integer representing the position of the selected node among its comment node siblings

  5. For a processing-instruction node:

    1º 2º 3º 4º ...
    225 where
    1º 2º 3º 4º ...
    214 is the name of the processing instruction node and
    1º 2º 3º 4º ...
    215 is an integer representing the position of the selected node among its like-named processing-instruction node siblings

  6. For a namespace node:

    1. If the namespace node has a name:

      1º 2º 3º 4º ...
      228, where
      1º 2º 3º 4º ...
      229 is the local part of the name of the namespace node (which represents the namespace prefix).

    2. If the namespace node has no name (that is, it represents the default namespace):

      1º 2º 3º 4º ...
      230

Error Conditions

The following errors may be raised when

let $para := 
In a hole in the ground there lived a hobbit.
         
25 is omitted:

  • If the context item is absentDM31, dynamic error [err:XPDY0002]XP31

  • If the context item is not a node, type error [err:XPTY0004]XP31.

Examples

op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
9

The expression

1º 2º 3º 4º ...
232 returns
1º 2º 3º 4º ...
233.

The expression

1º 2º 3º 4º ...
234 returns
1º 2º 3º 4º ...
235.

The expression

1º 2º 3º 4º ...
236 returns
1º 2º 3º 4º ...
237.

The expression

1º 2º 3º 4º ...
238 returns
1º 2º 3º 4º ...
239.

The expression

1º 2º 3º 4º ...
240 returns
1º 2º 3º 4º ...
241.

The expression

1º 2º 3º 4º ...
242 returns
1º 2º 3º 4º ...
243.

op:operation(fenceHeight, xs:integer) => op:operation(xs:integer, xs:integer)
0

The expression

1º 2º 3º 4º ...
244 returns
1º 2º 3º 4º ...
245.

The expression

1º 2º 3º 4º ...
246 returns
1º 2º 3º 4º ...
247.

The expression

1º 2º 3º 4º ...
248 returns
1º 2º 3º 4º ...
249.

13.7 fn:has-children

Summary

Returns true if the supplied node has one or more child nodes (of any kind).

Signatures

1º 2º 3º 4º ...
064()
let $para := 
In a hole in the ground there lived a hobbit.
         
71
op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
32

1º 2º 3º 4º ...
064(
1º 2º 3º 4º ...
058
let $para := 
In a hole in the ground there lived a hobbit.
         
71
op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
51)
let $para := 
In a hole in the ground there lived a hobbit.
         
71
op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
32

Properties

The zero-argument form of this function is ·deterministic·, ·context-dependent·, and ·focus-dependent·.

The one-argument form of this function is ·deterministic·, ·context-independent·, and ·focus-independent·.

Rules

If the argument is omitted, it defaults to the context item (

let $para := 
In a hole in the ground there lived a hobbit.
         
19). The behavior of the function if the argument is omitted is exactly the same as if the context item had been passed as the argument.

Provided that the supplied argument

1º 2º 3º 4º ...
058 matches the expected type
op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
51, the result of the function call
1º 2º 3º 4º ...
262 is defined to be the same as the result of the expression
1º 2º 3º 4º ...
263.

Error Conditions

The following errors may be raised when

1º 2º 3º 4º ...
058 is omitted:

  • If the context item is absentDM31, dynamic error [err:XPDY0002]XP31

  • If the context item is not a node, type error [err:XPTY0004]XP31.

Notes

If

1º 2º 3º 4º ...
058 is an empty sequence the result is false.

The motivation for this function is to support streamed evaluation. According to the streaming rules in [XSL Transformations (XSLT) Version 3.0], the following construct is not streamable:

op:operation(fenceHeight, xs:integer) => op:operation(xs:integer, xs:integer)
1

This is because it makes two downward selections to read the child

1º 2º 3º 4º ...
266 elements. The use of
1º 2º 3º 4º ...
064 in the
1º 2º 3º 4º ...
268 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.

13.8 fn:innermost

Summary

Returns every node within the input sequence that is not an ancestor of another member of the input sequence; the nodes are returned in document order with duplicates eliminated.

Signature

1º 2º 3º 4º ...
065(
1º 2º 3º 4º ...
270
let $para := 
In a hole in the ground there lived a hobbit.
         
71
1º 2º 3º 4º ...
272)
let $para := 
In a hole in the ground there lived a hobbit.
         
71
1º 2º 3º 4º ...
272

Properties

This function is ·deterministic·, ·context-independent·, and ·focus-independent·.

Rules

The effect of the function call

1º 2º 3º 4º ...
275 is defined to be equivalent to the result of the expression:

op:operation(fenceHeight, xs:integer) => op:operation(xs:integer, xs:integer)
2

That is, the function takes as input a sequence of nodes, and returns every node within the sequence that is not an ancestor of another node within the sequence; the nodes are returned in document order with duplicates eliminated.

Examples

If the source document contains nested sections represented by

1º 2º 3º 4º ...
276 elements, the expression
1º 2º 3º 4º ...
277 returns those
1º 2º 3º 4º ...
276 elements that do not contain further
1º 2º 3º 4º ...
276 elements.

13.9 fn:outermost

Summary

Returns every node within the input sequence that has no ancestor that is itself a member of the input sequence; the nodes are returned in document order with duplicates eliminated.

Signature

1º 2º 3º 4º ...
066(
1º 2º 3º 4º ...
270
let $para := 
In a hole in the ground there lived a hobbit.
         
71
1º 2º 3º 4º ...
272)
let $para := 
In a hole in the ground there lived a hobbit.
         
71
1º 2º 3º 4º ...
272

Properties

This function is ·deterministic·, ·context-independent·, and ·focus-independent·.

Rules

The effect of the function call

1º 2º 3º 4º ...
286 is defined to be equivalent to the result of the expression:

op:operation(fenceHeight, xs:integer) => op:operation(xs:integer, xs:integer)
3

That is, the function takes as input a sequence of nodes, and returns every node within the sequence that does not have another node within the sequence as an ancestor; the nodes are returned in document order with duplicates eliminated.

Notes

The formulation

1º 2º 3º 4º ...
287 might appear to be simpler, but does not correctly account for attribute nodes, as these are not descendants of their parent element.

The motivation for the function was based on XSLT streaming use cases. There are cases where the [XSL Transformations (XSLT) Version 3.0] streaming rules allow the construct

1º 2º 3º 4º ...
288 but do not allow
1º 2º 3º 4º ...
289; the function can therefore be useful in cases where it is known that sections will not be nested, as well as cases where the application actually wishes to process all sections except those that are nested within another.

Examples

If the source document contains nested sections represented by

1º 2º 3º 4º ...
276 elements, the expression
1º 2º 3º 4º ...
291 returns those
1º 2º 3º 4º ...
276 elements that are not contained within further
1º 2º 3º 4º ...
276 elements.

14 Functions and operators on sequences

A

1º 2º 3º 4º ...
294 is an ordered collection of zero or more
1º 2º 3º 4º ...
295. An
1º 2º 3º 4º ...
296 is either a node or an atomic value. The terms
1º 2º 3º 4º ...
294 and
1º 2º 3º 4º ...
296 are defined formally in [XQuery 3.1: An XML Query Language] and [XML Path Language (XPath) 3.1].

14.1 General functions and operators on sequences

The following functions are defined on sequences. These functions work on any sequence, without performing any operations that are sensitive to the individual items in the sequence.

FunctionMeaning
1º 2º 3º 4º ...
299Returns true if the argument is the empty sequence.
1º 2º 3º 4º ...
300Returns true if the argument is a non-empty sequence.
1º 2º 3º 4º ...
301Returns the first item in a sequence.
1º 2º 3º 4º ...
302Returns all but the first item in a sequence.
1º 2º 3º 4º ...
303Returns a sequence constructed by inserting an item or a sequence of items at a given position within an existing sequence.
1º 2º 3º 4º ...
304Returns a new sequence containing all the items of
1º 2º 3º 4º ...
305 except the item at position
1º 2º 3º 4º ...
306.
1º 2º 3º 4º ...
307Reverses the order of items in a sequence.
1º 2º 3º 4º ...
308Returns the contiguous sequence of items in the value of
1º 2º 3º 4º ...
309 beginning at the position indicated by the value of
1º 2º 3º 4º ...
310 and continuing for the number of items indicated by the value of
let $para := 
In a hole in the ground there lived a hobbit.
         
275.
op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
15Returns the items of
1º 2º 3º 4º ...
309 in an ·implementation-dependent· order.

As in the previous section, for the illustrative examples below, assume an XQuery or transformation operating on a non-empty Purchase Order document containing a number of line-item elements. The variable

let $para := 
In a hole in the ground there lived a hobbit.
         
021 is bound to the sequence of line-item nodes in document order. The variables
1º 2º 3º 4º ...
074,
1º 2º 3º 4º ...
075, etc. are bound to separate, individual line-item nodes in the sequence.

14.1.1 fn:empty

Summary

Returns true if the argument is the empty sequence.

Signature

1º 2º 3º 4º ...
299(
let $para := 
In a hole in the ground there lived a hobbit.
         
25
let $para := 
In a hole in the ground there lived a hobbit.
         
71
op:operation(fenceHeight, xs:integer) => op:operation(xs:integer, xs:integer)
16)
let $para := 
In a hole in the ground there lived a hobbit.
         
71
op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
32

Properties

This function is ·deterministic·, ·context-independent·, and ·focus-independent·.

Rules

If the value of

let $para := 
In a hole in the ground there lived a hobbit.
         
25 is the empty sequence, the function returns
op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
76; otherwise, the function returns
let $C := 'http://www.w3.org/2013/collation/UCA?strength=primary'
07.

Examples

The expression

1º 2º 3º 4º ...
326 returns
let $para := 
In a hole in the ground there lived a hobbit.
         
182.

The expression

1º 2º 3º 4º ...
328 returns
let $para := 
In a hole in the ground there lived a hobbit.
         
184.

The expression

1º 2º 3º 4º ...
330 returns
let $para := 
In a hole in the ground there lived a hobbit.
         
184.

The expression

1º 2º 3º 4º ...
332 returns
let $para := 
In a hole in the ground there lived a hobbit.
         
184.

The expression

1º 2º 3º 4º ...
334 returns
let $para := 
In a hole in the ground there lived a hobbit.
         
184.

Assuming

1º 2º 3º 4º ...
336 is an element with no children:

op:operation(fenceHeight, xs:integer) => op:operation(xs:integer, xs:integer)
4

The result is

let $para := 
In a hole in the ground there lived a hobbit.
         
184.

14.1.2 fn:exists

Summary

Returns true if the argument is a non-empty sequence.

Signature

1º 2º 3º 4º ...
300(
let $para := 
In a hole in the ground there lived a hobbit.
         
25
let $para := 
In a hole in the ground there lived a hobbit.
         
71
op:operation(fenceHeight, xs:integer) => op:operation(xs:integer, xs:integer)
16)
let $para := 
In a hole in the ground there lived a hobbit.
         
71
op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
32

Properties

This function is ·deterministic·, ·context-independent·, and ·focus-independent·.

Rules

If the value of

let $para := 
In a hole in the ground there lived a hobbit.
         
25 is a non-empty sequence, the function returns
op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
76; otherwise, the function returns
let $C := 'http://www.w3.org/2013/collation/UCA?strength=primary'
07.

Examples

The expression

1º 2º 3º 4º ...
347 returns
let $para := 
In a hole in the ground there lived a hobbit.
         
184.

The expression

1º 2º 3º 4º ...
349 returns
let $para := 
In a hole in the ground there lived a hobbit.
         
182.

The expression

1º 2º 3º 4º ...
351 returns
let $para := 
In a hole in the ground there lived a hobbit.
         
182.

The expression

1º 2º 3º 4º ...
353 returns
let $para := 
In a hole in the ground there lived a hobbit.
         
182.

The expression

1º 2º 3º 4º ...
355 returns
let $para := 
In a hole in the ground there lived a hobbit.
         
182.

Assuming

1º 2º 3º 4º ...
336 is an element with no children:

op:operation(fenceHeight, xs:integer) => op:operation(xs:integer, xs:integer)
5

The result is

let $para := 
In a hole in the ground there lived a hobbit.
         
182.

14.1.3 fn:head

Summary

Returns the first item in a sequence.

Signature

1º 2º 3º 4º ...
301(
let $para := 
In a hole in the ground there lived a hobbit.
         
25
let $para := 
In a hole in the ground there lived a hobbit.
         
71
op:operation(fenceHeight, xs:integer) => op:operation(xs:integer, xs:integer)
16)
let $para := 
In a hole in the ground there lived a hobbit.
         
71
let $para := 
In a hole in the ground there lived a hobbit.
         
79

Properties

This function is ·deterministic·, ·context-independent·, and ·focus-independent·.

Rules

The function returns the value of the expression

1º 2º 3º 4º ...
365

Notes

If

let $para := 
In a hole in the ground there lived a hobbit.
         
25 is the empty sequence, the empty sequence is returned. Otherwise the first item in the sequence is returned.

Examples

The expression

1º 2º 3º 4º ...
367 returns
declare %public function r:random-sequence($length as xs:integer) as xs:double* {
  r:random-sequence($length, fn:random-number-generator())
};

declare %private function r:random-sequence($length as xs:integer, 
                                            $G as map(xs:string, item())) {
  if ($length eq 0)
  then ()
  else ($G?number, r:random-sequence($length - 1, $G?next()))
};

r:random-sequence(200);
            
13.

The expression

1º 2º 3º 4º ...
369 returns
1º 2º 3º 4º ...
370.

The expression

1º 2º 3º 4º ...
371 returns
let $para := 
In a hole in the ground there lived a hobbit.
         
96.

The expression

1º 2º 3º 4º ...
373 returns
1º 2º 3º 4º ...
374.

14.1.4 fn:tail

Summary

Returns all but the first item in a sequence.

Signature

1º 2º 3º 4º ...
302(
let $para := 
In a hole in the ground there lived a hobbit.
         
25
let $para := 
In a hole in the ground there lived a hobbit.
         
71
op:operation(fenceHeight, xs:integer) => op:operation(xs:integer, xs:integer)
16)
let $para := 
In a hole in the ground there lived a hobbit.
         
71
op:operation(fenceHeight, xs:integer) => op:operation(xs:integer, xs:integer)
16

Properties

This function is ·deterministic·, ·context-independent·, and ·focus-independent·.

Rules

The function returns the value of the expression

1º 2º 3º 4º ...
381

Notes

If

let $para := 
In a hole in the ground there lived a hobbit.
         
25 is the empty sequence, or a sequence containing a single item, then the empty sequence is returned.

Examples

The expression

1º 2º 3º 4º ...
383 returns
1º 2º 3º 4º ...
384.

The expression

1º 2º 3º 4º ...
385 returns
1º 2º 3º 4º ...
386.

The expression

1º 2º 3º 4º ...
387 returns
let $para := 
In a hole in the ground there lived a hobbit.
         
96.

The expression

1º 2º 3º 4º ...
389 returns
let $para := 
In a hole in the ground there lived a hobbit.
         
96.

The expression

1º 2º 3º 4º ...
391 returns
let $para := 
In a hole in the ground there lived a hobbit.
         
96.

14.1.5 fn:insert-before

Summary

Returns a sequence constructed by inserting an item or a sequence of items at a given position within an existing sequence.

Signature

1º 2º 3º 4º ...
303(
1º 2º 3º 4º ...
305
let $para := 
In a hole in the ground there lived a hobbit.
         
71
op:operation(fenceHeight, xs:integer) => op:operation(xs:integer, xs:integer)
16,
1º 2º 3º 4º ...
306
let $para := 
In a hole in the ground there lived a hobbit.
         
71
let $para := 
In a hole in the ground there lived a hobbit.
         
85,
1º 2º 3º 4º ...
400
let $para := 
In a hole in the ground there lived a hobbit.
         
71
op:operation(fenceHeight, xs:integer) => op:operation(xs:integer, xs:integer)
16)
let $para := 
In a hole in the ground there lived a hobbit.
         
71
op:operation(fenceHeight, xs:integer) => op:operation(xs:integer, xs:integer)
16

Properties

This function is ·deterministic·, ·context-independent·, and ·focus-independent·.

Rules

The value returned by the function consists of all items of

1º 2º 3º 4º ...
305 whose index is less than
1º 2º 3º 4º ...
306, followed by all items of
1º 2º 3º 4º ...
400, followed by the remaining elements of
1º 2º 3º 4º ...
305, in that order.

Notes

If

1º 2º 3º 4º ...
305 is the empty sequence,
1º 2º 3º 4º ...
400 is returned. If
1º 2º 3º 4º ...
400 is the empty sequence,
1º 2º 3º 4º ...
305 is returned.

If

1º 2º 3º 4º ...
306 is less than one (1), the first position, the effective value of
1º 2º 3º 4º ...
306 is one (1). If
1º 2º 3º 4º ...
306 is greater than the number of items in
1º 2º 3º 4º ...
305, then the effective value of
1º 2º 3º 4º ...
306 is equal to the number of items in
1º 2º 3º 4º ...
305 plus 1.

The value of

1º 2º 3º 4º ...
305 is not affected by the sequence construction.

Examples

op:operation(fenceHeight, xs:integer) => op:operation(xs:integer, xs:integer)
6

The expression

1º 2º 3º 4º ...
420 returns
1º 2º 3º 4º ...
421.

The expression

1º 2º 3º 4º ...
422 returns
1º 2º 3º 4º ...
421.

The expression

1º 2º 3º 4º ...
424 returns
1º 2º 3º 4º ...
425.

The expression

1º 2º 3º 4º ...
426 returns
1º 2º 3º 4º ...
427.

The expression

1º 2º 3º 4º ...
428 returns
1º 2º 3º 4º ...
429.

14.1.6 fn:remove

Summary

Returns a new sequence containing all the items of

1º 2º 3º 4º ...
305 except the item at position
1º 2º 3º 4º ...
306.

Signature

1º 2º 3º 4º ...
304(
1º 2º 3º 4º ...
305
let $para := 
In a hole in the ground there lived a hobbit.
         
71
op:operation(fenceHeight, xs:integer) => op:operation(xs:integer, xs:integer)
16,
1º 2º 3º 4º ...
306
let $para := 
In a hole in the ground there lived a hobbit.
         
71
let $para := 
In a hole in the ground there lived a hobbit.
         
85)
let $para := 
In a hole in the ground there lived a hobbit.
         
71
op:operation(fenceHeight, xs:integer) => op:operation(xs:integer, xs:integer)
16

Properties

This function is ·deterministic·, ·context-independent·, and ·focus-independent·.

Rules

The function returns a sequence consisting of all items of

1º 2º 3º 4º ...
305 whose index is less than
1º 2º 3º 4º ...
306, followed by all items of
1º 2º 3º 4º ...
305 whose index is greater than
1º 2º 3º 4º ...
306.

Notes

If

1º 2º 3º 4º ...
306 is less than 1 or greater than the number of items in
1º 2º 3º 4º ...
305,
1º 2º 3º 4º ...
305 is returned.

If

1º 2º 3º 4º ...
305 is the empty sequence, the empty sequence is returned.

Examples

op:operation(fenceHeight, xs:integer) => op:operation(xs:integer, xs:integer)
6

The expression

1º 2º 3º 4º ...
449 returns
1º 2º 3º 4º ...
450.

The expression

1º 2º 3º 4º ...
451 returns
1º 2º 3º 4º ...
386.

The expression

1º 2º 3º 4º ...
453 returns
1º 2º 3º 4º ...
450.

The expression

1º 2º 3º 4º ...
455 returns
let $para := 
In a hole in the ground there lived a hobbit.
         
96.

14.1.7 fn:reverse

Summary

Reverses the order of items in a sequence.

Signature

1º 2º 3º 4º ...
307(
let $para := 
In a hole in the ground there lived a hobbit.
         
25
let $para := 
In a hole in the ground there lived a hobbit.
         
71
op:operation(fenceHeight, xs:integer) => op:operation(xs:integer, xs:integer)
16)
let $para := 
In a hole in the ground there lived a hobbit.
         
71
op:operation(fenceHeight, xs:integer) => op:operation(xs:integer, xs:integer)
16

Properties

This function is ·deterministic·, ·context-independent·, and ·focus-independent·.

Rules

The function returns a sequence containing the items in

let $para := 
In a hole in the ground there lived a hobbit.
         
25 in reverse order.

Notes

If

let $para := 
In a hole in the ground there lived a hobbit.
         
25 is the empty sequence, the empty sequence is returned.

Examples

op:operation(fenceHeight, xs:integer) => op:operation(xs:integer, xs:integer)
6

The expression

1º 2º 3º 4º ...
465 returns
1º 2º 3º 4º ...
466.

The expression

1º 2º 3º 4º ...
467 returns
1º 2º 3º 4º ...
468.

The expression

1º 2º 3º 4º ...
469 returns
let $para := 
In a hole in the ground there lived a hobbit.
         
96.

The expression

1º 2º 3º 4º ...
471 returns
1º 2º 3º 4º ...
374. (The input is a sequence containing a single item (the array)).

The expression

1º 2º 3º 4º ...
473 returns
1º 2º 3º 4º ...
474.

14.1.8 fn:subsequence

Summary

Returns the contiguous sequence of items in the value of

1º 2º 3º 4º ...
309 beginning at the position indicated by the value of
1º 2º 3º 4º ...
310 and continuing for the number of items indicated by the value of
let $para := 
In a hole in the ground there lived a hobbit.
         
275.

Signatures

1º 2º 3º 4º ...
308(
1º 2º 3º 4º ...
309
let $para := 
In a hole in the ground there lived a hobbit.
         
71
op:operation(fenceHeight, xs:integer) => op:operation(xs:integer, xs:integer)
16,
1º 2º 3º 4º ...
310
let $para := 
In a hole in the ground there lived a hobbit.
         
71
let $para := 
In a hole in the ground there lived a hobbit.
         
26)
let $para := 
In a hole in the ground there lived a hobbit.
         
71
op:operation(fenceHeight, xs:integer) => op:operation(xs:integer, xs:integer)
16

1º 2º 3º 4º ...
308(
1º 2º 3º 4º ...
309
let $para := 
In a hole in the ground there lived a hobbit.
         
71
op:operation(fenceHeight, xs:integer) => op:operation(xs:integer, xs:integer)
16,
1º 2º 3º 4º ...
310
let $para := 
In a hole in the ground there lived a hobbit.
         
71
let $para := 
In a hole in the ground there lived a hobbit.
         
26,
let $para := 
In a hole in the ground there lived a hobbit.
         
275
let $para := 
In a hole in the ground there lived a hobbit.
         
71
let $para := 
In a hole in the ground there lived a hobbit.
         
26)
let $para := 
In a hole in the ground there lived a hobbit.
         
71
op:operation(fenceHeight, xs:integer) => op:operation(xs:integer, xs:integer)
16

Properties

This function is ·deterministic·, ·context-independent·, and ·focus-independent·.

Rules

In the two-argument case, returns:

op:operation(fenceHeight, xs:integer) => op:operation(xs:integer, xs:integer)
9

In the three-argument case, returns:

fn:abs($N * $arg2) le fn:abs($arg1) 
               and fn:compare($N * $arg2, 0) eq fn:compare($arg1, 0).
0

Notes

The first item of a sequence is located at position 1, not position 0.

If

1º 2º 3º 4º ...
309 is the empty sequence, the empty sequence is returned.

In the two-argument case, the function returns a sequence comprising those items of

1º 2º 3º 4º ...
309 whose index position (counting from one) is greater than or equal to the value of
1º 2º 3º 4º ...
310 (rounded to an integer). No error occurs if
1º 2º 3º 4º ...
310 is zero or negative.

In the three-argument case, The function returns a sequence comprising those items of

1º 2º 3º 4º ...
309 whose index position (counting from one) is greater than or equal to the value of
1º 2º 3º 4º ...
310 (rounded to an integer), and less than the sum of
1º 2º 3º 4º ...
310 and
let $para := 
In a hole in the ground there lived a hobbit.
         
275 (both rounded to integers). No error occurs if
1º 2º 3º 4º ...
310 is zero or negative, or if
1º 2º 3º 4º ...
310 plus
let $para := 
In a hole in the ground there lived a hobbit.
         
275 exceeds the number of items in the sequence, or if
let $para := 
In a hole in the ground there lived a hobbit.
         
275 is negative.

As a consequence of the general rules, if

1º 2º 3º 4º ...
310 is
1º 2º 3º 4º ...
57 and
let $para := 
In a hole in the ground there lived a hobbit.
         
275 is
let $para := 
In a hole in the ground there lived a hobbit.
         
27, then
1º 2º 3º 4º ...
515 is
fn:abs($N * $arg2) le fn:abs($arg1) 
               and fn:compare($N * $arg2, 0) eq fn:compare($arg1, 0).
90; since
1º 2º 3º 4º ...
517 is always false, the result is an empty sequence.

The reason the function accepts arguments of type

let $para := 
In a hole in the ground there lived a hobbit.
         
26 is that many computations on untyped data return an
let $para := 
In a hole in the ground there lived a hobbit.
         
26 result; and the reason for the rounding rules is to compensate for any imprecision in these floating-point computations.

Examples

fn:abs($N * $arg2) le fn:abs($arg1) 
               and fn:compare($N * $arg2, 0) eq fn:compare($arg1, 0).
1

The expression

1º 2º 3º 4º ...
520 returns
1º 2º 3º 4º ...
521.

The expression

1º 2º 3º 4º ...
522 returns
1º 2º 3º 4º ...
523.

14.1.9 fn:unordered

Summary

Returns the items of

1º 2º 3º 4º ...
309 in an ·implementation-dependent· order.

Signature

op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
15(
1º 2º 3º 4º ...
309
let $para := 
In a hole in the ground there lived a hobbit.
         
71
op:operation(fenceHeight, xs:integer) => op:operation(xs:integer, xs:integer)
16)
let $para := 
In a hole in the ground there lived a hobbit.
         
71
op:operation(fenceHeight, xs:integer) => op:operation(xs:integer, xs:integer)
16

Properties

This function is ·nondeterministic-wrt-ordering·, ·context-independent·, and ·focus-independent·.

Rules

The function returns the items of

1º 2º 3º 4º ...
309 in an ·implementation-dependent· order.

Notes

Query optimizers may be able to do a better job if the order of the output sequence is not specified. For example, when retrieving prices from a purchase order, if an index exists on prices, it may be more efficient to return the prices in index order rather than in document order.

Examples

The expression

1º 2º 3º 4º ...
532 returns some permutation of
1º 2º 3º 4º ...
533.

14.2 Functions that compare values in sequences

The functions in this section rely on comparisons between the items in one or more sequences.

FunctionMeaning
op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
14Returns the values that appear in a sequence, with duplicates eliminated.
1º 2º 3º 4º ...
535Returns a sequence of positive integers giving the positions within the sequence
let $para := 
In a hole in the ground there lived a hobbit.
         
021 of items that are equal to
1º 2º 3º 4º ...
537.
op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
23This function assesses whether two sequences are deep-equal to each other. To be deep-equal, they must contain items that are pairwise deep-equal; and for two items to be deep-equal, they must either be atomic values that compare equal, or nodes of the same kind, with the same name, whose children are deep-equal, or maps with matching entries, or arrays with matching members.

14.2.1 fn:distinct-values

Summary

Returns the values that appear in a sequence, with duplicates eliminated.

Signatures

op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
14(
let $para := 
In a hole in the ground there lived a hobbit.
         
25
let $para := 
In a hole in the ground there lived a hobbit.
         
71
op:operation(fenceHeight, xs:integer) => op:operation(xs:integer, xs:integer)
12)
let $para := 
In a hole in the ground there lived a hobbit.
         
71
op:operation(fenceHeight, xs:integer) => op:operation(xs:integer, xs:integer)
12

op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
14(
let $para := 
In a hole in the ground there lived a hobbit.
         
25
let $para := 
In a hole in the ground there lived a hobbit.
         
71
op:operation(fenceHeight, xs:integer) => op:operation(xs:integer, xs:integer)
12,
let $para := 
In a hole in the ground there lived a hobbit.
         
128
let $para := 
In a hole in the ground there lived a hobbit.
         
71
let $para := 
In a hole in the ground there lived a hobbit.
         
10)
let $para := 
In a hole in the ground there lived a hobbit.
         
71
op:operation(fenceHeight, xs:integer) => op:operation(xs:integer, xs:integer)
12

Properties

The one-argument form of this function is ·nondeterministic-wrt-ordering·, ·context-dependent·, and ·focus-independent·. It depends on collations, and implicit timezone.

The two-argument form of this function is ·deterministic·, ·context-dependent·, and ·focus-independent·. It depends on collations, and static base URI, and implicit timezone.

Rules

The function returns the sequence that results from removing from

let $para := 
In a hole in the ground there lived a hobbit.
         
25 all but one of a set of values that are considered equal to one another. Two items $J and $K in the input sequence (after atomization, as required by the function signature) are considered equal if
1º 2º 3º 4º ...
555 is true, where
1º 2º 3º 4º ...
556 is the collation selected according to the rules in 5.3.5 Choosing a collation.
This collation is used when string comparison is required.

The order in which the sequence of values is returned is ·implementation-dependent·.

Which value of a set of values that compare equal is returned is ·implementation-dependent·.

If the input sequence contains values of different numeric types that differ from each other by small amounts, then the eq operator is not transitive, because of rounding effects occurring during type promotion. In the situation where the input contains three values

let $para := 
In a hole in the ground there lived a hobbit.
         
51,
1º 2º 3º 4º ...
558, and
fn:abs($N * $arg2) le fn:abs($arg1) 
               and fn:compare($N * $arg2, 0) eq fn:compare($arg1, 0).
546 such that
1º 2º 3º 4º ...
560,
1º 2º 3º 4º ...
561, but
1º 2º 3º 4º ...
562, then the number of items in the result of the function (as well as the choice of which items are returned) is ·implementation-dependent·, subject only to the constraints that (a) no two items in the result sequence compare equal to each other, and (b) every input item that does not appear in the result sequence compares equal to some item that does appear in the result sequence.

For example, this arises when computing:

fn:abs($N * $arg2) le fn:abs($arg1) 
               and fn:compare($N * $arg2, 0) eq fn:compare($arg1, 0).
2

because the values of type

let $para := 
In a hole in the ground there lived a hobbit.
         
83 and
let $para := 
In a hole in the ground there lived a hobbit.
         
26 both compare equal to the value of type
let $para := 
In a hole in the ground there lived a hobbit.
         
82 but not equal to each other.

Notes

If

let $para := 
In a hole in the ground there lived a hobbit.
         
25 is the empty sequence, the function returns the empty sequence.

Values of type

let $para := 
In a hole in the ground there lived a hobbit.
         
00 are compared as if they were of type
let $para := 
In a hole in the ground there lived a hobbit.
         
10.

Values that cannot be compared, because the

let $para := 
In a hole in the ground there lived a hobbit.
         
33 operator is not defined for their types, are considered to be distinct.

For

let $para := 
In a hole in the ground there lived a hobbit.
         
83 and
let $para := 
In a hole in the ground there lived a hobbit.
         
26 values, positive zero is equal to negative zero and, although
fn:abs($N * $arg2) le fn:abs($arg1) 
               and fn:compare($N * $arg2, 0) eq fn:compare($arg1, 0).
90 does not equal itself, if
let $para := 
In a hole in the ground there lived a hobbit.
         
25 contains multiple
fn:abs($N * $arg2) le fn:abs($arg1) 
               and fn:compare($N * $arg2, 0) eq fn:compare($arg1, 0).
90 values a single
fn:abs($N * $arg2) le fn:abs($arg1) 
               and fn:compare($N * $arg2, 0) eq fn:compare($arg1, 0).
90 is returned.

If

let $para := 
In a hole in the ground there lived a hobbit.
         
29,
op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
964 or
op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
965 values do not have a timezone, they are considered to have the implicit timezone provided by the dynamic context for the purpose of comparison. Note that
let $para := 
In a hole in the ground there lived a hobbit.
         
29,
op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
964 or
op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
965 values can compare equal even if their timezones are different.

Examples

The expression

1º 2º 3º 4º ...
582 returns some permutation of
1º 2º 3º 4º ...
583. (The result may include either the
let $para := 
In a hole in the ground there lived a hobbit.
         
85 2 or the
let $para := 
In a hole in the ground there lived a hobbit.
         
82 2.0).

The expression

1º 2º 3º 4º ...
586 returns some permutation of
1º 2º 3º 4º ...
587.

14.2.2 fn:index-of

Summary

Returns a sequence of positive integers giving the positions within the sequence

let $para := 
In a hole in the ground there lived a hobbit.
         
021 of items that are equal to
1º 2º 3º 4º ...
537.

Signatures

1º 2º 3º 4º ...
535(
let $para := 
In a hole in the ground there lived a hobbit.
         
021
let $para := 
In a hole in the ground there lived a hobbit.
         
71
op:operation(fenceHeight, xs:integer) => op:operation(xs:integer, xs:integer)
12,
1º 2º 3º 4º ...
537
let $para := 
In a hole in the ground there lived a hobbit.
         
71
let $para := 
In a hole in the ground there lived a hobbit.
         
34)
let $para := 
In a hole in the ground there lived a hobbit.
         
71
let $para := 
In a hole in the ground there lived a hobbit.
         
033

1º 2º 3º 4º ...
535(
let $para := 
In a hole in the ground there lived a hobbit.
         
021
let $para := 
In a hole in the ground there lived a hobbit.
         
71
op:operation(fenceHeight, xs:integer) => op:operation(xs:integer, xs:integer)
12,
1º 2º 3º 4º ...
537
let $para := 
In a hole in the ground there lived a hobbit.
         
71
let $para := 
In a hole in the ground there lived a hobbit.
         
34,
let $para := 
In a hole in the ground there lived a hobbit.
         
128
let $para := 
In a hole in the ground there lived a hobbit.
         
71
let $para := 
In a hole in the ground there lived a hobbit.
         
10)
let $para := 
In a hole in the ground there lived a hobbit.
         
71
let $para := 
In a hole in the ground there lived a hobbit.
         
033

Properties

The two-argument form of this function is ·deterministic·, ·context-dependent·, and ·focus-independent·. It depends on collations, and implicit timezone.

The three-argument form of this function is ·deterministic·, ·context-dependent·, and ·focus-independent·. It depends on collations, and static base URI, and implicit timezone.

Rules

The function returns a sequence of positive integers giving the positions within the sequence

let $para := 
In a hole in the ground there lived a hobbit.
         
021 of items that are equal to
1º 2º 3º 4º ...
537.

The collation used by this function is determined according to the rules in 5.3.5 Choosing a collation. This collation is used when string comparison is required.

The items in the sequence

let $para := 
In a hole in the ground there lived a hobbit.
         
021 are compared with
1º 2º 3º 4º ...
537 under the rules for the
let $para := 
In a hole in the ground there lived a hobbit.
         
33 operator. Values of type
let $para := 
In a hole in the ground there lived a hobbit.
         
00 are compared as if they were of type
let $para := 
In a hole in the ground there lived a hobbit.
         
10. Values that cannot be compared, because the
let $para := 
In a hole in the ground there lived a hobbit.
         
33 operator is not defined for their types, are considered to be distinct. If an item compares equal, then the position of that item in the sequence
let $para := 
In a hole in the ground there lived a hobbit.
         
021 is included in the result.

The first item in a sequence is at position 1, not position 0.

The result sequence is in ascending numeric order.

Notes

If the value of

let $para := 
In a hole in the ground there lived a hobbit.
         
021 is the empty sequence, or if no item in
let $para := 
In a hole in the ground there lived a hobbit.
         
021 matches
1º 2º 3º 4º ...
537, then the function returns the empty sequence.

No error occurs if non-comparable values are encountered. So when comparing two atomic values, the effective boolean value of

1º 2º 3º 4º ...
623 is true if
1º 2º 3º 4º ...
624 and
1º 2º 3º 4º ...
625 are equal, false if they are not equal or not comparable.

Examples

The expression

1º 2º 3º 4º ...
626 returns
let $para := 
In a hole in the ground there lived a hobbit.
         
96.

The expression

1º 2º 3º 4º ...
628 returns
1º 2º 3º 4º ...
629.

The expression

1º 2º 3º 4º ...
630 returns
1º 2º 3º 4º ...
631.

The expression

1º 2º 3º 4º ...
632 returns
let $para := 
In a hole in the ground there lived a hobbit.
         
96.

The expression

1º 2º 3º 4º ...
634 returns
1º 2º 3º 4º ...
635. (The array is atomized to a sequence of five integers).

If

1º 2º 3º 4º ...
636 is an attribute of type
let $para := 
In a hole in the ground there lived a hobbit.
         
42 whose string value is
1º 2º 3º 4º ...
638, and whose typed value is therefore
op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
180, then
1º 2º 3º 4º ...
640 returns
declare %public function r:random-sequence($length as xs:integer) as xs:double* {
  r:random-sequence($length, fn:random-number-generator())
};

declare %private function r:random-sequence($length as xs:integer, 
                                            $G as map(xs:string, item())) {
  if ($length eq 0)
  then ()
  else ($G?number, r:random-sequence($length - 1, $G?next()))
};

r:random-sequence(200);
            
07. This is because the function calling mechanism atomizes the attribute node to produce a sequence of three
1º 2º 3º 4º ...
642 values.

14.2.3 fn:deep-equal

Summary

This function assesses whether two sequences are deep-equal to each other. To be deep-equal, they must contain items that are pairwise deep-equal; and for two items to be deep-equal, they must either be atomic values that compare equal, or nodes of the same kind, with the same name, whose children are deep-equal, or maps with matching entries, or arrays with matching members.

Signatures

op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
23(
1º 2º 3º 4º ...
644
let $para := 
In a hole in the ground there lived a hobbit.
         
71
op:operation(fenceHeight, xs:integer) => op:operation(xs:integer, xs:integer)
16,
1º 2º 3º 4º ...
647
let $para := 
In a hole in the ground there lived a hobbit.
         
71
op:operation(fenceHeight, xs:integer) => op:operation(xs:integer, xs:integer)
16)
let $para := 
In a hole in the ground there lived a hobbit.
         
71
op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
32

op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
23(
1º 2º 3º 4º ...
644
let $para := 
In a hole in the ground there lived a hobbit.
         
71
op:operation(fenceHeight, xs:integer) => op:operation(xs:integer, xs:integer)
16,
1º 2º 3º 4º ...
647
let $para := 
In a hole in the ground there lived a hobbit.
         
71
op:operation(fenceHeight, xs:integer) => op:operation(xs:integer, xs:integer)
16,
let $para := 
In a hole in the ground there lived a hobbit.
         
128
let $para := 
In a hole in the ground there lived a hobbit.
         
71
let $para := 
In a hole in the ground there lived a hobbit.
         
10)
let $para := 
In a hole in the ground there lived a hobbit.
         
71
op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
32

Properties

The two-argument form of this function is ·deterministic·, ·context-dependent·, and ·focus-independent·. It depends on collations, and implicit timezone.

The three-argument form of this function is ·deterministic·, ·context-dependent·, and ·focus-independent·. It depends on collations, and static base URI, and implicit timezone.

Rules

The

let $para := 
In a hole in the ground there lived a hobbit.
         
128 argument identifies a collation which is used at all levels of recursion when strings are compared (but not when names are compared), according to the rules in 5.3.5 Choosing a collation.

If the two sequences are both empty, the function returns

op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
76.

If the two sequences are of different lengths, the function returns

let $C := 'http://www.w3.org/2013/collation/UCA?strength=primary'
07.

If the two sequences are of the same length, the function returns

op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
76 if and only if every item in the sequence
1º 2º 3º 4º ...
644 is deep-equal to the item at the same position in the sequence
1º 2º 3º 4º ...
647. The rules for deciding whether two items are deep-equal follow.

Call the two items

1º 2º 3º 4º ...
670 and
1º 2º 3º 4º ...
671 respectively.

If

1º 2º 3º 4º ...
670 and
1º 2º 3º 4º ...
671 are both atomic values, they are deep-equal if and only if
1º 2º 3º 4º ...
674 is
op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
76, or if both values are
fn:abs($N * $arg2) le fn:abs($arg1) 
               and fn:compare($N * $arg2, 0) eq fn:compare($arg1, 0).
90. If the
let $para := 
In a hole in the ground there lived a hobbit.
         
33 operator is not defined for
1º 2º 3º 4º ...
670 and
1º 2º 3º 4º ...
671, the function returns
let $C := 'http://www.w3.org/2013/collation/UCA?strength=primary'
07.

If

1º 2º 3º 4º ...
670 and
1º 2º 3º 4º ...
671 are both ·maps·, the result is
op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
76 if and only if all the following conditions apply:

  1. Both maps have the same number of entries.

  2. For every entry in the first map, there is an entry in the second map that:

    1. has the ·same key· (note that the collation is not used when comparing keys), and

    2. has the same associated value (compared using the

      op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
      23 function, under the collation supplied in the original call to
      op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
      23).

If

1º 2º 3º 4º ...
670 and
1º 2º 3º 4º ...
671 are both ·arrays·, the result is
op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
76 if and only if all the following conditions apply:

  1. Both arrays have the same number of members (

    1º 2º 3º 4º ...
    689).

  2. Members in the same position of both arrays are deep-equal to each other, under the collation supplied in the original call to

    op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
    23: that is,
    1º 2º 3º 4º ...
    691

If

1º 2º 3º 4º ...
670 and
1º 2º 3º 4º ...
671 are both nodes, they are compared as described below:

  1. If the two nodes are of different kinds, the result is

    let $C := 'http://www.w3.org/2013/collation/UCA?strength=primary'
    07.

  2. If the two nodes are both document nodes then they are deep-equal if and only if the sequence

    1º 2º 3º 4º ...
    695 is deep-equal to the sequence
    1º 2º 3º 4º ...
    696.

  3. If the two nodes are both element nodes then they are deep-equal if and only if all of the following conditions are satisfied:

    1. The two nodes have the same name, that is

      1º 2º 3º 4º ...
      697.

    2. Either both nodes are annotated as having simple content or both nodes are annotated as having complex content. For this purpose "simple content" means either a simple type or a complex type with simple content; "complex content" means a complex type whose variety is mixed, element-only, or empty.

      Note:

      It is a consequence of this rule that validating a document D against a schema will usually (but not necessarily) result in a document that is not deep-equal to D. The exception is when the schema allows all elements to have mixed content.

    3. The two nodes have the same number of attributes, and for every attribute

      1º 2º 3º 4º ...
      698 in
      1º 2º 3º 4º ...
      699 there exists an attribute
      1º 2º 3º 4º ...
      700 in
      1º 2º 3º 4º ...
      701 such that
      1º 2º 3º 4º ...
      698 and
      1º 2º 3º 4º ...
      700 are deep-equal.

    4. One of the following conditions holds:

      • Both element nodes are annotated as having simple content (as defined in 3(b) above), and the typed value of

        1º 2º 3º 4º ...
        670 is deep-equal to the typed value of
        1º 2º 3º 4º ...
        671.

      • Both element nodes have a type annotation that is a complex type with variety element-only, and the sequence

        1º 2º 3º 4º ...
        706 is deep-equal to the sequence
        1º 2º 3º 4º ...
        707.

      • Both element nodes have a type annotation that is a complex type with variety mixed, and the sequence

        1º 2º 3º 4º ...
        695 is deep-equal to the sequence
        1º 2º 3º 4º ...
        696.

      • Both element nodes have a type annotation that is a complex type with variety empty.

  4. If the two nodes are both attribute nodes then they are deep-equal if and only if both the following conditions are satisfied:

    1. The two nodes have the same name, that is

      1º 2º 3º 4º ...
      697.

    2. The typed value of

      1º 2º 3º 4º ...
      670 is deep-equal to the typed value of
      1º 2º 3º 4º ...
      671.

  5. If the two nodes are both processing instruction nodes, then they are deep-equal if and only if both the following conditions are satisfied:

    1. The two nodes have the same name, that is

      1º 2º 3º 4º ...
      697.

    2. The string value of

      1º 2º 3º 4º ...
      670 is equal to the string value of
      1º 2º 3º 4º ...
      671.

  6. If the two nodes are both namespace nodes, then they are deep-equal if and only if both the following conditions are satisfied:

    1. The two nodes either have the same name or are both nameless, that is

      1º 2º 3º 4º ...
      716.

    2. The string value of

      1º 2º 3º 4º ...
      670 is equal to the string value of
      1º 2º 3º 4º ...
      671 when compared using the Unicode codepoint collation.

  7. If the two nodes are both text nodes or comment nodes, then they are deep-equal if and only if their string-values are equal.

In all other cases the result is false.

Error Conditions

A type error is raised [err:FOTY0015] if either input sequence contains a function item that is not a map or array.

Notes

The two nodes are not required to have the same type annotation, and they are not required to have the same in-scope namespaces. They may also differ in their parent, their base URI, and the values returned by the

1º 2º 3º 4º ...
719 and
1º 2º 3º 4º ...
720 accessors (see Section 5.5 is-id Accessor DM31 and Section 5.6 is-idrefs Accessor DM31). The order of children is significant, but the order of attributes is insignificant.

The contents of comments and processing instructions are significant only if these nodes appear directly as items in the two sequences being compared. The content of a comment or processing instruction that appears as a descendant of an item in one of the sequences being compared does not affect the result. However, the presence of a comment or processing instruction, if it causes a text node to be split into two text nodes, may affect the result.

Comparing items of different kind (for example, comparing an atomic value to a node, or a map to an array, or an integer to an

op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
964) returns false, it does not return an error. So the result of
1º 2º 3º 4º ...
722 is
let $C := 'http://www.w3.org/2013/collation/UCA?strength=primary'
07.

Comparing a function (other than a map or array) to any other value raises a type error.

Examples

fn:abs($N * $arg2) le fn:abs($arg1) 
               and fn:compare($N * $arg2, 0) eq fn:compare($arg1, 0).
3

The expression

1º 2º 3º 4º ...
724 returns
let $para := 
In a hole in the ground there lived a hobbit.
         
184.

The expression

1º 2º 3º 4º ...
726 returns
let $para := 
In a hole in the ground there lived a hobbit.
         
184.

The expression

1º 2º 3º 4º ...
728 returns
let $para := 
In a hole in the ground there lived a hobbit.
         
182.

The expression

1º 2º 3º 4º ...
730 returns
let $para := 
In a hole in the ground there lived a hobbit.
         
184.

The expression

1º 2º 3º 4º ...
732 returns
let $para := 
In a hole in the ground there lived a hobbit.
         
182.

The expression

1º 2º 3º 4º ...
734 returns
let $para := 
In a hole in the ground there lived a hobbit.
         
182.

The expression

1º 2º 3º 4º ...
736 returns
let $para := 
In a hole in the ground there lived a hobbit.
         
184.

14.3 Functions that test the cardinality of sequences

The following functions test the cardinality of their sequence arguments.

FunctionMeaning
1º 2º 3º 4º ...
738Returns
let $para := 
In a hole in the ground there lived a hobbit.
         
25 if it contains zero or one items. Otherwise, raises an error.
1º 2º 3º 4º ...
740Returns
let $para := 
In a hole in the ground there lived a hobbit.
         
25 if it contains one or more items. Otherwise, raises an error.
1º 2º 3º 4º ...
742Returns
let $para := 
In a hole in the ground there lived a hobbit.
         
25 if it contains exactly one item. Otherwise, raises an error.

The functions

1º 2º 3º 4º ...
738,
1º 2º 3º 4º ...
740, and
1º 2º 3º 4º ...
742 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
1º 2º 3º 4º ...
747 requires the result of the call on
1º 2º 3º 4º ...
535 to be a singleton integer, but the static type system cannot infer this; writing the expression as
1º 2º 3º 4º ...
749 will provide a suitable static type at query analysis time, and ensures that the length of the sequence is correct with a dynamic check at query execution time.

The type signatures for these functions deliberately declare the argument type as

op:operation(fenceHeight, xs:integer) => op:operation(xs:integer, xs:integer)
16, permitting a sequence of any length. A more restrictive signature would defeat the purpose of the function, which is to defer cardinality checking until query execution time.

14.3.1 fn:zero-or-one

Summary

Returns

let $para := 
In a hole in the ground there lived a hobbit.
         
25 if it contains zero or one items. Otherwise, raises an error.

Signature

1º 2º 3º 4º ...
738(
let $para := 
In a hole in the ground there lived a hobbit.
         
25
let $para := 
In a hole in the ground there lived a hobbit.
         
71
op:operation(fenceHeight, xs:integer) => op:operation(xs:integer, xs:integer)
16)
let $para := 
In a hole in the ground there lived a hobbit.
         
71
let $para := 
In a hole in the ground there lived a hobbit.
         
79

Properties

This function is ·deterministic·, ·context-independent·, and ·focus-independent·.

Rules

Except in error cases, the function returns

let $para := 
In a hole in the ground there lived a hobbit.
         
25 unchanged.

Error Conditions

A dynamic error is raised [err:FORG0003] if

let $para := 
In a hole in the ground there lived a hobbit.
         
25 contains more than one item.

14.3.2 fn:one-or-more

Summary

Returns

let $para := 
In a hole in the ground there lived a hobbit.
         
25 if it contains one or more items. Otherwise, raises an error.

Signature

1º 2º 3º 4º ...
740(
let $para := 
In a hole in the ground there lived a hobbit.
         
25
let $para := 
In a hole in the ground there lived a hobbit.
         
71
op:operation(fenceHeight, xs:integer) => op:operation(xs:integer, xs:integer)
16)
let $para := 
In a hole in the ground there lived a hobbit.
         
71
1º 2º 3º 4º ...
766

Properties

This function is ·deterministic·, ·context-independent·, and ·focus-independent·.

Rules

Except in error cases, the function returns

let $para := 
In a hole in the ground there lived a hobbit.
         
25 unchanged.

Error Conditions

A dynamic error is raised [err:FORG0004] if

let $para := 
In a hole in the ground there lived a hobbit.
         
25 is an empty sequence.

14.3.3 fn:exactly-one

Summary

Returns

let $para := 
In a hole in the ground there lived a hobbit.
         
25 if it contains exactly one item. Otherwise, raises an error.

Signature

1º 2º 3º 4º ...
742(
let $para := 
In a hole in the ground there lived a hobbit.
         
25
let $para := 
In a hole in the ground there lived a hobbit.
         
71
op:operation(fenceHeight, xs:integer) => op:operation(xs:integer, xs:integer)
16)
let $para := 
In a hole in the ground there lived a hobbit.
         
71
1º 2º 3º 4º ...
775

Properties

This function is ·deterministic·, ·context-independent·, and ·focus-independent·.

Rules

Except in error cases, the function returns

let $para := 
In a hole in the ground there lived a hobbit.
         
25 unchanged.

Error Conditions

A dynamic error is raised [err:FORG0005] if

let $para := 
In a hole in the ground there lived a hobbit.
         
25 is an empty sequence or a sequence containing more than one item.

14.4 Aggregate functions

Aggregate functions take a sequence as argument and return a single value computed from values in the sequence. Except for

1º 2º 3º 4º ...
778, the sequence must consist of values of a single type or one if its subtypes, or they must be numeric.
let $para := 
In a hole in the ground there lived a hobbit.
         
00 values are permitted in the input sequence and handled by special conversion rules. The type of the items in the sequence must also support certain operations.

FunctionMeaning
1º 2º 3º 4º ...
778Returns the number of items in a sequence.
1º 2º 3º 4º ...
781Returns the average of the values in the input sequence
let $para := 
In a hole in the ground there lived a hobbit.
         
25, that is, the sum of the values divided by the number of values.
let $para := 
In a hole in the ground there lived a hobbit.
         
069Returns a value that is equal to the highest value appearing in the input sequence.
1º 2º 3º 4º ...
784Returns a value that is equal to the lowest value appearing in the input sequence.
1º 2º 3º 4º ...
785Returns a value obtained by adding together the values in
let $para := 
In a hole in the ground there lived a hobbit.
         
25.

14.4.1 fn:count

Summary

Returns the number of items in a sequence.

Signature

1º 2º 3º 4º ...
778(
let $para := 
In a hole in the ground there lived a hobbit.
         
25
let $para := 
In a hole in the ground there lived a hobbit.
         
71
op:operation(fenceHeight, xs:integer) => op:operation(xs:integer, xs:integer)
16)
let $para := 
In a hole in the ground there lived a hobbit.
         
71
let $para := 
In a hole in the ground there lived a hobbit.
         
85

Properties

This function is ·deterministic·, ·context-independent·, and ·focus-independent·.

Rules

The function returns the number of items in the value of

let $para := 
In a hole in the ground there lived a hobbit.
         
25.

Notes

Returns 0 if

let $para := 
In a hole in the ground there lived a hobbit.
         
25 is the empty sequence.

Examples

fn:abs($N * $arg2) le fn:abs($arg1) 
               and fn:compare($N * $arg2, 0) eq fn:compare($arg1, 0).
4

fn:abs($N * $arg2) le fn:abs($arg1) 
               and fn:compare($N * $arg2, 0) eq fn:compare($arg1, 0).
5

fn:abs($N * $arg2) le fn:abs($arg1) 
               and fn:compare($N * $arg2, 0) eq fn:compare($arg1, 0).
6

The expression

1º 2º 3º 4º ...
795 returns
let $para := 
In a hole in the ground there lived a hobbit.
         
226.

The expression

1º 2º 3º 4º ...
797 returns
declare %public function r:random-sequence($length as xs:integer) as xs:double* {
  r:random-sequence($length, fn:random-number-generator())
};

declare %private function r:random-sequence($length as xs:integer, 
                                            $G as map(xs:string, item())) {
  if ($length eq 0)
  then ()
  else ($G?number, r:random-sequence($length - 1, $G?next()))
};

r:random-sequence(200);
            
19.

The expression

1º 2º 3º 4º ...
799 returns
declare %public function r:random-sequence($length as xs:integer) as xs:double* {
  r:random-sequence($length, fn:random-number-generator())
};

declare %private function r:random-sequence($length as xs:integer, 
                                            $G as map(xs:string, item())) {
  if ($length eq 0)
  then ()
  else ($G?number, r:random-sequence($length - 1, $G?next()))
};

r:random-sequence(200);
            
07.

The expression

1º 2º 3º 4º ...
801 returns
declare %public function r:random-sequence($length as xs:integer) as xs:double* {
  r:random-sequence($length, fn:random-number-generator())
};

declare %private function r:random-sequence($length as xs:integer, 
                                            $G as map(xs:string, item())) {
  if ($length eq 0)
  then ()
  else ($G?number, r:random-sequence($length - 1, $G?next()))
};

r:random-sequence(200);
            
19.

The expression

1º 2º 3º 4º ...
803 returns
declare %public function r:random-sequence($length as xs:integer) as xs:double* {
  r:random-sequence($length, fn:random-number-generator())
};

declare %private function r:random-sequence($length as xs:integer, 
                                            $G as map(xs:string, item())) {
  if ($length eq 0)
  then ()
  else ($G?number, r:random-sequence($length - 1, $G?next()))
};

r:random-sequence(200);
            
13.

The expression

1º 2º 3º 4º ...
805 returns
declare %public function r:random-sequence($length as xs:integer) as xs:double* {
  r:random-sequence($length, fn:random-number-generator())
};

declare %private function r:random-sequence($length as xs:integer, 
                                            $G as map(xs:string, item())) {
  if ($length eq 0)
  then ()
  else ($G?number, r:random-sequence($length - 1, $G?next()))
};

r:random-sequence(200);
            
13.

14.4.2 fn:avg

Summary

Returns the average of the values in the input sequence

let $para := 
In a hole in the ground there lived a hobbit.
         
25, that is, the sum of the values divided by the number of values.

Signature

1º 2º 3º 4º ...
781(
let $para := 
In a hole in the ground there lived a hobbit.
         
25
let $para := 
In a hole in the ground there lived a hobbit.
         
71
op:operation(fenceHeight, xs:integer) => op:operation(xs:integer, xs:integer)
12)
let $para := 
In a hole in the ground there lived a hobbit.
         
71
let $para := 
In a hole in the ground there lived a hobbit.
         
196

Properties

This function is ·deterministic·, ·context-independent·, and ·focus-independent·.

Rules

If

let $para := 
In a hole in the ground there lived a hobbit.
         
25 is the empty sequence, the empty sequence is returned.

If

let $para := 
In a hole in the ground there lived a hobbit.
         
25 contains values of type
let $para := 
In a hole in the ground there lived a hobbit.
         
00 they are cast to
let $para := 
In a hole in the ground there lived a hobbit.
         
26.

Duration values must either all be

let $para := 
In a hole in the ground there lived a hobbit.
         
24 values or must all be
let $para := 
In a hole in the ground there lived a hobbit.
         
25 values. For numeric values, the numeric promotion rules defined in 4.2 Arithmetic operators on numeric values are used to promote all values to a single common type. After these operations,
let $para := 
In a hole in the ground there lived a hobbit.
         
25 must satisfy the following condition:

There must be a type T such that:

  1. every item in
    let $para := 
    In a hole in the ground there lived a hobbit.
             
    25 is an instance of T.
  2. T is one of
    let $para := 
    In a hole in the ground there lived a hobbit.
             
    26,
    let $para := 
    In a hole in the ground there lived a hobbit.
             
    83,
    let $para := 
    In a hole in the ground there lived a hobbit.
             
    82,
    let $para := 
    In a hole in the ground there lived a hobbit.
             
    24, or
    let $para := 
    In a hole in the ground there lived a hobbit.
             
    25.

The function returns the average of the values as

1º 2º 3º 4º ...
827; but the implementation may use an otherwise equivalent algorithm that avoids arithmetic overflow.

Error Conditions

A type error is raised [err:FORG0006] if the input sequence contains items of incompatible types, as described above.

Examples

fn:abs($N * $arg2) le fn:abs($arg1) 
               and fn:compare($N * $arg2, 0) eq fn:compare($arg1, 0).
7

fn:abs($N * $arg2) le fn:abs($arg1) 
               and fn:compare($N * $arg2, 0) eq fn:compare($arg1, 0).
8

fn:abs($N * $arg2) le fn:abs($arg1) 
               and fn:compare($N * $arg2, 0) eq fn:compare($arg1, 0).
9

The expression

1º 2º 3º 4º ...
828 returns
1º 2º 3º 4º ...
829. (The result is of type
let $para := 
In a hole in the ground there lived a hobbit.
         
82.)

The expression

1º 2º 3º 4º ...
831 returns
1º 2º 3º 4º ...
832.

1º 2º 3º 4º ...
833 raises a type error [err:FORG0006].

The expression

1º 2º 3º 4º ...
834 returns
let $para := 
In a hole in the ground there lived a hobbit.
         
96.

The expression

1º 2º 3º 4º ...
836 returns
1º 2º 3º 4º ...
837.

The expression

1º 2º 3º 4º ...
838 returns
1º 2º 3º 4º ...
837.

14.4.3 fn:max

Summary

Returns a value that is equal to the highest value appearing in the input sequence.

Signatures

let $para := 
In a hole in the ground there lived a hobbit.
         
069(
let $para := 
In a hole in the ground there lived a hobbit.
         
25
let $para := 
In a hole in the ground there lived a hobbit.
         
71
op:operation(fenceHeight, xs:integer) => op:operation(xs:integer, xs:integer)
12)
let $para := 
In a hole in the ground there lived a hobbit.
         
71
let $para := 
In a hole in the ground there lived a hobbit.
         
196

let $para := 
In a hole in the ground there lived a hobbit.
         
069(
let $para := 
In a hole in the ground there lived a hobbit.
         
25
let $para := 
In a hole in the ground there lived a hobbit.
         
71
op:operation(fenceHeight, xs:integer) => op:operation(xs:integer, xs:integer)
12,
let $para := 
In a hole in the ground there lived a hobbit.
         
128
let $para := 
In a hole in the ground there lived a hobbit.
         
71
let $para := 
In a hole in the ground there lived a hobbit.
         
10)
let $para := 
In a hole in the ground there lived a hobbit.
         
71
let $para := 
In a hole in the ground there lived a hobbit.
         
196

Properties

The zero-argument form of this function is ·deterministic·, ·context-dependent·, and ·focus-independent·. It depends on collations, and implicit timezone.

The one-argument form of this function is ·deterministic·, ·context-dependent·, and ·focus-independent·. It depends on collations, and static base URI, and implicit timezone.

Rules

The following conversions are applied to the input sequence

let $para := 
In a hole in the ground there lived a hobbit.
         
25, in order:

  1. Values of type

    let $para := 
    In a hole in the ground there lived a hobbit.
             
    00 in
    let $para := 
    In a hole in the ground there lived a hobbit.
             
    25 are cast to
    let $para := 
    In a hole in the ground there lived a hobbit.
             
    26.

  2. If the resulting sequence contains values that are instances of more than one primitive type (meaning the 19 primitive types defined in [Schema 1.1 Part 2]), then:

    1. If each value is an instance of one of the types

      let $para := 
      In a hole in the ground there lived a hobbit.
               
      10 or
      let $para := 
      In a hole in the ground there lived a hobbit.
               
      30, then all the values are cast to type
      let $para := 
      In a hole in the ground there lived a hobbit.
               
      10.

    2. If each value is an instance of one of the types

      let $para := 
      In a hole in the ground there lived a hobbit.
               
      82 or
      let $para := 
      In a hole in the ground there lived a hobbit.
               
      83, then all the values are cast to type
      let $para := 
      In a hole in the ground there lived a hobbit.
               
      83.

    3. If each value is an instance of one of the types

      let $para := 
      In a hole in the ground there lived a hobbit.
               
      82,
      let $para := 
      In a hole in the ground there lived a hobbit.
               
      83, or
      let $para := 
      In a hole in the ground there lived a hobbit.
               
      26, then all the values are cast to type
      let $para := 
      In a hole in the ground there lived a hobbit.
               
      26.

    4. Otherwise, a type error is raised [err:FORG0006].

    Note:

    The primitive type of an

    let $para := 
    In a hole in the ground there lived a hobbit.
             
    85 value for this purpose is
    let $para := 
    In a hole in the ground there lived a hobbit.
             
    82.

The items in the resulting sequence may be reordered in an arbitrary order. The resulting sequence is referred to below as the converted sequence. The function returns an item from the converted sequence rather than the input sequence.

If the converted sequence is empty, the function returns the empty sequence.

All items in the converted sequence must be derived from a single base type for which the

1º 2º 3º 4º ...
871 operator is defined. In addition, the values in the sequence must have a total order. If date/time values do not have a timezone, they are considered to have the implicit timezone provided by the dynamic context for the purpose of comparison. Duration values must either all be
let $para := 
In a hole in the ground there lived a hobbit.
         
24 values or must all be
let $para := 
In a hole in the ground there lived a hobbit.
         
25 values.

If the converted sequence contains the value

fn:abs($N * $arg2) le fn:abs($arg1) 
               and fn:compare($N * $arg2, 0) eq fn:compare($arg1, 0).
90, the value
fn:abs($N * $arg2) le fn:abs($arg1) 
               and fn:compare($N * $arg2, 0) eq fn:compare($arg1, 0).
90 is returned (as an
let $para := 
In a hole in the ground there lived a hobbit.
         
83 or
let $para := 
In a hole in the ground there lived a hobbit.
         
26 as appropriate)
.

If the items in the converted sequence are of type

let $para := 
In a hole in the ground there lived a hobbit.
         
10 or types derived by restriction from
let $para := 
In a hole in the ground there lived a hobbit.
         
10, then the determination of the item with the smallest value is made according to the collation that is used. If the type of the items in the converted sequence is not
let $para := 
In a hole in the ground there lived a hobbit.
         
10 and
let $para := 
In a hole in the ground there lived a hobbit.
         
128 is specified, the collation is ignored.

The collation used by this function is determined according to the rules in 5.3.5 Choosing a collation.

The function returns the result of the expression:

1º 2º 3º 4º ...
0

evaluated with

let $para := 
In a hole in the ground there lived a hobbit.
         
128 as the default collation if specified, and with
1º 2º 3º 4º ...
883 as the converted sequence.

Error Conditions

A type error is raised [err:FORG0006] if the input sequence contains items of incompatible types, as described above.

Notes

Because the rules allow the sequence to be reordered, if there are two or more items that are "equal highest", the specific item whose value is returned is ·implementation-dependent·. This can arise for example if two different strings compare equal under the selected collation, or if two different

let $para := 
In a hole in the ground there lived a hobbit.
         
29 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

let $para := 
In a hole in the ground there lived a hobbit.
         
069 function is applied to
let $para := 
In a hole in the ground there lived a hobbit.
         
00 values is
let $para := 
In a hole in the ground there lived a hobbit.
         
26. This differs from the default type for operators such as
1º 2º 3º 4º ...
888, and for sorting in XQuery and XSLT, which is
let $para := 
In a hole in the ground there lived a hobbit.
         
10.

The rules for the dynamic type of the result are stricter in version 3.1 of the specification than in earlier versions. For example, if all the values in the input sequence belong to types derived from

let $para := 
In a hole in the ground there lived a hobbit.
         
85, version 3.0 required only that the result be an instance of the least common supertype of the types present in the input sequence; Version 3.1 requires that the returned value retains its original type. This does not apply, however, where type promotion is needed to convert all the values to a common primitive type.

Examples

The expression

1º 2º 3º 4º ...
891 returns
declare %public function r:random-sequence($length as xs:integer) as xs:double* {
  r:random-sequence($length, fn:random-number-generator())
};

declare %private function r:random-sequence($length as xs:integer, 
                                            $G as map(xs:string, item())) {
  if ($length eq 0)
  then ()
  else ($G?number, r:random-sequence($length - 1, $G?next()))
};

r:random-sequence(200);
            
21.

The expression

1º 2º 3º 4º ...
893 returns
declare %public function r:random-sequence($length as xs:integer) as xs:double* {
  r:random-sequence($length, fn:random-number-generator())
};

declare %private function r:random-sequence($length as xs:integer, 
                                            $G as map(xs:string, item())) {
  if ($length eq 0)
  then ()
  else ($G?number, r:random-sequence($length - 1, $G?next()))
};

r:random-sequence(200);
            
21. (Arrays are atomized).

The expression

1º 2º 3º 4º ...
895 returns
1º 2º 3º 4º ...
896.

1º 2º 3º 4º ...
897 raises a type error [err:FORG0006].

The expression

1º 2º 3º 4º ...
898 returns
1º 2º 3º 4º ...
899. (Assuming that the current date is during the 21st century.)

The expression

1º 2º 3º 4º ...
900 returns
1º 2º 3º 4º ...
901. (Assuming a typical default collation.)

14.4.4 fn:min

Summary

Returns a value that is equal to the lowest value appearing in the input sequence.

Signatures

1º 2º 3º 4º ...
784(
let $para := 
In a hole in the ground there lived a hobbit.
         
25
let $para := 
In a hole in the ground there lived a hobbit.
         
71
op:operation(fenceHeight, xs:integer) => op:operation(xs:integer, xs:integer)
12)
let $para := 
In a hole in the ground there lived a hobbit.
         
71
let $para := 
In a hole in the ground there lived a hobbit.
         
196

1º 2º 3º 4º ...
784(
let $para := 
In a hole in the ground there lived a hobbit.
         
25
let $para := 
In a hole in the ground there lived a hobbit.
         
71
op:operation(fenceHeight, xs:integer) => op:operation(xs:integer, xs:integer)
12,
let $para := 
In a hole in the ground there lived a hobbit.
         
128
let $para := 
In a hole in the ground there lived a hobbit.
         
71
let $para := 
In a hole in the ground there lived a hobbit.
         
10)
let $para := 
In a hole in the ground there lived a hobbit.
         
71
let $para := 
In a hole in the ground there lived a hobbit.
         
196

Properties

The zero-argument form of this function is ·deterministic·, ·context-dependent·, and ·focus-independent·. It depends on collations, and implicit timezone.

The one-argument form of this function is ·deterministic·, ·context-dependent·, and ·focus-independent·. It depends on collations, and static base URI, and implicit timezone.

Rules

The following rules are applied to the input sequence:

  • Values of type

    let $para := 
    In a hole in the ground there lived a hobbit.
             
    00 in
    let $para := 
    In a hole in the ground there lived a hobbit.
             
    25 are cast to
    let $para := 
    In a hole in the ground there lived a hobbit.
             
    26.

  • If the resulting sequence contains values that are instances of more than one primitive type (meaning the 19 primitive types defined in [Schema 1.1 Part 2]), then:

    1. If each value is an instance of one of the types

      let $para := 
      In a hole in the ground there lived a hobbit.
               
      10 or
      let $para := 
      In a hole in the ground there lived a hobbit.
               
      30, then all the values are cast to type
      let $para := 
      In a hole in the ground there lived a hobbit.
               
      10.

    2. If each value is an instance of one of the types

      let $para := 
      In a hole in the ground there lived a hobbit.
               
      82 or
      let $para := 
      In a hole in the ground there lived a hobbit.
               
      83, then all the values are cast to type
      let $para := 
      In a hole in the ground there lived a hobbit.
               
      83.

    3. If each value is an instance of one of the types

      let $para := 
      In a hole in the ground there lived a hobbit.
               
      82,
      let $para := 
      In a hole in the ground there lived a hobbit.
               
      83, or
      let $para := 
      In a hole in the ground there lived a hobbit.
               
      26, then all the values are cast to type
      let $para := 
      In a hole in the ground there lived a hobbit.
               
      26.

    4. Otherwise, a type error is raised [err:FORG0006].

    Note:

    The primitive type of an

    let $para := 
    In a hole in the ground there lived a hobbit.
             
    85 value for this purpose is
    let $para := 
    In a hole in the ground there lived a hobbit.
             
    82.

The items in the resulting sequence may be reordered in an arbitrary order. The resulting sequence is referred to below as the converted sequence. The function returns an item from the converted sequence rather than the input sequence.

If the converted sequence is empty, the empty sequence is returned.

All items in the converted sequence must be derived from a single base type for which the

1º 2º 3º 4º ...
871 operator is defined. In addition, the values in the sequence must have a total order. If date/time values do not have a timezone, they are considered to have the implicit timezone provided by the dynamic context for the purpose of comparison. Duration values must either all be
let $para := 
In a hole in the ground there lived a hobbit.
         
24 values or must all be
let $para := 
In a hole in the ground there lived a hobbit.
         
25 values.

If the converted sequence contains the value

fn:abs($N * $arg2) le fn:abs($arg1) 
               and fn:compare($N * $arg2, 0) eq fn:compare($arg1, 0).
90, the value
fn:abs($N * $arg2) le fn:abs($arg1) 
               and fn:compare($N * $arg2, 0) eq fn:compare($arg1, 0).
90 is returned (as an
let $para := 
In a hole in the ground there lived a hobbit.
         
83 or
let $para := 
In a hole in the ground there lived a hobbit.
         
26 as appropriate)
.

If the items in the converted sequence are of type

let $para := 
In a hole in the ground there lived a hobbit.
         
10 or types derived by restriction from
let $para := 
In a hole in the ground there lived a hobbit.
         
10, then the determination of the item with the smallest value is made according to the collation that is used. If the type of the items in the converted sequence is not
let $para := 
In a hole in the ground there lived a hobbit.
         
10 and
let $para := 
In a hole in the ground there lived a hobbit.
         
128 is specified, the collation is ignored.

The collation used by this function is determined according to the rules in 5.3.5 Choosing a collation.

The function returns the result of the expression:

1º 2º 3º 4º ...
1

evaluated with

let $para := 
In a hole in the ground there lived a hobbit.
         
128 as the default collation if specified, and with
1º 2º 3º 4º ...
883 as the converted sequence.

Error Conditions

A type error is raised [err:FORG0006] if the input sequence contains items of incompatible types, as described above.

Notes

Because the rules allow the sequence to be reordered, if there are two or items that are "equal lowest", the specific item whose value is returned is ·implementation-dependent·. This can arise for example if two different strings compare equal under the selected collation, or if two different

let $para := 
In a hole in the ground there lived a hobbit.
         
29 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

1º 2º 3º 4º ...
784 function is applied to
let $para := 
In a hole in the ground there lived a hobbit.
         
00 values is
let $para := 
In a hole in the ground there lived a hobbit.
         
26. This differs from the default type for operators such as
1º 2º 3º 4º ...
949, and for sorting in XQuery and XSLT, which is
let $para := 
In a hole in the ground there lived a hobbit.
         
10.

The rules for the dynamic type of the result are stricter in version 3.1 of the specification than in earlier versions. For example, if all the values in the input sequence belong to types derived from

let $para := 
In a hole in the ground there lived a hobbit.
         
85, version 3.0 required only that the result be an instance of the least common supertype of the types present in the input sequence; Version 3.1 requires that the returned value retains its original type. This does not apply, however, where type promotion is needed to convert all the values to a common primitive type.

Examples

The expression

1º 2º 3º 4º ...
952 returns
declare %public function r:random-sequence($length as xs:integer) as xs:double* {
  r:random-sequence($length, fn:random-number-generator())
};

declare %private function r:random-sequence($length as xs:integer, 
                                            $G as map(xs:string, item())) {
  if ($length eq 0)
  then ()
  else ($G?number, r:random-sequence($length - 1, $G?next()))
};

r:random-sequence(200);
            
07.

The expression

1º 2º 3º 4º ...
954 returns
declare %public function r:random-sequence($length as xs:integer) as xs:double* {
  r:random-sequence($length, fn:random-number-generator())
};

declare %private function r:random-sequence($length as xs:integer, 
                                            $G as map(xs:string, item())) {
  if ($length eq 0)
  then ()
  else ($G?number, r:random-sequence($length - 1, $G?next()))
};

r:random-sequence(200);
            
07. (Arrays are atomized).

The expression

1º 2º 3º 4º ...
956 returns
1º 2º 3º 4º ...
896.

1º 2º 3º 4º ...
958 raises a type error [err:FORG0006].

1º 2º 3º 4º ...
959 can return either positive or negative zero. The two items are equal, so it is ·implementation-dependent· which is returned.

The expression

1º 2º 3º 4º ...
960 returns
1º 2º 3º 4º ...
961. (Assuming that the current date is set to a reasonable value.)

The expression

1º 2º 3º 4º ...
962 returns
1º 2º 3º 4º ...
370. (Assuming a typical default collation.)

14.4.5 fn:sum

Summary

Returns a value obtained by adding together the values in

let $para := 
In a hole in the ground there lived a hobbit.
         
25.

Signatures

1º 2º 3º 4º ...
785(
let $para := 
In a hole in the ground there lived a hobbit.
         
25
let $para := 
In a hole in the ground there lived a hobbit.
         
71
op:operation(fenceHeight, xs:integer) => op:operation(xs:integer, xs:integer)
12)
let $para := 
In a hole in the ground there lived a hobbit.
         
71
let $para := 
In a hole in the ground there lived a hobbit.
         
34

1º 2º 3º 4º ...
785(
let $para := 
In a hole in the ground there lived a hobbit.
         
25
let $para := 
In a hole in the ground there lived a hobbit.
         
71
op:operation(fenceHeight, xs:integer) => op:operation(xs:integer, xs:integer)
12,
1º 2º 3º 4º ...
975
let $para := 
In a hole in the ground there lived a hobbit.
         
71
let $para := 
In a hole in the ground there lived a hobbit.
         
196)
let $para := 
In a hole in the ground there lived a hobbit.
         
71
let $para := 
In a hole in the ground there lived a hobbit.
         
196

Properties

This function is ·deterministic·, ·context-independent·, and ·focus-independent·.

Rules

Any values of type

let $para := 
In a hole in the ground there lived a hobbit.
         
00 in
let $para := 
In a hole in the ground there lived a hobbit.
         
25 are cast to
let $para := 
In a hole in the ground there lived a hobbit.
         
26. The items in the resulting sequence may be reordered in an arbitrary order. The resulting sequence is referred to below as the converted sequence.

If the converted sequence is empty, then the single-argument form of the function returns the

let $para := 
In a hole in the ground there lived a hobbit.
         
85 value
declare %public function r:random-sequence($length as xs:integer) as xs:double* {
  r:random-sequence($length, fn:random-number-generator())
};

declare %private function r:random-sequence($length as xs:integer, 
                                            $G as map(xs:string, item())) {
  if ($length eq 0)
  then ()
  else ($G?number, r:random-sequence($length - 1, $G?next()))
};

r:random-sequence(200);
            
19; the two-argument form returns the value of the argument
1º 2º 3º 4º ...
975.

If the converted sequence contains the value

fn:abs($N * $arg2) le fn:abs($arg1) 
               and fn:compare($N * $arg2, 0) eq fn:compare($arg1, 0).
90,
fn:abs($N * $arg2) le fn:abs($arg1) 
               and fn:compare($N * $arg2, 0) eq fn:compare($arg1, 0).
90 is returned.

All items in

let $para := 
In a hole in the ground there lived a hobbit.
         
25 must be numeric or derived from a single base type. In addition, the type must support addition. Duration values must either all be
let $para := 
In a hole in the ground there lived a hobbit.
         
24 values or must all be
let $para := 
In a hole in the ground there lived a hobbit.
         
25 values. For numeric values, the numeric promotion rules defined in 4.2 Arithmetic operators on numeric values are used to promote all values to a single common type. The sum of a sequence of integers will therefore be an integer, while the sum of a numeric sequence that includes at least one
let $para := 
In a hole in the ground there lived a hobbit.
         
26 will be an
let $para := 
In a hole in the ground there lived a hobbit.
         
26.

The result of the function, using the second signature, is the result of the expression:

1º 2º 3º 4º ...
2

where

1º 2º 3º 4º ...
883 is the converted sequence.

The result of the function, using the first signature, is the result of the expression:

1º 2º 3º 4º ...
994.

Error Conditions

A type error is raised [err:FORG0006] if the input sequence contains items of incompatible types, as described above.

Notes

The second argument allows an appropriate value to be defined to represent the sum of an empty sequence. For example, when summing a sequence of durations it would be appropriate to return a zero-length duration of the appropriate type. This argument is necessary because a system that does dynamic typing cannot distinguish "an empty sequence of integers", for example, from "an empty sequence of durations".

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

Examples

fn:abs($N * $arg2) le fn:abs($arg1) 
               and fn:compare($N * $arg2, 0) eq fn:compare($arg1, 0).
7

fn:abs($N * $arg2) le fn:abs($arg1) 
               and fn:compare($N * $arg2, 0) eq fn:compare($arg1, 0).
8

1º 2º 3º 4º ...
5

fn:abs($N * $arg2) le fn:abs($arg1) 
               and fn:compare($N * $arg2, 0) eq fn:compare($arg1, 0).
9

The expression

1º 2º 3º 4º ...
995 returns
1º 2º 3º 4º ...
996.

The expression

1º 2º 3º 4º ...
997 returns
1º 2º 3º 4º ...
998.

The expression

1º 2º 3º 4º ...
999 returns
op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
700.

The expression

Primo Secondo Terzo Quarto Quinto ...
001 returns
declare %public function r:random-sequence($length as xs:integer) as xs:double* {
  r:random-sequence($length, fn:random-number-generator())
};

declare %private function r:random-sequence($length as xs:integer, 
                                            $G as map(xs:string, item())) {
  if ($length eq 0)
  then ()
  else ($G?number, r:random-sequence($length - 1, $G?next()))
};

r:random-sequence(200);
            
19.

The expression

Primo Secondo Terzo Quarto Quinto ...
003 returns
let $para := 
In a hole in the ground there lived a hobbit.
         
96.

The expression

Primo Secondo Terzo Quarto Quinto ...
005 returns
declare %public function r:random-sequence($length as xs:integer) as xs:double* {
  r:random-sequence($length, fn:random-number-generator())
};

declare %private function r:random-sequence($length as xs:integer, 
                                            $G as map(xs:string, item())) {
  if ($length eq 0)
  then ()
  else ($G?number, r:random-sequence($length - 1, $G?next()))
};

r:random-sequence(200);
            
19.

Primo Secondo Terzo Quarto Quinto ...
007 raises a type error [err:FORG0006].

The expression

Primo Secondo Terzo Quarto Quinto ...
008 returns
1º 2º 3º 4º ...
996. (There is no requirement that the
1º 2º 3º 4º ...
975 value should be the same type as the items in
let $para := 
In a hole in the ground there lived a hobbit.
         
25, or even that it should belong to a type that supports addition.)

The expression

Primo Secondo Terzo Quarto Quinto ...
012 returns
Primo Secondo Terzo Quarto Quinto ...
013. (Atomizing an array returns the sequence obtained by atomizing its members.)

The expression

Primo Secondo Terzo Quarto Quinto ...
014 returns
let $para := 
In a hole in the ground there lived a hobbit.
         
054. (Atomizing an array returns the sequence obtained by atomizing its members.)

14.5 Functions on node identifiers

This section defines a number of functions used to find elements by

Primo Secondo Terzo Quarto Quinto ...
016 or
Primo Secondo Terzo Quarto Quinto ...
017 value, or to generate IDs.

FunctionMeaning
Primo Secondo Terzo Quarto Quinto ...
018Returns the sequence of element nodes that have an
Primo Secondo Terzo Quarto Quinto ...
016 value matching the value of one or more of the
Primo Secondo Terzo Quarto Quinto ...
017 values supplied in
let $para := 
In a hole in the ground there lived a hobbit.
         
25.
Primo Secondo Terzo Quarto Quinto ...
022Returns the sequence of element nodes that have an
Primo Secondo Terzo Quarto Quinto ...
016 value matching the value of one or more of the
Primo Secondo Terzo Quarto Quinto ...
017 values supplied in
let $para := 
In a hole in the ground there lived a hobbit.
         
25.
Primo Secondo Terzo Quarto Quinto ...
026Returns the sequence of element or attribute nodes with an
Primo Secondo Terzo Quarto Quinto ...
017 value matching the value of one or more of the
Primo Secondo Terzo Quarto Quinto ...
016 values supplied in
let $para := 
In a hole in the ground there lived a hobbit.
         
25.
Primo Secondo Terzo Quarto Quinto ...
030This function returns a string that uniquely identifies a given node.

14.5.1 fn:id

Summary

Returns the sequence of element nodes that have an

Primo Secondo Terzo Quarto Quinto ...
016 value matching the value of one or more of the
Primo Secondo Terzo Quarto Quinto ...
017 values supplied in
let $para := 
In a hole in the ground there lived a hobbit.
         
25.

Signatures

Primo Secondo Terzo Quarto Quinto ...
018(
let $para := 
In a hole in the ground there lived a hobbit.
         
25
let $para := 
In a hole in the ground there lived a hobbit.
         
71
let $para := 
In a hole in the ground there lived a hobbit.
         
234)
let $para := 
In a hole in the ground there lived a hobbit.
         
71
Primo Secondo Terzo Quarto Quinto ...
039

Primo Secondo Terzo Quarto Quinto ...
018(
let $para := 
In a hole in the ground there lived a hobbit.
         
25
let $para := 
In a hole in the ground there lived a hobbit.
         
71
let $para := 
In a hole in the ground there lived a hobbit.
         
234,
1º 2º 3º 4º ...
058
let $para := 
In a hole in the ground there lived a hobbit.
         
71
1º 2º 3º 4º ...
147)
let $para := 
In a hole in the ground there lived a hobbit.
         
71
Primo Secondo Terzo Quarto Quinto ...
039

Properties

The one-argument form of this function is ·deterministic·, ·context-dependent·, and ·focus-dependent·.

The two-argument form of this function is ·deterministic·, ·context-independent·, and ·focus-independent·.

Rules

The function returns a sequence, in document order with duplicates eliminated, containing every element node

fn:abs($N * $arg2) le fn:abs($arg1) 
               and fn:compare($N * $arg2, 0) eq fn:compare($arg1, 0).
547 that satisfies all the following conditions:

  1. fn:abs($N * $arg2) le fn:abs($arg1) 
                   and fn:compare($N * $arg2, 0) eq fn:compare($arg1, 0).
    547 is in the target document. The target document is the document containing
    1º 2º 3º 4º ...
    058, or the document containing the context item (
    let $para := 
    In a hole in the ground there lived a hobbit.
             
    19) if the second argument is omitted. The behavior of the function if
    1º 2º 3º 4º ...
    058 is omitted is exactly the same as if the context item had been passed as
    1º 2º 3º 4º ...
    058.

  2. fn:abs($N * $arg2) le fn:abs($arg1) 
                   and fn:compare($N * $arg2, 0) eq fn:compare($arg1, 0).
    547 has an
    Primo Secondo Terzo Quarto Quinto ...
    016 value equal to one of the candidate
    Primo Secondo Terzo Quarto Quinto ...
    017 values, where:

    • An element has an

      Primo Secondo Terzo Quarto Quinto ...
      016 value equal to
      Primo Secondo Terzo Quarto Quinto ...
      059 if either or both of the following conditions are true:

      • The

        1º 2º 3º 4º ...
        719 property (See Section 5.5 is-id Accessor DM31.) of the element node is true, and the typed value of the element node is equal to
        Primo Secondo Terzo Quarto Quinto ...
        059 under the rules of the
        let $para := 
        In a hole in the ground there lived a hobbit.
                 
        33 operator using the Unicode codepoint collation (
        let $para := 
        In a hole in the ground there lived a hobbit.
                 
        078).

      • The element has an attribute node whose

        1º 2º 3º 4º ...
        719 property (See Section 5.5 is-id Accessor DM31.) is true and whose typed value is equal to
        Primo Secondo Terzo Quarto Quinto ...
        059 under the rules of the
        let $para := 
        In a hole in the ground there lived a hobbit.
                 
        33 operator using the Unicode code point collation (
        let $para := 
        In a hole in the ground there lived a hobbit.
                 
        078).

    • Each

      let $para := 
      In a hole in the ground there lived a hobbit.
               
      10 in
      let $para := 
      In a hole in the ground there lived a hobbit.
               
      25 is parsed as if it were of type
      Primo Secondo Terzo Quarto Quinto ...
      070, that is, each
      let $para := 
      In a hole in the ground there lived a hobbit.
               
      10 in
      let $para := 
      In a hole in the ground there lived a hobbit.
               
      25 is treated as a whitespace-separated sequence of tokens, each acting as an
      Primo Secondo Terzo Quarto Quinto ...
      017. These tokens are then included in the list of candidate
      Primo Secondo Terzo Quarto Quinto ...
      017s. If any of the tokens is not a lexically valid
      Primo Secondo Terzo Quarto Quinto ...
      017 (that is, if it is not lexically an
      let $para := 
      In a hole in the ground there lived a hobbit.
               
      35), it is ignored. Formally, the candidate
      Primo Secondo Terzo Quarto Quinto ...
      017 values are the strings in the sequence given by the expression:

      1º 2º 3º 4º ...
      7

  3. If several elements have the same

    Primo Secondo Terzo Quarto Quinto ...
    016 value, then
    fn:abs($N * $arg2) le fn:abs($arg1) 
                   and fn:compare($N * $arg2, 0) eq fn:compare($arg1, 0).
    547 is the one that is first in document order.

Error Conditions

A dynamic error is raised [err:FODC0001] if

1º 2º 3º 4º ...
058, or the context item if the second argument is absent, is a node in a tree whose root is not a document node.

The following errors may be raised when

1º 2º 3º 4º ...
058 is omitted:

  • If the context item is absentDM31, dynamic error [err:XPDY0002]XP31

  • If the context item is not a node, type error [err:XPTY0004]XP31.

Notes

The effect of this function is anomalous in respect of element nodes with the

1º 2º 3º 4º ...
719 property. For legacy reasons, this function returns the element that has the
1º 2º 3º 4º ...
719 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
Primo Secondo Terzo Quarto Quinto ...
022 has been introduced with the desired behavior.

If the data model is constructed from an Infoset, an attribute will have the

1º 2º 3º 4º ...
719 property if the corresponding attribute in the Infoset had an attribute type of
Primo Secondo Terzo Quarto Quinto ...
016: typically this means the attribute was declared as an
Primo Secondo Terzo Quarto Quinto ...
016 in a DTD.

If the data model is constructed from a PSVI, an element or attribute will have the

1º 2º 3º 4º ...
719 property if its typed value is a single atomic value of type
Primo Secondo Terzo Quarto Quinto ...
089 or a type derived by restriction from
Primo Secondo Terzo Quarto Quinto ...
089.

No error is raised in respect of a candidate

Primo Secondo Terzo Quarto Quinto ...
017 value that does not match the
Primo Secondo Terzo Quarto Quinto ...
016 of any element in the document. If no candidate
Primo Secondo Terzo Quarto Quinto ...
017 value matches the
Primo Secondo Terzo Quarto Quinto ...
016 value of any element, the function returns the empty sequence.

It is not necessary that the supplied argument should have type

Primo Secondo Terzo Quarto Quinto ...
095 or
let $para := 
In a hole in the ground there lived a hobbit.
         
41, or that it should be derived from a node with the
1º 2º 3º 4º ...
720 property.

An element may have more than one

Primo Secondo Terzo Quarto Quinto ...
016 value. This can occur with synthetic data models or with data models constructed from a PSVI where the element and one of its attributes are both typed as
Primo Secondo Terzo Quarto Quinto ...
089.

If the source document is well-formed but not valid, it is possible for two or more elements to have the same

Primo Secondo Terzo Quarto Quinto ...
016 value. In this situation, the function will select the first such element.

It is also possible in a well-formed but invalid document to have an element or attribute that has the

1º 2º 3º 4º ...
719 property but whose value does not conform to the lexical rules for the
Primo Secondo Terzo Quarto Quinto ...
089 type. Such a node will never be selected by this function.

Examples

1º 2º 3º 4º ...
8

The expression

Primo Secondo Terzo Quarto Quinto ...
103 returns
Primo Secondo Terzo Quarto Quinto ...
104. (The
Primo Secondo Terzo Quarto Quinto ...
105 attribute has the
1º 2º 3º 4º ...
719 property, so the employee element is selected.)

The expression

Primo Secondo Terzo Quarto Quinto ...
107 returns
Primo Secondo Terzo Quarto Quinto ...
108. (Assuming the
Primo Secondo Terzo Quarto Quinto ...
109 element is given the type
Primo Secondo Terzo Quarto Quinto ...
089 as a result of schema validation, the element will have the
1º 2º 3º 4º ...
719 property and is therefore selected. Note the difference from the behavior of
Primo Secondo Terzo Quarto Quinto ...
022.)

14.5.2 fn:element-with-id

Summary

Returns the sequence of element nodes that have an

Primo Secondo Terzo Quarto Quinto ...
016 value matching the value of one or more of the
Primo Secondo Terzo Quarto Quinto ...
017 values supplied in
let $para := 
In a hole in the ground there lived a hobbit.
         
25.

Signatures

Primo Secondo Terzo Quarto Quinto ...
022(
let $para := 
In a hole in the ground there lived a hobbit.
         
25
let $para := 
In a hole in the ground there lived a hobbit.
         
71
let $para := 
In a hole in the ground there lived a hobbit.
         
234)
let $para := 
In a hole in the ground there lived a hobbit.
         
71
Primo Secondo Terzo Quarto Quinto ...
039

Primo Secondo Terzo Quarto Quinto ...
022(
let $para := 
In a hole in the ground there lived a hobbit.
         
25
let $para := 
In a hole in the ground there lived a hobbit.
         
71
let $para := 
In a hole in the ground there lived a hobbit.
         
234,
1º 2º 3º 4º ...
058
let $para := 
In a hole in the ground there lived a hobbit.
         
71
1º 2º 3º 4º ...
147)
let $para := 
In a hole in the ground there lived a hobbit.
         
71
Primo Secondo Terzo Quarto Quinto ...
039

Properties

The one-argument form of this function is ·deterministic·, ·context-dependent·, and ·focus-dependent·.

The two-argument form of this function is ·deterministic·, ·context-independent·, and ·focus-independent·.

Rules

Note:

The effect of this function is identical to

Primo Secondo Terzo Quarto Quinto ...
018 in respect of elements that have an attribute with the
1º 2º 3º 4º ...
719 property. However, it behaves differently in respect of element nodes with the
1º 2º 3º 4º ...
719 property. Whereas the
Primo Secondo Terzo Quarto Quinto ...
018 function, for legacy reasons, returns the element that has the
1º 2º 3º 4º ...
719 property, this function returns the element identified by the ID, which is the parent of the element having the
1º 2º 3º 4º ...
719 property.

The function returns a sequence, in document order with duplicates eliminated, containing every element node

fn:abs($N * $arg2) le fn:abs($arg1) 
               and fn:compare($N * $arg2, 0) eq fn:compare($arg1, 0).
547 that satisfies all the following conditions:

  1. fn:abs($N * $arg2) le fn:abs($arg1) 
                   and fn:compare($N * $arg2, 0) eq fn:compare($arg1, 0).
    547 is in the target document. The target document is the document containing
    1º 2º 3º 4º ...
    058, or the document containing the context item (
    let $para := 
    In a hole in the ground there lived a hobbit.
             
    19) if the second argument is omitted. The behavior of the function if
    1º 2º 3º 4º ...
    058 is omitted is exactly the same as if the context item had been passed as
    1º 2º 3º 4º ...
    058.

  2. fn:abs($N * $arg2) le fn:abs($arg1) 
                   and fn:compare($N * $arg2, 0) eq fn:compare($arg1, 0).
    547 has an
    Primo Secondo Terzo Quarto Quinto ...
    016 value equal to one of the candidate
    Primo Secondo Terzo Quarto Quinto ...
    017 values, where:

    • An element has an

      Primo Secondo Terzo Quarto Quinto ...
      016 value equal to
      Primo Secondo Terzo Quarto Quinto ...
      059 if either or both of the following conditions are true:

      • The element has an child element node whose

        1º 2º 3º 4º ...
        719 property (See Section 5.5 is-id Accessor DM31.) is true and whose typed value is equal to
        Primo Secondo Terzo Quarto Quinto ...
        059 under the rules of the
        let $para := 
        In a hole in the ground there lived a hobbit.
                 
        33 operator using the Unicode code point collation (
        let $para := 
        In a hole in the ground there lived a hobbit.
                 
        078).

      • The element has an attribute node whose

        1º 2º 3º 4º ...
        719 property (See Section 5.5 is-id Accessor DM31.) is true and whose typed value is equal to
        Primo Secondo Terzo Quarto Quinto ...
        059 under the rules of the
        let $para := 
        In a hole in the ground there lived a hobbit.
                 
        33 operator using the Unicode code point collation (
        let $para := 
        In a hole in the ground there lived a hobbit.
                 
        078).

    • Each

      let $para := 
      In a hole in the ground there lived a hobbit.
               
      10 in
      let $para := 
      In a hole in the ground there lived a hobbit.
               
      25 is parsed as if it were of type
      Primo Secondo Terzo Quarto Quinto ...
      070, that is, each
      let $para := 
      In a hole in the ground there lived a hobbit.
               
      10 in
      let $para := 
      In a hole in the ground there lived a hobbit.
               
      25 is treated as a whitespace-separated sequence of tokens, each acting as an
      Primo Secondo Terzo Quarto Quinto ...
      017. These tokens are then included in the list of candidate
      Primo Secondo Terzo Quarto Quinto ...
      017s. If any of the tokens is not a lexically valid
      Primo Secondo Terzo Quarto Quinto ...
      017 (that is, if it is not lexically an
      let $para := 
      In a hole in the ground there lived a hobbit.
               
      35), it is ignored. Formally, the candidate
      Primo Secondo Terzo Quarto Quinto ...
      017 values are the strings in the sequence given by the expression:

      1º 2º 3º 4º ...
      9

  3. If several elements have the same

    Primo Secondo Terzo Quarto Quinto ...
    016 value, then
    fn:abs($N * $arg2) le fn:abs($arg1) 
                   and fn:compare($N * $arg2, 0) eq fn:compare($arg1, 0).
    547 is the one that is first in document order.

Error Conditions

A dynamic error is raised [err:FODC0001] if

1º 2º 3º 4º ...
058, or the context item if the second argument is omitted, is a node in a tree whose root is not a document node.

The following errors may be raised when

1º 2º 3º 4º ...
058 is omitted:

  • If the context item is absentDM31, dynamic error [err:XPDY0002]XP31

  • If the context item is not a node, type error [err:XPTY0004]XP31.

Notes

This function is equivalent to the

Primo Secondo Terzo Quarto Quinto ...
018 function except when dealing with ID-valued element nodes. Whereas the
Primo Secondo Terzo Quarto Quinto ...
018 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

1º 2º 3º 4º ...
719 property if the corresponding attribute in the Infoset had an attribute type of
Primo Secondo Terzo Quarto Quinto ...
016: typically this means the attribute was declared as an
Primo Secondo Terzo Quarto Quinto ...
016 in a DTD.

If the data model is constructed from a PSVI, an element or attribute will have the

1º 2º 3º 4º ...
719 property if its typed value is a single atomic value of type
Primo Secondo Terzo Quarto Quinto ...
089 or a type derived by restriction from
Primo Secondo Terzo Quarto Quinto ...
089.

No error is raised in respect of a candidate

Primo Secondo Terzo Quarto Quinto ...
017 value that does not match the
Primo Secondo Terzo Quarto Quinto ...
016 of any element in the document. If no candidate
Primo Secondo Terzo Quarto Quinto ...
017 value matches the
Primo Secondo Terzo Quarto Quinto ...
016 value of any element, the function returns the empty sequence.

It is not necessary that the supplied argument should have type

Primo Secondo Terzo Quarto Quinto ...
095 or
let $para := 
In a hole in the ground there lived a hobbit.
         
41, or that it should be derived from a node with the
1º 2º 3º 4º ...
720 property.

An element may have more than one

Primo Secondo Terzo Quarto Quinto ...
016 value. This can occur with synthetic data models or with data models constructed from a PSVI where the element and one of its attributes are both typed as
Primo Secondo Terzo Quarto Quinto ...
089.

If the source document is well-formed but not valid, it is possible for two or more elements to have the same

Primo Secondo Terzo Quarto Quinto ...
016 value. In this situation, the function will select the first such element.

It is also possible in a well-formed but invalid document to have an element or attribute that has the

1º 2º 3º 4º ...
719 property but whose value does not conform to the lexical rules for the
Primo Secondo Terzo Quarto Quinto ...
089 type. Such a node will never be selected by this function.

Examples

Primo Secondo Terzo Quarto Quinto ...
0

The expression

Primo Secondo Terzo Quarto Quinto ...
190 returns
Primo Secondo Terzo Quarto Quinto ...
104. (The
Primo Secondo Terzo Quarto Quinto ...
105 attribute has the
1º 2º 3º 4º ...
719 property, so the employee element is selected.)

The expression

Primo Secondo Terzo Quarto Quinto ...
194 returns
Primo Secondo Terzo Quarto Quinto ...
104. (Assuming the
Primo Secondo Terzo Quarto Quinto ...
109 element is given the type
Primo Secondo Terzo Quarto Quinto ...
089 as a result of schema validation, the element will have the
1º 2º 3º 4º ...
719 property and is therefore its parent is selected. Note the difference from the behavior of
Primo Secondo Terzo Quarto Quinto ...
018.)

14.5.3 fn:idref

Summary

Returns the sequence of element or attribute nodes with an

Primo Secondo Terzo Quarto Quinto ...
017 value matching the value of one or more of the
Primo Secondo Terzo Quarto Quinto ...
016 values supplied in
let $para := 
In a hole in the ground there lived a hobbit.
         
25.

Signatures

Primo Secondo Terzo Quarto Quinto ...
026(
let $para := 
In a hole in the ground there lived a hobbit.
         
25
let $para := 
In a hole in the ground there lived a hobbit.
         
71
let $para := 
In a hole in the ground there lived a hobbit.
         
234)
let $para := 
In a hole in the ground there lived a hobbit.
         
71
1º 2º 3º 4º ...
272

Primo Secondo Terzo Quarto Quinto ...
026(
let $para := 
In a hole in the ground there lived a hobbit.
         
25
let $para := 
In a hole in the ground there lived a hobbit.
         
71
let $para := 
In a hole in the ground there lived a hobbit.
         
234,
1º 2º 3º 4º ...
058
let $para := 
In a hole in the ground there lived a hobbit.
         
71
1º 2º 3º 4º ...
147)
let $para := 
In a hole in the ground there lived a hobbit.
         
71
1º 2º 3º 4º ...
272

Properties

The one-argument form of this function is ·deterministic·, ·context-dependent·, and ·focus-dependent·.

The two-argument form of this function is ·deterministic·, ·context-independent·, and ·focus-independent·.

Rules

The function returns a sequence, in document order with duplicates eliminated, containing every element or attribute node

Primo Secondo Terzo Quarto Quinto ...
98 that satisfies all the following conditions:

  1. Primo Secondo Terzo Quarto Quinto ...
    98 is in the target document. The target document is the document containing
    1º 2º 3º 4º ...
    058 or the document containing the context item (
    let $para := 
    In a hole in the ground there lived a hobbit.
             
    19) if the second argument is omitted. The behavior of the function if
    1º 2º 3º 4º ...
    058 is omitted is exactly the same as if the context item had been passed as
    1º 2º 3º 4º ...
    058.

  2. Primo Secondo Terzo Quarto Quinto ...
    98 has an
    Primo Secondo Terzo Quarto Quinto ...
    017 value equal to one of the candidate
    Primo Secondo Terzo Quarto Quinto ...
    016 values, where:

    • A node

      Primo Secondo Terzo Quarto Quinto ...
      98 has an
      Primo Secondo Terzo Quarto Quinto ...
      017 value equal to
      Primo Secondo Terzo Quarto Quinto ...
      059 if both of the following conditions are true:

      • The

        1º 2º 3º 4º ...
        720 property (see Section 5.6 is-idrefs Accessor DM31) of
        Primo Secondo Terzo Quarto Quinto ...
        98 is
        op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
        76.

      • The sequence

        Primo Secondo Terzo Quarto Quinto ...
        1

        contains a string that is equal to

        Primo Secondo Terzo Quarto Quinto ...
        059 under the rules of the
        let $para := 
        In a hole in the ground there lived a hobbit.
                 
        33 operator using the Unicode code point collation (
        let $para := 
        In a hole in the ground there lived a hobbit.
                 
        078).

    • Each

      let $para := 
      In a hole in the ground there lived a hobbit.
               
      10 in
      let $para := 
      In a hole in the ground there lived a hobbit.
               
      25 is parsed as if it were of lexically of type
      Primo Secondo Terzo Quarto Quinto ...
      089. These
      let $para := 
      In a hole in the ground there lived a hobbit.
               
      10s are then included in the list of candidate
      Primo Secondo Terzo Quarto Quinto ...
      089s. If any of the strings in
      let $para := 
      In a hole in the ground there lived a hobbit.
               
      25 is not a lexically valid
      Primo Secondo Terzo Quarto Quinto ...
      089 (that is, if it is not lexically an
      let $para := 
      In a hole in the ground there lived a hobbit.
               
      35), it is ignored. More formally, the candidate
      Primo Secondo Terzo Quarto Quinto ...
      016 values are the strings in the sequence:

      Primo Secondo Terzo Quarto Quinto ...
      2

Error Conditions

A dynamic error is raised [err:FODC0001] if

1º 2º 3º 4º ...
058, or the context item if the second argument is omitted, is a node in a tree whose root is not a document node.

The following errors may be raised when

1º 2º 3º 4º ...
058 is omitted:

  • If the context item is absentDM31, dynamic error [err:XPDY0002]XP31

  • If the context item is not a node, type error [err:XPTY0004]XP31.

Notes

An element or attribute typically acquires the

1º 2º 3º 4º ...
720 property by being validated against the schema type
Primo Secondo Terzo Quarto Quinto ...
095 or
let $para := 
In a hole in the ground there lived a hobbit.
         
41, or (for attributes only) by being described as of type
Primo Secondo Terzo Quarto Quinto ...
017 or
Primo Secondo Terzo Quarto Quinto ...
070 in a DTD.

Because the function is sensitive to the way in which the data model is constructed, calls on this function are not always interoperable.

No error is raised in respect of a candidate

Primo Secondo Terzo Quarto Quinto ...
016 value that does not match the
Primo Secondo Terzo Quarto Quinto ...
017 value of any element or attribute in the document. If no candidate
Primo Secondo Terzo Quarto Quinto ...
016 value matches the
Primo Secondo Terzo Quarto Quinto ...
017 value of any element or attribute, the function returns the empty sequence.

It is possible for two or more nodes to have an

Primo Secondo Terzo Quarto Quinto ...
017 value that matches a given candidate
Primo Secondo Terzo Quarto Quinto ...
016 value. In this situation, the function will return all such nodes. However, each matching node will be returned at most once, regardless how many candidate
Primo Secondo Terzo Quarto Quinto ...
016 values it matches.

It is possible in a well-formed but invalid document to have a node whose

1º 2º 3º 4º ...
720 property is true but that does not conform to the lexical rules for the
Primo Secondo Terzo Quarto Quinto ...
095 type. The effect of the above rules is that ill-formed candidate
Primo Secondo Terzo Quarto Quinto ...
016 values and ill-formed
Primo Secondo Terzo Quarto Quinto ...
017 values are ignored.

If the data model is constructed from a PSVI, the typed value of a node that has the

1º 2º 3º 4º ...
720 property will contain at least one atomic value of type
Primo Secondo Terzo Quarto Quinto ...
095 (or a type derived by restriction from
Primo Secondo Terzo Quarto Quinto ...
095). It may also contain atomic values of other types. These atomic values are treated as candidate
Primo Secondo Terzo Quarto Quinto ...
016 values if two conditions are met: their lexical form must be valid as an
let $para := 
In a hole in the ground there lived a hobbit.
         
35, and there must be at least one instance of
Primo Secondo Terzo Quarto Quinto ...
095 in the typed value of the node. If these conditions are not satisfied, such values are ignored.

Examples

Primo Secondo Terzo Quarto Quinto ...
3

The expression

Primo Secondo Terzo Quarto Quinto ...
269 returns
Primo Secondo Terzo Quarto Quinto ...
270. (Assuming that
Primo Secondo Terzo Quarto Quinto ...
271 has the is-idref property, the call on
Primo Secondo Terzo Quarto Quinto ...
026 selects the
Primo Secondo Terzo Quarto Quinto ...
271 element. If, instead, the
Primo Secondo Terzo Quarto Quinto ...
271 had a
Primo Secondo Terzo Quarto Quinto ...
275 attribute with the is-idref property, the call on
Primo Secondo Terzo Quarto Quinto ...
026 would select the attribute node.)

The expression

Primo Secondo Terzo Quarto Quinto ...
277 returns
Primo Secondo Terzo Quarto Quinto ...
278. (Assuming that
Primo Secondo Terzo Quarto Quinto ...
279 has the is-idref property, the call on
Primo Secondo Terzo Quarto Quinto ...
026 selects the
Primo Secondo Terzo Quarto Quinto ...
281 element.)

14.5.4 fn:generate-id

Summary

This function returns a string that uniquely identifies a given node.

Signatures

Primo Secondo Terzo Quarto Quinto ...
030()
let $para := 
In a hole in the ground there lived a hobbit.
         
71
let $para := 
In a hole in the ground there lived a hobbit.
         
10

Primo Secondo Terzo Quarto Quinto ...
030(
let $para := 
In a hole in the ground there lived a hobbit.
         
25
let $para := 
In a hole in the ground there lived a hobbit.
         
71
op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
51)
let $para := 
In a hole in the ground there lived a hobbit.
         
71
let $para := 
In a hole in the ground there lived a hobbit.
         
10

Properties

The zero-argument form of this function is ·deterministic·, ·context-dependent·, and ·focus-dependent·.

The one-argument form of this function is ·deterministic·, ·context-independent·, and ·focus-independent·.

Rules

If the argument is omitted, it defaults to the context item (

let $para := 
In a hole in the ground there lived a hobbit.
         
19). The behavior of the function if the argument is omitted is exactly the same as if the context item had been passed as the argument.

If the argument is the empty sequence, the result is the zero-length string.

In other cases, the function returns a string that uniquely identifies a given node. More formally, it is guaranteed that within a single ·execution scope·,

Primo Secondo Terzo Quarto Quinto ...
292 returns true if and only if
Primo Secondo Terzo Quarto Quinto ...
293 returns true.

The returned identifier must consist of ASCII alphanumeric characters and must start with an alphabetic character. Thus, the string is syntactically an XML name.

Error Conditions

The following errors may be raised when

let $para := 
In a hole in the ground there lived a hobbit.
         
25 is omitted:

  • If the context item is absentDM31, dynamic error [err:XPDY0002]XP31

  • If the context item is not a node, type error [err:XPTY0004]XP31.

Notes

An implementation is free to generate an identifier in any convenient way provided that it always generates the same identifier for the same node and that different identifiers are always generated from different nodes. An implementation is under no obligation to generate the same identifiers each time a document is transformed or queried.

There is no guarantee that a generated unique identifier will be distinct from any unique IDs specified in the source document.

There is no inverse to this function; it is not directly possible to find the node with a given generated ID. Of course, it is possible to search a given sequence of nodes using an expression such as

Primo Secondo Terzo Quarto Quinto ...
295.

It is advisable, but not required, for implementations to generate IDs that are distinct even when compared using a case-blind collation.

Examples

The primary use case for this function is to generate hyperlinks. For example, when generating HTML, an anchor for a given section

Primo Secondo Terzo Quarto Quinto ...
296 can be generated by writing (in either XSLT or XQuery):

Primo Secondo Terzo Quarto Quinto ...
297

and a link to that section can then be produced with code such as:

Primo Secondo Terzo Quarto Quinto ...
298

Note that anchors generated in this way will not necessarily be the same each time a document is republished.

Since the keys in a map must be atomic values, it is possible to use generated IDs as surrogates for nodes when constructing a map. For example, in some implementations, testing whether a node

Primo Secondo Terzo Quarto Quinto ...
98 is a member of a large node-set
Primo Secondo Terzo Quarto Quinto ...
300 using the expression
Primo Secondo Terzo Quarto Quinto ...
301 may be expensive; there may then be performance benefits in creating a map:

Primo Secondo Terzo Quarto Quinto ...
302

and then testing for membership of the node-set using:

Primo Secondo Terzo Quarto Quinto ...
303

14.6 Functions giving access to external information

The functions in this section provide access to resources (such as files) in the external environment.

FunctionMeaning
op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
09Retrieves a document using a URI supplied as an
let $para := 
In a hole in the ground there lived a hobbit.
         
10, and returns the corresponding document node.
Primo Secondo Terzo Quarto Quinto ...
306The function returns true if and only if the function call
Primo Secondo Terzo Quarto Quinto ...
307 would return a document node.
op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
10Returns a sequence of items identified by a collection URI; or a default collection if no URI is supplied.
Primo Secondo Terzo Quarto Quinto ...
309Returns a sequence of
let $para := 
In a hole in the ground there lived a hobbit.
         
30 values representing the URIs in a URI collection.
Primo Secondo Terzo Quarto Quinto ...
311The
Primo Secondo Terzo Quarto Quinto ...
311 function reads an external resource (for example, a file) and returns a string representation of the resource.
Primo Secondo Terzo Quarto Quinto ...
313The
Primo Secondo Terzo Quarto Quinto ...
313 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.
Primo Secondo Terzo Quarto Quinto ...
315Because errors in evaluating the
Primo Secondo Terzo Quarto Quinto ...
311 function are non-recoverable, these two functions are provided to allow an application to determine whether a call with particular arguments would succeed.
Primo Secondo Terzo Quarto Quinto ...
317Returns the value of a system environment variable, if it exists.
Primo Secondo Terzo Quarto Quinto ...
318Returns a list of environment variable names that are suitable for passing to
Primo Secondo Terzo Quarto Quinto ...
317, as a (possibly empty) sequence of strings.

14.6.1 fn:doc

Summary

Retrieves a document using a URI supplied as an

let $para := 
In a hole in the ground there lived a hobbit.
         
10, and returns the corresponding document node.

Signature

op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
09(
op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
324
let $para := 
In a hole in the ground there lived a hobbit.
         
71
let $para := 
In a hole in the ground there lived a hobbit.
         
244)
let $para := 
In a hole in the ground there lived a hobbit.
         
71
Primo Secondo Terzo Quarto Quinto ...
326

Properties

This function is ·deterministic·, ·context-dependent·, and ·focus-independent·. It depends on available documents, and static base URI.

Rules

If

op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
324 is the empty sequence, the result is an empty sequence.

If

op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
324 is a relative URI reference, it is resolved relative to the value of the static base URI property from the static context. The resulting absolute URI is promoted to an
let $para := 
In a hole in the ground there lived a hobbit.
         
10.

If the available documents described in Section 2.1.2 Dynamic Context XP31 provides a mapping from this string to a document node, the function returns that document node.

The URI may include a fragment identifier.

By default, this function is ·deterministic·. Two calls on this function return the same document node if the same URI Reference (after resolution to an absolute URI Reference) is supplied to both calls. Thus, the following expression (if it does not raise an error) will always be true:

Primo Secondo Terzo Quarto Quinto ...
4

However, for performance reasons, implementations may provide a user option to evaluate the function without a guarantee of determinism. The manner in which any such option is provided is implementation-defined. If the user has not selected such an option, a call of the function must either return a deterministic result or must raise a dynamic error [err:FODC0003].

Note:

If

op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
324 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
op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
258 function, and passing the resulting absolute URI as an argument to the
op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
09 function.

If two calls to this function supply different absolute URI References as arguments, the same document node may be returned if the implementation can determine that the two arguments refer to the same resource.

By defining the semantics of this function in terms of a string-to-document-node mapping in the dynamic context, the specification is acknowledging that the results of this function are outside the purview of the language specification itself, and depend entirely on the run-time environment in which the expression is evaluated. This run-time environment includes not only an unpredictable collection of resources ("the web"), but configurable machinery for locating resources and turning their contents into document nodes within the XPath data model. Both the set of resources that are reachable, and the mechanisms by which those resources are parsed and validated, are ·implementation-dependent·.

One possible processing model for this function is as follows. The resource identified by the URI Reference is retrieved. If the resource cannot be retrieved, a dynamic error is raised [err:FODC0002]. The data resulting from the retrieval action is then parsed as an XML document and a tree is constructed in accordance with the [XQuery and XPath Data Model (XDM) 3.0]. If the top-level media type is known and is "text", the content is parsed in the same way as if the media type were text/xml; otherwise, it is parsed in the same way as if the media type were application/xml. If the contents cannot be parsed successfully, a dynamic error is raised [err:FODC0002]. Otherwise, the result of the function is the document node at the root of the resulting tree. This tree is then optionally validated against a schema.

Various aspects of this processing are ·implementation-defined·. Implementations may provide external configuration options that allow any aspect of the processing to be controlled by the user. In particular:

  • The set of URI schemes that the implementation recognizes is implementation-defined. Implementations may allow the mapping of URIs to resources to be configured by the user, using mechanisms such as catalogs or user-written URI handlers.

  • The handling of non-XML media types is implementation-defined. Implementations may allow instances of the data model to be constructed from non-XML resources, under user control.

  • It is ·implementation-defined· whether DTD validation and/or schema validation is applied to the source document.

  • Implementations may provide user-defined error handling options that allow processing to continue following an error in retrieving a resource, or in parsing and validating its content. When errors have been handled in this way, the function may return either an empty sequence, or a fallback document provided by the error handler.

  • Implementations may provide user options that relax the requirement for the function to return deterministic results.

  • The effect of a fragment identifier in the supplied URI is ·implementation-defined·. One possible interpretation is to treat the fragment identifier as an ID attribute value, and to return a document node having the element with the selected ID value as its only child.

Error Conditions

A dynamic error may be raised [err:FODC0005] if

op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
324 is not a valid URI reference.

A dynamic error is raised [err:FODC0002] if a relative URI reference is supplied, and the base-URI property in the static context is absent.

A dynamic error is raised [err:FODC0002] if the available documents provides no mapping for the absolutized URI.

A dynamic error is raised [err:FODC0002] if the resource cannot be retrieved or cannot be parsed successfully as XML.

A dynamic error is raised [err:FODC0003] if the implementation is not able to guarantee that the result of the function will be deterministic, and the user has not indicated that an unstable result is acceptable.

14.6.2 fn:doc-available

Summary

The function returns true if and only if the function call

Primo Secondo Terzo Quarto Quinto ...
307 would return a document node.

Signature

Primo Secondo Terzo Quarto Quinto ...
306(
op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
324
let $para := 
In a hole in the ground there lived a hobbit.
         
71
let $para := 
In a hole in the ground there lived a hobbit.
         
244)
let $para := 
In a hole in the ground there lived a hobbit.
         
71
op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
32

Properties

This function is ·deterministic·, ·context-dependent·, and ·focus-independent·. It depends on available documents, and static base URI.

Rules

If

op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
324 is an empty sequence, this function returns
let $C := 'http://www.w3.org/2013/collation/UCA?strength=primary'
07.

If a call on

Primo Secondo Terzo Quarto Quinto ...
307 would return a document node, this function returns
op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
76.

In all other cases this function returns

let $C := 'http://www.w3.org/2013/collation/UCA?strength=primary'
07. This includes the case where an invalid URI is supplied, and also the case where a valid relative URI reference is supplied, and cannot be resolved, for example because the static base URI is absent.

If this function returns

op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
76, then calling
Primo Secondo Terzo Quarto Quinto ...
307 within the same ·execution scope· must return a document node. However, if nondeterministic processing has been selected for the
op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
09 function, this guarantee is lost.

14.6.3 fn:collection

Summary

Returns a sequence of items identified by a collection URI; or a default collection if no URI is supplied.

Signatures

op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
10()
let $para := 
In a hole in the ground there lived a hobbit.
         
71
op:operation(fenceHeight, xs:integer) => op:operation(xs:integer, xs:integer)
16

op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
10(
let $para := 
In a hole in the ground there lived a hobbit.
         
25
let $para := 
In a hole in the ground there lived a hobbit.
         
71
let $para := 
In a hole in the ground there lived a hobbit.
         
244)
let $para := 
In a hole in the ground there lived a hobbit.
         
71
op:operation(fenceHeight, xs:integer) => op:operation(xs:integer, xs:integer)
16

Properties

This function is ·deterministic·, ·context-dependent·, and ·focus-independent·. It depends on available collections, and static base URI.

Rules

This function takes an

let $para := 
In a hole in the ground there lived a hobbit.
         
10 as argument and returns a sequence of items obtained by interpreting
let $para := 
In a hole in the ground there lived a hobbit.
         
25 as an
let $para := 
In a hole in the ground there lived a hobbit.
         
30 and resolving it according to the mapping specified in available collections described in Section C.2 Dynamic Context Components XP31.

If available collections provides a mapping from this string to a sequence of items, the function returns that sequence. If available collections maps the string to an empty sequence, then the function returns an empty sequence.

If

let $para := 
In a hole in the ground there lived a hobbit.
         
25 is not specified, the function returns the sequence of items in the default collection in the dynamic context. See Section C.2 Dynamic Context Components XP31.

If the value of

let $para := 
In a hole in the ground there lived a hobbit.
         
25 is a relative
let $para := 
In a hole in the ground there lived a hobbit.
         
30, it is resolved against the value of the base-URI property from the static context.

If

let $para := 
In a hole in the ground there lived a hobbit.
         
25 is the empty sequence, the function behaves as if it had been called without an argument. See above.

By default, this function is ·deterministic·. This means that repeated calls on the function with the same argument will return the same result. However, for performance reasons, implementations may provide a user option to evaluate the function without a guarantee of determinism. The manner in which any such option is provided is ·implementation-defined·. If the user has not selected such an option, a call to this function must either return a deterministic result or must raise a dynamic error [err:FODC0003].

There is no requirement that any nodes in the result should be in document order, nor is there a requirement that the result should contain no duplicates.

Error Conditions

A dynamic error is raised [err:FODC0002] if no URI is supplied and the value of the default collection is absentDM31.

A dynamic error is raised [err:FODC0002] if a relative URI reference is supplied, and the base-URI property in the static context is absent.

A dynamic error is raised [err:FODC0002] if available node collections provides no mapping for the absolutized URI.

A dynamic error may be raised [err:FODC0004] if

let $para := 
In a hole in the ground there lived a hobbit.
         
25 is not a valid
let $para := 
In a hole in the ground there lived a hobbit.
         
30.

Notes

In earlier releases, the primary use for the

op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
10 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 be returned as arrays or maps, non-XML text files might be returned as strings, and binary files might be returned as instances of
let $para := 
In a hole in the ground there lived a hobbit.
         
196.

The abstract concept of a collection might be realized in different ways by different implementations, and the ways in which URIs map to collections can be equally variable. Specifying resources using URIs is useful because URIs are dynamic, can be parameterized, and do not rely on an external environment.

14.6.4 fn:uri-collection

Summary

Returns a sequence of

let $para := 
In a hole in the ground there lived a hobbit.
         
30 values representing the URIs in a URI collection.

Signatures

Primo Secondo Terzo Quarto Quinto ...
309()
let $para := 
In a hole in the ground there lived a hobbit.
         
71
Primo Secondo Terzo Quarto Quinto ...
372

Primo Secondo Terzo Quarto Quinto ...
309(
let $para := 
In a hole in the ground there lived a hobbit.
         
25
let $para := 
In a hole in the ground there lived a hobbit.
         
71
let $para := 
In a hole in the ground there lived a hobbit.
         
244)
let $para := 
In a hole in the ground there lived a hobbit.
         
71
Primo Secondo Terzo Quarto Quinto ...
372

Properties

This function is ·deterministic·, ·context-dependent·, and ·focus-independent·. It depends on available URI collections, and static base URI.

Rules

The zero-argument form of the function returns the URIs in the default URI collection described in Section C.2 Dynamic Context Components XP31.

If the value of

let $para := 
In a hole in the ground there lived a hobbit.
         
25 is a relative
let $para := 
In a hole in the ground there lived a hobbit.
         
30, it is resolved against the value of the base-URI property from the static context.

If

let $para := 
In a hole in the ground there lived a hobbit.
         
25 is the empty sequence, the function behaves as if it had been called without an argument. See above.

The single-argument form of the function returns the sequence of URIs corresponding to the supplied URI in the available URI collections described in Section C.2 Dynamic Context Components XP31.

By default, this function is ·deterministic·. This means that repeated calls on the function with the same argument will return the same result. However, for performance reasons, implementations may provide a user option to evaluate the function without a guarantee of determinism. The manner in which any such option is provided is ·implementation-defined·. If the user has not selected such an option, a call to this function must either return a deterministic result or must raise a dynamic error [err:FODC0003].

There is no requirement that the URIs returned by this function should all be distinct, and no assumptions can be made about the order of URIs in the sequence, unless the implementation defines otherwise.

Error Conditions

A dynamic error is raised [err:FODC0002] if no URI is supplied (that is, if the function is called with no arguments, or with a single argument that evaluates to an empty sequence), and the value of the default resource collection is absentDM31.

A dynamic error is raised [err:FODC0002] if a relative URI reference is supplied, and the base-URI property in the static context is absent.

A dynamic error is raised [err:FODC0002] if available resource collections provides no mapping for the absolutized URI.

A dynamic error may be raised [err:FODC0004] if

let $para := 
In a hole in the ground there lived a hobbit.
         
25 is not a valid
let $para := 
In a hole in the ground there lived a hobbit.
         
30.

Notes

In some implementations, there might be a close relationship between collections (as retrieved by the

op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
10 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 items that do not have any URI; or a URI collection might contain URIs that cannot be dereferenced to return any resource.

Thus, some implementations might ensure that calling

Primo Secondo Terzo Quarto Quinto ...
309 and then applying
op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
09 to each of the returned URIs delivers the same result as calling
op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
10 with the same argument; however, this is not guaranteed.

In the case where

Primo Secondo Terzo Quarto Quinto ...
309 returns the URIs of resources that could also be retrieved directly using
op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
10, there are several reasons why it might be appropriate to use this function in preference to the
op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
10 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

    Primo Secondo Terzo Quarto Quinto ...
    311 function rather than the
    op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
    09 function.

  • In XSLT 3.0 it allows the documents in a collection to be processed in streaming mode using the

    Primo Secondo Terzo Quarto Quinto ...
    393 instruction.

  • It allows recovery from failures to read, parse, or validate individual documents, by calling the

    op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
    09 (or other dereferencing) function within the scope of try/catch.

  • It allows selection of which documents to read based on their URI, for example they can be filtered to select those whose URIs end in

    Primo Secondo Terzo Quarto Quinto ...
    395, or those that use the
    Primo Secondo Terzo Quarto Quinto ...
    396 scheme.

  • An application might choose to limit the number of URIs processed in a single run, for example it might process only the first 50 URIs in the collection; or it might present the URIs to the user and allow the user to select which of them need to be further processed.

  • It allows the URIs to be modified before they are dereferenced, for example by adding or removing query parameters, or by redirecting the request to a local cache or to a mirror site.

For some of these use cases, this assumes that the cost of calling

op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
10 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.

14.6.5 fn:unparsed-text

Summary

The

Primo Secondo Terzo Quarto Quinto ...
311 function reads an external resource (for example, a file) and returns a string representation of the resource.

Signatures

Primo Secondo Terzo Quarto Quinto ...
311(
Primo Secondo Terzo Quarto Quinto ...
400
let $para := 
In a hole in the ground there lived a hobbit.
         
71
let $para := 
In a hole in the ground there lived a hobbit.
         
244)
let $para := 
In a hole in the ground there lived a hobbit.
         
71
let $para := 
In a hole in the ground there lived a hobbit.
         
244

Primo Secondo Terzo Quarto Quinto ...
311(
Primo Secondo Terzo Quarto Quinto ...
400
let $para := 
In a hole in the ground there lived a hobbit.
         
71
let $para := 
In a hole in the ground there lived a hobbit.
         
244,
Primo Secondo Terzo Quarto Quinto ...
409
let $para := 
In a hole in the ground there lived a hobbit.
         
71
let $para := 
In a hole in the ground there lived a hobbit.
         
10)
let $para := 
In a hole in the ground there lived a hobbit.
         
71
let $para := 
In a hole in the ground there lived a hobbit.
         
244

Properties

This function is ·deterministic·, ·context-dependent·, and ·focus-independent·. It depends on static base URI.

Rules

The

Primo Secondo Terzo Quarto Quinto ...
400 argument must be a string in the form of a URI reference, which must contain no fragment identifier, and must identify a resource for which a string representation is available. If the URI is a relative URI reference, then it is resolved relative to the static base URI property from the static context.

The mapping of URIs to the string representation of a resource is the mapping defined in the available text resourcesXP31 component of the dynamic context.

If the value of the

Primo Secondo Terzo Quarto Quinto ...
400 argument is an empty sequence, the function returns an empty sequence.

The

Primo Secondo Terzo Quarto Quinto ...
409 argument, if present, is the name of an encoding. The values for this attribute follow the same rules as for the
Primo Secondo Terzo Quarto Quinto ...
417 attribute in an XML declaration. The only values which every ·implementation· is required to recognize are
Primo Secondo Terzo Quarto Quinto ...
418 and
Primo Secondo Terzo Quarto Quinto ...
419.

The encoding of the external resource is determined as follows:

  1. external encoding information is used if available, otherwise

  2. if the media type of the resource is

    Primo Secondo Terzo Quarto Quinto ...
    420 or
    Primo Secondo Terzo Quarto Quinto ...
    421 (see [RFC 2376]), or if it matches the conventions
    Primo Secondo Terzo Quarto Quinto ...
    422 or
    Primo Secondo Terzo Quarto Quinto ...
    423 (see [RFC 7303] and/or its successors), then the encoding is recognized as specified in [Extensible Markup Language (XML) 1.0 (Fifth Edition)], otherwise

  3. the value of the

    Primo Secondo Terzo Quarto Quinto ...
    409 argument is used if present, otherwise

  4. the processor may use ·implementation-defined· heuristics to determine the likely encoding, otherwise

  5. UTF-8 is assumed.

The result of the function is a string containing the string representation of the resource retrieved using the URI.

Error Conditions

A dynamic error is raised [err:FOUT1170] if

Primo Secondo Terzo Quarto Quinto ...
400 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 retrieve the string representation of a resource.

A dynamic error is raised [err:FOUT1190] if the value of the

Primo Secondo Terzo Quarto Quinto ...
409 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 into Unicode ·characters· using the specified encoding, or if the resulting characters are not permitted XML characters.

A dynamic error is raised [err:FOUT1200] if

Primo Secondo Terzo Quarto Quinto ...
409 is absent and the ·processor· cannot infer the encoding using external information and the encoding is not UTF-8.

Notes

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

op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
258 function before passing it to the
Primo Secondo Terzo Quarto Quinto ...
311 function.

There is no essential relationship between the sets of URIs accepted by the two functions

Primo Secondo Terzo Quarto Quinto ...
311 and
op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
09 (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).

There are no constraints on the MIME type of the resource.

The fact that the resolution of URIs is defined by a mapping in the dynamic context means that in effect, various aspects of the behavior of this function are ·implementation-defined·. Implementations may provide external configuration options that allow any aspect of the processing to be controlled by the user. In particular:

  • The set of URI schemes that the implementation recognizes is implementation-defined. Implementations may allow the mapping of URIs to resources to be configured by the user, using mechanisms such as catalogs or user-written URI handlers.

  • The handling of media types is implementation-defined.

  • Implementations may provide user-defined error handling options that allow processing to continue following an error in retrieving a resource, or in reading its content. When errors have been handled in this way, the function may return a fallback document provided by the error handler.

  • Implementations may provide user options that relax the requirement for the function to return deterministic results.

The rules for determining the encoding are chosen for consistency with [XML Inclusions (XInclude) Version 1.0 (Second Edition)]. Files with an XML media type are treated specially because there are use cases for this function where the retrieved text is to be included as unparsed XML within a CDATA section of a containing document, and because processors are likely to be able to reuse the code that performs encoding detection for XML external entities.

If the text file contains characters such as

Primo Secondo Terzo Quarto Quinto ...
432 and
Primo Secondo Terzo Quarto Quinto ...
433, these will typically be output as
Primo Secondo Terzo Quarto Quinto ...
434 and
Primo Secondo Terzo Quarto Quinto ...
435 if the string is serialized as XML or HTML. If these characters actually represent markup (for example, if the text file contains HTML), then an XSLT stylesheet can attempt to write them as markup to the output file using the
Primo Secondo Terzo Quarto Quinto ...
436 attribute of the
Primo Secondo Terzo Quarto Quinto ...
437 instruction. Note, however, that XSLT implementations are not required to support this feature.

Examples

This XSLT example attempts to read a file containing 'boilerplate' HTML and copy it directly to the serialized output file:

Primo Secondo Terzo Quarto Quinto ...
5

14.6.6 fn:unparsed-text-lines

Summary

The

Primo Secondo Terzo Quarto Quinto ...
313 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.

Signatures

Primo Secondo Terzo Quarto Quinto ...
313(
Primo Secondo Terzo Quarto Quinto ...
400
let $para := 
In a hole in the ground there lived a hobbit.
         
71
let $para := 
In a hole in the ground there lived a hobbit.
         
244)
let $para := 
In a hole in the ground there lived a hobbit.
         
71
let $para := 
In a hole in the ground there lived a hobbit.
         
234

Primo Secondo Terzo Quarto Quinto ...
313(
Primo Secondo Terzo Quarto Quinto ...
400
let $para := 
In a hole in the ground there lived a hobbit.
         
71
let $para := 
In a hole in the ground there lived a hobbit.
         
244,
Primo Secondo Terzo Quarto Quinto ...
409
let $para := 
In a hole in the ground there lived a hobbit.
         
71
let $para := 
In a hole in the ground there lived a hobbit.
         
10)
let $para := 
In a hole in the ground there lived a hobbit.
         
71
let $para := 
In a hole in the ground there lived a hobbit.
         
234

Properties

This function is ·deterministic·, ·context-dependent·, and ·focus-independent·. It depends on static base URI.

Rules

The

Primo Secondo Terzo Quarto Quinto ...
454 function reads an external resource (for example, a file) and returns its string representation as a sequence of strings, separated at newline boundaries.

The result of the single-argument function is the same as the result of the expression

Primo Secondo Terzo Quarto Quinto ...
455. The result of the two-argument function is the same as the result of the expression
Primo Secondo Terzo Quarto Quinto ...
456.

The result is thus a sequence of strings containing the text of the resource retrieved using the URI, each string representing one line of text. Lines are separated by one of the sequences x0A, x0D, or x0Dx0A. The characters representing the newline are not included in the returned strings. If there are two adjacent newline sequences, a zero-length string will be returned to represent the empty line; but if the external resource ends with the sequence x0A, x0D, or x0Dx0A, the result will be as if this final line ending were not present.

Error Conditions

Error conditions are the same as for the

Primo Secondo Terzo Quarto Quinto ...
311 function.

Notes

See the notes for

Primo Secondo Terzo Quarto Quinto ...
311.

14.6.7 fn:unparsed-text-available

Summary

Because errors in evaluating the

Primo Secondo Terzo Quarto Quinto ...
311 function are non-recoverable, these two functions are provided to allow an application to determine whether a call with particular arguments would succeed.

Signatures

Primo Secondo Terzo Quarto Quinto ...
315(
Primo Secondo Terzo Quarto Quinto ...
400
let $para := 
In a hole in the ground there lived a hobbit.
         
71
let $para := 
In a hole in the ground there lived a hobbit.
         
244)
let $para := 
In a hole in the ground there lived a hobbit.
         
71
op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
32

Primo Secondo Terzo Quarto Quinto ...
315(
Primo Secondo Terzo Quarto Quinto ...
400
let $para := 
In a hole in the ground there lived a hobbit.
         
71
let $para := 
In a hole in the ground there lived a hobbit.
         
244,
Primo Secondo Terzo Quarto Quinto ...
409
let $para := 
In a hole in the ground there lived a hobbit.
         
71
let $para := 
In a hole in the ground there lived a hobbit.
         
10)
let $para := 
In a hole in the ground there lived a hobbit.
         
71
op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
32

Properties

This function is ·deterministic·, ·context-dependent·, and ·focus-independent·. It depends on static base URI.

Rules

The

Primo Secondo Terzo Quarto Quinto ...
315 function determines whether a call on the
Primo Secondo Terzo Quarto Quinto ...
311 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

Primo Secondo Terzo Quarto Quinto ...
311 with the same arguments would succeed, and false if a call on
Primo Secondo Terzo Quarto Quinto ...
311 with the same arguments would fail with a non-recoverable dynamic error.

The functions

Primo Secondo Terzo Quarto Quinto ...
311 and
Primo Secondo Terzo Quarto Quinto ...
315 have the same requirement for ·determinism· as the functions
op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
09 and
Primo Secondo Terzo Quarto Quinto ...
306. 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
Primo Secondo Terzo Quarto Quinto ...
315 must be consistent with the results of a subsequent call on
Primo Secondo Terzo Quarto Quinto ...
484 with the same arguments.

Notes

This requires that the

Primo Secondo Terzo Quarto Quinto ...
315 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
Primo Secondo Terzo Quarto Quinto ...
311 or
Primo Secondo Terzo Quarto Quinto ...
313 function. Alternatively, implementations may be able to rewrite an expression such as
Primo Secondo Terzo Quarto Quinto ...
488 to generate a single call internally.

Since the function

Primo Secondo Terzo Quarto Quinto ...
313 succeeds or fails under exactly the same circumstances as
Primo Secondo Terzo Quarto Quinto ...
311, the
Primo Secondo Terzo Quarto Quinto ...
315 function may equally be used to test whether a call on
Primo Secondo Terzo Quarto Quinto ...
313 would succeed.

14.6.8 fn:environment-variable

Summary

Returns the value of a system environment variable, if it exists.

Signature

Primo Secondo Terzo Quarto Quinto ...
317(
Primo Secondo Terzo Quarto Quinto ...
494
let $para := 
In a hole in the ground there lived a hobbit.
         
71
let $para := 
In a hole in the ground there lived a hobbit.
         
10)
let $para := 
In a hole in the ground there lived a hobbit.
         
71
let $para := 
In a hole in the ground there lived a hobbit.
         
244

Properties

This function is ·deterministic·, ·context-dependent·, and ·focus-independent·. It depends on environment variables.

Rules

The set of available environment variablesXP31 is a set of (name, value) pairs forming part of the dynamic context, in which the name is unique within the set of pairs. The name and value are arbitrary strings.

If the

Primo Secondo Terzo Quarto Quinto ...
494 argument matches the name of one of these pairs, the function returns the corresponding value.

If there is no environment variable with a matching name, the function returns the empty sequence.

The collation used for matching names is ·implementation-defined·, but must be the same as the collation used to ensure that the names of all environment variables are unique.

The function is ·deterministic·, which means that if it is called several times within the same ·execution scope·, with the same arguments, it must return the same result.

Notes

On many platforms, the term "environment variable" has a natural meaning in terms of facilities provided by the operating system. This interpretation of the concept does not exclude other interpretations, such as a mapping to a set of configuration parameters in a database system.

Environment variable names are usually case sensitive. Names are usually of the form

Primo Secondo Terzo Quarto Quinto ...
500, but this varies by platform.

On some platforms, there may sometimes be multiple environment variables with the same name; in this case, it is implementation-dependent as to which is returned; see for example [POSIX.1-2008] (Chapter 8, Environment Variables). Implementations may use prefixes or other naming conventions to disambiguate the names.

The requirement to ensure that the function is deterministic means in practice that the implementation must make a snapshot of the environment variables at some time during execution, and return values obtained from this snapshot, rather than using live values that are subject to change at any time.

Operating system environment variables may be associated with a particular process, while queries and stylesheets may execute across multiple processes (or multiple machines). In such circumstances implementations may choose to provide access to the environment variables associated with the process in which the query or stylesheet processing was initiated.

Security advice: Queries from untrusted sources should not be permitted unrestricted 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

Primo Secondo Terzo Quarto Quinto ...
317 always return the empty sequence.

14.6.9 fn:available-environment-variables

Summary

Returns a list of environment variable names that are suitable for passing to

Primo Secondo Terzo Quarto Quinto ...
317, as a (possibly empty) sequence of strings.

Signature

Primo Secondo Terzo Quarto Quinto ...
318()
let $para := 
In a hole in the ground there lived a hobbit.
         
71
let $para := 
In a hole in the ground there lived a hobbit.
         
234

Properties

This function is ·deterministic·, ·context-dependent·, and ·focus-independent·. It depends on environment variables.

Rules

The function returns a sequence of strings, being the names of the environment variables in the dynamic context in some ·implementation-dependent· order.

The function is ·deterministic·: that is, the set of available environment variables does not vary during evaluation.

Notes

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

Primo Secondo Terzo Quarto Quinto ...
317.

See also the note on security under the definition of the

Primo Secondo Terzo Quarto Quinto ...
317 function. If access to environment variables has been disabled,
Primo Secondo Terzo Quarto Quinto ...
318 always returns the empty sequence.

14.7 Parsing and serializing

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

FunctionMeaning
op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
19This function takes as input an XML document represented as a string, and returns the document node at the root of an XDM tree representing the parsed document.
op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
20This function takes as input an XML external entity represented as a string, and returns the document node at the root of an XDM tree representing the parsed document fragment.
Primo Secondo Terzo Quarto Quinto ...
511This function serializes the supplied input sequence
let $para := 
In a hole in the ground there lived a hobbit.
         
25 as described in [XSLT and XQuery Serialization 3.1], returning the serialized representation of the sequence as a string.

14.7.1 fn:parse-xml

Summary

This function takes as input an XML document represented as a string, and returns the document node at the root of an XDM tree representing the parsed document.

Signature

op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
19(
let $para := 
In a hole in the ground there lived a hobbit.
         
25
let $para := 
In a hole in the ground there lived a hobbit.
         
71
let $para := 
In a hole in the ground there lived a hobbit.
         
244)
let $para := 
In a hole in the ground there lived a hobbit.
         
71
Primo Secondo Terzo Quarto Quinto ...
518

Properties

This function is ·nondeterministic·, ·context-dependent·, and ·focus-independent·. It depends on static base URI.

Rules

If

let $para := 
In a hole in the ground there lived a hobbit.
         
25 is the empty sequence, the function returns the empty sequence.

The precise process used to construct the XDM instance is ·implementation-defined·. In particular, it is implementation-defined whether DTD and/or schema validation is invoked, and it is implementation-defined whether an XML 1.0 or XML 1.1 parser is used.

The static base URI property from the static context of the

op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
19 function call is used both as the base URI used by the XML parser to resolve relative entity references within the document, and as the base URI of the document node that is returned.

The document URI of the returned node is ·absent·.

The function is not ·deterministic·: that is, if the function is called twice with the same arguments, it is ·implementation-dependent· whether the same node is returned on both occasions.

Error Conditions

A dynamic error is raised [err:FODC0006] if the content of

let $para := 
In a hole in the ground there lived a hobbit.
         
25 is not a well-formed and namespace-well-formed XML document.

A dynamic error is raised [err:FODC0006] if DTD-based validation is carried out and the content of

let $para := 
In a hole in the ground there lived a hobbit.
         
25 is not valid against its DTD.

Notes

Since the XML document is presented to the parser as a string, rather than as a sequence of octets, the encoding specified within the XML declaration has no meaning. If the XML parser accepts input only in the form of a sequence of octets, then the processor must ensure that the string is encoded as octets in a way that is consistent with rules used by the XML parser to detect the encoding.

The primary 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

op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
19 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 services or read from databases.

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

Primo Secondo Terzo Quarto Quinto ...
311 function, editing the resulting string, and then passing it to the
op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
19 function.

Examples

The expression

Primo Secondo Terzo Quarto Quinto ...
526 returns a newly created document node, having an
Primo Secondo Terzo Quarto Quinto ...
527 element as its only child; the
Primo Secondo Terzo Quarto Quinto ...
527 element in turn is the parent of a text node whose string value is
Primo Secondo Terzo Quarto Quinto ...
529.

14.7.2 fn:parse-xml-fragment

Summary

This function takes as input an XML external entity represented as a string, and returns the document node at the root of an XDM tree representing the parsed document fragment.

Signature

op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
20(
let $para := 
In a hole in the ground there lived a hobbit.
         
25
let $para := 
In a hole in the ground there lived a hobbit.
         
71
let $para := 
In a hole in the ground there lived a hobbit.
         
244)
let $para := 
In a hole in the ground there lived a hobbit.
         
71
Primo Secondo Terzo Quarto Quinto ...
326

Properties

This function is ·nondeterministic·, ·context-dependent·, and ·focus-independent·. It depends on static base URI.

Rules

If

let $para := 
In a hole in the ground there lived a hobbit.
         
25 is the empty sequence, the function returns the empty sequence.

The input must be a namespace-well-formed external general parsed entity. More specifically, it must be a string conforming to the production rule extParsedEntxml in [Extensible Markup Language (XML) 1.0 (Fifth Edition)], it must contain no entity references other than references to predefined entities, and it must satisfy all the rules of [Namespaces in XML] for namespace-well-formed documents with the exception that the rule requiring it to be a well-formed document is replaced by the rule requiring it to be a well-formed external general parsed entity.

The string is parsed to form a sequence of nodes which become children of the new document node, in the same way as the content of any element is converted into a sequence of children for the resulting element node.

Schema validation is not invoked, which means that the nodes in the returned document will all be untyped.

The precise process used to construct the XDM instance is ·implementation-defined·. In particular, it is implementation-defined whether an XML 1.0 or XML 1.1 parser is used.

The static base URI from the static context of the

op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
20 function call is used as the base URI of the document node that is returned.

The document URI of the returned node is ·absent·.

The function is not ·deterministic·: that is, if the function is called twice with the same arguments, it is ·implementation-dependent· whether the same node is returned on both occasions.

Error Conditions

A dynamic error is raised [err:FODC0006] if the content of

let $para := 
In a hole in the ground there lived a hobbit.
         
25 is not a well-formed external general parsed entity, if it contains entity references other than references to predefined entities, or if a document that incorporates this well-formed parsed entity would not be namespace-well-formed.

Notes

See also the notes for the

op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
19 function.

The main differences between

op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
19 and
op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
20 are that for
op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
19, the children of the resulting document node must contain exactly one element node and no text nodes, wheras for
op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
20, 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 the start of a well-formed document.

Note that all whitespace outside the text declaration is significant, including whitespace that precedes the first element node.

One use case for this function is to handle XML fragments stored in databases, which frequently allow zero-or-more top level element nodes. Another use case is to parse the contents of a

Primo Secondo Terzo Quarto Quinto ...
544 section embedded within another XML document.

Examples

The expression

Primo Secondo Terzo Quarto Quinto ...
545 returns a newly created document node, having two elements named
Primo Secondo Terzo Quarto Quinto ...
527 and
Primo Secondo Terzo Quarto Quinto ...
547 as its children; each of these elements in turn is the parent of a text node.

The expression

Primo Secondo Terzo Quarto Quinto ...
548 returns a newly created document node having three children: a text node whose string value is
Primo Secondo Terzo Quarto Quinto ...
549, an element node named
let $para := 
In a hole in the ground there lived a hobbit.
         
274 having a child text node with string value
Primo Secondo Terzo Quarto Quinto ...
551, and a text node whose string value is
Primo Secondo Terzo Quarto Quinto ...
552.

The expression

Primo Secondo Terzo Quarto Quinto ...
553 returns a document node having no children.

The expression

Primo Secondo Terzo Quarto Quinto ...
554 returns a document node whose children comprise a single text node whose string value is a single space.

The expression

Primo Secondo Terzo Quarto Quinto ...
555 results in a dynamic error [err:FODC0006] 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
op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
19 function will also be accepted by
op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
20.)

14.7.3 fn:serialize

Summary

This function serializes the supplied input sequence

let $para := 
In a hole in the ground there lived a hobbit.
         
25 as described in [XSLT and XQuery Serialization 3.1], returning the serialized representation of the sequence as a string.

Signatures

Primo Secondo Terzo Quarto Quinto ...
511(
let $para := 
In a hole in the ground there lived a hobbit.
         
25
let $para := 
In a hole in the ground there lived a hobbit.
         
71
op:operation(fenceHeight, xs:integer) => op:operation(xs:integer, xs:integer)
16)
let $para := 
In a hole in the ground there lived a hobbit.
         
71
let $para := 
In a hole in the ground there lived a hobbit.
         
10

Primo Secondo Terzo Quarto Quinto ...
511(
let $para := 
In a hole in the ground there lived a hobbit.
         
25
let $para := 
In a hole in the ground there lived a hobbit.
         
71
op:operation(fenceHeight, xs:integer) => op:operation(xs:integer, xs:integer)
16,
Primo Secondo Terzo Quarto Quinto ...
569
let $para := 
In a hole in the ground there lived a hobbit.
         
71
let $para := 
In a hole in the ground there lived a hobbit.
         
79)
let $para := 
In a hole in the ground there lived a hobbit.
         
71
let $para := 
In a hole in the ground there lived a hobbit.
         
10

Properties

This function is ·deterministic·, ·context-independent·, and ·focus-independent·.

Rules

The value of the first argument

let $para := 
In a hole in the ground there lived a hobbit.
         
25 acts as the input sequence to the serialization process, which starts with sequence normalization.

The second argument

Primo Secondo Terzo Quarto Quinto ...
569, if present, provides serialization parameters. These may be supplied in either of two forms:

  1. As an

    Primo Secondo Terzo Quarto Quinto ...
    576 element, having the format described in Section 3.1 Setting Serialization Parameters by Means of a Data Model Instance SER31. In this case the type of the supplied argument must match the required type
    Primo Secondo Terzo Quarto Quinto ...
    577.

  2. As a map. In this case the type of the supplied argument must match the required type

    let $para := 
    In a hole in the ground there lived a hobbit.
             
    32

The single-argument version of this function has the same effect as the two-argument version called with

Primo Secondo Terzo Quarto Quinto ...
569 set to an empty sequence. This in turn is the same as the effect of passing an
Primo Secondo Terzo Quarto Quinto ...
576 element with no child elements.

The final stage of serialization, that is, encoding, is skipped. If the serializer does not allow this phase to be skipped, then the sequence of octets returned by the serializer is decoded into a string by reversing the character encoding performed in the final stage.

If the second argument is omitted, or is supplied in the form of an

Primo Secondo Terzo Quarto Quinto ...
576 element, then the values of any serialization parameters that are not explicitly specified is ·implementation-defined·, and may depend on the context.

If the second argument is supplied as a map, then the ·option parameter conventions· apply. In this case:

  1. Each entry in the map defines one serialization parameter.

  2. The key of the entry is an

    let $para := 
    In a hole in the ground there lived a hobbit.
             
    10 value in the cases of parameter names defined in these specifications, or an
    let $para := 
    In a hole in the ground there lived a hobbit.
             
    36 (with non-absent namespace) in the case of implementation-defined serialization parameters.

  3. The required type of each parameter, and its default value, are defined by the following table. The default value is used when the map contains no entry for the parameter in question, and also when an entry is present, with the empty sequence as its value. The table also indicates how the value of the map entry is to be interpreted in cases where further explanation is needed.

ParameterRequired typeInterpretationDefault Value
Primo Secondo Terzo Quarto Quinto ...
584
op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
63
let $para := 
In a hole in the ground there lived a hobbit.
         
182 means "yes",
let $para := 
In a hole in the ground there lived a hobbit.
         
184 means "no"
let $para := 
In a hole in the ground there lived a hobbit.
         
095
Primo Secondo Terzo Quarto Quinto ...
589
op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
63
let $para := 
In a hole in the ground there lived a hobbit.
         
182 means "yes",
let $para := 
In a hole in the ground there lived a hobbit.
         
184 means "no"
let $para := 
In a hole in the ground there lived a hobbit.
         
095
Primo Secondo Terzo Quarto Quinto ...
594
Primo Secondo Terzo Quarto Quinto ...
595
let $para := 
In a hole in the ground there lived a hobbit.
         
96
Primo Secondo Terzo Quarto Quinto ...
597
let $para := 
In a hole in the ground there lived a hobbit.
         
244Zero-length string and
let $para := 
In a hole in the ground there lived a hobbit.
         
96 both represent "absent"absent
Primo Secondo Terzo Quarto Quinto ...
600
let $para := 
In a hole in the ground there lived a hobbit.
         
244Zero-length string and
let $para := 
In a hole in the ground there lived a hobbit.
         
96 both represent "absent"absent
Primo Secondo Terzo Quarto Quinto ...
417
let $para := 
In a hole in the ground there lived a hobbit.
         
244
Primo Secondo Terzo Quarto Quinto ...
418
Primo Secondo Terzo Quarto Quinto ...
606
op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
63
let $para := 
In a hole in the ground there lived a hobbit.
         
182 means "yes",
let $para := 
In a hole in the ground there lived a hobbit.
         
184 means "no"
let $para := 
In a hole in the ground there lived a hobbit.
         
097
Primo Secondo Terzo Quarto Quinto ...
611
op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
728
declare %public function r:random-sequence($length as xs:integer) as xs:double* {
  r:random-sequence($length, fn:random-number-generator())
};

declare %private function r:random-sequence($length as xs:integer, 
                                            $G as map(xs:string, item())) {
  if ($length eq 0)
  then ()
  else ($G?number, r:random-sequence($length - 1, $G?next()))
};

r:random-sequence(200);
            
21
Primo Secondo Terzo Quarto Quinto ...
614
op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
63
let $para := 
In a hole in the ground there lived a hobbit.
         
182 means "yes",
let $para := 
In a hole in the ground there lived a hobbit.
         
184 means "no"
let $para := 
In a hole in the ground there lived a hobbit.
         
097
Primo Secondo Terzo Quarto Quinto ...
619
op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
63
let $para := 
In a hole in the ground there lived a hobbit.
         
182 means "yes",
let $para := 
In a hole in the ground there lived a hobbit.
         
184 means "no"
let $para := 
In a hole in the ground there lived a hobbit.
         
095
Primo Secondo Terzo Quarto Quinto ...
624
let $para := 
In a hole in the ground there lived a hobbit.
         
244absent
Primo Secondo Terzo Quarto Quinto ...
626
Primo Secondo Terzo Quarto Quinto ...
627See Notes 1, 2
Primo Secondo Terzo Quarto Quinto ...
628
Primo Secondo Terzo Quarto Quinto ...
629
let $para := 
In a hole in the ground there lived a hobbit.
         
244(a media type suitable for the chosen
Primo Secondo Terzo Quarto Quinto ...
631)
Primo Secondo Terzo Quarto Quinto ...
631
Primo Secondo Terzo Quarto Quinto ...
627See Notes 1, 2
Primo Secondo Terzo Quarto Quinto ...
628
Primo Secondo Terzo Quarto Quinto ...
635
let $para := 
In a hole in the ground there lived a hobbit.
         
244
op:operation(fenceHeight, xs:integer) => op:operation(xs:integer, xs:integer)
90
Primo Secondo Terzo Quarto Quinto ...
638
op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
63
let $para := 
In a hole in the ground there lived a hobbit.
         
182 means "yes",
let $para := 
In a hole in the ground there lived a hobbit.
         
184 means "no"
let $para := 
In a hole in the ground there lived a hobbit.
         
097
Primo Secondo Terzo Quarto Quinto ...
643
op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
63
let $para := 
In a hole in the ground there lived a hobbit.
         
182 means "yes",
let $para := 
In a hole in the ground there lived a hobbit.
         
184 means "no",
let $para := 
In a hole in the ground there lived a hobbit.
         
96 means "omit"
Primo Secondo Terzo Quarto Quinto ...
648
Primo Secondo Terzo Quarto Quinto ...
649
Primo Secondo Terzo Quarto Quinto ...
595
let $para := 
In a hole in the ground there lived a hobbit.
         
96
Primo Secondo Terzo Quarto Quinto ...
652
op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
63
let $para := 
In a hole in the ground there lived a hobbit.
         
182 means "yes",
let $para := 
In a hole in the ground there lived a hobbit.
         
184 means "no"
let $para := 
In a hole in the ground there lived a hobbit.
         
095
Primo Secondo Terzo Quarto Quinto ...
657
Primo Secondo Terzo Quarto Quinto ...
658See Note 3
Primo Secondo Terzo Quarto Quinto ...
659
Primo Secondo Terzo Quarto Quinto ...
660
let $para := 
In a hole in the ground there lived a hobbit.
         
244
Primo Secondo Terzo Quarto Quinto ...
662

Notes to the table:

  1. The notation

    let $para := 
    In a hole in the ground there lived a hobbit.
             
    52 is used to represent a union type whose member types are
    let $para := 
    In a hole in the ground there lived a hobbit.
             
    51 and
    1º 2º 3º 4º ...
    558.

  2. If an

    let $para := 
    In a hole in the ground there lived a hobbit.
             
    36 is supplied for the
    Primo Secondo Terzo Quarto Quinto ...
    631 or
    Primo Secondo Terzo Quarto Quinto ...
    626 options,
    then it must have a non-absent namespace URI. This means that system-defined serialization methods such as
    Primo Secondo Terzo Quarto Quinto ...
    628 and
    Primo Secondo Terzo Quarto Quinto ...
    670 are defined as strings, not as
    let $para := 
    In a hole in the ground there lived a hobbit.
             
    36 values.

  3. For the

    Primo Secondo Terzo Quarto Quinto ...
    657 option, the value is a map, whose keys are the characters to be mapped (as
    let $para := 
    In a hole in the ground there lived a hobbit.
             
    10 instances), and whose corresponding values are the strings to be substituted for these characters.

Error Conditions

A type error [err:XPTY0004]XP31 occurs if the second argument is present and does not match either of the types

Primo Secondo Terzo Quarto Quinto ...
674 or
let $para := 
In a hole in the ground there lived a hobbit.
         
32.

Note:

This is defined as a type error so that it can be enforced via the function signature by implementations that generalize the type system in a suitable way.

If the host language makes serialization an optional feature and the implementation does not support serialization, then a dynamic error [err:FODC0010] is raised.

The serialization process will raise an error if

let $para := 
In a hole in the ground there lived a hobbit.
         
25 is an attribute or namespace node.

When the second argument is supplied as a map, and the supplied value is of the wrong type for the particular parameter, for example if the value of

Primo Secondo Terzo Quarto Quinto ...
619 is a string rather than a boolean, then as defined by the ·option parameter conventions·, a type error [err:XPTY0004]XP31 is raised. If the value is of the correct type, but does not satisfy the rules for that parameter defined in [XSLT and XQuery Serialization 3.1], then a dynamic error [err:SEPM0016]SER31 is raised. (For example, this occurs if the map supplied to
Primo Secondo Terzo Quarto Quinto ...
657 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

Primo Secondo Terzo Quarto Quinto ...
511 call failing with a dynamic error.

Notes

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

op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
19 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.

There are also use cases where the application wants to post-process the output of a query or transformation, for example by adding an internal DTD subset, or by inserting proprietary markup delimiters such as the

Primo Secondo Terzo Quarto Quinto ...
681 used by some templating languages.

The ability to specify the serialization parameters in an

Primo Secondo Terzo Quarto Quinto ...
576 element provides backwards compatibility with the 3.0 version of this specification; the ability to use a map takes advantage of new features in the 3.1 version. The default parameter values are implementation-defined when an
Primo Secondo Terzo Quarto Quinto ...
576 element is used (or when the argument is omitted), but are fixed by this specification in the case where a map (including an empty map) is supplied for the argument.

Examples

Given the variables:

Primo Secondo Terzo Quarto Quinto ...
6

Primo Secondo Terzo Quarto Quinto ...
7

The following call might produce the output shown:

The expression

Primo Secondo Terzo Quarto Quinto ...
684 returns
Primo Secondo Terzo Quarto Quinto ...
685.

The following call would also produce the output shown (though the second argument could equally well be supplied as an empty map (

Primo Secondo Terzo Quarto Quinto ...
659), since both parameters are given their default values):

The expression

Primo Secondo Terzo Quarto Quinto ...
687 returns
Primo Secondo Terzo Quarto Quinto ...
685.

15 Context functions

The following functions are defined to obtain information from the static or dynamic context.

FunctionMeaning
Primo Secondo Terzo Quarto Quinto ...
689Returns the context position from the dynamic context.
Primo Secondo Terzo Quarto Quinto ...
690Returns the context size from the dynamic context.
let $para := 
In a hole in the ground there lived a hobbit.
         
69Returns the current date and time (with timezone).
let $para := 
In a hole in the ground there lived a hobbit.
         
80Returns the current date.
let $para := 
In a hole in the ground there lived a hobbit.
         
82Returns the current time.
let $para := 
In a hole in the ground there lived a hobbit.
         
84Returns the value of the implicit timezone property from the dynamic context.
op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
07Returns the value of the default collation property from the static context.
let $para := 
In a hole in the ground there lived a hobbit.
         
83Returns the value of the default language property from the dynamic context.
op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
08This function returns the value of the static base URI property from the static context.

15.1 fn:position

Summary

Returns the context position from the dynamic context.

Signature

Primo Secondo Terzo Quarto Quinto ...
689()
let $para := 
In a hole in the ground there lived a hobbit.
         
71
let $para := 
In a hole in the ground there lived a hobbit.
         
85

Properties

This function is ·deterministic·, ·context-dependent·, and ·focus-dependent·.

Rules

Returns the context position from the dynamic context. (See Section C.2 Dynamic Context Components XP31.)

Error Conditions

A dynamic error is raised [err:XPDY0002]XP31 if the context item is absentDM31.

15.2 fn:last

Summary

Returns the context size from the dynamic context.

Signature

Primo Secondo Terzo Quarto Quinto ...
690()
let $para := 
In a hole in the ground there lived a hobbit.
         
71
let $para := 
In a hole in the ground there lived a hobbit.
         
85

Properties

This function is ·deterministic·, ·context-dependent·, and ·focus-dependent·.

Rules

Returns the context size from the dynamic context. (See Section C.2 Dynamic Context Components XP31.)

Error Conditions

A dynamic error is raised [err:XPDY0002]XP31 if the context size is absentDM31.

Notes

Under most circumstances, the context size is absent only if the context item is absent. However, XSLT 3.0 with streaming defines situations in which the context item and context position are known, but the context size is unknown.

Examples

The expression

Primo Secondo Terzo Quarto Quinto ...
704 returns
Primo Secondo Terzo Quarto Quinto ...
705.

15.3 fn:current-dateTime

Summary

Returns the current date and time (with timezone).

Signature

let $para := 
In a hole in the ground there lived a hobbit.
         
69()
let $para := 
In a hole in the ground there lived a hobbit.
         
71
let $para := 
In a hole in the ground there lived a hobbit.
         
23

Properties

This function is ·deterministic·, ·context-dependent·, and ·focus-independent·. It depends on implicit timezone.

Rules

Returns the current dateTime (with timezone) from the dynamic context. (See Section C.2 Dynamic Context Components XP31.) This is an

let $para := 
In a hole in the ground there lived a hobbit.
         
29 that is current at some time during the evaluation of a query or transformation in which
let $para := 
In a hole in the ground there lived a hobbit.
         
69 is executed.

This function is ·deterministic·. The precise instant during the query or transformation represented by the value of

let $para := 
In a hole in the ground there lived a hobbit.
         
019 is ·implementation-dependent·.

If the implementation supports data types from XSD 1.1 then the returned value will be an instance of

let $para := 
In a hole in the ground there lived a hobbit.
         
23. Otherwise, the only guarantees are that it will be an instance of
let $para := 
In a hole in the ground there lived a hobbit.
         
29 and will have a timezone component.

Notes

The returned

let $para := 
In a hole in the ground there lived a hobbit.
         
29 will always have an associated timezone, which will always be the same as the implicit timezone in the dynamic context

Examples

let $para := 
In a hole in the ground there lived a hobbit.
         
019 returns an
let $para := 
In a hole in the ground there lived a hobbit.
         
23 corresponding to the current date and time. For example, a call of
let $para := 
In a hole in the ground there lived a hobbit.
         
019 might return
Primo Secondo Terzo Quarto Quinto ...
718 corresponding to the current time on May 12, 2004 in timezone
fn:abs($N * $arg2) le fn:abs($arg1) 
               and fn:compare($N * $arg2, 0) eq fn:compare($arg1, 0).
073.

15.4 fn:current-date

Summary

Returns the current date.

Signature

let $para := 
In a hole in the ground there lived a hobbit.
         
80()
let $para := 
In a hole in the ground there lived a hobbit.
         
71
op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
964

Properties

This function is ·deterministic·, ·context-dependent·, and ·focus-independent·. It depends on implicit timezone.

Rules

Returns

Primo Secondo Terzo Quarto Quinto ...
723. This is an
op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
964 (with timezone) that is current at some time during the evaluation of a query or transformation in which
let $para := 
In a hole in the ground there lived a hobbit.
         
80 is executed.

This function is ·deterministic·. The precise instant during the query or transformation represented by the value of

let $para := 
In a hole in the ground there lived a hobbit.
         
80 is ·implementation-dependent·.

Notes

The returned date will always have an associated timezone, which will always be the same as the implicit timezone in the dynamic context

Examples

Primo Secondo Terzo Quarto Quinto ...
727 returns an
op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
964 corresponding to the current date. For example, a call of
Primo Secondo Terzo Quarto Quinto ...
727 might return
Primo Secondo Terzo Quarto Quinto ...
730.

15.5 fn:current-time

Summary

Returns the current time.

Signature

let $para := 
In a hole in the ground there lived a hobbit.
         
82()
let $para := 
In a hole in the ground there lived a hobbit.
         
71
op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
965

Properties

This function is ·deterministic·, ·context-dependent·, and ·focus-independent·. It depends on implicit timezone.

Rules

Returns

Primo Secondo Terzo Quarto Quinto ...
734. This is an
op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
965 (with timezone) that is current at some time during the evaluation of a query or transformation in which
let $para := 
In a hole in the ground there lived a hobbit.
         
82 is executed.

This function is ·deterministic·. The precise instant during the query or transformation represented by the value of

Primo Secondo Terzo Quarto Quinto ...
737 is ·implementation-dependent·.

Notes

The returned time will always have an associated timezone, which will always be the same as the implicit timezone in the dynamic context

Examples

Primo Secondo Terzo Quarto Quinto ...
737 returns an
op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
965 corresponding to the current time. For example, a call of
Primo Secondo Terzo Quarto Quinto ...
737 might return
Primo Secondo Terzo Quarto Quinto ...
741.

15.6 fn:implicit-timezone

Summary

Returns the value of the implicit timezone property from the dynamic context.

Signature

let $para := 
In a hole in the ground there lived a hobbit.
         
84()
let $para := 
In a hole in the ground there lived a hobbit.
         
71
let $para := 
In a hole in the ground there lived a hobbit.
         
25

Properties

This function is ·deterministic·, ·context-dependent·, and ·focus-independent·. It depends on implicit timezone.

Rules

Returns the value of the implicit timezone property from the dynamic context. Components of the dynamic context are described in Section C.2 Dynamic Context Components XP31.

15.7 fn:default-collation

Summary

Returns the value of the default collation property from the static context.

Signature

op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
07()
let $para := 
In a hole in the ground there lived a hobbit.
         
71
let $para := 
In a hole in the ground there lived a hobbit.
         
10

Properties

This function is ·deterministic·, ·context-dependent·, and ·focus-independent·. It depends on collations.

Rules

Returns the value of the default collation property from the static context. Components of the static context are described in Section C.1 Static Context Components XP31.

Notes

The default collation property can never be absent. If it is not explicitly defined, a system defined default can be invoked. If this is not provided, the Unicode codepoint collation (

let $para := 
In a hole in the ground there lived a hobbit.
         
078) is used.

15.8 fn:default-language

Summary

Returns the value of the default language property from the dynamic context.

Signature

let $para := 
In a hole in the ground there lived a hobbit.
         
83()
let $para := 
In a hole in the ground there lived a hobbit.
         
71
let $para := 
In a hole in the ground there lived a hobbit.
         
101

Properties

This function is ·deterministic·, ·context-dependent·, and ·focus-independent·. It depends on default language.

Rules

Returns the value of the default language property from the dynamic context. Components of the dynamic context are described in Section 2.1.2 Dynamic Context XP31.

Notes

The default language property can never be absent. The functions

let $para := 
In a hole in the ground there lived a hobbit.
         
225,
fn:abs($N * $arg2) le fn:abs($arg1) 
               and fn:compare($N * $arg2, 0) eq fn:compare($arg1, 0).
342,
fn:abs($N * $arg2) le fn:abs($arg1) 
               and fn:compare($N * $arg2, 0) eq fn:compare($arg1, 0).
344, and
fn:abs($N * $arg2) le fn:abs($arg1) 
               and fn:compare($N * $arg2, 0) eq fn:compare($arg1, 0).
340 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.

15.9 fn:static-base-uri

Summary

This function returns the value of the static base URI property from the static context.

Signature

op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
08()
let $para := 
In a hole in the ground there lived a hobbit.
         
71
op:operation(fenceHeight, xs:integer) => op:operation(xs:integer, xs:integer)
44

Properties

This function is ·deterministic·, ·context-dependent·, and ·focus-independent·. It depends on static base URI.

Rules

The function returns the value of the static base URI property from the static context. If the property is absent, the empty sequence is returned.

Components of the static context are described in Section 2.1.1 Static Context XP31 .

Notes

XQuery 3.0 and XSLT 3.0 give an implementation freedom to use different base URIs during the static analysis phase and the dynamic evaluation phase, that is, for compile-time 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

op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
08 function should return a URI suitable for locating resources needed during dynamic evaluation.

16 Higher-order functions

16.1 Functions on functions

The functions included in this section operate on function items, that is, values referring to a function.

[Definition] Functions that accept functions among their arguments, or that return functions in their result, are described in this specification as higher-order functions. 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.

Note:

Some functions such as

Primo Secondo Terzo Quarto Quinto ...
760 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.

FunctionMeaning
let $para := 
In a hole in the ground there lived a hobbit.
         
77Returns the function having a given name and arity, if there is one.
let $para := 
In a hole in the ground there lived a hobbit.
         
90Returns the name of the function identified by a function item.
Primo Secondo Terzo Quarto Quinto ...
763Returns the arity of the function identified by a function item.

16.1.1 fn:function-lookup

Summary

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

Signature

let $para := 
In a hole in the ground there lived a hobbit.
         
77(
Primo Secondo Terzo Quarto Quinto ...
494
let $para := 
In a hole in the ground there lived a hobbit.
         
71
let $para := 
In a hole in the ground there lived a hobbit.
         
36,
Primo Secondo Terzo Quarto Quinto ...
768
let $para := 
In a hole in the ground there lived a hobbit.
         
71
let $para := 
In a hole in the ground there lived a hobbit.
         
85)
let $para := 
In a hole in the ground there lived a hobbit.
         
71
Primo Secondo Terzo Quarto Quinto ...
772

Properties

This function is ·deterministic·, ·context-dependent·, ·focus-dependent·, and ·higher-order·.

Rules

A call to

let $para := 
In a hole in the ground there lived a hobbit.
         
77 returns the function obtained by looking up the expanded QName supplied as
Primo Secondo Terzo Quarto Quinto ...
494 and the arity supplied as
Primo Secondo Terzo Quarto Quinto ...
768 in the named functions component of the dynamic context (specifically, the dynamic context of the call to
let $para := 
In a hole in the ground there lived a hobbit.
         
77).

Furthermore, if that function has an implementation-dependent implementation (see note below), then the implementation of the function returned by

let $para := 
In a hole in the ground there lived a hobbit.
         
77 is associated with the static and dynamic context of the call to
let $para := 
In a hole in the ground there lived a hobbit.
         
77.

Note:

The above rule deliberately uses the same wording as the corresponding rule for Named Function References. The term "a function [with] an implementation-dependent implementation" essentially means a function whose implementation is provided by the language processor rather than by the stylesheet or query author. This rule is therefore relevant to built-in functions and vendor-supplied extension functions whose result depends on the context of the function call.

Otherwise (if no known function can be identified by name and arity), an empty sequence is returned.

If the arguments to

let $para := 
In a hole in the ground there lived a hobbit.
         
77 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 dynamic context, which is ·implementation-defined·.

Notes

This function can be useful where there is a need to make a dynamic decision on which of several statically-known functions to call. It can thus be used as a substitute for polymorphism, in the case where the application has been designed so several functions implement the same interface.

The function can also be useful in cases where a query or stylesheet module is written to work with alternative versions of a library module. In such cases the author of the main module might wish to test whether an imported library module contains or does not 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

let $para := 
In a hole in the ground there lived a hobbit.
         
77 allows the caller to take fallback action in this situation.

If the function that is retrieved by

let $para := 
In a hole in the ground there lived a hobbit.
         
77 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
let $para := 
In a hole in the ground there lived a hobbit.
         
77 function itself. The context thus effectively forms part of the closure of the returned function. In practice this applies only where the target of
let $para := 
In a hole in the ground there lived a hobbit.
         
77 is a built-in function, because user-defined functions never depend on the static or dynamic context of the function call. The rule applies recursively, since
let $para := 
In a hole in the ground there lived a hobbit.
         
77 is itself a context-dependent built-in 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 to the dynamic context. Equally, these specifications do not define any mechanism for creating context-dependent functions other than the built-in context-dependent functions, but neither do they rule out the existence of such functions.

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

Primo Secondo Terzo Quarto Quinto ...
785 function are not added to the dynamic context.

Examples

The expression

Primo Secondo Terzo Quarto Quinto ...
786 returns
Primo Secondo Terzo Quarto Quinto ...
787.

The expression

Primo Secondo Terzo Quarto Quinto ...
788 returns an
let $para := 
In a hole in the ground there lived a hobbit.
         
29 value set to the specified date, time, and timezone; if the implementation supports XSD 1.1 then the result will be an instance of the derived type
let $para := 
In a hole in the ground there lived a hobbit.
         
23. The query is written to ensure that no failure occurs when the implementation does not recognize the type
let $para := 
In a hole in the ground there lived a hobbit.
         
23.

The expression

Primo Secondo Terzo Quarto Quinto ...
792 returns the result of calling
Primo Secondo Terzo Quarto Quinto ...
793 if the function is available, or an empty sequence otherwise.

16.1.2 fn:function-name

Summary

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

Signature

let $para := 
In a hole in the ground there lived a hobbit.
         
90(
Primo Secondo Terzo Quarto Quinto ...
795
let $para := 
In a hole in the ground there lived a hobbit.
         
71
Primo Secondo Terzo Quarto Quinto ...
797)
let $para := 
In a hole in the ground there lived a hobbit.
         
71
op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
47

Properties

This function is ·deterministic·, ·context-independent·, ·focus-independent·, and ·higher-order·.

Rules

If

Primo Secondo Terzo Quarto Quinto ...
795 refers to a named function,
Primo Secondo Terzo Quarto Quinto ...
801 returns the name of that function.

Otherwise (

Primo Secondo Terzo Quarto Quinto ...
795 refers to an anonymous function),
Primo Secondo Terzo Quarto Quinto ...
801 returns an empty sequence.

The prefix part of the returned QName is ·implementation-dependent·.

Examples

The expression

Primo Secondo Terzo Quarto Quinto ...
804 returns
Primo Secondo Terzo Quarto Quinto ...
805. (The namespace prefix of the returned QName is not predictable.)

The expression

Primo Secondo Terzo Quarto Quinto ...
806 returns
let $para := 
In a hole in the ground there lived a hobbit.
         
96.

16.1.3 fn:function-arity

Summary

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

Signature

Primo Secondo Terzo Quarto Quinto ...
763(
Primo Secondo Terzo Quarto Quinto ...
795
let $para := 
In a hole in the ground there lived a hobbit.
         
71
Primo Secondo Terzo Quarto Quinto ...
797)
let $para := 
In a hole in the ground there lived a hobbit.
         
71
let $para := 
In a hole in the ground there lived a hobbit.
         
85

Properties

This function is ·deterministic·, ·context-independent·, ·focus-independent·, and ·higher-order·.

Rules

The

Primo Secondo Terzo Quarto Quinto ...
763 function returns the arity (number of arguments) of the function identified by
Primo Secondo Terzo Quarto Quinto ...
795.

Examples

The expression

Primo Secondo Terzo Quarto Quinto ...
816 returns
let $para := 
In a hole in the ground there lived a hobbit.
         
226.

The expression

Primo Secondo Terzo Quarto Quinto ...
818 returns
declare %public function r:random-sequence($length as xs:integer) as xs:double* {
  r:random-sequence($length, fn:random-number-generator())
};

declare %private function r:random-sequence($length as xs:integer, 
                                            $G as map(xs:string, item())) {
  if ($length eq 0)
  then ()
  else ($G?number, r:random-sequence($length - 1, $G?next()))
};

r:random-sequence(200);
            
13.

The expression

Primo Secondo Terzo Quarto Quinto ...
820 returns
declare %public function r:random-sequence($length as xs:integer) as xs:double* {
  r:random-sequence($length, fn:random-number-generator())
};

declare %private function r:random-sequence($length as xs:integer, 
                                            $G as map(xs:string, item())) {
  if ($length eq 0)
  then ()
  else ($G?number, r:random-sequence($length - 1, $G?next()))
};

r:random-sequence(200);
            
13.

16.2 Basic higher-order functions

The following functions take function items as an argument.

FunctionMeaning
Primo Secondo Terzo Quarto Quinto ...
822Applies the function item $action to every item from the sequence $seq in turn, returning the concatenation of the resulting sequences in order.
Primo Secondo Terzo Quarto Quinto ...
823Returns those items from the sequence $seq for which the supplied function $f returns true.
Primo Secondo Terzo Quarto Quinto ...
824Processes the supplied sequence from left to right, applying the supplied function repeatedly to each item in turn, together with an accumulated result value.
Primo Secondo Terzo Quarto Quinto ...
825Processes the supplied sequence from right to left, applying the supplied function repeatedly to each item in turn, together with an accumulated result value.
Primo Secondo Terzo Quarto Quinto ...
826Applies the function item $action to successive pairs of items taken one from $seq1 and one from $seq2, returning the concatenation of the resulting sequences in order.
Primo Secondo Terzo Quarto Quinto ...
827Sorts a supplied sequence, based on the value of a sort key supplied as a function.
Primo Secondo Terzo Quarto Quinto ...
828Makes a dynamic call on a function with an argument list supplied in the form of an array.

With all these functions, if the caller-supplied function fails with a dynamic error, this error is propagated as an error from the higher-order function itself.

16.2.1 fn:for-each

Summary

Applies the function item $action to every item from the sequence $seq in turn, returning the concatenation of the resulting sequences in order.

Signature

Primo Secondo Terzo Quarto Quinto ...
822(
let $para := 
In a hole in the ground there lived a hobbit.
         
021
let $para := 
In a hole in the ground there lived a hobbit.
         
71
op:operation(fenceHeight, xs:integer) => op:operation(xs:integer, xs:integer)
16,
Primo Secondo Terzo Quarto Quinto ...
833
let $para := 
In a hole in the ground there lived a hobbit.
         
71
Primo Secondo Terzo Quarto Quinto ...
835)
let $para := 
In a hole in the ground there lived a hobbit.
         
71
op:operation(fenceHeight, xs:integer) => op:operation(xs:integer, xs:integer)
16

Properties

This function is ·deterministic·, ·context-independent·, ·focus-independent·, and ·higher-order·.

Rules

The effect of the function is equivalent to the following implementation in XQuery:

Primo Secondo Terzo Quarto Quinto ...
8

or its equivalent in XSLT:

Primo Secondo Terzo Quarto Quinto ...
9

Notes

The function call

Primo Secondo Terzo Quarto Quinto ...
838 is equivalent to the expression
Primo Secondo Terzo Quarto Quinto ...
839, assuming that ordering mode is
Primo Secondo Terzo Quarto Quinto ...
840.

Examples

The expression

Primo Secondo Terzo Quarto Quinto ...
841 returns
Primo Secondo Terzo Quarto Quinto ...
842.

The expression

Primo Secondo Terzo Quarto Quinto ...
843 returns
Primo Secondo Terzo Quarto Quinto ...
844.

The expression

Primo Secondo Terzo Quarto Quinto ...
845 returns
Primo Secondo Terzo Quarto Quinto ...
846.

16.2.2 fn:filter

Summary

Returns those items from the sequence $seq for which the supplied function $f returns true.

Signature

Primo Secondo Terzo Quarto Quinto ...
823(
let $para := 
In a hole in the ground there lived a hobbit.
         
021
let $para := 
In a hole in the ground there lived a hobbit.
         
71
op:operation(fenceHeight, xs:integer) => op:operation(xs:integer, xs:integer)
16,
Primo Secondo Terzo Quarto Quinto ...
851
let $para := 
In a hole in the ground there lived a hobbit.
         
71
Primo Secondo Terzo Quarto Quinto ...
853)
let $para := 
In a hole in the ground there lived a hobbit.
         
71
op:operation(fenceHeight, xs:integer) => op:operation(xs:integer, xs:integer)
16

Properties

This function is ·deterministic·, ·context-independent·, ·focus-independent·, and ·higher-order·.

Rules

The effect of the function is equivalent to the following implementation in XQuery:

declare %public function r:random-sequence($length as xs:integer) as xs:double* {
  r:random-sequence($length, fn:random-number-generator())
};

declare %private function r:random-sequence($length as xs:integer, 
                                            $G as map(xs:string, item())) {
  if ($length eq 0)
  then ()
  else ($G?number, r:random-sequence($length - 1, $G?next()))
};

r:random-sequence(200);
            
0

or its equivalent in XSLT:

declare %public function r:random-sequence($length as xs:integer) as xs:double* {
  r:random-sequence($length, fn:random-number-generator())
};

declare %private function r:random-sequence($length as xs:integer, 
                                            $G as map(xs:string, item())) {
  if ($length eq 0)
  then ()
  else ($G?number, r:random-sequence($length - 1, $G?next()))
};

r:random-sequence(200);
            
1

Error Conditions

As a consequence of the function signature and the function calling rules, a type error occurs if the supplied function $f returns anything other than a single

op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
32 item; there is no conversion to an effective boolean value.

Notes

The function call

Primo Secondo Terzo Quarto Quinto ...
857 has a very similar effect to the expression
Primo Secondo Terzo Quarto Quinto ...
858. There are some differences, however. In the case of
Primo Secondo Terzo Quarto Quinto ...
823, the function
Primo Secondo Terzo Quarto Quinto ...
860 is required to return a boolean; there is no special treatment for numeric predicate values, and no conversion to an effective boolean value. Also, with a filter expression
Primo Secondo Terzo Quarto Quinto ...
858, the focus within the predicate is different from that outside; this means that the use of a context-sensitive function such as
let $para := 
In a hole in the ground there lived a hobbit.
         
95 will give different results in the two cases.

Examples

The expression

Primo Secondo Terzo Quarto Quinto ...
863 returns
Primo Secondo Terzo Quarto Quinto ...
864.

The expression

Primo Secondo Terzo Quarto Quinto ...
865 returns
let $para := 
In a hole in the ground there lived a hobbit.
         
96.

16.2.3 fn:fold-left

Summary

Processes the supplied sequence from left to right, applying the supplied function repeatedly to each item in turn, together with an accumulated result value.

Signature

Primo Secondo Terzo Quarto Quinto ...
824(
let $para := 
In a hole in the ground there lived a hobbit.
         
021
let $para := 
In a hole in the ground there lived a hobbit.
         
71
op:operation(fenceHeight, xs:integer) => op:operation(xs:integer, xs:integer)
16,
1º 2º 3º 4º ...
975
let $para := 
In a hole in the ground there lived a hobbit.
         
71
op:operation(fenceHeight, xs:integer) => op:operation(xs:integer, xs:integer)
16,
Primo Secondo Terzo Quarto Quinto ...
851
let $para := 
In a hole in the ground there lived a hobbit.
         
71
Primo Secondo Terzo Quarto Quinto ...
876)
let $para := 
In a hole in the ground there lived a hobbit.
         
71
op:operation(fenceHeight, xs:integer) => op:operation(xs:integer, xs:integer)
16

Properties

This function is ·deterministic·, ·context-independent·, ·focus-independent·, and ·higher-order·.

Rules

The effect of the function is equivalent to the following implementation in XQuery:

declare %public function r:random-sequence($length as xs:integer) as xs:double* {
  r:random-sequence($length, fn:random-number-generator())
};

declare %private function r:random-sequence($length as xs:integer, 
                                            $G as map(xs:string, item())) {
  if ($length eq 0)
  then ()
  else ($G?number, r:random-sequence($length - 1, $G?next()))
};

r:random-sequence(200);
            
2

or its equivalent in XSLT:

declare %public function r:random-sequence($length as xs:integer) as xs:double* {
  r:random-sequence($length, fn:random-number-generator())
};

declare %private function r:random-sequence($length as xs:integer, 
                                            $G as map(xs:string, item())) {
  if ($length eq 0)
  then ()
  else ($G?number, r:random-sequence($length - 1, $G?next()))
};

r:random-sequence(200);
            
3

Error Conditions

As a consequence of the function signature and the function calling rules, a type error occurs if the supplied function $f cannot be applied to two arguments, where the first argument is either the value of $zero or the result of a previous application of $f, and the second is any single item from the sequence $seq.

Notes

This operation is often referred to in the functional programming literature as "folding" or "reducing" a sequence. It takes a function that operates on a pair of values, and applies it repeatedly, with an accumulated result as the first argument, and the next item in the sequence as the second argument. The accumulated result is initially set to the value of the $zero argument, which is conventionally a value (such as zero in the case of addition, one in 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.

Examples

The expression

Primo Secondo Terzo Quarto Quinto ...
879 returns
let $para := 
In a hole in the ground there lived a hobbit.
         
222. (This returns the sum of the items in the sequence).

The expression

Primo Secondo Terzo Quarto Quinto ...
881 returns
Primo Secondo Terzo Quarto Quinto ...
882. (This returns the product of the items in the sequence).

The expression

Primo Secondo Terzo Quarto Quinto ...
883 returns
let $para := 
In a hole in the ground there lived a hobbit.
         
182. (This returns true if any item in the sequence has an effective boolean value of true).

The expression

Primo Secondo Terzo Quarto Quinto ...
885 returns
let $para := 
In a hole in the ground there lived a hobbit.
         
184. (This returns true only if every item in the sequence has an effective boolean value of true).

The expression

Primo Secondo Terzo Quarto Quinto ...
887 returns
Primo Secondo Terzo Quarto Quinto ...
888. (This reverses the order of the items in a sequence).

The expression

Primo Secondo Terzo Quarto Quinto ...
889 returns
Primo Secondo Terzo Quarto Quinto ...
890.

The expression

Primo Secondo Terzo Quarto Quinto ...
891 returns
Primo Secondo Terzo Quarto Quinto ...
892.

The expression

Primo Secondo Terzo Quarto Quinto ...
893 returns
Primo Secondo Terzo Quarto Quinto ...
894.

16.2.4 fn:fold-right

Summary

Processes the supplied sequence from right to left, applying the supplied function repeatedly to each item in turn, together with an accumulated result value.

Signature

Primo Secondo Terzo Quarto Quinto ...
825(
let $para := 
In a hole in the ground there lived a hobbit.
         
021
let $para := 
In a hole in the ground there lived a hobbit.
         
71
op:operation(fenceHeight, xs:integer) => op:operation(xs:integer, xs:integer)
16,
1º 2º 3º 4º ...
975
let $para := 
In a hole in the ground there lived a hobbit.
         
71
op:operation(fenceHeight, xs:integer) => op:operation(xs:integer, xs:integer)
16,
Primo Secondo Terzo Quarto Quinto ...
851
let $para := 
In a hole in the ground there lived a hobbit.
         
71
Primo Secondo Terzo Quarto Quinto ...
904)
let $para := 
In a hole in the ground there lived a hobbit.
         
71
op:operation(fenceHeight, xs:integer) => op:operation(xs:integer, xs:integer)
16

Properties

This function is ·deterministic·, ·context-independent·, ·focus-independent·, and ·higher-order·.

Rules

The effect of the function is equivalent to the following implementation in XQuery:

declare %public function r:random-sequence($length as xs:integer) as xs:double* {
  r:random-sequence($length, fn:random-number-generator())
};

declare %private function r:random-sequence($length as xs:integer, 
                                            $G as map(xs:string, item())) {
  if ($length eq 0)
  then ()
  else ($G?number, r:random-sequence($length - 1, $G?next()))
};

r:random-sequence(200);
            
4

or its equivalent in XSLT:

declare %public function r:random-sequence($length as xs:integer) as xs:double* {
  r:random-sequence($length, fn:random-number-generator())
};

declare %private function r:random-sequence($length as xs:integer, 
                                            $G as map(xs:string, item())) {
  if ($length eq 0)
  then ()
  else ($G?number, r:random-sequence($length - 1, $G?next()))
};

r:random-sequence(200);
            
5

Error Conditions

As a consequence of the function signature and the function calling rules, a type error occurs if the supplied function $f cannot be applied to two arguments, where the first argument is any item in the sequence $seq, and the second is either the value of $zero or the result of a previous application of $f.

Notes

This operation is often referred to in the functional programming literature as "folding" or "reducing" a sequence. It takes a function that operates on a pair of values, and applies it repeatedly, with the next item in the sequence as the first argument, and the result of processing the remainder of the sequence as the second argument. The accumulated result is initially set to the value of the $zero argument, which is conventionally a value (such as zero in the case of addition, one in 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),

Primo Secondo Terzo Quarto Quinto ...
825 produces the same result as
Primo Secondo Terzo Quarto Quinto ...
824.

Examples

The expression

Primo Secondo Terzo Quarto Quinto ...
909 returns
let $para := 
In a hole in the ground there lived a hobbit.
         
222. (This returns the sum of the items in the sequence).

The expression

Primo Secondo Terzo Quarto Quinto ...
911 returns
Primo Secondo Terzo Quarto Quinto ...
912.

The expression

Primo Secondo Terzo Quarto Quinto ...
913 returns
Primo Secondo Terzo Quarto Quinto ...
914.

16.2.5 fn:for-each-pair

Summary

Applies the function item $action to successive pairs of items taken one from $seq1 and one from $seq2, returning the concatenation of the resulting sequences in order.

Signature

Primo Secondo Terzo Quarto Quinto ...
826(
Primo Secondo Terzo Quarto Quinto ...
916
let $para := 
In a hole in the ground there lived a hobbit.
         
71
op:operation(fenceHeight, xs:integer) => op:operation(xs:integer, xs:integer)
16,
Primo Secondo Terzo Quarto Quinto ...
919
let $para := 
In a hole in the ground there lived a hobbit.
         
71
op:operation(fenceHeight, xs:integer) => op:operation(xs:integer, xs:integer)
16,
Primo Secondo Terzo Quarto Quinto ...
833
let $para := 
In a hole in the ground there lived a hobbit.
         
71
Primo Secondo Terzo Quarto Quinto ...
924)
let $para := 
In a hole in the ground there lived a hobbit.
         
71
op:operation(fenceHeight, xs:integer) => op:operation(xs:integer, xs:integer)
16

Properties

This function is ·deterministic·, ·context-independent·, ·focus-independent·, and ·higher-order·.

Rules

The effect of the function is equivalent to the following implementation in XQuery:

declare %public function r:random-sequence($length as xs:integer) as xs:double* {
  r:random-sequence($length, fn:random-number-generator())
};

declare %private function r:random-sequence($length as xs:integer, 
                                            $G as map(xs:string, item())) {
  if ($length eq 0)
  then ()
  else ($G?number, r:random-sequence($length - 1, $G?next()))
};

r:random-sequence(200);
            
6

or its equivalent in XSLT:

declare %public function r:random-sequence($length as xs:integer) as xs:double* {
  r:random-sequence($length, fn:random-number-generator())
};

declare %private function r:random-sequence($length as xs:integer, 
                                            $G as map(xs:string, item())) {
  if ($length eq 0)
  then ()
  else ($G?number, r:random-sequence($length - 1, $G?next()))
};

r:random-sequence(200);
            
7

Notes

If one sequence is longer than the other, excess items in the longer sequence are ignored.

Examples

The expression

Primo Secondo Terzo Quarto Quinto ...
927 returns
Primo Secondo Terzo Quarto Quinto ...
928.

The expression

Primo Secondo Terzo Quarto Quinto ...
929 returns
Primo Secondo Terzo Quarto Quinto ...
930.

The expression

Primo Secondo Terzo Quarto Quinto ...
931 returns
Primo Secondo Terzo Quarto Quinto ...
932.

16.2.6 fn:sort

Summary

Sorts a supplied sequence, based on the value of a sort key supplied as a function.

Signatures

Primo Secondo Terzo Quarto Quinto ...
827(
let $para := 
In a hole in the ground there lived a hobbit.
         
232
let $para := 
In a hole in the ground there lived a hobbit.
         
71
op:operation(fenceHeight, xs:integer) => op:operation(xs:integer, xs:integer)
16)
let $para := 
In a hole in the ground there lived a hobbit.
         
71
op:operation(fenceHeight, xs:integer) => op:operation(xs:integer, xs:integer)
16

Primo Secondo Terzo Quarto Quinto ...
827(
let $para := 
In a hole in the ground there lived a hobbit.
         
232
let $para := 
In a hole in the ground there lived a hobbit.
         
71
op:operation(fenceHeight, xs:integer) => op:operation(xs:integer, xs:integer)
16,
let $para := 
In a hole in the ground there lived a hobbit.
         
128
let $para := 
In a hole in the ground there lived a hobbit.
         
71
let $para := 
In a hole in the ground there lived a hobbit.
         
244)
let $para := 
In a hole in the ground there lived a hobbit.
         
71
op:operation(fenceHeight, xs:integer) => op:operation(xs:integer, xs:integer)
16

Primo Secondo Terzo Quarto Quinto ...
827(
let $para := 
In a hole in the ground there lived a hobbit.
         
232
let $para := 
In a hole in the ground there lived a hobbit.
         
71
op:operation(fenceHeight, xs:integer) => op:operation(xs:integer, xs:integer)
16,
let $para := 
In a hole in the ground there lived a hobbit.
         
128
let $para := 
In a hole in the ground there lived a hobbit.
         
71
let $para := 
In a hole in the ground there lived a hobbit.
         
244,
let $para := 
In a hole in the ground there lived a hobbit.
         
192
let $para := 
In a hole in the ground there lived a hobbit.
         
71
Primo Secondo Terzo Quarto Quinto ...
957)
let $para := 
In a hole in the ground there lived a hobbit.
         
71
op:operation(fenceHeight, xs:integer) => op:operation(xs:integer, xs:integer)
16

Properties

The one-argument form of this function is ·deterministic·, ·context-dependent·, and ·focus-independent·. It depends on collations.

The two-argument form of this function is ·deterministic·, ·context-dependent·, and ·focus-independent·. It depends on collations.

The three-argument form of this function is ·deterministic·, ·context-dependent·, ·focus-independent·, and ·higher-order·. It depends on collations.

Rules

Calling the single-argument version of the function is equivalent to calling the two-argument form with

Primo Secondo Terzo Quarto Quinto ...
960 as the second argument: that is, it sorts a sequence of items according to the typed value of the items, using the default collation to compare strings.

Calling the two-argument version of the function is equivalent to calling the three-argument form with

Primo Secondo Terzo Quarto Quinto ...
961 as the third argument: that is, it sorts a sequence of items according to the typed value of the items, using a specified collation to compare strings.

In the case of both

Primo Secondo Terzo Quarto Quinto ...
962 and
Primo Secondo Terzo Quarto Quinto ...
963, supplying an empty sequence as the second argument is equivalent to supplying
Primo Secondo Terzo Quarto Quinto ...
964. For more information on collations see 5.3.5 Choosing a collation.

The result of the function is obtained as follows:

  • For each item in the sequence

    let $para := 
    In a hole in the ground there lived a hobbit.
             
    232, the function supplied as
    let $para := 
    In a hole in the ground there lived a hobbit.
             
    192 is evaluated with that item as its argument. The resulting values are the sort keys of the items in the input sequence.

  • The result sequence contains the same items as the input sequence

    let $para := 
    In a hole in the ground there lived a hobbit.
             
    232, but generally in a different order.

  • Let $C be the selected collation, or the default collation where applicable.

  • The order of items in the result is such that, given two items

    let $para := 
    In a hole in the ground there lived a hobbit.
             
    080 and
    let $para := 
    In a hole in the ground there lived a hobbit.
             
    081:

    • If

      Primo Secondo Terzo Quarto Quinto ...
      970, then the relative order of
      let $para := 
      In a hole in the ground there lived a hobbit.
               
      080 and
      let $para := 
      In a hole in the ground there lived a hobbit.
               
      081 in the output is the same as their relative order in the input (that is, the sort is stable)

    • Otherwise, if

      Primo Secondo Terzo Quarto Quinto ...
      973, then
      let $para := 
      In a hole in the ground there lived a hobbit.
               
      080 precedes
      let $para := 
      In a hole in the ground there lived a hobbit.
               
      081 in the output. The function
      Primo Secondo Terzo Quarto Quinto ...
      976 is defined as the boolean result of the expression:

      declare %public function r:random-sequence($length as xs:integer) as xs:double* {
        r:random-sequence($length, fn:random-number-generator())
      };
      
      declare %private function r:random-sequence($length as xs:integer, 
                                                  $G as map(xs:string, item())) {
        if ($length eq 0)
        then ()
        else ($G?number, r:random-sequence($length - 1, $G?next()))
      };
      
      r:random-sequence(200);
                  
      8

      where the function

      Primo Secondo Terzo Quarto Quinto ...
      977 returns true if and only if
      Primo Secondo Terzo Quarto Quinto ...
      978 is an instance of
      let $para := 
      In a hole in the ground there lived a hobbit.
               
      10,
      let $para := 
      In a hole in the ground there lived a hobbit.
               
      30, or
      let $para := 
      In a hole in the ground there lived a hobbit.
               
      00.

      This ordering of sequences is referred to by mathematicians as "lexicographic ordering".

Error Conditions

If the set of computed sort keys contains values that are not comparable using the

1º 2º 3º 4º ...
949 operator then the sort operation will fail with a type error ([err:XPTY0004]XP31).

Notes

XSLT and XQuery both provide native sorting capability, but previous releases of XPath provided no sorting functionality for use in standalone environments.

In addition there are cases where this function may be more flexible than the built-in sorting capability for XQuery or XSLT, for example when the sort key or collation is chosen dynamically, or when the sort key is a sequence of items rather than a single item.

The results are compatible with the results of XSLT sorting (using

Primo Secondo Terzo Quarto Quinto ...
983) in the case where the sort key evaluates to a sequence of length zero or one, given the options
Primo Secondo Terzo Quarto Quinto ...
984 and
Primo Secondo Terzo Quarto Quinto ...
985.

The results are compatible with the results of XQuery sorting (using the

let $para := 
In a hole in the ground there lived a hobbit.
         
220 clause) in the case where the sort key evaluates to a sequence of length zero or one, given the options
Primo Secondo Terzo Quarto Quinto ...
987,
Primo Secondo Terzo Quarto Quinto ...
988, and
Primo Secondo Terzo Quarto Quinto ...
989.

Examples

The expression

Primo Secondo Terzo Quarto Quinto ...
990 returns
Primo Secondo Terzo Quarto Quinto ...
991.

The expression

Primo Secondo Terzo Quarto Quinto ...
992 returns
Primo Secondo Terzo Quarto Quinto ...
993.

To sort a set of strings

1º 2º 3º 4º ...
336 using Swedish collation:

declare %public function r:random-sequence($length as xs:integer) as xs:double* {
  r:random-sequence($length, fn:random-number-generator())
};

declare %private function r:random-sequence($length as xs:integer, 
                                            $G as map(xs:string, item())) {
  if ($length eq 0)
  then ()
  else ($G?number, r:random-sequence($length - 1, $G?next()))
};

r:random-sequence(200);
            
9

To sort a sequence of employees by last name as the major sort key and first name as the minor sort key, using the default collation:

let $C := 'http://www.w3.org/2013/collation/UCA?strength=primary'
0

16.2.7 fn:apply

Summary

Makes a dynamic call on a function with an argument list supplied in the form of an array.

Signature

Primo Secondo Terzo Quarto Quinto ...
828(
Primo Secondo Terzo Quarto Quinto ...
996
let $para := 
In a hole in the ground there lived a hobbit.
         
71
Primo Secondo Terzo Quarto Quinto ...
797,
Primo Secondo Terzo Quarto Quinto ...
999
let $para := 
In a hole in the ground there lived a hobbit.
         
71
declare %public function r:random-sequence($length as xs:integer) as xs:double* {
  r:random-sequence($length, fn:random-number-generator())
};

declare %private function r:random-sequence($length as xs:integer, 
                                            $G as map(xs:string, item())) {
  if ($length eq 0)
  then ()
  else ($G?number, r:random-sequence($length - 1, $G?next()))
};

r:random-sequence(200);
            
001)
let $para := 
In a hole in the ground there lived a hobbit.
         
71
op:operation(fenceHeight, xs:integer) => op:operation(xs:integer, xs:integer)
16

Properties

This function is ·deterministic·, ·context-independent·, ·focus-independent·, and ·higher-order·.

Rules

The result of the function is obtained by invoking the supplied function

Primo Secondo Terzo Quarto Quinto ...
996 with arguments taken from the members of the supplied array
Primo Secondo Terzo Quarto Quinto ...
999. The first argument of the function call is the first member of
Primo Secondo Terzo Quarto Quinto ...
999, the second argument is the second member of
Primo Secondo Terzo Quarto Quinto ...
999, and so on.

The arity of the supplied function

Primo Secondo Terzo Quarto Quinto ...
996 must be the same as the size of the array
Primo Secondo Terzo Quarto Quinto ...
999.

The effect of calling

declare %public function r:random-sequence($length as xs:integer) as xs:double* {
  r:random-sequence($length, fn:random-number-generator())
};

declare %private function r:random-sequence($length as xs:integer, 
                                            $G as map(xs:string, item())) {
  if ($length eq 0)
  then ()
  else ($G?number, r:random-sequence($length - 1, $G?next()))
};

r:random-sequence(200);
            
010 is the same as the effect of the dynamic function call
declare %public function r:random-sequence($length as xs:integer) as xs:double* {
  r:random-sequence($length, fn:random-number-generator())
};

declare %private function r:random-sequence($length as xs:integer, 
                                            $G as map(xs:string, item())) {
  if ($length eq 0)
  then ()
  else ($G?number, r:random-sequence($length - 1, $G?next()))
};

r:random-sequence(200);
            
011. For example, the function conversion rules are applied to the supplied arguments in the usual way.

Error Conditions

A dynamic error is raised if the arity of the function

Primo Secondo Terzo Quarto Quinto ...
996 is not the same as the size of the array
Primo Secondo Terzo Quarto Quinto ...
999 ([err:FOAP0001]).

Notes

The function is useful where the arity of a function item is not known statically.

Examples

The expression

declare %public function r:random-sequence($length as xs:integer) as xs:double* {
  r:random-sequence($length, fn:random-number-generator())
};

declare %private function r:random-sequence($length as xs:integer, 
                                            $G as map(xs:string, item())) {
  if ($length eq 0)
  then ()
  else ($G?number, r:random-sequence($length - 1, $G?next()))
};

r:random-sequence(200);
            
014 returns
let $para := 
In a hole in the ground there lived a hobbit.
         
803.

The expression

declare %public function r:random-sequence($length as xs:integer) as xs:double* {
  r:random-sequence($length, fn:random-number-generator())
};

declare %private function r:random-sequence($length as xs:integer, 
                                            $G as map(xs:string, item())) {
  if ($length eq 0)
  then ()
  else ($G?number, r:random-sequence($length - 1, $G?next()))
};

r:random-sequence(200);
            
016 calls the supplied function
Primo Secondo Terzo Quarto Quinto ...
851 supplying the number of arguments required by its arity.

16.3 Dynamic Loading

The following functions allow dynamic loading and execution of XQuery queries and XSLT stylesheets.

FunctionMeaning
Primo Secondo Terzo Quarto Quinto ...
785Provides access to the public functions and global variables of a dynamically-loaded XQuery library module.
declare %public function r:random-sequence($length as xs:integer) as xs:double* {
  r:random-sequence($length, fn:random-number-generator())
};

declare %private function r:random-sequence($length as xs:integer, 
                                            $G as map(xs:string, item())) {
  if ($length eq 0)
  then ()
  else ($G?number, r:random-sequence($length - 1, $G?next()))
};

r:random-sequence(200);
            
019Invokes a transformation using a dynamically-loaded XSLT stylesheet.

16.3.1 fn:load-xquery-module

Summary

Provides access to the public functions and global variables of a dynamically-loaded XQuery library module.

Signatures

Primo Secondo Terzo Quarto Quinto ...
785(
declare %public function r:random-sequence($length as xs:integer) as xs:double* {
  r:random-sequence($length, fn:random-number-generator())
};

declare %private function r:random-sequence($length as xs:integer, 
                                            $G as map(xs:string, item())) {
  if ($length eq 0)
  then ()
  else ($G?number, r:random-sequence($length - 1, $G?next()))
};

r:random-sequence(200);
            
021
let $para := 
In a hole in the ground there lived a hobbit.
         
71
let $para := 
In a hole in the ground there lived a hobbit.
         
10)
let $para := 
In a hole in the ground there lived a hobbit.
         
71
let $para := 
In a hole in the ground there lived a hobbit.
         
32

Primo Secondo Terzo Quarto Quinto ...
785(
declare %public function r:random-sequence($length as xs:integer) as xs:double* {
  r:random-sequence($length, fn:random-number-generator())
};

declare %private function r:random-sequence($length as xs:integer, 
                                            $G as map(xs:string, item())) {
  if ($length eq 0)
  then ()
  else ($G?number, r:random-sequence($length - 1, $G?next()))
};

r:random-sequence(200);
            
021
let $para := 
In a hole in the ground there lived a hobbit.
         
71
let $para := 
In a hole in the ground there lived a hobbit.
         
10,
declare %public function r:random-sequence($length as xs:integer) as xs:double* {
  r:random-sequence($length, fn:random-number-generator())
};

declare %private function r:random-sequence($length as xs:integer, 
                                            $G as map(xs:string, item())) {
  if ($length eq 0)
  then ()
  else ($G?number, r:random-sequence($length - 1, $G?next()))
};

r:random-sequence(200);
            
030
let $para := 
In a hole in the ground there lived a hobbit.
         
71
let $para := 
In a hole in the ground there lived a hobbit.
         
32)
let $para := 
In a hole in the ground there lived a hobbit.
         
71
let $para := 
In a hole in the ground there lived a hobbit.
         
32

Properties

This function is ·deterministic·, ·context-dependent·, ·focus-independent·, and ·higher-order·.

Rules

The function loads an implementation-defined set of modules having the target namespace

declare %public function r:random-sequence($length as xs:integer) as xs:double* {
  r:random-sequence($length, fn:random-number-generator())
};

declare %private function r:random-sequence($length as xs:integer, 
                                            $G as map(xs:string, item())) {
  if ($length eq 0)
  then ()
  else ($G?number, r:random-sequence($length - 1, $G?next()))
};

r:random-sequence(200);
            
021.

Calling the one-argument version of the function has the same effect as calling the two-argument version with an empty map as the second argument.

The

declare %public function r:random-sequence($length as xs:integer) as xs:double* {
  r:random-sequence($length, fn:random-number-generator())
};

declare %private function r:random-sequence($length as xs:integer, 
                                            $G as map(xs:string, item())) {
  if ($length eq 0)
  then ()
  else ($G?number, r:random-sequence($length - 1, $G?next()))
};

r:random-sequence(200);
            
030 argument can be used to control the way in which the function operates. The ·option parameter conventions· apply.

KeyMeaning
declare %public function r:random-sequence($length as xs:integer) as xs:double* {
  r:random-sequence($length, fn:random-number-generator())
};

declare %private function r:random-sequence($length as xs:integer, 
                                            $G as map(xs:string, item())) {
  if ($length eq 0)
  then ()
  else ($G?number, r:random-sequence($length - 1, $G?next()))
};

r:random-sequence(200);
            
037The minimum level of the XQuery language that the processor must support.
  • Type:

    let $para := 
    In a hole in the ground there lived a hobbit.
             
    82

  • Default:

    declare %public function r:random-sequence($length as xs:integer) as xs:double* {
      r:random-sequence($length, fn:random-number-generator())
    };
    
    declare %private function r:random-sequence($length as xs:integer, 
                                                $G as map(xs:string, item())) {
      if ($length eq 0)
      then ()
      else ($G?number, r:random-sequence($length - 1, $G?next()))
    };
    
    r:random-sequence(200);
                
    039

declare %public function r:random-sequence($length as xs:integer) as xs:double* {
  r:random-sequence($length, fn:random-number-generator())
};

declare %private function r:random-sequence($length as xs:integer, 
                                            $G as map(xs:string, item())) {
  if ($length eq 0)
  then ()
  else ($G?number, r:random-sequence($length - 1, $G?next()))
};

r:random-sequence(200);
            
040A sequence of URIs (in the form of
let $para := 
In a hole in the ground there lived a hobbit.
         
10 values) which may be used or ignored in an ·implementation-defined· way.
  • Type:

    let $para := 
    In a hole in the ground there lived a hobbit.
             
    234

  • Default:

    declare %public function r:random-sequence($length as xs:integer) as xs:double* {
      r:random-sequence($length, fn:random-number-generator())
    };
    
    declare %private function r:random-sequence($length as xs:integer, 
                                                $G as map(xs:string, item())) {
      if ($length eq 0)
      then ()
      else ($G?number, r:random-sequence($length - 1, $G?next()))
    };
    
    r:random-sequence(200);
                
    043

declare %public function r:random-sequence($length as xs:integer) as xs:double* {
  r:random-sequence($length, fn:random-number-generator())
};

declare %private function r:random-sequence($length as xs:integer, 
                                            $G as map(xs:string, item())) {
  if ($length eq 0)
  then ()
  else ($G?number, r:random-sequence($length - 1, $G?next()))
};

r:random-sequence(200);
            
044The item to be used as the initial context item when evaluating global variables in the library module. Supplying an empty sequence is equivalent to omitting the entry from the map, and indicates the absence of a context item. If the library module specifies a required type for the context item, then the supplied value must conform to this type, without conversion.
  • Type:

    let $para := 
    In a hole in the ground there lived a hobbit.
             
    79

  • Default:

    declare %public function r:random-sequence($length as xs:integer) as xs:double* {
      r:random-sequence($length, fn:random-number-generator())
    };
    
    declare %private function r:random-sequence($length as xs:integer, 
                                                $G as map(xs:string, item())) {
      if ($length eq 0)
      then ()
      else ($G?number, r:random-sequence($length - 1, $G?next()))
    };
    
    r:random-sequence(200);
                
    046

declare %public function r:random-sequence($length as xs:integer) as xs:double* {
  r:random-sequence($length, fn:random-number-generator())
};

declare %private function r:random-sequence($length as xs:integer, 
                                            $G as map(xs:string, item())) {
  if ($length eq 0)
  then ()
  else ($G?number, r:random-sequence($length - 1, $G?next()))
};

r:random-sequence(200);
            
047Values for external variables defined in the library module. Values must be supplied for external variables that have no default value, and may be supplied for external variables that do have a default value. The supplied value must conform to the required type of the variable, without conversion. The map contains one entry for each external variable: the key is the variable's name, and the associated value is the variable's value. The ·option parameter conventions· do not apply to this contained map.
  • Type:

    declare %public function r:random-sequence($length as xs:integer) as xs:double* {
      r:random-sequence($length, fn:random-number-generator())
    };
    
    declare %private function r:random-sequence($length as xs:integer, 
                                                $G as map(xs:string, item())) {
      if ($length eq 0)
      then ()
      else ($G?number, r:random-sequence($length - 1, $G?next()))
    };
    
    r:random-sequence(200);
                
    048

  • Default:

    declare %public function r:random-sequence($length as xs:integer) as xs:double* {
      r:random-sequence($length, fn:random-number-generator())
    };
    
    declare %private function r:random-sequence($length as xs:integer, 
                                                $G as map(xs:string, item())) {
      if ($length eq 0)
      then ()
      else ($G?number, r:random-sequence($length - 1, $G?next()))
    };
    
    r:random-sequence(200);
                
    049

declare %public function r:random-sequence($length as xs:integer) as xs:double* {
  r:random-sequence($length, fn:random-number-generator())
};

declare %private function r:random-sequence($length as xs:integer, 
                                            $G as map(xs:string, item())) {
  if ($length eq 0)
  then ()
  else ($G?number, r:random-sequence($length - 1, $G?next()))
};

r:random-sequence(200);
            
050Values for vendor-defined configuration options for the XQuery processor used to process the request. The key is the name of an option, expressed as a QName: the namespace URI of the QName should be a URI controlled by the vendor of the XQuery processor. The meaning of the associated value is ·implementation-defined·. Implementations should ignore options whose names are in an unrecognized namespace. The ·option parameter conventions· do not apply to this contained map.
  • Type:

    declare %public function r:random-sequence($length as xs:integer) as xs:double* {
      r:random-sequence($length, fn:random-number-generator())
    };
    
    declare %private function r:random-sequence($length as xs:integer, 
                                                $G as map(xs:string, item())) {
      if ($length eq 0)
      then ()
      else ($G?number, r:random-sequence($length - 1, $G?next()))
    };
    
    r:random-sequence(200);
                
    048

  • Default:

    declare %public function r:random-sequence($length as xs:integer) as xs:double* {
      r:random-sequence($length, fn:random-number-generator())
    };
    
    declare %private function r:random-sequence($length as xs:integer, 
                                                $G as map(xs:string, item())) {
      if ($length eq 0)
      then ()
      else ($G?number, r:random-sequence($length - 1, $G?next()))
    };
    
    r:random-sequence(200);
                
    049

The result of the function is a map R with two entries:

  1. There is an entry whose key is the

    let $para := 
    In a hole in the ground there lived a hobbit.
             
    10 value
    declare %public function r:random-sequence($length as xs:integer) as xs:double* {
      r:random-sequence($length, fn:random-number-generator())
    };
    
    declare %private function r:random-sequence($length as xs:integer, 
                                                $G as map(xs:string, item())) {
      if ($length eq 0)
      then ()
      else ($G?number, r:random-sequence($length - 1, $G?next()))
    };
    
    r:random-sequence(200);
                
    054 and whose associated value is a map V. This map (V) contains one entry for each public global variable declared in the library module. The key of the entry is the name of the variable, as an
    let $para := 
    In a hole in the ground there lived a hobbit.
             
    36 value; the associated value is the value of the variable.

  2. There is an entry whose key is the

    let $para := 
    In a hole in the ground there lived a hobbit.
             
    10 value
    declare %public function r:random-sequence($length as xs:integer) as xs:double* {
      r:random-sequence($length, fn:random-number-generator())
    };
    
    declare %private function r:random-sequence($length as xs:integer, 
                                                $G as map(xs:string, item())) {
      if ($length eq 0)
      then ()
      else ($G?number, r:random-sequence($length - 1, $G?next()))
    };
    
    r:random-sequence(200);
                
    057 and whose associated value is a map F. This map (F) contains one entry for each public function declared in the library module, except that when two functions have the same name (but different arity), they share the same entry. The key of the entry is the name of the function(s), as an
    let $para := 
    In a hole in the ground there lived a hobbit.
             
    36 value; the associated value is a map A. This map (A) contains one entry for each function with the given name; its key is the arity of the function, as an
    let $para := 
    In a hole in the ground there lived a hobbit.
             
    85 value, and its associated value is the function itself, as a function item. The function can be invoked using the rules for dynamic function invocation.

The static and dynamic context of the library module are established according to the rules in Section C Context Components XQ31.

It is ·implementation-defined· whether constructs in the library module are evaluated in the same ·execution scope· as the calling module.

The library module that is loaded may import other modules using an

declare %public function r:random-sequence($length as xs:integer) as xs:double* {
  r:random-sequence($length, fn:random-number-generator())
};

declare %private function r:random-sequence($length as xs:integer, 
                                            $G as map(xs:string, item())) {
  if ($length eq 0)
  then ()
  else ($G?number, r:random-sequence($length - 1, $G?next()))
};

r:random-sequence(200);
            
060 declaration. The result of
Primo Secondo Terzo Quarto Quinto ...
785 does not include global variables or functions declared in such a transitively-imported module. However, the
declare %public function r:random-sequence($length as xs:integer) as xs:double* {
  r:random-sequence($length, fn:random-number-generator())
};

declare %private function r:random-sequence($length as xs:integer, 
                                            $G as map(xs:string, item())) {
  if ($length eq 0)
  then ()
  else ($G?number, r:random-sequence($length - 1, $G?next()))
};

r:random-sequence(200);
            
062 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.

The library module that is loaded may import schema declarations using an

declare %public function r:random-sequence($length as xs:integer) as xs:double* {
  r:random-sequence($length, fn:random-number-generator())
};

declare %private function r:random-sequence($length as xs:integer, 
                                            $G as map(xs:string, item())) {
  if ($length eq 0)
  then ()
  else ($G?number, r:random-sequence($length - 1, $G?next()))
};

r:random-sequence(200);
            
063 declaration. It is ·implementation-defined· whether schema components in the in-scope schema definitions of the calling module are automatically added to the in-scope schema definitions of the dynamically loaded module. The in-scope schema definitions of the calling and called modules must be consistent, according to the rules defined in Section 2.2.5 Consistency Constraints XQ31.

Where nodes are passed to or from the dynamically loaded module, for example as an argument or result of a function, they should if possible retain their node identity, their base URI, their type annotations, and their relationships to all other nodes in the containing tree (including ancestors and siblings). If this is not possible, for example because the only way of passing nodes to the chosen XQuery implementation is by serializing and re-parsing, then a node may be passed in the form of a deep copy, which may lose information about the identity of the node, about its ancestors and siblings, about its base URI, about its type annotations, and about its relationships to other nodes passed across the interface.

Error Conditions

If

declare %public function r:random-sequence($length as xs:integer) as xs:double* {
  r:random-sequence($length, fn:random-number-generator())
};

declare %private function r:random-sequence($length as xs:integer, 
                                            $G as map(xs:string, item())) {
  if ($length eq 0)
  then ()
  else ($G?number, r:random-sequence($length - 1, $G?next()))
};

r:random-sequence(200);
            
021 is a zero length string, a dynamic error is raised [err:FOQM0001].

If the implementation is not able to find a library module with the specified target namespace, an error is raised [err:FOQM0002].

If a static error (including a statically-detected type error) is encountered when processing the library module, a dynamic error is raised [err:FOQM0003].

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, a dynamic error is raised [err:FOQM0005].

If no suitable XQuery processor is available, a dynamic error is raised [err:FOQM0006]. This includes (but is not limited to) the following cases:

  1. No XQuery processor is available;

  2. Use of the function has been disabled;

  3. No XQuery processor supporting the requested version of XQuery is available;

  4. No XQuery processor supporting the optional Module Feature is available.

If a dynamic error (including a dynamically-detected type error) is encountered when processing the module (for example, when evaluating its global variables), the dynamic error is returned as is.

Notes

As with all other functions in this specification, conformance requirements depend on the host language. For example, a host language might specify that provision of this function is optional, or that it is excluded entirely, or that implementations are required to support XQuery modules using a specified version of XQuery.

Even where support for this function is mandatory, it is recommended for security reasons that implementations should provide a user option to disable its use, or to disable aspects of its functionality.

16.3.2 fn:transform

Summary

Invokes a transformation using a dynamically-loaded XSLT stylesheet.

Signature

declare %public function r:random-sequence($length as xs:integer) as xs:double* {
  r:random-sequence($length, fn:random-number-generator())
};

declare %private function r:random-sequence($length as xs:integer, 
                                            $G as map(xs:string, item())) {
  if ($length eq 0)
  then ()
  else ($G?number, r:random-sequence($length - 1, $G?next()))
};

r:random-sequence(200);
            
019(
declare %public function r:random-sequence($length as xs:integer) as xs:double* {
  r:random-sequence($length, fn:random-number-generator())
};

declare %private function r:random-sequence($length as xs:integer, 
                                            $G as map(xs:string, item())) {
  if ($length eq 0)
  then ()
  else ($G?number, r:random-sequence($length - 1, $G?next()))
};

r:random-sequence(200);
            
030
let $para := 
In a hole in the ground there lived a hobbit.
         
71
let $para := 
In a hole in the ground there lived a hobbit.
         
32)
let $para := 
In a hole in the ground there lived a hobbit.
         
71
let $para := 
In a hole in the ground there lived a hobbit.
         
32

Properties

This function is ·nondeterministic·, ·context-dependent·, and ·focus-independent·.

Rules

This function loads an XSLT stylesheet and invokes it to perform a transformation.

The inputs to the transformation are supplied in the form of a map. The ·option parameter conventions· apply to this map; they do not apply to any nested map unless otherwise specified.

The function first identifies the requested XSLT version, as follows:

  • If the

    declare %public function r:random-sequence($length as xs:integer) as xs:double* {
      r:random-sequence($length, fn:random-number-generator())
    };
    
    declare %private function r:random-sequence($length as xs:integer, 
                                                $G as map(xs:string, item())) {
      if ($length eq 0)
      then ()
      else ($G?number, r:random-sequence($length - 1, $G?next()))
    };
    
    r:random-sequence(200);
                
    071 option is present, the requested XSLT version is the value of that option.

  • Otherwise, the requested XSLT version is the value of the

    declare %public function r:random-sequence($length as xs:integer) as xs:double* {
      r:random-sequence($length, fn:random-number-generator())
    };
    
    declare %private function r:random-sequence($length as xs:integer, 
                                                $G as map(xs:string, item())) {
      if ($length eq 0)
      then ()
      else ($G?number, r:random-sequence($length - 1, $G?next()))
    };
    
    r:random-sequence(200);
                
    072 attribute of the outermost element in the supplied stylesheet or package.

The function then attempts to locate an XSLT processor that implements the requested XSLT version.

  • If a processor that implements the requested XSLT version is available, then it is used.

  • Otherwise, if a processor that implements a version later than the requested version is available, then it is used.

  • Otherwise, the function fails indicating that no suitable XSLT processor is available.

Note:

The phrase locate an XSLT processor includes the possibility of locating a software product and configuring it to act as an XSLT processor that implements the requested XSLT version.

If more than one XSLT processor is available under the above rules, then the one that is chosen may be selected according to the availability of requested features: see below.

Once an XSLT processor has been selected that implements a given version of XSLT, the processor follows the rules of that version of the XSLT specification. This includes any decision to operate in backwards or forwards compatibility mode. For example, if an XSLT 2.0 processor is selected, and the stylesheet specifies

declare %public function r:random-sequence($length as xs:integer) as xs:double* {
  r:random-sequence($length, fn:random-number-generator())
};

declare %private function r:random-sequence($length as xs:integer, 
                                            $G as map(xs:string, item())) {
  if ($length eq 0)
  then ()
  else ($G?number, r:random-sequence($length - 1, $G?next()))
};

r:random-sequence(200);
            
073, then the processor will operate in backwards compatibility mode; if the same processor is selected and the stylesheet specifies
declare %public function r:random-sequence($length as xs:integer) as xs:double* {
  r:random-sequence($length, fn:random-number-generator())
};

declare %private function r:random-sequence($length as xs:integer, 
                                            $G as map(xs:string, item())) {
  if ($length eq 0)
  then ()
  else ($G?number, r:random-sequence($length - 1, $G?next()))
};

r:random-sequence(200);
            
074, the processor will operate in forwards compatibility mode.

The combinations of options that are relevant to each version of XSLT, other than

declare %public function r:random-sequence($length as xs:integer) as xs:double* {
  r:random-sequence($length, fn:random-number-generator())
};

declare %private function r:random-sequence($length as xs:integer, 
                                            $G as map(xs:string, item())) {
  if ($length eq 0)
  then ()
  else ($G?number, r:random-sequence($length - 1, $G?next()))
};

r:random-sequence(200);
            
071 itself, are listed below. This is followed by a table giving the meaning of each option.

  1. For invocation of an XSLT 1.0 processor (see [XSL Transformations (XSLT) Version 1.0]), the supplied options must include all of the following (if anything else is present, it is ignored):

    1. The stylesheet, provided by supplying exactly one of the following:

      declare %public function r:random-sequence($length as xs:integer) as xs:double* {
        r:random-sequence($length, fn:random-number-generator())
      };
      
      declare %private function r:random-sequence($length as xs:integer, 
                                                  $G as map(xs:string, item())) {
        if ($length eq 0)
        then ()
        else ($G?number, r:random-sequence($length - 1, $G?next()))
      };
      
      r:random-sequence(200);
                  
      076
      declare %public function r:random-sequence($length as xs:integer) as xs:double* {
        r:random-sequence($length, fn:random-number-generator())
      };
      
      declare %private function r:random-sequence($length as xs:integer, 
                                                  $G as map(xs:string, item())) {
        if ($length eq 0)
        then ()
        else ($G?number, r:random-sequence($length - 1, $G?next()))
      };
      
      r:random-sequence(200);
                  
      077
      declare %public function r:random-sequence($length as xs:integer) as xs:double* {
        r:random-sequence($length, fn:random-number-generator())
      };
      
      declare %private function r:random-sequence($length as xs:integer, 
                                                  $G as map(xs:string, item())) {
        if ($length eq 0)
        then ()
        else ($G?number, r:random-sequence($length - 1, $G?next()))
      };
      
      r:random-sequence(200);
                  
      078

    2. The source tree, provided as the value of the

      declare %public function r:random-sequence($length as xs:integer) as xs:double* {
        r:random-sequence($length, fn:random-number-generator())
      };
      
      declare %private function r:random-sequence($length as xs:integer, 
                                                  $G as map(xs:string, item())) {
        if ($length eq 0)
        then ()
        else ($G?number, r:random-sequence($length - 1, $G?next()))
      };
      
      r:random-sequence(200);
                  
      079 option.

    3. Zero or more of the following additional options:

      declare %public function r:random-sequence($length as xs:integer) as xs:double* {
        r:random-sequence($length, fn:random-number-generator())
      };
      
      declare %private function r:random-sequence($length as xs:integer, 
                                                  $G as map(xs:string, item())) {
        if ($length eq 0)
        then ()
        else ($G?number, r:random-sequence($length - 1, $G?next()))
      };
      
      r:random-sequence(200);
                  
      080
      declare %public function r:random-sequence($length as xs:integer) as xs:double* {
        r:random-sequence($length, fn:random-number-generator())
      };
      
      declare %private function r:random-sequence($length as xs:integer, 
                                                  $G as map(xs:string, item())) {
        if ($length eq 0)
        then ()
        else ($G?number, r:random-sequence($length - 1, $G?next()))
      };
      
      r:random-sequence(200);
                  
      081 (defaults to an empty map)
      declare %public function r:random-sequence($length as xs:integer) as xs:double* {
        r:random-sequence($length, fn:random-number-generator())
      };
      
      declare %private function r:random-sequence($length as xs:integer, 
                                                  $G as map(xs:string, item())) {
        if ($length eq 0)
        then ()
        else ($G?number, r:random-sequence($length - 1, $G?next()))
      };
      
      r:random-sequence(200);
                  
      082 (defaults to the unnamed mode)
      declare %public function r:random-sequence($length as xs:integer) as xs:double* {
        r:random-sequence($length, fn:random-number-generator())
      };
      
      declare %private function r:random-sequence($length as xs:integer, 
                                                  $G as map(xs:string, item())) {
        if ($length eq 0)
        then ()
        else ($G?number, r:random-sequence($length - 1, $G?next()))
      };
      
      r:random-sequence(200);
                  
      083 (defaults to
      declare %public function r:random-sequence($length as xs:integer) as xs:double* {
        r:random-sequence($length, fn:random-number-generator())
      };
      
      declare %private function r:random-sequence($length as xs:integer, 
                                                  $G as map(xs:string, item())) {
        if ($length eq 0)
        then ()
        else ($G?number, r:random-sequence($length - 1, $G?next()))
      };
      
      r:random-sequence(200);
                  
      084)
      declare %public function r:random-sequence($length as xs:integer) as xs:double* {
        r:random-sequence($length, fn:random-number-generator())
      };
      
      declare %private function r:random-sequence($length as xs:integer, 
                                                  $G as map(xs:string, item())) {
        if ($length eq 0)
        then ()
        else ($G?number, r:random-sequence($length - 1, $G?next()))
      };
      
      r:random-sequence(200);
                  
      085 (defaults to an empty map)
      declare %public function r:random-sequence($length as xs:integer) as xs:double* {
        r:random-sequence($length, fn:random-number-generator())
      };
      
      declare %private function r:random-sequence($length as xs:integer, 
                                                  $G as map(xs:string, item())) {
        if ($length eq 0)
        then ()
        else ($G?number, r:random-sequence($length - 1, $G?next()))
      };
      
      r:random-sequence(200);
                  
      086 (default is implementation-defined)
      declare %public function r:random-sequence($length as xs:integer) as xs:double* {
        r:random-sequence($length, fn:random-number-generator())
      };
      
      declare %private function r:random-sequence($length as xs:integer, 
                                                  $G as map(xs:string, item())) {
        if ($length eq 0)
        then ()
        else ($G?number, r:random-sequence($length - 1, $G?next()))
      };
      
      r:random-sequence(200);
                  
      087 (default is an empty map)
      declare %public function r:random-sequence($length as xs:integer) as xs:double* {
        r:random-sequence($length, fn:random-number-generator())
      };
      
      declare %private function r:random-sequence($length as xs:integer, 
                                                  $G as map(xs:string, item())) {
        if ($length eq 0)
        then ()
        else ($G?number, r:random-sequence($length - 1, $G?next()))
      };
      
      r:random-sequence(200);
                  
      050 (defaults to an empty map)
      declare %public function r:random-sequence($length as xs:integer) as xs:double* {
        r:random-sequence($length, fn:random-number-generator())
      };
      
      declare %private function r:random-sequence($length as xs:integer, 
                                                  $G as map(xs:string, item())) {
        if ($length eq 0)
        then ()
        else ($G?number, r:random-sequence($length - 1, $G?next()))
      };
      
      r:random-sequence(200);
                  
      089 (default is implementation-defined)

  2. For invocation of an XSLT 2.0 processor (see [XSL Transformations (XSLT) Version 2.0]), the supplied options must include all of the following (if anything else is present, it is ignored):

    1. The stylesheet, provided by supplying exactly one of the following:

      declare %public function r:random-sequence($length as xs:integer) as xs:double* {
        r:random-sequence($length, fn:random-number-generator())
      };
      
      declare %private function r:random-sequence($length as xs:integer, 
                                                  $G as map(xs:string, item())) {
        if ($length eq 0)
        then ()
        else ($G?number, r:random-sequence($length - 1, $G?next()))
      };
      
      r:random-sequence(200);
                  
      076
      declare %public function r:random-sequence($length as xs:integer) as xs:double* {
        r:random-sequence($length, fn:random-number-generator())
      };
      
      declare %private function r:random-sequence($length as xs:integer, 
                                                  $G as map(xs:string, item())) {
        if ($length eq 0)
        then ()
        else ($G?number, r:random-sequence($length - 1, $G?next()))
      };
      
      r:random-sequence(200);
                  
      077
      declare %public function r:random-sequence($length as xs:integer) as xs:double* {
        r:random-sequence($length, fn:random-number-generator())
      };
      
      declare %private function r:random-sequence($length as xs:integer, 
                                                  $G as map(xs:string, item())) {
        if ($length eq 0)
        then ()
        else ($G?number, r:random-sequence($length - 1, $G?next()))
      };
      
      r:random-sequence(200);
                  
      078

    2. Invocation details, as exactly one of the following:

      1. For apply-templates invocation, all of the following:

        declare %public function r:random-sequence($length as xs:integer) as xs:double* {
          r:random-sequence($length, fn:random-number-generator())
        };
        
        declare %private function r:random-sequence($length as xs:integer, 
                                                    $G as map(xs:string, item())) {
          if ($length eq 0)
          then ()
          else ($G?number, r:random-sequence($length - 1, $G?next()))
        };
        
        r:random-sequence(200);
                    
        079

        Optionally,

        declare %public function r:random-sequence($length as xs:integer) as xs:double* {
          r:random-sequence($length, fn:random-number-generator())
        };
        
        declare %private function r:random-sequence($length as xs:integer, 
                                                    $G as map(xs:string, item())) {
          if ($length eq 0)
          then ()
          else ($G?number, r:random-sequence($length - 1, $G?next()))
        };
        
        r:random-sequence(200);
                    
        082 (defaults to the unnamed mode)

      2. For call-template invocation, all of the following:

        declare %public function r:random-sequence($length as xs:integer) as xs:double* {
          r:random-sequence($length, fn:random-number-generator())
        };
        
        declare %private function r:random-sequence($length as xs:integer, 
                                                    $G as map(xs:string, item())) {
          if ($length eq 0)
          then ()
          else ($G?number, r:random-sequence($length - 1, $G?next()))
        };
        
        r:random-sequence(200);
                    
        095

        Optionally,

        declare %public function r:random-sequence($length as xs:integer) as xs:double* {
          r:random-sequence($length, fn:random-number-generator())
        };
        
        declare %private function r:random-sequence($length as xs:integer, 
                                                    $G as map(xs:string, item())) {
          if ($length eq 0)
          then ()
          else ($G?number, r:random-sequence($length - 1, $G?next()))
        };
        
        r:random-sequence(200);
                    
        079

    3. Zero or more of the following additional options:

      declare %public function r:random-sequence($length as xs:integer) as xs:double* {
        r:random-sequence($length, fn:random-number-generator())
      };
      
      declare %private function r:random-sequence($length as xs:integer, 
                                                  $G as map(xs:string, item())) {
        if ($length eq 0)
        then ()
        else ($G?number, r:random-sequence($length - 1, $G?next()))
      };
      
      r:random-sequence(200);
                  
      080
      declare %public function r:random-sequence($length as xs:integer) as xs:double* {
        r:random-sequence($length, fn:random-number-generator())
      };
      
      declare %private function r:random-sequence($length as xs:integer, 
                                                  $G as map(xs:string, item())) {
        if ($length eq 0)
        then ()
        else ($G?number, r:random-sequence($length - 1, $G?next()))
      };
      
      r:random-sequence(200);
                  
      081 (defaults to an empty map)
      declare %public function r:random-sequence($length as xs:integer) as xs:double* {
        r:random-sequence($length, fn:random-number-generator())
      };
      
      declare %private function r:random-sequence($length as xs:integer, 
                                                  $G as map(xs:string, item())) {
        if ($length eq 0)
        then ()
        else ($G?number, r:random-sequence($length - 1, $G?next()))
      };
      
      r:random-sequence(200);
                  
      099 (defaults to absent)
      declare %public function r:random-sequence($length as xs:integer) as xs:double* {
        r:random-sequence($length, fn:random-number-generator())
      };
      
      declare %private function r:random-sequence($length as xs:integer, 
                                                  $G as map(xs:string, item())) {
        if ($length eq 0)
        then ()
        else ($G?number, r:random-sequence($length - 1, $G?next()))
      };
      
      r:random-sequence(200);
                  
      083 (defaults to
      declare %public function r:random-sequence($length as xs:integer) as xs:double* {
        r:random-sequence($length, fn:random-number-generator())
      };
      
      declare %private function r:random-sequence($length as xs:integer, 
                                                  $G as map(xs:string, item())) {
        if ($length eq 0)
        then ()
        else ($G?number, r:random-sequence($length - 1, $G?next()))
      };
      
      r:random-sequence(200);
                  
      084)
      declare %public function r:random-sequence($length as xs:integer) as xs:double* {
        r:random-sequence($length, fn:random-number-generator())
      };
      
      declare %private function r:random-sequence($length as xs:integer, 
                                                  $G as map(xs:string, item())) {
        if ($length eq 0)
        then ()
        else ($G?number, r:random-sequence($length - 1, $G?next()))
      };
      
      r:random-sequence(200);
                  
      085 (defaults to an empty map)
      declare %public function r:random-sequence($length as xs:integer) as xs:double* {
        r:random-sequence($length, fn:random-number-generator())
      };
      
      declare %private function r:random-sequence($length as xs:integer, 
                                                  $G as map(xs:string, item())) {
        if ($length eq 0)
        then ()
        else ($G?number, r:random-sequence($length - 1, $G?next()))
      };
      
      r:random-sequence(200);
                  
      086 (default is implementation-defined)
      declare %public function r:random-sequence($length as xs:integer) as xs:double* {
        r:random-sequence($length, fn:random-number-generator())
      };
      
      declare %private function r:random-sequence($length as xs:integer, 
                                                  $G as map(xs:string, item())) {
        if ($length eq 0)
        then ()
        else ($G?number, r:random-sequence($length - 1, $G?next()))
      };
      
      r:random-sequence(200);
                  
      104 (default is implementation-defined)
      declare %public function r:random-sequence($length as xs:integer) as xs:double* {
        r:random-sequence($length, fn:random-number-generator())
      };
      
      declare %private function r:random-sequence($length as xs:integer, 
                                                  $G as map(xs:string, item())) {
        if ($length eq 0)
        then ()
        else ($G?number, r:random-sequence($length - 1, $G?next()))
      };
      
      r:random-sequence(200);
                  
      087 (default is an empty map)
      declare %public function r:random-sequence($length as xs:integer) as xs:double* {
        r:random-sequence($length, fn:random-number-generator())
      };
      
      declare %private function r:random-sequence($length as xs:integer, 
                                                  $G as map(xs:string, item())) {
        if ($length eq 0)
        then ()
        else ($G?number, r:random-sequence($length - 1, $G?next()))
      };
      
      r:random-sequence(200);
                  
      050 (defaults to an empty map)
      declare %public function r:random-sequence($length as xs:integer) as xs:double* {
        r:random-sequence($length, fn:random-number-generator())
      };
      
      declare %private function r:random-sequence($length as xs:integer, 
                                                  $G as map(xs:string, item())) {
        if ($length eq 0)
        then ()
        else ($G?number, r:random-sequence($length - 1, $G?next()))
      };
      
      r:random-sequence(200);
                  
      089 (default is implementation-defined)

  3. For invocation of an XSLT 3.0 processor (see [XSL Transformations (XSLT) Version 3.0]), the supplied options must include all of the following (if anything else is present, it is ignored):

    1. The stylesheet, provided either by supplying exactly one of the following:

      declare %public function r:random-sequence($length as xs:integer) as xs:double* {
        r:random-sequence($length, fn:random-number-generator())
      };
      
      declare %private function r:random-sequence($length as xs:integer, 
                                                  $G as map(xs:string, item())) {
        if ($length eq 0)
        then ()
        else ($G?number, r:random-sequence($length - 1, $G?next()))
      };
      
      r:random-sequence(200);
                  
      076
      declare %public function r:random-sequence($length as xs:integer) as xs:double* {
        r:random-sequence($length, fn:random-number-generator())
      };
      
      declare %private function r:random-sequence($length as xs:integer, 
                                                  $G as map(xs:string, item())) {
        if ($length eq 0)
        then ()
        else ($G?number, r:random-sequence($length - 1, $G?next()))
      };
      
      r:random-sequence(200);
                  
      077
      declare %public function r:random-sequence($length as xs:integer) as xs:double* {
        r:random-sequence($length, fn:random-number-generator())
      };
      
      declare %private function r:random-sequence($length as xs:integer, 
                                                  $G as map(xs:string, item())) {
        if ($length eq 0)
        then ()
        else ($G?number, r:random-sequence($length - 1, $G?next()))
      };
      
      r:random-sequence(200);
                  
      078

      Or by supplying exactly one of the following:

      declare %public function r:random-sequence($length as xs:integer) as xs:double* {
        r:random-sequence($length, fn:random-number-generator())
      };
      
      declare %private function r:random-sequence($length as xs:integer, 
                                                  $G as map(xs:string, item())) {
        if ($length eq 0)
        then ()
        else ($G?number, r:random-sequence($length - 1, $G?next()))
      };
      
      r:random-sequence(200);
                  
      111
      declare %public function r:random-sequence($length as xs:integer) as xs:double* {
        r:random-sequence($length, fn:random-number-generator())
      };
      
      declare %private function r:random-sequence($length as xs:integer, 
                                                  $G as map(xs:string, item())) {
        if ($length eq 0)
        then ()
        else ($G?number, r:random-sequence($length - 1, $G?next()))
      };
      
      r:random-sequence(200);
                  
      112
      declare %public function r:random-sequence($length as xs:integer) as xs:double* {
        r:random-sequence($length, fn:random-number-generator())
      };
      
      declare %private function r:random-sequence($length as xs:integer, 
                                                  $G as map(xs:string, item())) {
        if ($length eq 0)
        then ()
        else ($G?number, r:random-sequence($length - 1, $G?next()))
      };
      
      r:random-sequence(200);
                  
      113
      declare %public function r:random-sequence($length as xs:integer) as xs:double* {
        r:random-sequence($length, fn:random-number-generator())
      };
      
      declare %private function r:random-sequence($length as xs:integer, 
                                                  $G as map(xs:string, item())) {
        if ($length eq 0)
        then ()
        else ($G?number, r:random-sequence($length - 1, $G?next()))
      };
      
      r:random-sequence(200);
                  
      114 plus optionally
      declare %public function r:random-sequence($length as xs:integer) as xs:double* {
        r:random-sequence($length, fn:random-number-generator())
      };
      
      declare %private function r:random-sequence($length as xs:integer, 
                                                  $G as map(xs:string, item())) {
        if ($length eq 0)
        then ()
        else ($G?number, r:random-sequence($length - 1, $G?next()))
      };
      
      r:random-sequence(200);
                  
      115

    2. Invocation details, as exactly one of the following combinations:

      1. For apply-templates invocation, all of the following:

        Exactly one of

        declare %public function r:random-sequence($length as xs:integer) as xs:double* {
          r:random-sequence($length, fn:random-number-generator())
        };
        
        declare %private function r:random-sequence($length as xs:integer, 
                                                    $G as map(xs:string, item())) {
          if ($length eq 0)
          then ()
          else ($G?number, r:random-sequence($length - 1, $G?next()))
        };
        
        r:random-sequence(200);
                    
        079 or
        declare %public function r:random-sequence($length as xs:integer) as xs:double* {
          r:random-sequence($length, fn:random-number-generator())
        };
        
        declare %private function r:random-sequence($length as xs:integer, 
                                                    $G as map(xs:string, item())) {
          if ($length eq 0)
          then ()
          else ($G?number, r:random-sequence($length - 1, $G?next()))
        };
        
        r:random-sequence(200);
                    
        117

        Optionally,

        declare %public function r:random-sequence($length as xs:integer) as xs:double* {
          r:random-sequence($length, fn:random-number-generator())
        };
        
        declare %private function r:random-sequence($length as xs:integer, 
                                                    $G as map(xs:string, item())) {
          if ($length eq 0)
          then ()
          else ($G?number, r:random-sequence($length - 1, $G?next()))
        };
        
        r:random-sequence(200);
                    
        082

        Optionally,

        declare %public function r:random-sequence($length as xs:integer) as xs:double* {
          r:random-sequence($length, fn:random-number-generator())
        };
        
        declare %private function r:random-sequence($length as xs:integer, 
                                                    $G as map(xs:string, item())) {
          if ($length eq 0)
          then ()
          else ($G?number, r:random-sequence($length - 1, $G?next()))
        };
        
        r:random-sequence(200);
                    
        119

        Optionally,

        declare %public function r:random-sequence($length as xs:integer) as xs:double* {
          r:random-sequence($length, fn:random-number-generator())
        };
        
        declare %private function r:random-sequence($length as xs:integer, 
                                                    $G as map(xs:string, item())) {
          if ($length eq 0)
          then ()
          else ($G?number, r:random-sequence($length - 1, $G?next()))
        };
        
        r:random-sequence(200);
                    
        120

      2. For call-template invocation using an explicit template name, all of the following:

        declare %public function r:random-sequence($length as xs:integer) as xs:double* {
          r:random-sequence($length, fn:random-number-generator())
        };
        
        declare %private function r:random-sequence($length as xs:integer, 
                                                    $G as map(xs:string, item())) {
          if ($length eq 0)
          then ()
          else ($G?number, r:random-sequence($length - 1, $G?next()))
        };
        
        r:random-sequence(200);
                    
        095

        Optionally,

        declare %public function r:random-sequence($length as xs:integer) as xs:double* {
          r:random-sequence($length, fn:random-number-generator())
        };
        
        declare %private function r:random-sequence($length as xs:integer, 
                                                    $G as map(xs:string, item())) {
          if ($length eq 0)
          then ()
          else ($G?number, r:random-sequence($length - 1, $G?next()))
        };
        
        r:random-sequence(200);
                    
        119

        Optionally,

        declare %public function r:random-sequence($length as xs:integer) as xs:double* {
          r:random-sequence($length, fn:random-number-generator())
        };
        
        declare %private function r:random-sequence($length as xs:integer, 
                                                    $G as map(xs:string, item())) {
          if ($length eq 0)
          then ()
          else ($G?number, r:random-sequence($length - 1, $G?next()))
        };
        
        r:random-sequence(200);
                    
        120

        Optionally,

        declare %public function r:random-sequence($length as xs:integer) as xs:double* {
          r:random-sequence($length, fn:random-number-generator())
        };
        
        declare %private function r:random-sequence($length as xs:integer, 
                                                    $G as map(xs:string, item())) {
          if ($length eq 0)
          then ()
          else ($G?number, r:random-sequence($length - 1, $G?next()))
        };
        
        r:random-sequence(200);
                    
        079

      3. For call-template invocation using the defaulted template name

        declare %public function r:random-sequence($length as xs:integer) as xs:double* {
          r:random-sequence($length, fn:random-number-generator())
        };
        
        declare %private function r:random-sequence($length as xs:integer, 
                                                    $G as map(xs:string, item())) {
          if ($length eq 0)
          then ()
          else ($G?number, r:random-sequence($length - 1, $G?next()))
        };
        
        r:random-sequence(200);
                    
        125, all of the following:

        Optionally,

        declare %public function r:random-sequence($length as xs:integer) as xs:double* {
          r:random-sequence($length, fn:random-number-generator())
        };
        
        declare %private function r:random-sequence($length as xs:integer, 
                                                    $G as map(xs:string, item())) {
          if ($length eq 0)
          then ()
          else ($G?number, r:random-sequence($length - 1, $G?next()))
        };
        
        r:random-sequence(200);
                    
        119

        Optionally,

        declare %public function r:random-sequence($length as xs:integer) as xs:double* {
          r:random-sequence($length, fn:random-number-generator())
        };
        
        declare %private function r:random-sequence($length as xs:integer, 
                                                    $G as map(xs:string, item())) {
          if ($length eq 0)
          then ()
          else ($G?number, r:random-sequence($length - 1, $G?next()))
        };
        
        r:random-sequence(200);
                    
        120

        Note:

        If the

        declare %public function r:random-sequence($length as xs:integer) as xs:double* {
          r:random-sequence($length, fn:random-number-generator())
        };
        
        declare %private function r:random-sequence($length as xs:integer, 
                                                    $G as map(xs:string, item())) {
          if ($length eq 0)
          then ()
          else ($G?number, r:random-sequence($length - 1, $G?next()))
        };
        
        r:random-sequence(200);
                    
        079 option is present and
        declare %public function r:random-sequence($length as xs:integer) as xs:double* {
          r:random-sequence($length, fn:random-number-generator())
        };
        
        declare %private function r:random-sequence($length as xs:integer, 
                                                    $G as map(xs:string, item())) {
          if ($length eq 0)
          then ()
          else ($G?number, r:random-sequence($length - 1, $G?next()))
        };
        
        r:random-sequence(200);
                    
        095 is absent, then apply-templates invocation will be used. To use call-template invocation on the template named
        declare %public function r:random-sequence($length as xs:integer) as xs:double* {
          r:random-sequence($length, fn:random-number-generator())
        };
        
        declare %private function r:random-sequence($length as xs:integer, 
                                                    $G as map(xs:string, item())) {
          if ($length eq 0)
          then ()
          else ($G?number, r:random-sequence($length - 1, $G?next()))
        };
        
        r:random-sequence(200);
                    
        125 while also supplying a context item for use when evaluating global variables, either (a) supply the context item using the
        declare %public function r:random-sequence($length as xs:integer) as xs:double* {
          r:random-sequence($length, fn:random-number-generator())
        };
        
        declare %private function r:random-sequence($length as xs:integer, 
                                                    $G as map(xs:string, item())) {
          if ($length eq 0)
          then ()
          else ($G?number, r:random-sequence($length - 1, $G?next()))
        };
        
        r:random-sequence(200);
                    
        131 option, or (b) supply
        declare %public function r:random-sequence($length as xs:integer) as xs:double* {
          r:random-sequence($length, fn:random-number-generator())
        };
        
        declare %private function r:random-sequence($length as xs:integer, 
                                                    $G as map(xs:string, item())) {
          if ($length eq 0)
          then ()
          else ($G?number, r:random-sequence($length - 1, $G?next()))
        };
        
        r:random-sequence(200);
                    
        079, and set the
        declare %public function r:random-sequence($length as xs:integer) as xs:double* {
          r:random-sequence($length, fn:random-number-generator())
        };
        
        declare %private function r:random-sequence($length as xs:integer, 
                                                    $G as map(xs:string, item())) {
          if ($length eq 0)
          then ()
          else ($G?number, r:random-sequence($length - 1, $G?next()))
        };
        
        r:random-sequence(200);
                    
        095 option explicitly to the QName
        declare %public function r:random-sequence($length as xs:integer) as xs:double* {
          r:random-sequence($length, fn:random-number-generator())
        };
        
        declare %private function r:random-sequence($length as xs:integer, 
                                                    $G as map(xs:string, item())) {
          if ($length eq 0)
          then ()
          else ($G?number, r:random-sequence($length - 1, $G?next()))
        };
        
        r:random-sequence(200);
                    
        125

      4. For call-function invocation, all of the following:

        declare %public function r:random-sequence($length as xs:integer) as xs:double* {
          r:random-sequence($length, fn:random-number-generator())
        };
        
        declare %private function r:random-sequence($length as xs:integer, 
                                                    $G as map(xs:string, item())) {
          if ($length eq 0)
          then ()
          else ($G?number, r:random-sequence($length - 1, $G?next()))
        };
        
        r:random-sequence(200);
                    
        135

        declare %public function r:random-sequence($length as xs:integer) as xs:double* {
          r:random-sequence($length, fn:random-number-generator())
        };
        
        declare %private function r:random-sequence($length as xs:integer, 
                                                    $G as map(xs:string, item())) {
          if ($length eq 0)
          then ()
          else ($G?number, r:random-sequence($length - 1, $G?next()))
        };
        
        r:random-sequence(200);
                    
        136

      Note:

      The invocation method can be determined as the first of the following which applies:

      • If

        declare %public function r:random-sequence($length as xs:integer) as xs:double* {
          r:random-sequence($length, fn:random-number-generator())
        };
        
        declare %private function r:random-sequence($length as xs:integer, 
                                                    $G as map(xs:string, item())) {
          if ($length eq 0)
          then ()
          else ($G?number, r:random-sequence($length - 1, $G?next()))
        };
        
        r:random-sequence(200);
                    
        135 is present, then call-function invocation.

      • If

        declare %public function r:random-sequence($length as xs:integer) as xs:double* {
          r:random-sequence($length, fn:random-number-generator())
        };
        
        declare %private function r:random-sequence($length as xs:integer, 
                                                    $G as map(xs:string, item())) {
          if ($length eq 0)
          then ()
          else ($G?number, r:random-sequence($length - 1, $G?next()))
        };
        
        r:random-sequence(200);
                    
        095 is present, then call-template invocation.

      • If

        declare %public function r:random-sequence($length as xs:integer) as xs:double* {
          r:random-sequence($length, fn:random-number-generator())
        };
        
        declare %private function r:random-sequence($length as xs:integer, 
                                                    $G as map(xs:string, item())) {
          if ($length eq 0)
          then ()
          else ($G?number, r:random-sequence($length - 1, $G?next()))
        };
        
        r:random-sequence(200);
                    
        079 or
        declare %public function r:random-sequence($length as xs:integer) as xs:double* {
          r:random-sequence($length, fn:random-number-generator())
        };
        
        declare %private function r:random-sequence($length as xs:integer, 
                                                    $G as map(xs:string, item())) {
          if ($length eq 0)
          then ()
          else ($G?number, r:random-sequence($length - 1, $G?next()))
        };
        
        r:random-sequence(200);
                    
        117 is present, then apply-templates invocation.

      • Otherwise,

        declare %public function r:random-sequence($length as xs:integer) as xs:double* {
          r:random-sequence($length, fn:random-number-generator())
        };
        
        declare %private function r:random-sequence($length as xs:integer, 
                                                    $G as map(xs:string, item())) {
          if ($length eq 0)
          then ()
          else ($G?number, r:random-sequence($length - 1, $G?next()))
        };
        
        r:random-sequence(200);
                    
        141 invocation using the default entry point
        declare %public function r:random-sequence($length as xs:integer) as xs:double* {
          r:random-sequence($length, fn:random-number-generator())
        };
        
        declare %private function r:random-sequence($length as xs:integer, 
                                                    $G as map(xs:string, item())) {
          if ($length eq 0)
          then ()
          else ($G?number, r:random-sequence($length - 1, $G?next()))
        };
        
        r:random-sequence(200);
                    
        125.

    3. Zero or more of the following additional options:

      declare %public function r:random-sequence($length as xs:integer) as xs:double* {
        r:random-sequence($length, fn:random-number-generator())
      };
      
      declare %private function r:random-sequence($length as xs:integer, 
                                                  $G as map(xs:string, item())) {
        if ($length eq 0)
        then ()
        else ($G?number, r:random-sequence($length - 1, $G?next()))
      };
      
      r:random-sequence(200);
                  
      080
      declare %public function r:random-sequence($length as xs:integer) as xs:double* {
        r:random-sequence($length, fn:random-number-generator())
      };
      
      declare %private function r:random-sequence($length as xs:integer, 
                                                  $G as map(xs:string, item())) {
        if ($length eq 0)
        then ()
        else ($G?number, r:random-sequence($length - 1, $G?next()))
      };
      
      r:random-sequence(200);
                  
      144 (defaults to an empty map)
      declare %public function r:random-sequence($length as xs:integer) as xs:double* {
        r:random-sequence($length, fn:random-number-generator())
      };
      
      declare %private function r:random-sequence($length as xs:integer, 
                                                  $G as map(xs:string, item())) {
        if ($length eq 0)
        then ()
        else ($G?number, r:random-sequence($length - 1, $G?next()))
      };
      
      r:random-sequence(200);
                  
      081 (defaults to an empty map)
      declare %public function r:random-sequence($length as xs:integer) as xs:double* {
        r:random-sequence($length, fn:random-number-generator())
      };
      
      declare %private function r:random-sequence($length as xs:integer, 
                                                  $G as map(xs:string, item())) {
        if ($length eq 0)
        then ()
        else ($G?number, r:random-sequence($length - 1, $G?next()))
      };
      
      r:random-sequence(200);
                  
      131 (defaults to absent)
      declare %public function r:random-sequence($length as xs:integer) as xs:double* {
        r:random-sequence($length, fn:random-number-generator())
      };
      
      declare %private function r:random-sequence($length as xs:integer, 
                                                  $G as map(xs:string, item())) {
        if ($length eq 0)
        then ()
        else ($G?number, r:random-sequence($length - 1, $G?next()))
      };
      
      r:random-sequence(200);
                  
      099 (defaults to absent)
      declare %public function r:random-sequence($length as xs:integer) as xs:double* {
        r:random-sequence($length, fn:random-number-generator())
      };
      
      declare %private function r:random-sequence($length as xs:integer, 
                                                  $G as map(xs:string, item())) {
        if ($length eq 0)
        then ()
        else ($G?number, r:random-sequence($length - 1, $G?next()))
      };
      
      r:random-sequence(200);
                  
      083
      declare %public function r:random-sequence($length as xs:integer) as xs:double* {
        r:random-sequence($length, fn:random-number-generator())
      };
      
      declare %private function r:random-sequence($length as xs:integer, 
                                                  $G as map(xs:string, item())) {
        if ($length eq 0)
        then ()
        else ($G?number, r:random-sequence($length - 1, $G?next()))
      };
      
      r:random-sequence(200);
                  
      085 (defaults to an empty map)
      declare %public function r:random-sequence($length as xs:integer) as xs:double* {
        r:random-sequence($length, fn:random-number-generator())
      };
      
      declare %private function r:random-sequence($length as xs:integer, 
                                                  $G as map(xs:string, item())) {
        if ($length eq 0)
        then ()
        else ($G?number, r:random-sequence($length - 1, $G?next()))
      };
      
      r:random-sequence(200);
                  
      150 (default is false)
      declare %public function r:random-sequence($length as xs:integer) as xs:double* {
        r:random-sequence($length, fn:random-number-generator())
      };
      
      declare %private function r:random-sequence($length as xs:integer, 
                                                  $G as map(xs:string, item())) {
        if ($length eq 0)
        then ()
        else ($G?number, r:random-sequence($length - 1, $G?next()))
      };
      
      r:random-sequence(200);
                  
      086 (default is implementation-defined)
      declare %public function r:random-sequence($length as xs:integer) as xs:double* {
        r:random-sequence($length, fn:random-number-generator())
      };
      
      declare %private function r:random-sequence($length as xs:integer, 
                                                  $G as map(xs:string, item())) {
        if ($length eq 0)
        then ()
        else ($G?number, r:random-sequence($length - 1, $G?next()))
      };
      
      r:random-sequence(200);
                  
      104 (default is implementation-defined)
      declare %public function r:random-sequence($length as xs:integer) as xs:double* {
        r:random-sequence($length, fn:random-number-generator())
      };
      
      declare %private function r:random-sequence($length as xs:integer, 
                                                  $G as map(xs:string, item())) {
        if ($length eq 0)
        then ()
        else ($G?number, r:random-sequence($length - 1, $G?next()))
      };
      
      r:random-sequence(200);
                  
      087 (default is an empty map)
      declare %public function r:random-sequence($length as xs:integer) as xs:double* {
        r:random-sequence($length, fn:random-number-generator())
      };
      
      declare %private function r:random-sequence($length as xs:integer, 
                                                  $G as map(xs:string, item())) {
        if ($length eq 0)
        then ()
        else ($G?number, r:random-sequence($length - 1, $G?next()))
      };
      
      r:random-sequence(200);
                  
      050 (defaults to an empty map)
      declare %public function r:random-sequence($length as xs:integer) as xs:double* {
        r:random-sequence($length, fn:random-number-generator())
      };
      
      declare %private function r:random-sequence($length as xs:integer, 
                                                  $G as map(xs:string, item())) {
        if ($length eq 0)
        then ()
        else ($G?number, r:random-sequence($length - 1, $G?next()))
      };
      
      r:random-sequence(200);
                  
      089 (default is implementation-defined)

The meanings of each option are defined in the table below.

KeyApplies toValueMeaning
declare %public function r:random-sequence($length as xs:integer) as xs:double* {
  r:random-sequence($length, fn:random-number-generator())
};

declare %private function r:random-sequence($length as xs:integer, 
                                            $G as map(xs:string, item())) {
  if ($length eq 0)
  then ()
  else ($G?number, r:random-sequence($length - 1, $G?next()))
};

r:random-sequence(200);
            
0991.0, 2.0, 3.0The 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
declare %public function r:random-sequence($length as xs:integer) as xs:double* {
  r:random-sequence($length, fn:random-number-generator())
};

declare %private function r:random-sequence($length as xs:integer, 
                                            $G as map(xs:string, item())) {
  if ($length eq 0)
  then ()
  else ($G?number, r:random-sequence($length - 1, $G?next()))
};

r:random-sequence(200);
            
019 function call.
  • Type:

    let $para := 
    In a hole in the ground there lived a hobbit.
             
    10

  • Default:

    declare %public function r:random-sequence($length as xs:integer) as xs:double* {
      r:random-sequence($length, fn:random-number-generator())
    };
    
    declare %private function r:random-sequence($length as xs:integer, 
                                                $G as map(xs:string, item())) {
      if ($length eq 0)
      then ()
      else ($G?number, r:random-sequence($length - 1, $G?next()))
    };
    
    r:random-sequence(200);
                
    159

declare %public function r:random-sequence($length as xs:integer) as xs:double* {
  r:random-sequence($length, fn:random-number-generator())
};

declare %private function r:random-sequence($length as xs:integer, 
                                            $G as map(xs:string, item())) {
  if ($length eq 0)
  then ()
  else ($G?number, r:random-sequence($length - 1, $G?next()))
};

r:random-sequence(200);
            
0891.0, 2.0, 3.0This option has no effect on the result of the transformation but may affect efficiency. The value
op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
76 indicates an expectation that the same stylesheet is likely to be used for more than one transformation; the value
let $C := 'http://www.w3.org/2013/collation/UCA?strength=primary'
07 indicates an expectation that the stylesheet will be used once only.
  • Type:

    op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
    32

  • Default:

    let $para := 
    In a hole in the ground there lived a hobbit.
             
    182

declare %public function r:random-sequence($length as xs:integer) as xs:double* {
  r:random-sequence($length, fn:random-number-generator())
};

declare %private function r:random-sequence($length as xs:integer, 
                                            $G as map(xs:string, item())) {
  if ($length eq 0)
  then ()
  else ($G?number, r:random-sequence($length - 1, $G?next()))
};

r:random-sequence(200);
            
0831.0, 2.0, 3.0The manner in which the transformation results should be delivered. Applies both to the principal result document and to secondary result documents created using
declare %public function r:random-sequence($length as xs:integer) as xs:double* {
  r:random-sequence($length, fn:random-number-generator())
};

declare %private function r:random-sequence($length as xs:integer, 
                                            $G as map(xs:string, item())) {
  if ($length eq 0)
  then ()
  else ($G?number, r:random-sequence($length - 1, $G?next()))
};

r:random-sequence(200);
            
166.
  • Type:

    let $para := 
    In a hole in the ground there lived a hobbit.
             
    10

  • Default:

    declare %public function r:random-sequence($length as xs:integer) as xs:double* {
      r:random-sequence($length, fn:random-number-generator())
    };
    
    declare %private function r:random-sequence($length as xs:integer, 
                                                $G as map(xs:string, item())) {
      if ($length eq 0)
      then ()
      else ($G?number, r:random-sequence($length - 1, $G?next()))
    };
    
    r:random-sequence(200);
                
    168

declare %public function r:random-sequence($length as xs:integer) as xs:double* {
  r:random-sequence($length, fn:random-number-generator())
};

declare %private function r:random-sequence($length as xs:integer, 
                                            $G as map(xs:string, item())) {
  if ($length eq 0)
  then ()
  else ($G?number, r:random-sequence($length - 1, $G?next()))
};

r:random-sequence(200);
            
084The result is delivered as a document node.
declare %public function r:random-sequence($length as xs:integer) as xs:double* {
  r:random-sequence($length, fn:random-number-generator())
};

declare %private function r:random-sequence($length as xs:integer, 
                                            $G as map(xs:string, item())) {
  if ($length eq 0)
  then ()
  else ($G?number, r:random-sequence($length - 1, $G?next()))
};

r:random-sequence(200);
            
170The result is delivered as a string, representing the results of serialization. Note that (as with the
Primo Secondo Terzo Quarto Quinto ...
511 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.
declare %public function r:random-sequence($length as xs:integer) as xs:double* {
  r:random-sequence($length, fn:random-number-generator())
};

declare %private function r:random-sequence($length as xs:integer, 
                                            $G as map(xs:string, item())) {
  if ($length eq 0)
  then ()
  else ($G?number, r:random-sequence($length - 1, $G?next()))
};

r:random-sequence(200);
            
172The result of the initial template or function is returned as an arbitrary XDM value (after conversion to the declared type, but without wrapping in a document node, and without serialization): when this option is chosen, the returned map contains the raw result.
declare %public function r:random-sequence($length as xs:integer) as xs:double* {
  r:random-sequence($length, fn:random-number-generator())
};

declare %private function r:random-sequence($length as xs:integer, 
                                            $G as map(xs:string, item())) {
  if ($length eq 0)
  then ()
  else ($G?number, r:random-sequence($length - 1, $G?next()))
};

r:random-sequence(200);
            
1503.0Indicates whether any
declare %public function r:random-sequence($length as xs:integer) as xs:double* {
  r:random-sequence($length, fn:random-number-generator())
};

declare %private function r:random-sequence($length as xs:integer, 
                                            $G as map(xs:string, item())) {
  if ($length eq 0)
  then ()
  else ($G?number, r:random-sequence($length - 1, $G?next()))
};

r:random-sequence(200);
            
174 instructions in the stylesheet are to be evaluated.
  • Type:

    op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
    32

  • Default:

    let $para := 
    In a hole in the ground there lived a hobbit.
             
    184

declare %public function r:random-sequence($length as xs:integer) as xs:double* {
  r:random-sequence($length, fn:random-number-generator())
};

declare %private function r:random-sequence($length as xs:integer, 
                                            $G as map(xs:string, item())) {
  if ($length eq 0)
  then ()
  else ($G?number, r:random-sequence($length - 1, $G?next()))
};

r:random-sequence(200);
            
0861.0, 2.0, 3.0Indicates whether any
declare %public function r:random-sequence($length as xs:integer) as xs:double* {
  r:random-sequence($length, fn:random-number-generator())
};

declare %private function r:random-sequence($length as xs:integer, 
                                            $G as map(xs:string, item())) {
  if ($length eq 0)
  then ()
  else ($G?number, r:random-sequence($length - 1, $G?next()))
};

r:random-sequence(200);
            
178 instructions in the stylesheet are to be evaluated. The destination and formatting of any such messages is implementation-defined.
  • Type:

    op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
    32

  • Default:

    declare %public function r:random-sequence($length as xs:integer) as xs:double* {
      r:random-sequence($length, fn:random-number-generator())
    };
    
    declare %private function r:random-sequence($length as xs:integer, 
                                                $G as map(xs:string, item())) {
      if ($length eq 0)
      then ()
      else ($G?number, r:random-sequence($length - 1, $G?next()))
    };
    
    r:random-sequence(200);
                
    180

declare %public function r:random-sequence($length as xs:integer) as xs:double* {
  r:random-sequence($length, fn:random-number-generator())
};

declare %private function r:random-sequence($length as xs:integer, 
                                            $G as map(xs:string, item())) {
  if ($length eq 0)
  then ()
  else ($G?number, r:random-sequence($length - 1, $G?next()))
};

r:random-sequence(200);
            
1042.0, 3.0Indicates whether any
fn:abs($N * $arg2) le fn:abs($arg1) 
               and fn:compare($N * $arg2, 0) eq fn:compare($arg1, 0).
43 functions in the stylesheet are to generate diagnostic messages. The destination and formatting of any such messages is implementation-defined.
  • Type:

    op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
    32

  • Default:

    declare %public function r:random-sequence($length as xs:integer) as xs:double* {
      r:random-sequence($length, fn:random-number-generator())
    };
    
    declare %private function r:random-sequence($length as xs:integer, 
                                                $G as map(xs:string, item())) {
      if ($length eq 0)
      then ()
      else ($G?number, r:random-sequence($length - 1, $G?next()))
    };
    
    r:random-sequence(200);
                
    180

declare %public function r:random-sequence($length as xs:integer) as xs:double* {
  r:random-sequence($length, fn:random-number-generator())
};

declare %private function r:random-sequence($length as xs:integer, 
                                            $G as map(xs:string, item())) {
  if ($length eq 0)
  then ()
  else ($G?number, r:random-sequence($length - 1, $G?next()))
};

r:random-sequence(200);
            
1363.0An array of values to be used as the arguments to the initial function call. The value is converted to the required type of the declared parameter using the function conversion rules.
  • Type:

    declare %public function r:random-sequence($length as xs:integer) as xs:double* {
      r:random-sequence($length, fn:random-number-generator())
    };
    
    declare %private function r:random-sequence($length as xs:integer, 
                                                $G as map(xs:string, item())) {
      if ($length eq 0)
      then ()
      else ($G?number, r:random-sequence($length - 1, $G?next()))
    };
    
    r:random-sequence(200);
                
    186

  • Default:

    declare %public function r:random-sequence($length as xs:integer) as xs:double* {
      r:random-sequence($length, fn:random-number-generator())
    };
    
    declare %private function r:random-sequence($length as xs:integer, 
                                                $G as map(xs:string, item())) {
      if ($length eq 0)
      then ()
      else ($G?number, r:random-sequence($length - 1, $G?next()))
    };
    
    r:random-sequence(200);
                
    187

declare %public function r:random-sequence($length as xs:integer) as xs:double* {
  r:random-sequence($length, fn:random-number-generator())
};

declare %private function r:random-sequence($length as xs:integer, 
                                            $G as map(xs:string, item())) {
  if ($length eq 0)
  then ()
  else ($G?number, r:random-sequence($length - 1, $G?next()))
};

r:random-sequence(200);
            
1313.0The value of the global context item, as defined in XSLT 3.0
  • Type:

    1º 2º 3º 4º ...
    775

  • Default:

    declare %public function r:random-sequence($length as xs:integer) as xs:double* {
      r:random-sequence($length, fn:random-number-generator())
    };
    
    declare %private function r:random-sequence($length as xs:integer, 
                                                $G as map(xs:string, item())) {
      if ($length eq 0)
      then ()
      else ($G?number, r:random-sequence($length - 1, $G?next()))
    };
    
    r:random-sequence(200);
                
    190

declare %public function r:random-sequence($length as xs:integer) as xs:double* {
  r:random-sequence($length, fn:random-number-generator())
};

declare %private function r:random-sequence($length as xs:integer, 
                                            $G as map(xs:string, item())) {
  if ($length eq 0)
  then ()
  else ($G?number, r:random-sequence($length - 1, $G?next()))
};

r:random-sequence(200);
            
1353.0The name of the initial function to be called for call-function invocation. The arity of the function is inferred from the length of
declare %public function r:random-sequence($length as xs:integer) as xs:double* {
  r:random-sequence($length, fn:random-number-generator())
};

declare %private function r:random-sequence($length as xs:integer, 
                                            $G as map(xs:string, item())) {
  if ($length eq 0)
  then ()
  else ($G?number, r:random-sequence($length - 1, $G?next()))
};

r:random-sequence(200);
            
136.
  • Type:

    let $para := 
    In a hole in the ground there lived a hobbit.
             
    36

  • Default:

    declare %public function r:random-sequence($length as xs:integer) as xs:double* {
      r:random-sequence($length, fn:random-number-generator())
    };
    
    declare %private function r:random-sequence($length as xs:integer, 
                                                $G as map(xs:string, item())) {
      if ($length eq 0)
      then ()
      else ($G?number, r:random-sequence($length - 1, $G?next()))
    };
    
    r:random-sequence(200);
                
    194

declare %public function r:random-sequence($length as xs:integer) as xs:double* {
  r:random-sequence($length, fn:random-number-generator())
};

declare %private function r:random-sequence($length as xs:integer, 
                                            $G as map(xs:string, item())) {
  if ($length eq 0)
  then ()
  else ($G?number, r:random-sequence($length - 1, $G?next()))
};

r:random-sequence(200);
            
1173.0The value of the initial match selection, as defined in XSLT 3.0
  • Type:

    op:operation(fenceHeight, xs:integer) => op:operation(xs:integer, xs:integer)
    16

  • Default:

    declare %public function r:random-sequence($length as xs:integer) as xs:double* {
      r:random-sequence($length, fn:random-number-generator())
    };
    
    declare %private function r:random-sequence($length as xs:integer, 
                                                $G as map(xs:string, item())) {
      if ($length eq 0)
      then ()
      else ($G?number, r:random-sequence($length - 1, $G?next()))
    };
    
    r:random-sequence(200);
                
    190

declare %public function r:random-sequence($length as xs:integer) as xs:double* {
  r:random-sequence($length, fn:random-number-generator())
};

declare %private function r:random-sequence($length as xs:integer, 
                                            $G as map(xs:string, item())) {
  if ($length eq 0)
  then ()
  else ($G?number, r:random-sequence($length - 1, $G?next()))
};

r:random-sequence(200);
            
0821.0, 2.0, 3.0The name of the initial processing mode.
  • Type:

    let $para := 
    In a hole in the ground there lived a hobbit.
             
    36

  • Default:

declare %public function r:random-sequence($length as xs:integer) as xs:double* {
  r:random-sequence($length, fn:random-number-generator())
};

declare %private function r:random-sequence($length as xs:integer, 
                                            $G as map(xs:string, item())) {
  if ($length eq 0)
  then ()
  else ($G?number, r:random-sequence($length - 1, $G?next()))
};

r:random-sequence(200);
            
0952.0, 3.0The name of a named template in the stylesheet to act as the initial entry point.
  • Type:

    let $para := 
    In a hole in the ground there lived a hobbit.
             
    36

  • Default:

    declare %public function r:random-sequence($length as xs:integer) as xs:double* {
      r:random-sequence($length, fn:random-number-generator())
    };
    
    declare %private function r:random-sequence($length as xs:integer, 
                                                $G as map(xs:string, item())) {
      if ($length eq 0)
      then ()
      else ($G?number, r:random-sequence($length - 1, $G?next()))
    };
    
    r:random-sequence(200);
                
    125

declare %public function r:random-sequence($length as xs:integer) as xs:double* {
  r:random-sequence($length, fn:random-number-generator())
};

declare %private function r:random-sequence($length as xs:integer, 
                                            $G as map(xs:string, item())) {
  if ($length eq 0)
  then ()
  else ($G?number, r:random-sequence($length - 1, $G?next()))
};

r:random-sequence(200);
            
1143.0The name of the top-level stylesheet package to be invoked (an absolute URI)
  • Type:

    let $para := 
    In a hole in the ground there lived a hobbit.
             
    10

  • Default:

    declare %public function r:random-sequence($length as xs:integer) as xs:double* {
      r:random-sequence($length, fn:random-number-generator())
    };
    
    declare %private function r:random-sequence($length as xs:integer, 
                                                $G as map(xs:string, item())) {
      if ($length eq 0)
      then ()
      else ($G?number, r:random-sequence($length - 1, $G?next()))
    };
    
    r:random-sequence(200);
                
    194

declare %public function r:random-sequence($length as xs:integer) as xs:double* {
  r:random-sequence($length, fn:random-number-generator())
};

declare %private function r:random-sequence($length as xs:integer, 
                                            $G as map(xs:string, item())) {
  if ($length eq 0)
  then ()
  else ($G?number, r:random-sequence($length - 1, $G?next()))
};

r:random-sequence(200);
            
1113.0The location of the top-level stylesheet package, as a relative or absolute URI
  • Type:

    let $para := 
    In a hole in the ground there lived a hobbit.
             
    10

  • Default:

    declare %public function r:random-sequence($length as xs:integer) as xs:double* {
      r:random-sequence($length, fn:random-number-generator())
    };
    
    declare %private function r:random-sequence($length as xs:integer, 
                                                $G as map(xs:string, item())) {
      if ($length eq 0)
      then ()
      else ($G?number, r:random-sequence($length - 1, $G?next()))
    };
    
    r:random-sequence(200);
                
    194

declare %public function r:random-sequence($length as xs:integer) as xs:double* {
  r:random-sequence($length, fn:random-number-generator())
};

declare %private function r:random-sequence($length as xs:integer, 
                                            $G as map(xs:string, item())) {
  if ($length eq 0)
  then ()
  else ($G?number, r:random-sequence($length - 1, $G?next()))
};

r:random-sequence(200);
            
1123.0A document or element node containing the top-level stylesheet package
  • Type:

    1º 2º 3º 4º ...
    147

  • Default:

    declare %public function r:random-sequence($length as xs:integer) as xs:double* {
      r:random-sequence($length, fn:random-number-generator())
    };
    
    declare %private function r:random-sequence($length as xs:integer, 
                                                $G as map(xs:string, item())) {
      if ($length eq 0)
      then ()
      else ($G?number, r:random-sequence($length - 1, $G?next()))
    };
    
    r:random-sequence(200);
                
    194

declare %public function r:random-sequence($length as xs:integer) as xs:double* {
  r:random-sequence($length, fn:random-number-generator())
};

declare %private function r:random-sequence($length as xs:integer, 
                                            $G as map(xs:string, item())) {
  if ($length eq 0)
  then ()
  else ($G?number, r:random-sequence($length - 1, $G?next()))
};

r:random-sequence(200);
            
1133.0The top-level stylesheet package in the form of unparsed lexical XML.
  • Type:

    let $para := 
    In a hole in the ground there lived a hobbit.
             
    10

  • Default:

    declare %public function r:random-sequence($length as xs:integer) as xs:double* {
      r:random-sequence($length, fn:random-number-generator())
    };
    
    declare %private function r:random-sequence($length as xs:integer, 
                                                $G as map(xs:string, item())) {
      if ($length eq 0)
      then ()
      else ($G?number, r:random-sequence($length - 1, $G?next()))
    };
    
    r:random-sequence(200);
                
    194

declare %public function r:random-sequence($length as xs:integer) as xs:double* {
  r:random-sequence($length, fn:random-number-generator())
};

declare %private function r:random-sequence($length as xs:integer, 
                                            $G as map(xs:string, item())) {
  if ($length eq 0)
  then ()
  else ($G?number, r:random-sequence($length - 1, $G?next()))
};

r:random-sequence(200);
            
1153.0The version of the top-level stylesheet package to be invoked.
  • Type:

    let $para := 
    In a hole in the ground there lived a hobbit.
             
    10

  • Default:

    declare %public function r:random-sequence($length as xs:integer) as xs:double* {
      r:random-sequence($length, fn:random-number-generator())
    };
    
    declare %private function r:random-sequence($length as xs:integer, 
                                                $G as map(xs:string, item())) {
      if ($length eq 0)
      then ()
      else ($G?number, r:random-sequence($length - 1, $G?next()))
    };
    
    r:random-sequence(200);
                
    217

declare %public function r:random-sequence($length as xs:integer) as xs:double* {
  r:random-sequence($length, fn:random-number-generator())
};

declare %private function r:random-sequence($length as xs:integer, 
                                            $G as map(xs:string, item())) {
  if ($length eq 0)
  then ()
  else ($G?number, r:random-sequence($length - 1, $G?next()))
};

r:random-sequence(200);
            
2181.0 2.0 3.0A function that is used to post-process each result document of the transformation (both the principal result and secondary results), in whatever form it would otherwise be delivered (document, serialized, or raw). The first argument of the function is the key used to identify the result in the map return by the
declare %public function r:random-sequence($length as xs:integer) as xs:double* {
  r:random-sequence($length, fn:random-number-generator())
};

declare %private function r:random-sequence($length as xs:integer, 
                                            $G as map(xs:string, item())) {
  if ($length eq 0)
  then ()
  else ($G?number, r:random-sequence($length - 1, $G?next()))
};

r:random-sequence(200);
            
019 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
declare %public function r:random-sequence($length as xs:integer) as xs:double* {
  r:random-sequence($length, fn:random-number-generator())
};

declare %private function r:random-sequence($length as xs:integer, 
                                            $G as map(xs:string, item())) {
  if ($length eq 0)
  then ()
  else ($G?number, r:random-sequence($length - 1, $G?next()))
};

r:random-sequence(200);
            
019 function is the result of applying this post-processing.

Note:

If the implementation provides a way of writing or invoking functions with side-effects, this post-processing function might be used to save a copy of the result document to persistent storage. For example, if the implementation provides access to the EXPath File library [EXPath], then a serialized document might be written to filestore by calling the

declare %public function r:random-sequence($length as xs:integer) as xs:double* {
  r:random-sequence($length, fn:random-number-generator())
};

declare %private function r:random-sequence($length as xs:integer, 
                                            $G as map(xs:string, item())) {
  if ($length eq 0)
  then ()
  else ($G?number, r:random-sequence($length - 1, $G?next()))
};

r:random-sequence(200);
            
221 function. Similar mechanisms might be used to issue an HTTP POST request that posts the result to an HTTP server, or to send the document to an email recipient. The semantics of calling functions with side-effects are entirely ·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

declare %public function r:random-sequence($length as xs:integer) as xs:double* {
  r:random-sequence($length, fn:random-number-generator())
};

declare %private function r:random-sequence($length as xs:integer, 
                                            $G as map(xs:string, item())) {
  if ($length eq 0)
  then ()
  else ($G?number, r:random-sequence($length - 1, $G?next()))
};

r:random-sequence(200);
            
019 function, then it does not matter what the post-processing function actually returns (it could be an empty sequence, for example).

Calls to

declare %public function r:random-sequence($length as xs:integer) as xs:double* {
  r:random-sequence($length, fn:random-number-generator())
};

declare %private function r:random-sequence($length as xs:integer, 
                                            $G as map(xs:string, item())) {
  if ($length eq 0)
  then ()
  else ($G?number, r:random-sequence($length - 1, $G?next()))
};

r:random-sequence(200);
            
019 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 ·implementation-defined·.

  • Type:

    declare %public function r:random-sequence($length as xs:integer) as xs:double* {
      r:random-sequence($length, fn:random-number-generator())
    };
    
    declare %private function r:random-sequence($length as xs:integer, 
                                                $G as map(xs:string, item())) {
      if ($length eq 0)
      then ()
      else ($G?number, r:random-sequence($length - 1, $G?next()))
    };
    
    r:random-sequence(200);
                
    224

  • Default:

    declare %public function r:random-sequence($length as xs:integer) as xs:double* {
      r:random-sequence($length, fn:random-number-generator())
    };
    
    declare %private function r:random-sequence($length as xs:integer, 
                                                $G as map(xs:string, item())) {
      if ($length eq 0)
      then ()
      else ($G?number, r:random-sequence($length - 1, $G?next()))
    };
    
    r:random-sequence(200);
                
    225

declare %public function r:random-sequence($length as xs:integer) as xs:double* {
  r:random-sequence($length, fn:random-number-generator())
};

declare %private function r:random-sequence($length as xs:integer, 
                                            $G as map(xs:string, item())) {
  if ($length eq 0)
  then ()
  else ($G?number, r:random-sequence($length - 1, $G?next()))
};

r:random-sequence(200);
            
0871.0, 2.0, 3.0The keys in the map are QNames that could legitimately be supplied in a call to the XSLT
declare %public function r:random-sequence($length as xs:integer) as xs:double* {
  r:random-sequence($length, fn:random-number-generator())
};

declare %private function r:random-sequence($length as xs:integer, 
                                            $G as map(xs:string, item())) {
  if ($length eq 0)
  then ()
  else ($G?number, r:random-sequence($length - 1, $G?next()))
};

r:random-sequence(200);
            
227 function; the values in the map are the requested settings of the corresponding property. The boolean values
let $para := 
In a hole in the ground there lived a hobbit.
         
182 and
let $para := 
In a hole in the ground there lived a hobbit.
         
184 are equivalent to the string values
let $para := 
In a hole in the ground there lived a hobbit.
         
097 and
let $para := 
In a hole in the ground there lived a hobbit.
         
095. As a special case, setting a value for
declare %public function r:random-sequence($length as xs:integer) as xs:double* {
  r:random-sequence($length, fn:random-number-generator())
};

declare %private function r:random-sequence($length as xs:integer, 
                                            $G as map(xs:string, item())) {
  if ($length eq 0)
  then ()
  else ($G?number, r:random-sequence($length - 1, $G?next()))
};

r:random-sequence(200);
            
232 has no effect, because of the potential for conflict with other options. For example:
  • Setting

    declare %public function r:random-sequence($length as xs:integer) as xs:double* {
      r:random-sequence($length, fn:random-number-generator())
    };
    
    declare %private function r:random-sequence($length as xs:integer, 
                                                $G as map(xs:string, item())) {
      if ($length eq 0)
      then ()
      else ($G?number, r:random-sequence($length - 1, $G?next()))
    };
    
    r:random-sequence(200);
                
    233 to a particular value requests a particular XSLT software product.

  • Setting

    declare %public function r:random-sequence($length as xs:integer) as xs:double* {
      r:random-sequence($length, fn:random-number-generator())
    };
    
    declare %private function r:random-sequence($length as xs:integer, 
                                                $G as map(xs:string, item())) {
      if ($length eq 0)
      then ()
      else ($G?number, r:random-sequence($length - 1, $G?next()))
    };
    
    r:random-sequence(200);
                
    234 requests a specific version of that product.

  • Setting

    declare %public function r:random-sequence($length as xs:integer) as xs:double* {
      r:random-sequence($length, fn:random-number-generator())
    };
    
    declare %private function r:random-sequence($length as xs:integer, 
                                                $G as map(xs:string, item())) {
      if ($length eq 0)
      then ()
      else ($G?number, r:random-sequence($length - 1, $G?next()))
    };
    
    r:random-sequence(200);
                
    235 to
    let $para := 
    In a hole in the ground there lived a hobbit.
             
    182 requests a schema-aware processor.

  • Setting

    declare %public function r:random-sequence($length as xs:integer) as xs:double* {
      r:random-sequence($length, fn:random-number-generator())
    };
    
    declare %private function r:random-sequence($length as xs:integer, 
                                                $G as map(xs:string, item())) {
      if ($length eq 0)
      then ()
      else ($G?number, r:random-sequence($length - 1, $G?next()))
    };
    
    r:random-sequence(200);
                
    237 to
    declare %public function r:random-sequence($length as xs:integer) as xs:double* {
      r:random-sequence($length, fn:random-number-generator())
    };
    
    declare %private function r:random-sequence($length as xs:integer, 
                                                $G as map(xs:string, item())) {
      if ($length eq 0)
      then ()
      else ($G?number, r:random-sequence($length - 1, $G?next()))
    };
    
    r:random-sequence(200);
                
    238 requests a processor that supports XML Schema version 1.1.

Setting a boolean property such as
declare %public function r:random-sequence($length as xs:integer) as xs:double* {
  r:random-sequence($length, fn:random-number-generator())
};

declare %private function r:random-sequence($length as xs:integer, 
                                            $G as map(xs:string, item())) {
  if ($length eq 0)
  then ()
  else ($G?number, r:random-sequence($length - 1, $G?next()))
};

r:random-sequence(200);
            
239 to
let $para := 
In a hole in the ground there lived a hobbit.
         
184 is interpreted as an explicit request for a processor in which the value of the property is false. The effect if the requests cannot be precisely met is implementation-defined. In some cases it may be appropriate to ignore the request or to provide an alternative (for example, a later version of the product than the one requested); in other cases it may be more appropriate to raise an error [err:FOXT0001] indicating that no suitable XSLT processor is available.
  • Type:

    declare %public function r:random-sequence($length as xs:integer) as xs:double* {
      r:random-sequence($length, fn:random-number-generator())
    };
    
    declare %private function r:random-sequence($length as xs:integer, 
                                                $G as map(xs:string, item())) {
      if ($length eq 0)
      then ()
      else ($G?number, r:random-sequence($length - 1, $G?next()))
    };
    
    r:random-sequence(200);
                
    241

  • Default:

    declare %public function r:random-sequence($length as xs:integer) as xs:double* {
      r:random-sequence($length, fn:random-number-generator())
    };
    
    declare %private function r:random-sequence($length as xs:integer, 
                                                $G as map(xs:string, item())) {
      if ($length eq 0)
      then ()
      else ($G?number, r:random-sequence($length - 1, $G?next()))
    };
    
    r:random-sequence(200);
                
    242

declare %public function r:random-sequence($length as xs:integer) as xs:double* {
  r:random-sequence($length, fn:random-number-generator())
};

declare %private function r:random-sequence($length as xs:integer, 
                                            $G as map(xs:string, item())) {
  if ($length eq 0)
  then ()
  else ($G?number, r:random-sequence($length - 1, $G?next()))
};

r:random-sequence(200);
            
0851.0, 2.0, 3.0Serialization parameters for the principal result document. The supplied map follows the same rules that apply to a map supplied as the second argument of
Primo Secondo Terzo Quarto Quinto ...
511.
  • When a parameter is supplied, the corresponding value overrides or augments the value specified in the unnamed

    declare %public function r:random-sequence($length as xs:integer) as xs:double* {
      r:random-sequence($length, fn:random-number-generator())
    };
    
    declare %private function r:random-sequence($length as xs:integer, 
                                                $G as map(xs:string, item())) {
      if ($length eq 0)
      then ()
      else ($G?number, r:random-sequence($length - 1, $G?next()))
    };
    
    r:random-sequence(200);
                
    245 declaration (or its default), following the same rules as when one
    declare %public function r:random-sequence($length as xs:integer) as xs:double* {
      r:random-sequence($length, fn:random-number-generator())
    };
    
    declare %private function r:random-sequence($length as xs:integer, 
                                                $G as map(xs:string, item())) {
      if ($length eq 0)
      then ()
      else ($G?number, r:random-sequence($length - 1, $G?next()))
    };
    
    r:random-sequence(200);
                
    245 declaration overrides another with lower import precedence.

  • When a parameter is supplied and the corresponding value is an empty sequence (for example,

    declare %public function r:random-sequence($length as xs:integer) as xs:double* {
      r:random-sequence($length, fn:random-number-generator())
    };
    
    declare %private function r:random-sequence($length as xs:integer, 
                                                $G as map(xs:string, item())) {
      if ($length eq 0)
      then ()
      else ($G?number, r:random-sequence($length - 1, $G?next()))
    };
    
    r:random-sequence(200);
                
    247), any value specified in the unnamed
    declare %public function r:random-sequence($length as xs:integer) as xs:double* {
      r:random-sequence($length, fn:random-number-generator())
    };
    
    declare %private function r:random-sequence($length as xs:integer, 
                                                $G as map(xs:string, item())) {
      if ($length eq 0)
      then ()
      else ($G?number, r:random-sequence($length - 1, $G?next()))
    };
    
    r:random-sequence(200);
                
    245 declaration is overridden by the default value.

  • When a parameter is not supplied in

    declare %public function r:random-sequence($length as xs:integer) as xs:double* {
      r:random-sequence($length, fn:random-number-generator())
    };
    
    declare %private function r:random-sequence($length as xs:integer, 
                                                $G as map(xs:string, item())) {
      if ($length eq 0)
      then ()
      else ($G?number, r:random-sequence($length - 1, $G?next()))
    };
    
    r:random-sequence(200);
                
    085 (that is, when the key is absent) the value that applies is the value appearing in the unnamed
    declare %public function r:random-sequence($length as xs:integer) as xs:double* {
      r:random-sequence($length, fn:random-number-generator())
    };
    
    declare %private function r:random-sequence($length as xs:integer, 
                                                $G as map(xs:string, item())) {
      if ($length eq 0)
      then ()
      else ($G?number, r:random-sequence($length - 1, $G?next()))
    };
    
    r:random-sequence(200);
                
    245 declaration, or its default.

  • Type:

    declare %public function r:random-sequence($length as xs:integer) as xs:double* {
      r:random-sequence($length, fn:random-number-generator())
    };
    
    declare %private function r:random-sequence($length as xs:integer, 
                                                $G as map(xs:string, item())) {
      if ($length eq 0)
      then ()
      else ($G?number, r:random-sequence($length - 1, $G?next()))
    };
    
    r:random-sequence(200);
                
    251

  • Default:

    declare %public function r:random-sequence($length as xs:integer) as xs:double* {
      r:random-sequence($length, fn:random-number-generator())
    };
    
    declare %private function r:random-sequence($length as xs:integer, 
                                                $G as map(xs:string, item())) {
      if ($length eq 0)
      then ()
      else ($G?number, r:random-sequence($length - 1, $G?next()))
    };
    
    r:random-sequence(200);
                
    242

declare %public function r:random-sequence($length as xs:integer) as xs:double* {
  r:random-sequence($length, fn:random-number-generator())
};

declare %private function r:random-sequence($length as xs:integer, 
                                            $G as map(xs:string, item())) {
  if ($length eq 0)
  then ()
  else ($G?number, r:random-sequence($length - 1, $G?next()))
};

r:random-sequence(200);
            
0791.0, 2.0, 3.0When
declare %public function r:random-sequence($length as xs:integer) as xs:double* {
  r:random-sequence($length, fn:random-number-generator())
};

declare %private function r:random-sequence($length as xs:integer, 
                                            $G as map(xs:string, item())) {
  if ($length eq 0)
  then ()
  else ($G?number, r:random-sequence($length - 1, $G?next()))
};

r:random-sequence(200);
            
079 is supplied then the
declare %public function r:random-sequence($length as xs:integer) as xs:double* {
  r:random-sequence($length, fn:random-number-generator())
};

declare %private function r:random-sequence($length as xs:integer, 
                                            $G as map(xs:string, item())) {
  if ($length eq 0)
  then ()
  else ($G?number, r:random-sequence($length - 1, $G?next()))
};

r:random-sequence(200);
            
131 (the context item for evaluating global variables) is the root of the tree containing the supplied node. In addition, for apply-templates invocation, the
declare %public function r:random-sequence($length as xs:integer) as xs:double* {
  r:random-sequence($length, fn:random-number-generator())
};

declare %private function r:random-sequence($length as xs:integer, 
                                            $G as map(xs:string, item())) {
  if ($length eq 0)
  then ()
  else ($G?number, r:random-sequence($length - 1, $G?next()))
};

r:random-sequence(200);
            
079 acts as the
declare %public function r:random-sequence($length as xs:integer) as xs:double* {
  r:random-sequence($length, fn:random-number-generator())
};

declare %private function r:random-sequence($length as xs:integer, 
                                            $G as map(xs:string, item())) {
  if ($length eq 0)
  then ()
  else ($G?number, r:random-sequence($length - 1, $G?next()))
};

r:random-sequence(200);
            
117, that is, stylesheet execution starts by applying templates to this node.
  • Type:

    1º 2º 3º 4º ...
    147

  • Default:

    declare %public function r:random-sequence($length as xs:integer) as xs:double* {
      r:random-sequence($length, fn:random-number-generator())
    };
    
    declare %private function r:random-sequence($length as xs:integer, 
                                                $G as map(xs:string, item())) {
      if ($length eq 0)
      then ()
      else ($G?number, r:random-sequence($length - 1, $G?next()))
    };
    
    r:random-sequence(200);
                
    194

declare %public function r:random-sequence($length as xs:integer) as xs:double* {
  r:random-sequence($length, fn:random-number-generator())
};

declare %private function r:random-sequence($length as xs:integer, 
                                            $G as map(xs:string, item())) {
  if ($length eq 0)
  then ()
  else ($G?number, r:random-sequence($length - 1, $G?next()))
};

r:random-sequence(200);
            
1443.0The values of static parameters defined in the stylesheet; the keys are the names of the parameters, and the associated values are their values. The value is converted to the required type of the declared parameter using the function conversion rules.
  • Type:

    declare %public function r:random-sequence($length as xs:integer) as xs:double* {
      r:random-sequence($length, fn:random-number-generator())
    };
    
    declare %private function r:random-sequence($length as xs:integer, 
                                                $G as map(xs:string, item())) {
      if ($length eq 0)
      then ()
      else ($G?number, r:random-sequence($length - 1, $G?next()))
    };
    
    r:random-sequence(200);
                
    048

  • Default:

    declare %public function r:random-sequence($length as xs:integer) as xs:double* {
      r:random-sequence($length, fn:random-number-generator())
    };
    
    declare %private function r:random-sequence($length as xs:integer, 
                                                $G as map(xs:string, item())) {
      if ($length eq 0)
      then ()
      else ($G?number, r:random-sequence($length - 1, $G?next()))
    };
    
    r:random-sequence(200);
                
    242

declare %public function r:random-sequence($length as xs:integer) as xs:double* {
  r:random-sequence($length, fn:random-number-generator())
};

declare %private function r:random-sequence($length as xs:integer, 
                                            $G as map(xs:string, item())) {
  if ($length eq 0)
  then ()
  else ($G?number, r:random-sequence($length - 1, $G?next()))
};

r:random-sequence(200);
            
0801.0, 2.0, 3.0A string intended to be used as the static base URI of the principal stylesheet module. This value must be used if no other static base URI is available. If the supplied stylesheet already has a base URI (which will generally be the case if the stylesheet is supplied using
declare %public function r:random-sequence($length as xs:integer) as xs:double* {
  r:random-sequence($length, fn:random-number-generator())
};

declare %private function r:random-sequence($length as xs:integer, 
                                            $G as map(xs:string, item())) {
  if ($length eq 0)
  then ()
  else ($G?number, r:random-sequence($length - 1, $G?next()))
};

r:random-sequence(200);
            
077 or
declare %public function r:random-sequence($length as xs:integer) as xs:double* {
  r:random-sequence($length, fn:random-number-generator())
};

declare %private function r:random-sequence($length as xs:integer, 
                                            $G as map(xs:string, item())) {
  if ($length eq 0)
  then ()
  else ($G?number, r:random-sequence($length - 1, $G?next()))
};

r:random-sequence(200);
            
076) then it is ·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
declare %public function r:random-sequence($length as xs:integer) as xs:double* {
  r:random-sequence($length, fn:random-number-generator())
};

declare %private function r:random-sequence($length as xs:integer, 
                                            $G as map(xs:string, item())) {
  if ($length eq 0)
  then ()
  else ($G?number, r:random-sequence($length - 1, $G?next()))
};

r:random-sequence(200);
            
019 function call.
  • Type:

    let $para := 
    In a hole in the ground there lived a hobbit.
             
    10

  • Default:

    declare %public function r:random-sequence($length as xs:integer) as xs:double* {
      r:random-sequence($length, fn:random-number-generator())
    };
    
    declare %private function r:random-sequence($length as xs:integer, 
                                                $G as map(xs:string, item())) {
      if ($length eq 0)
      then ()
      else ($G?number, r:random-sequence($length - 1, $G?next()))
    };
    
    r:random-sequence(200);
                
    194

declare %public function r:random-sequence($length as xs:integer) as xs:double* {
  r:random-sequence($length, fn:random-number-generator())
};

declare %private function r:random-sequence($length as xs:integer, 
                                            $G as map(xs:string, item())) {
  if ($length eq 0)
  then ()
  else ($G?number, r:random-sequence($length - 1, $G?next()))
};

r:random-sequence(200);
            
0761.0, 2.0, 3.0URI that can be used to locate the principal stylesheet module. If relative, it is resolved against the static base URI of the
declare %public function r:random-sequence($length as xs:integer) as xs:double* {
  r:random-sequence($length, fn:random-number-generator())
};

declare %private function r:random-sequence($length as xs:integer, 
                                            $G as map(xs:string, item())) {
  if ($length eq 0)
  then ()
  else ($G?number, r:random-sequence($length - 1, $G?next()))
};

r:random-sequence(200);
            
019 function call. The value also acts as the default for stylesheet-base-uri.
  • Type:

    let $para := 
    In a hole in the ground there lived a hobbit.
             
    10

  • Default:

    declare %public function r:random-sequence($length as xs:integer) as xs:double* {
      r:random-sequence($length, fn:random-number-generator())
    };
    
    declare %private function r:random-sequence($length as xs:integer, 
                                                $G as map(xs:string, item())) {
      if ($length eq 0)
      then ()
      else ($G?number, r:random-sequence($length - 1, $G?next()))
    };
    
    r:random-sequence(200);
                
    194

declare %public function r:random-sequence($length as xs:integer) as xs:double* {
  r:random-sequence($length, fn:random-number-generator())
};

declare %private function r:random-sequence($length as xs:integer, 
                                            $G as map(xs:string, item())) {
  if ($length eq 0)
  then ()
  else ($G?number, r:random-sequence($length - 1, $G?next()))
};

r:random-sequence(200);
            
0771.0, 2.0, 3.0Root of the tree containing the principal stylesheet module, as a document or element node. The base URI of the node acts as the default for stylesheet-base-uri.
  • Type:

    1º 2º 3º 4º ...
    147

  • Default:

    declare %public function r:random-sequence($length as xs:integer) as xs:double* {
      r:random-sequence($length, fn:random-number-generator())
    };
    
    declare %private function r:random-sequence($length as xs:integer, 
                                                $G as map(xs:string, item())) {
      if ($length eq 0)
      then ()
      else ($G?number, r:random-sequence($length - 1, $G?next()))
    };
    
    r:random-sequence(200);
                
    194

declare %public function r:random-sequence($length as xs:integer) as xs:double* {
  r:random-sequence($length, fn:random-number-generator())
};

declare %private function r:random-sequence($length as xs:integer, 
                                            $G as map(xs:string, item())) {
  if ($length eq 0)
  then ()
  else ($G?number, r:random-sequence($length - 1, $G?next()))
};

r:random-sequence(200);
            
0811.0, 2.0, 3.0A map holding values to be supplied for stylesheet parameters. The keys are the parameter names; the values are the corresponding parameter values. The values are converted if necessary to the required type using the function conversion rules. The default is an empty map.
  • Type:

    declare %public function r:random-sequence($length as xs:integer) as xs:double* {
      r:random-sequence($length, fn:random-number-generator())
    };
    
    declare %private function r:random-sequence($length as xs:integer, 
                                                $G as map(xs:string, item())) {
      if ($length eq 0)
      then ()
      else ($G?number, r:random-sequence($length - 1, $G?next()))
    };
    
    r:random-sequence(200);
                
    048

  • Default:

    declare %public function r:random-sequence($length as xs:integer) as xs:double* {
      r:random-sequence($length, fn:random-number-generator())
    };
    
    declare %private function r:random-sequence($length as xs:integer, 
                                                $G as map(xs:string, item())) {
      if ($length eq 0)
      then ()
      else ($G?number, r:random-sequence($length - 1, $G?next()))
    };
    
    r:random-sequence(200);
                
    242

declare %public function r:random-sequence($length as xs:integer) as xs:double* {
  r:random-sequence($length, fn:random-number-generator())
};

declare %private function r:random-sequence($length as xs:integer, 
                                            $G as map(xs:string, item())) {
  if ($length eq 0)
  then ()
  else ($G?number, r:random-sequence($length - 1, $G?next()))
};

r:random-sequence(200);
            
0781.0, 2.0, 3.0The principal stylesheet module in the form of unparsed lexical XML.
  • Type:

    let $para := 
    In a hole in the ground there lived a hobbit.
             
    10

  • Default:

    declare %public function r:random-sequence($length as xs:integer) as xs:double* {
      r:random-sequence($length, fn:random-number-generator())
    };
    
    declare %private function r:random-sequence($length as xs:integer, 
                                                $G as map(xs:string, item())) {
      if ($length eq 0)
      then ()
      else ($G?number, r:random-sequence($length - 1, $G?next()))
    };
    
    r:random-sequence(200);
                
    194

declare %public function r:random-sequence($length as xs:integer) as xs:double* {
  r:random-sequence($length, fn:random-number-generator())
};

declare %private function r:random-sequence($length as xs:integer, 
                                            $G as map(xs:string, item())) {
  if ($length eq 0)
  then ()
  else ($G?number, r:random-sequence($length - 1, $G?next()))
};

r:random-sequence(200);
            
1193.0The values of non-tunnel parameters to be supplied to the initial template, used with both apply-templates and call-template invocation. Each value is converted to the required type of the declared parameter using the function conversion rules.
  • Type:

    declare %public function r:random-sequence($length as xs:integer) as xs:double* {
      r:random-sequence($length, fn:random-number-generator())
    };
    
    declare %private function r:random-sequence($length as xs:integer, 
                                                $G as map(xs:string, item())) {
      if ($length eq 0)
      then ()
      else ($G?number, r:random-sequence($length - 1, $G?next()))
    };
    
    r:random-sequence(200);
                
    048

  • Default:

declare %public function r:random-sequence($length as xs:integer) as xs:double* {
  r:random-sequence($length, fn:random-number-generator())
};

declare %private function r:random-sequence($length as xs:integer, 
                                            $G as map(xs:string, item())) {
  if ($length eq 0)
  then ()
  else ($G?number, r:random-sequence($length - 1, $G?next()))
};

r:random-sequence(200);
            
1203.0The values of tunnel parameters to be supplied to the initial template, used with both apply-templates and call-template invocation. Each value is converted to the required type of the declared parameter using the function conversion rules.
  • Type:

    declare %public function r:random-sequence($length as xs:integer) as xs:double* {
      r:random-sequence($length, fn:random-number-generator())
    };
    
    declare %private function r:random-sequence($length as xs:integer, 
                                                $G as map(xs:string, item())) {
      if ($length eq 0)
      then ()
      else ($G?number, r:random-sequence($length - 1, $G?next()))
    };
    
    r:random-sequence(200);
                
    048

  • Default:

    declare %public function r:random-sequence($length as xs:integer) as xs:double* {
      r:random-sequence($length, fn:random-number-generator())
    };
    
    declare %private function r:random-sequence($length as xs:integer, 
                                                $G as map(xs:string, item())) {
      if ($length eq 0)
      then ()
      else ($G?number, r:random-sequence($length - 1, $G?next()))
    };
    
    r:random-sequence(200);
                
    242

declare %public function r:random-sequence($length as xs:integer) as xs:double* {
  r:random-sequence($length, fn:random-number-generator())
};

declare %private function r:random-sequence($length as xs:integer, 
                                            $G as map(xs:string, item())) {
  if ($length eq 0)
  then ()
  else ($G?number, r:random-sequence($length - 1, $G?next()))
};

r:random-sequence(200);
            
0501.0, 2.0, 3.0Values for vendor-defined configuration options for the XSLT processor used to process the request. The key is the name of an option, expressed as a QName: the namespace URI of the QName should be a URI controlled by the vendor of the XSLT processor. The meaning of the associated value is ·implementation-defined·. Implementations should ignore options whose names are in an unrecognized namespace. Default is an empty map.
  • Type:

    declare %public function r:random-sequence($length as xs:integer) as xs:double* {
      r:random-sequence($length, fn:random-number-generator())
    };
    
    declare %private function r:random-sequence($length as xs:integer, 
                                                $G as map(xs:string, item())) {
      if ($length eq 0)
      then ()
      else ($G?number, r:random-sequence($length - 1, $G?next()))
    };
    
    r:random-sequence(200);
                
    288

  • Default:

    declare %public function r:random-sequence($length as xs:integer) as xs:double* {
      r:random-sequence($length, fn:random-number-generator())
    };
    
    declare %private function r:random-sequence($length as xs:integer, 
                                                $G as map(xs:string, item())) {
      if ($length eq 0)
      then ()
      else ($G?number, r:random-sequence($length - 1, $G?next()))
    };
    
    r:random-sequence(200);
                
    242

declare %public function r:random-sequence($length as xs:integer) as xs:double* {
  r:random-sequence($length, fn:random-number-generator())
};

declare %private function r:random-sequence($length as xs:integer, 
                                            $G as map(xs:string, item())) {
  if ($length eq 0)
  then ()
  else ($G?number, r:random-sequence($length - 1, $G?next()))
};

r:random-sequence(200);
            
0711.0, 2.0, 3.0The minimum level of the XSLT language that the processor must support.
  • Type:

    let $para := 
    In a hole in the ground there lived a hobbit.
             
    82

  • Default:

    declare %public function r:random-sequence($length as xs:integer) as xs:double* {
      r:random-sequence($length, fn:random-number-generator())
    };
    
    declare %private function r:random-sequence($length as xs:integer, 
                                                $G as map(xs:string, item())) {
      if ($length eq 0)
      then ()
      else ($G?number, r:random-sequence($length - 1, $G?next()))
    };
    
    r:random-sequence(200);
                
    292

The result of the transformation is returned as a map. There is one entry in the map for the principal result document, and one for each secondary result document. The key is a URI in the form of an

let $para := 
In a hole in the ground there lived a hobbit.
         
10 value. The key for the principal result document is the base output URI if specified, or the string
declare %public function r:random-sequence($length as xs:integer) as xs:double* {
  r:random-sequence($length, fn:random-number-generator())
};

declare %private function r:random-sequence($length as xs:integer, 
                                            $G as map(xs:string, item())) {
  if ($length eq 0)
  then ()
  else ($G?number, r:random-sequence($length - 1, $G?next()))
};

r:random-sequence(200);
            
294 otherwise. The key for secondary result documents is the URI of the document, as an absolute URI. The associated value in each entry depends on the requested delivery format. If the delivery format is
declare %public function r:random-sequence($length as xs:integer) as xs:double* {
  r:random-sequence($length, fn:random-number-generator())
};

declare %private function r:random-sequence($length as xs:integer, 
                                            $G as map(xs:string, item())) {
  if ($length eq 0)
  then ()
  else ($G?number, r:random-sequence($length - 1, $G?next()))
};

r:random-sequence(200);
            
084, the value is a document node. If the delivery format is
declare %public function r:random-sequence($length as xs:integer) as xs:double* {
  r:random-sequence($length, fn:random-number-generator())
};

declare %private function r:random-sequence($length as xs:integer, 
                                            $G as map(xs:string, item())) {
  if ($length eq 0)
  then ()
  else ($G?number, r:random-sequence($length - 1, $G?next()))
};

r:random-sequence(200);
            
170, the value is a string containing the serialized result.

Where nodes are passed to or from the transformation, for example as the value of a stylesheet parameter or the result of a function, they should if possible retain their node identity, their base URI, their type annotations, and their relationships to all other nodes in the containing tree (including ancestors and siblings). If this is not possible, for example because the only way of passing nodes to the chosen XSLT implementation is by serializing and re-parsing, then a node may be passed in the form of a deep copy, which may lose information about the identity of the node, about its ancestors and siblings, about its base URI, about its type annotation, and about its relationships to other nodes passed across the interface.

It is ·implementation-defined· whether the XSLT transformation is executed within the same ·execution scope· as the calling code.

The function is ·nondeterministic· in that it is ·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

let $para := 
In a hole in the ground there lived a hobbit.
         
69 is different for the two invocations, or because the contents of external documents accessed using
op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
09 or
declare %public function r:random-sequence($length as xs:integer) as xs:double* {
  r:random-sequence($length, fn:random-number-generator())
};

declare %private function r:random-sequence($length as xs:integer, 
                                            $G as map(xs:string, item())) {
  if ($length eq 0)
  then ()
  else ($G?number, r:random-sequence($length - 1, $G?next()))
};

r:random-sequence(200);
            
299 change between one invocation and the next.

Error Conditions

A dynamic error is raised [err:FOXT0001] if the transformation cannot be invoked because no suitable XSLT processor is available. This includes (but is not limited to) the following cases:

  1. No XSLT processor is available;

  2. No XSLT processor supporting the requested version of XSLT is available;

  3. The XSLT processor API does not support some requested feature (for example, the ability to supply tunnel parameters externally);

A dynamic error is raised [err:FOXT0002] if an error is detected in the supplied parameters (for example if two mutually-exclusive parameters are supplied).

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 [err:FOXT0003] if the XSLT transformation invoked by a call on

declare %public function r:random-sequence($length as xs:integer) as xs:double* {
  r:random-sequence($length, fn:random-number-generator())
};

declare %private function r:random-sequence($length as xs:integer, 
                                            $G as map(xs:string, item())) {
  if ($length eq 0)
  then ()
  else ($G?number, r:random-sequence($length - 1, $G?next()))
};

r:random-sequence(200);
            
019 fails with a static or dynamic error, and no more specific error code is available.

Note:

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 to happen with static errors) then the error code should where possible be that of one of these errors, chosen arbitrarily; the processor may make details of additional errors available to the application in an ·implementation-defined· way.

A dynamic error is raised [err:FOXT0004] if the use of this function (or of selected options) has been externally disabled, for example for security reasons.

A dynamic error is raised [err:FOXT0006] 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

declare %public function r:random-sequence($length as xs:integer) as xs:double* {
  r:random-sequence($length, fn:random-number-generator())
};

declare %private function r:random-sequence($length as xs:integer, 
                                            $G as map(xs:string, item())) {
  if ($length eq 0)
  then ()
  else ($G?number, r:random-sequence($length - 1, $G?next()))
};

r:random-sequence(200);
            
019 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.

Notes

As with all other functions in this specification, conformance requirements depend on the host language. For example, a host language might specify that provision of this function is optional, or that it is excluded entirely, or that implementations are required to support a particular set of values for the

declare %public function r:random-sequence($length as xs:integer) as xs:double* {
  r:random-sequence($length, fn:random-number-generator())
};

declare %private function r:random-sequence($length as xs:integer, 
                                            $G as map(xs:string, item())) {
  if ($length eq 0)
  then ()
  else ($G?number, r:random-sequence($length - 1, $G?next()))
};

r:random-sequence(200);
            
071 parameter.

Even where support for this function is mandatory, it is recommended for security reasons that implementations should provide a user option to disable its use, or to disable aspects of its functionality such as the ability to write to persistent resources.

Examples

The following example loads a stylesheet from the location

declare %public function r:random-sequence($length as xs:integer) as xs:double* {
  r:random-sequence($length, fn:random-number-generator())
};

declare %private function r:random-sequence($length as xs:integer, 
                                            $G as map(xs:string, item())) {
  if ($length eq 0)
  then ()
  else ($G?number, r:random-sequence($length - 1, $G?next()))
};

r:random-sequence(200);
            
303, applies it to a document loaded from
declare %public function r:random-sequence($length as xs:integer) as xs:double* {
  r:random-sequence($length, fn:random-number-generator())
};

declare %private function r:random-sequence($length as xs:integer, 
                                            $G as map(xs:string, item())) {
  if ($length eq 0)
  then ()
  else ($G?number, r:random-sequence($length - 1, $G?next()))
};

r:random-sequence(200);
            
304, and uses an XPath expression to examine the result:

let $C := 'http://www.w3.org/2013/collation/UCA?strength=primary'
1

17 Maps and Arrays

Maps and arrays are introduced as new datatypes in XDM 3.1. This section describes functions that operate on maps and arrays. It also describes functions that operate on JSON data structures, which make extensive use of maps and arrays.

17.1 Functions that Operate on Maps

The functions defined in this section use a conventional namespace prefix

let $para := 
In a hole in the ground there lived a hobbit.
         
53, which is assumed to be bound to the namespace URI
let $para := 
In a hole in the ground there lived a hobbit.
         
52.

A map is an additional kind of item.

[Definition] A map consists of a set of entries. Each entry comprises a key which is an arbitrary atomic value, and an arbitrary sequence called the associated value.

[Definition] Within a map, no two entries have the same key. Two atomic values

declare %public function r:random-sequence($length as xs:integer) as xs:double* {
  r:random-sequence($length, fn:random-number-generator())
};

declare %private function r:random-sequence($length as xs:integer, 
                                            $G as map(xs:string, item())) {
  if ($length eq 0)
  then ()
  else ($G?number, r:random-sequence($length - 1, $G?next()))
};

r:random-sequence(200);
            
307 and
declare %public function r:random-sequence($length as xs:integer) as xs:double* {
  r:random-sequence($length, fn:random-number-generator())
};

declare %private function r:random-sequence($length as xs:integer, 
                                            $G as map(xs:string, item())) {
  if ($length eq 0)
  then ()
  else ($G?number, r:random-sequence($length - 1, $G?next()))
};

r:random-sequence(200);
            
308 are the same key for this purpose if the (internal) function call
declare %public function r:random-sequence($length as xs:integer) as xs:double* {
  r:random-sequence($length, fn:random-number-generator())
};

declare %private function r:random-sequence($length as xs:integer, 
                                            $G as map(xs:string, item())) {
  if ($length eq 0)
  then ()
  else ($G?number, r:random-sequence($length - 1, $G?next()))
};

r:random-sequence(200);
            
309 returns true.

It is not necessary that all the keys in a map should be of the same type (for example, they can include a mixture of integers and strings).

As with all other values, the functions in this specification treat maps as immutable. For example, the

declare %public function r:random-sequence($length as xs:integer) as xs:double* {
  r:random-sequence($length, fn:random-number-generator())
};

declare %private function r:random-sequence($length as xs:integer, 
                                            $G as map(xs:string, item())) {
  if ($length eq 0)
  then ()
  else ($G?number, r:random-sequence($length - 1, $G?next()))
};

r:random-sequence(200);
            
310 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
declare %public function r:random-sequence($length as xs:integer) as xs:double* {
  r:random-sequence($length, fn:random-number-generator())
};

declare %private function r:random-sequence($length as xs:integer, 
                                            $G as map(xs:string, item())) {
  if ($length eq 0)
  then ()
  else ($G?number, r:random-sequence($length - 1, $G?next()))
};

r:random-sequence(200);
            
310 with the same arguments return maps that are indistinguishable from each other; there is no way of asking whether these are "the same map".

The function call

declare %public function r:random-sequence($length as xs:integer) as xs:double* {
  r:random-sequence($length, fn:random-number-generator())
};

declare %private function r:random-sequence($length as xs:integer, 
                                            $G as map(xs:string, item())) {
  if ($length eq 0)
  then ()
  else ($G?number, r:random-sequence($length - 1, $G?next()))
};

r:random-sequence(200);
            
312 can be used to retrieve the value associated with a given key.

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

declare %public function r:random-sequence($length as xs:integer) as xs:double* {
  r:random-sequence($length, fn:random-number-generator())
};

declare %private function r:random-sequence($length as xs:integer, 
                                            $G as map(xs:string, item())) {
  if ($length eq 0)
  then ()
  else ($G?number, r:random-sequence($length - 1, $G?next()))
};

r:random-sequence(200);
            
313. Calling the function has the same effect as calling the
declare %public function r:random-sequence($length as xs:integer) as xs:double* {
  r:random-sequence($length, fn:random-number-generator())
};

declare %private function r:random-sequence($length as xs:integer, 
                                            $G as map(xs:string, item())) {
  if ($length eq 0)
  then ()
  else ($G?number, r:random-sequence($length - 1, $G?next()))
};

r:random-sequence(200);
            
314 function: the expression
declare %public function r:random-sequence($length as xs:integer) as xs:double* {
  r:random-sequence($length, fn:random-number-generator())
};

declare %private function r:random-sequence($length as xs:integer, 
                                            $G as map(xs:string, item())) {
  if ($length eq 0)
  then ()
  else ($G?number, r:random-sequence($length - 1, $G?next()))
};

r:random-sequence(200);
            
315 returns the same result as
declare %public function r:random-sequence($length as xs:integer) as xs:double* {
  r:random-sequence($length, fn:random-number-generator())
};

declare %private function r:random-sequence($length as xs:integer, 
                                            $G as map(xs:string, item())) {
  if ($length eq 0)
  then ()
  else ($G?number, r:random-sequence($length - 1, $G?next()))
};

r:random-sequence(200);
            
316. For example, if
declare %public function r:random-sequence($length as xs:integer) as xs:double* {
  r:random-sequence($length, fn:random-number-generator())
};

declare %private function r:random-sequence($length as xs:integer, 
                                            $G as map(xs:string, item())) {
  if ($length eq 0)
  then ()
  else ($G?number, r:random-sequence($length - 1, $G?next()))
};

r:random-sequence(200);
            
317 is a map whose keys are ISBNs and whose assocated values are
declare %public function r:random-sequence($length as xs:integer) as xs:double* {
  r:random-sequence($length, fn:random-number-generator())
};

declare %private function r:random-sequence($length as xs:integer, 
                                            $G as map(xs:string, item())) {
  if ($length eq 0)
  then ()
  else ($G?number, r:random-sequence($length - 1, $G?next()))
};

r:random-sequence(200);
            
318 elements, then the expression
declare %public function r:random-sequence($length as xs:integer) as xs:double* {
  r:random-sequence($length, fn:random-number-generator())
};

declare %private function r:random-sequence($length as xs:integer, 
                                            $G as map(xs:string, item())) {
  if ($length eq 0)
  then ()
  else ($G?number, r:random-sequence($length - 1, $G?next()))
};

r:random-sequence(200);
            
319 returns the
declare %public function r:random-sequence($length as xs:integer) as xs:double* {
  r:random-sequence($length, fn:random-number-generator())
};

declare %private function r:random-sequence($length as xs:integer, 
                                            $G as map(xs:string, item())) {
  if ($length eq 0)
  then ()
  else ($G?number, r:random-sequence($length - 1, $G?next()))
};

r:random-sequence(200);
            
318 element with the given ISBN. The fact that a map is a function item allows it to be passed as an argument to higher-order functions that expect a function item as one of their arguments.

There is no operation to atomize a map or convert it to a string. The function

Primo Secondo Terzo Quarto Quinto ...
511 can in some cases be used to produce a JSON representation of a map.

FunctionMeaning
let $para := 
In a hole in the ground there lived a hobbit.
         
34Determines whether two atomic values can coexist as separate keys within a map.
declare %public function r:random-sequence($length as xs:integer) as xs:double* {
  r:random-sequence($length, fn:random-number-generator())
};

declare %private function r:random-sequence($length as xs:integer, 
                                            $G as map(xs:string, item())) {
  if ($length eq 0)
  then ()
  else ($G?number, r:random-sequence($length - 1, $G?next()))
};

r:random-sequence(200);
            
323Returns a map that combines the entries from a number of existing maps.
declare %public function r:random-sequence($length as xs:integer) as xs:double* {
  r:random-sequence($length, fn:random-number-generator())
};

declare %private function r:random-sequence($length as xs:integer, 
                                            $G as map(xs:string, item())) {
  if ($length eq 0)
  then ()
  else ($G?number, r:random-sequence($length - 1, $G?next()))
};

r:random-sequence(200);
            
324Returns the number of entries in the supplied map.
op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
16Returns a sequence containing all the keys present in a map
let $para := 
In a hole in the ground there lived a hobbit.
         
37Tests whether a supplied map contains an entry for a given key
let $para := 
In a hole in the ground there lived a hobbit.
         
38Returns the value associated with a supplied key in a given map.
declare %public function r:random-sequence($length as xs:integer) as xs:double* {
  r:random-sequence($length, fn:random-number-generator())
};

declare %private function r:random-sequence($length as xs:integer, 
                                            $G as map(xs:string, item())) {
  if ($length eq 0)
  then ()
  else ($G?number, r:random-sequence($length - 1, $G?next()))
};

r:random-sequence(200);
            
328Searches the supplied input sequence and any contained maps and arrays for a map entry with the supplied key, and returns the corresponding values.
declare %public function r:random-sequence($length as xs:integer) as xs:double* {
  r:random-sequence($length, fn:random-number-generator())
};

declare %private function r:random-sequence($length as xs:integer, 
                                            $G as map(xs:string, item())) {
  if ($length eq 0)
  then ()
  else ($G?number, r:random-sequence($length - 1, $G?next()))
};

r:random-sequence(200);
            
329Returns a map containing all the contents of the supplied map, but with an additional entry, which replaces any existing entry for the same key.
declare %public function r:random-sequence($length as xs:integer) as xs:double* {
  r:random-sequence($length, fn:random-number-generator())
};

declare %private function r:random-sequence($length as xs:integer, 
                                            $G as map(xs:string, item())) {
  if ($length eq 0)
  then ()
  else ($G?number, r:random-sequence($length - 1, $G?next()))
};

r:random-sequence(200);
            
330Returns a map that contains a single entry (a key-value pair).
declare %public function r:random-sequence($length as xs:integer) as xs:double* {
  r:random-sequence($length, fn:random-number-generator())
};

declare %private function r:random-sequence($length as xs:integer, 
                                            $G as map(xs:string, item())) {
  if ($length eq 0)
  then ()
  else ($G?number, r:random-sequence($length - 1, $G?next()))
};

r:random-sequence(200);
            
310Returns a map containing all the entries from a supplied map, except those having a specified key.
op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
17Applies a supplied function to every entry in a map, returning the concatenation of the results.

17.1.1 op:same-key

Summary

Determines whether two atomic values can coexist as separate keys within a map.

Signature

let $para := 
In a hole in the ground there lived a hobbit.
         
34(
declare %public function r:random-sequence($length as xs:integer) as xs:double* {
  r:random-sequence($length, fn:random-number-generator())
};

declare %private function r:random-sequence($length as xs:integer, 
                                            $G as map(xs:string, item())) {
  if ($length eq 0)
  then ()
  else ($G?number, r:random-sequence($length - 1, $G?next()))
};

r:random-sequence(200);
            
334
let $para := 
In a hole in the ground there lived a hobbit.
         
71
let $para := 
In a hole in the ground there lived a hobbit.
         
34,
declare %public function r:random-sequence($length as xs:integer) as xs:double* {
  r:random-sequence($length, fn:random-number-generator())
};

declare %private function r:random-sequence($length as xs:integer, 
                                            $G as map(xs:string, item())) {
  if ($length eq 0)
  then ()
  else ($G?number, r:random-sequence($length - 1, $G?next()))
};

r:random-sequence(200);
            
337
let $para := 
In a hole in the ground there lived a hobbit.
         
71
let $para := 
In a hole in the ground there lived a hobbit.
         
34)
let $para := 
In a hole in the ground there lived a hobbit.
         
71
op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
32

Properties

This function is ·deterministic·, ·context-independent·, and ·focus-independent·.

Rules

The internal function

let $para := 
In a hole in the ground there lived a hobbit.
         
34 (which is not available at the user level) is used to assess whether two atomic values 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
let $para := 
In a hole in the ground there lived a hobbit.
         
38 and
declare %public function r:random-sequence($length as xs:integer) as xs:double* {
  r:random-sequence($length, fn:random-number-generator())
};

declare %private function r:random-sequence($length as xs:integer, 
                                            $G as map(xs:string, item())) {
  if ($length eq 0)
  then ()
  else ($G?number, r:random-sequence($length - 1, $G?next()))
};

r:random-sequence(200);
            
310.

The function returns true if and only if one of the following conditions is true:

  1. All of the following conditions are true:

    1. declare %public function r:random-sequence($length as xs:integer) as xs:double* {
        r:random-sequence($length, fn:random-number-generator())
      };
      
      declare %private function r:random-sequence($length as xs:integer, 
                                                  $G as map(xs:string, item())) {
        if ($length eq 0)
        then ()
        else ($G?number, r:random-sequence($length - 1, $G?next()))
      };
      
      r:random-sequence(200);
                  
      334 is an instance of
      let $para := 
      In a hole in the ground there lived a hobbit.
               
      10,
      let $para := 
      In a hole in the ground there lived a hobbit.
               
      30, or
      let $para := 
      In a hole in the ground there lived a hobbit.
               
      00

    2. declare %public function r:random-sequence($length as xs:integer) as xs:double* {
        r:random-sequence($length, fn:random-number-generator())
      };
      
      declare %private function r:random-sequence($length as xs:integer, 
                                                  $G as map(xs:string, item())) {
        if ($length eq 0)
        then ()
        else ($G?number, r:random-sequence($length - 1, $G?next()))
      };
      
      r:random-sequence(200);
                  
      337 is an instance of
      let $para := 
      In a hole in the ground there lived a hobbit.
               
      10,
      let $para := 
      In a hole in the ground there lived a hobbit.
               
      30, or
      let $para := 
      In a hole in the ground there lived a hobbit.
               
      00

    3. declare %public function r:random-sequence($length as xs:integer) as xs:double* {
        r:random-sequence($length, fn:random-number-generator())
      };
      
      declare %private function r:random-sequence($length as xs:integer, 
                                                  $G as map(xs:string, item())) {
        if ($length eq 0)
        then ()
        else ($G?number, r:random-sequence($length - 1, $G?next()))
      };
      
      r:random-sequence(200);
                  
      353

    Note:

    Strings are compared without any dependency on collations.

  2. All of the following conditions are true:

    1. declare %public function r:random-sequence($length as xs:integer) as xs:double* {
        r:random-sequence($length, fn:random-number-generator())
      };
      
      declare %private function r:random-sequence($length as xs:integer, 
                                                  $G as map(xs:string, item())) {
        if ($length eq 0)
        then ()
        else ($G?number, r:random-sequence($length - 1, $G?next()))
      };
      
      r:random-sequence(200);
                  
      334 is an instance of
      let $para := 
      In a hole in the ground there lived a hobbit.
               
      82,
      let $para := 
      In a hole in the ground there lived a hobbit.
               
      26, or
      let $para := 
      In a hole in the ground there lived a hobbit.
               
      83

    2. declare %public function r:random-sequence($length as xs:integer) as xs:double* {
        r:random-sequence($length, fn:random-number-generator())
      };
      
      declare %private function r:random-sequence($length as xs:integer, 
                                                  $G as map(xs:string, item())) {
        if ($length eq 0)
        then ()
        else ($G?number, r:random-sequence($length - 1, $G?next()))
      };
      
      r:random-sequence(200);
                  
      337 is an instance of
      let $para := 
      In a hole in the ground there lived a hobbit.
               
      82,
      let $para := 
      In a hole in the ground there lived a hobbit.
               
      26, or
      let $para := 
      In a hole in the ground there lived a hobbit.
               
      83

    3. One of the following conditions is true:

      1. Both

        declare %public function r:random-sequence($length as xs:integer) as xs:double* {
          r:random-sequence($length, fn:random-number-generator())
        };
        
        declare %private function r:random-sequence($length as xs:integer, 
                                                    $G as map(xs:string, item())) {
          if ($length eq 0)
          then ()
          else ($G?number, r:random-sequence($length - 1, $G?next()))
        };
        
        r:random-sequence(200);
                    
        334 and
        declare %public function r:random-sequence($length as xs:integer) as xs:double* {
          r:random-sequence($length, fn:random-number-generator())
        };
        
        declare %private function r:random-sequence($length as xs:integer, 
                                                    $G as map(xs:string, item())) {
          if ($length eq 0)
          then ()
          else ($G?number, r:random-sequence($length - 1, $G?next()))
        };
        
        r:random-sequence(200);
                    
        337 are
        fn:abs($N * $arg2) le fn:abs($arg1) 
                       and fn:compare($N * $arg2, 0) eq fn:compare($arg1, 0).
        90

        Note:

        let $para := 
        In a hole in the ground there lived a hobbit.
                 
        220 is the same key as
        1º 2º 3º 4º ...
        837

      2. Both

        declare %public function r:random-sequence($length as xs:integer) as xs:double* {
          r:random-sequence($length, fn:random-number-generator())
        };
        
        declare %private function r:random-sequence($length as xs:integer, 
                                                    $G as map(xs:string, item())) {
          if ($length eq 0)
          then ()
          else ($G?number, r:random-sequence($length - 1, $G?next()))
        };
        
        r:random-sequence(200);
                    
        334 and
        declare %public function r:random-sequence($length as xs:integer) as xs:double* {
          r:random-sequence($length, fn:random-number-generator())
        };
        
        declare %private function r:random-sequence($length as xs:integer, 
                                                    $G as map(xs:string, item())) {
          if ($length eq 0)
          then ()
          else ($G?number, r:random-sequence($length - 1, $G?next()))
        };
        
        r:random-sequence(200);
                    
        337 are positive infinity

        Note:

        let $para := 
        In a hole in the ground there lived a hobbit.
                 
        518 is the same key as
        declare %public function r:random-sequence($length as xs:integer) as xs:double* {
          r:random-sequence($length, fn:random-number-generator())
        };
        
        declare %private function r:random-sequence($length as xs:integer, 
                                                    $G as map(xs:string, item())) {
          if ($length eq 0)
          then ()
          else ($G?number, r:random-sequence($length - 1, $G?next()))
        };
        
        r:random-sequence(200);
                    
        370

      3. Both

        declare %public function r:random-sequence($length as xs:integer) as xs:double* {
          r:random-sequence($length, fn:random-number-generator())
        };
        
        declare %private function r:random-sequence($length as xs:integer, 
                                                    $G as map(xs:string, item())) {
          if ($length eq 0)
          then ()
          else ($G?number, r:random-sequence($length - 1, $G?next()))
        };
        
        r:random-sequence(200);
                    
        334 and
        declare %public function r:random-sequence($length as xs:integer) as xs:double* {
          r:random-sequence($length, fn:random-number-generator())
        };
        
        declare %private function r:random-sequence($length as xs:integer, 
                                                    $G as map(xs:string, item())) {
          if ($length eq 0)
          then ()
          else ($G?number, r:random-sequence($length - 1, $G?next()))
        };
        
        r:random-sequence(200);
                    
        337 are negative infinity

        Note:

        let $para := 
        In a hole in the ground there lived a hobbit.
                 
        563 is the same key as
        declare %public function r:random-sequence($length as xs:integer) as xs:double* {
          r:random-sequence($length, fn:random-number-generator())
        };
        
        declare %private function r:random-sequence($length as xs:integer, 
                                                    $G as map(xs:string, item())) {
          if ($length eq 0)
          then ()
          else ($G?number, r:random-sequence($length - 1, $G?next()))
        };
        
        r:random-sequence(200);
                    
        374

      4. declare %public function r:random-sequence($length as xs:integer) as xs:double* {
          r:random-sequence($length, fn:random-number-generator())
        };
        
        declare %private function r:random-sequence($length as xs:integer, 
                                                    $G as map(xs:string, item())) {
          if ($length eq 0)
          then ()
          else ($G?number, r:random-sequence($length - 1, $G?next()))
        };
        
        r:random-sequence(200);
                    
        334 and
        declare %public function r:random-sequence($length as xs:integer) as xs:double* {
          r:random-sequence($length, fn:random-number-generator())
        };
        
        declare %private function r:random-sequence($length as xs:integer, 
                                                    $G as map(xs:string, item())) {
          if ($length eq 0)
          then ()
          else ($G?number, r:random-sequence($length - 1, $G?next()))
        };
        
        r:random-sequence(200);
                    
        337 when converted to decimal numbers with no rounding or loss of precision are mathematically equal.

        Note:

        Every instance of

        let $para := 
        In a hole in the ground there lived a hobbit.
                 
        26,
        let $para := 
        In a hole in the ground there lived a hobbit.
                 
        83, and
        let $para := 
        In a hole in the ground there lived a hobbit.
                 
        82 can be represented exactly as a decimal number provided enough digits are available both before and after the decimal point. Unlike the
        let $para := 
        In a hole in the ground there lived a hobbit.
                 
        33 relation, which converts both operands to
        let $para := 
        In a hole in the ground there lived a hobbit.
                 
        26 values, possibly losing precision in the process, this comparison is transitive.

        Note:

        Positive and negative zero are the same key.

  3. All of the following conditions are true:

    1. declare %public function r:random-sequence($length as xs:integer) as xs:double* {
        r:random-sequence($length, fn:random-number-generator())
      };
      
      declare %private function r:random-sequence($length as xs:integer, 
                                                  $G as map(xs:string, item())) {
        if ($length eq 0)
        then ()
        else ($G?number, r:random-sequence($length - 1, $G?next()))
      };
      
      r:random-sequence(200);
                  
      334 is an instance of
      op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
      964,
      op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
      965,
      let $para := 
      In a hole in the ground there lived a hobbit.
               
      29,
      op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
      967,
      op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
      966,
      op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
      969,
      op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
      968, or
      op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
      970

    2. declare %public function r:random-sequence($length as xs:integer) as xs:double* {
        r:random-sequence($length, fn:random-number-generator())
      };
      
      declare %private function r:random-sequence($length as xs:integer, 
                                                  $G as map(xs:string, item())) {
        if ($length eq 0)
        then ()
        else ($G?number, r:random-sequence($length - 1, $G?next()))
      };
      
      r:random-sequence(200);
                  
      337 is an instance of
      op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
      964,
      op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
      965,
      let $para := 
      In a hole in the ground there lived a hobbit.
               
      29,
      op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
      967,
      op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
      966,
      op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
      969,
      op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
      968, or
      op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
      970

    3. One of the following conditions is true:

      1. Both

        declare %public function r:random-sequence($length as xs:integer) as xs:double* {
          r:random-sequence($length, fn:random-number-generator())
        };
        
        declare %private function r:random-sequence($length as xs:integer, 
                                                    $G as map(xs:string, item())) {
          if ($length eq 0)
          then ()
          else ($G?number, r:random-sequence($length - 1, $G?next()))
        };
        
        r:random-sequence(200);
                    
        334 and
        declare %public function r:random-sequence($length as xs:integer) as xs:double* {
          r:random-sequence($length, fn:random-number-generator())
        };
        
        declare %private function r:random-sequence($length as xs:integer, 
                                                    $G as map(xs:string, item())) {
          if ($length eq 0)
          then ()
          else ($G?number, r:random-sequence($length - 1, $G?next()))
        };
        
        r:random-sequence(200);
                    
        337 have a timezone

      2. Neither

        declare %public function r:random-sequence($length as xs:integer) as xs:double* {
          r:random-sequence($length, fn:random-number-generator())
        };
        
        declare %private function r:random-sequence($length as xs:integer, 
                                                    $G as map(xs:string, item())) {
          if ($length eq 0)
          then ()
          else ($G?number, r:random-sequence($length - 1, $G?next()))
        };
        
        r:random-sequence(200);
                    
        334 nor
        declare %public function r:random-sequence($length as xs:integer) as xs:double* {
          r:random-sequence($length, fn:random-number-generator())
        };
        
        declare %private function r:random-sequence($length as xs:integer, 
                                                    $G as map(xs:string, item())) {
          if ($length eq 0)
          then ()
          else ($G?number, r:random-sequence($length - 1, $G?next()))
        };
        
        r:random-sequence(200);
                    
        337 has a timezone

    4. declare %public function r:random-sequence($length as xs:integer) as xs:double* {
        r:random-sequence($length, fn:random-number-generator())
      };
      
      declare %private function r:random-sequence($length as xs:integer, 
                                                  $G as map(xs:string, item())) {
        if ($length eq 0)
        then ()
        else ($G?number, r:random-sequence($length - 1, $G?next()))
      };
      
      r:random-sequence(200);
                  
      404

      Note:

      The use of

      declare %public function r:random-sequence($length as xs:integer) as xs:double* {
        r:random-sequence($length, fn:random-number-generator())
      };
      
      declare %private function r:random-sequence($length as xs:integer, 
                                                  $G as map(xs:string, item())) {
        if ($length eq 0)
        then ()
        else ($G?number, r:random-sequence($length - 1, $G?next()))
      };
      
      r:random-sequence(200);
                  
      405 rather than
      let $para := 
      In a hole in the ground there lived a hobbit.
               
      33 ensures that comparing values of different types yields
      let $C := 'http://www.w3.org/2013/collation/UCA?strength=primary'
      07 rather than an error.

    Note:

    Unlike the

    let $para := 
    In a hole in the ground there lived a hobbit.
             
    33 operator, this comparison has no dependency on the implicit timezone, which means that the question of whether or not a map contains duplicate keys is not dependent on this aspect of the dynamic context.

  4. All of the following conditions are true:

    1. declare %public function r:random-sequence($length as xs:integer) as xs:double* {
        r:random-sequence($length, fn:random-number-generator())
      };
      
      declare %private function r:random-sequence($length as xs:integer, 
                                                  $G as map(xs:string, item())) {
        if ($length eq 0)
        then ()
        else ($G?number, r:random-sequence($length - 1, $G?next()))
      };
      
      r:random-sequence(200);
                  
      334 is an instance of
      op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
      32,
      let $para := 
      In a hole in the ground there lived a hobbit.
               
      219,
      let $para := 
      In a hole in the ground there lived a hobbit.
               
      196,
      op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
      489,
      let $para := 
      In a hole in the ground there lived a hobbit.
               
      36, or
      1º 2º 3º 4º ...
      021

    2. declare %public function r:random-sequence($length as xs:integer) as xs:double* {
        r:random-sequence($length, fn:random-number-generator())
      };
      
      declare %private function r:random-sequence($length as xs:integer, 
                                                  $G as map(xs:string, item())) {
        if ($length eq 0)
        then ()
        else ($G?number, r:random-sequence($length - 1, $G?next()))
      };
      
      r:random-sequence(200);
                  
      337 is an instance of
      op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
      32,
      let $para := 
      In a hole in the ground there lived a hobbit.
               
      219,
      let $para := 
      In a hole in the ground there lived a hobbit.
               
      196,
      op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
      489,
      let $para := 
      In a hole in the ground there lived a hobbit.
               
      36, or
      1º 2º 3º 4º ...
      021

    3. declare %public function r:random-sequence($length as xs:integer) as xs:double* {
        r:random-sequence($length, fn:random-number-generator())
      };
      
      declare %private function r:random-sequence($length as xs:integer, 
                                                  $G as map(xs:string, item())) {
        if ($length eq 0)
        then ()
        else ($G?number, r:random-sequence($length - 1, $G?next()))
      };
      
      r:random-sequence(200);
                  
      404

      Note:

      The use of

      declare %public function r:random-sequence($length as xs:integer) as xs:double* {
        r:random-sequence($length, fn:random-number-generator())
      };
      
      declare %private function r:random-sequence($length as xs:integer, 
                                                  $G as map(xs:string, item())) {
        if ($length eq 0)
        then ()
        else ($G?number, r:random-sequence($length - 1, $G?next()))
      };
      
      r:random-sequence(200);
                  
      405 rather than
      let $para := 
      In a hole in the ground there lived a hobbit.
               
      33 ensures that comparing values of different types yields
      let $C := 'http://www.w3.org/2013/collation/UCA?strength=primary'
      07 rather than an error.

Notes

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

  • Context-free: there is no dependency on the static or dynamic context

  • Error-free: any two atomic values can be compared, and the result is either true or false, never an error

  • Transitive: if A is the same key as B, and B is the same key as C, then A is the same key as C.

As always, any algorithm that delivers the right result is acceptable. For example, when testing whether an

let $para := 
In a hole in the ground there lived a hobbit.
         
26 value D is the same key as an
let $para := 
In a hole in the ground there lived a hobbit.
         
82 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 significant digits (or indeed, simply knowing that there are more than N significant digits) is sufficient.

17.1.2 map:merge

Summary

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

Signatures

declare %public function r:random-sequence($length as xs:integer) as xs:double* {
  r:random-sequence($length, fn:random-number-generator())
};

declare %private function r:random-sequence($length as xs:integer, 
                                            $G as map(xs:string, item())) {
  if ($length eq 0)
  then ()
  else ($G?number, r:random-sequence($length - 1, $G?next()))
};

r:random-sequence(200);
            
323(
declare %public function r:random-sequence($length as xs:integer) as xs:double* {
  r:random-sequence($length, fn:random-number-generator())
};

declare %private function r:random-sequence($length as xs:integer, 
                                            $G as map(xs:string, item())) {
  if ($length eq 0)
  then ()
  else ($G?number, r:random-sequence($length - 1, $G?next()))
};

r:random-sequence(200);
            
430
let $para := 
In a hole in the ground there lived a hobbit.
         
71
declare %public function r:random-sequence($length as xs:integer) as xs:double* {
  r:random-sequence($length, fn:random-number-generator())
};

declare %private function r:random-sequence($length as xs:integer, 
                                            $G as map(xs:string, item())) {
  if ($length eq 0)
  then ()
  else ($G?number, r:random-sequence($length - 1, $G?next()))
};

r:random-sequence(200);
            
432)
let $para := 
In a hole in the ground there lived a hobbit.
         
71
let $para := 
In a hole in the ground there lived a hobbit.
         
32

declare %public function r:random-sequence($length as xs:integer) as xs:double* {
  r:random-sequence($length, fn:random-number-generator())
};

declare %private function r:random-sequence($length as xs:integer, 
                                            $G as map(xs:string, item())) {
  if ($length eq 0)
  then ()
  else ($G?number, r:random-sequence($length - 1, $G?next()))
};

r:random-sequence(200);
            
323(
declare %public function r:random-sequence($length as xs:integer) as xs:double* {
  r:random-sequence($length, fn:random-number-generator())
};

declare %private function r:random-sequence($length as xs:integer, 
                                            $G as map(xs:string, item())) {
  if ($length eq 0)
  then ()
  else ($G?number, r:random-sequence($length - 1, $G?next()))
};

r:random-sequence(200);
            
430
let $para := 
In a hole in the ground there lived a hobbit.
         
71
declare %public function r:random-sequence($length as xs:integer) as xs:double* {
  r:random-sequence($length, fn:random-number-generator())
};

declare %private function r:random-sequence($length as xs:integer, 
                                            $G as map(xs:string, item())) {
  if ($length eq 0)
  then ()
  else ($G?number, r:random-sequence($length - 1, $G?next()))
};

r:random-sequence(200);
            
432,
declare %public function r:random-sequence($length as xs:integer) as xs:double* {
  r:random-sequence($length, fn:random-number-generator())
};

declare %private function r:random-sequence($length as xs:integer, 
                                            $G as map(xs:string, item())) {
  if ($length eq 0)
  then ()
  else ($G?number, r:random-sequence($length - 1, $G?next()))
};

r:random-sequence(200);
            
030
let $para := 
In a hole in the ground there lived a hobbit.
         
71
let $para := 
In a hole in the ground there lived a hobbit.
         
32)
let $para := 
In a hole in the ground there lived a hobbit.
         
71
let $para := 
In a hole in the ground there lived a hobbit.
         
32

Properties

This function is ·deterministic·, ·context-independent·, and ·focus-independent·.

Rules

The function

declare %public function r:random-sequence($length as xs:integer) as xs:double* {
  r:random-sequence($length, fn:random-number-generator())
};

declare %private function r:random-sequence($length as xs:integer, 
                                            $G as map(xs:string, item())) {
  if ($length eq 0)
  then ()
  else ($G?number, r:random-sequence($length - 1, $G?next()))
};

r:random-sequence(200);
            
323 returns a map that is formed by combining the contents of the maps supplied in the
declare %public function r:random-sequence($length as xs:integer) as xs:double* {
  r:random-sequence($length, fn:random-number-generator())
};

declare %private function r:random-sequence($length as xs:integer, 
                                            $G as map(xs:string, item())) {
  if ($length eq 0)
  then ()
  else ($G?number, r:random-sequence($length - 1, $G?next()))
};

r:random-sequence(200);
            
430 argument.

Informally, the supplied maps are combined as follows:

  1. There is one entry in the returned map for each distinct key present in the union of the input maps, where two keys are distinct if they are not the ·same key·.

  2. If there are duplicate keys, that is, if two or more maps contain entries having the ·same key·, then the way this is handled is controlled by the second (

    declare %public function r:random-sequence($length as xs:integer) as xs:double* {
      r:random-sequence($length, fn:random-number-generator())
    };
    
    declare %private function r:random-sequence($length as xs:integer, 
                                                $G as map(xs:string, item())) {
      if ($length eq 0)
      then ()
      else ($G?number, r:random-sequence($length - 1, $G?next()))
    };
    
    r:random-sequence(200);
                
    030) argument.

The definitive specification is as follows.

  1. The effect of calling the single-argument function is the same as the effect of calling the two-argument function with an empty map as the value of

    declare %public function r:random-sequence($length as xs:integer) as xs:double* {
      r:random-sequence($length, fn:random-number-generator())
    };
    
    declare %private function r:random-sequence($length as xs:integer, 
                                                $G as map(xs:string, item())) {
      if ($length eq 0)
      then ()
      else ($G?number, r:random-sequence($length - 1, $G?next()))
    };
    
    r:random-sequence(200);
                
    030.

  2. The

    declare %public function r:random-sequence($length as xs:integer) as xs:double* {
      r:random-sequence($length, fn:random-number-generator())
    };
    
    declare %private function r:random-sequence($length as xs:integer, 
                                                $G as map(xs:string, item())) {
      if ($length eq 0)
      then ()
      else ($G?number, r:random-sequence($length - 1, $G?next()))
    };
    
    r:random-sequence(200);
                
    030 argument can be used to control the way in which duplicate keys are handled. The ·option parameter conventions· apply.

  3. The entries that may appear in the

    declare %public function r:random-sequence($length as xs:integer) as xs:double* {
      r:random-sequence($length, fn:random-number-generator())
    };
    
    declare %private function r:random-sequence($length as xs:integer, 
                                                $G as map(xs:string, item())) {
      if ($length eq 0)
      then ()
      else ($G?number, r:random-sequence($length - 1, $G?next()))
    };
    
    r:random-sequence(200);
                
    030 map are as follows:

    KeyValueMeaning
    declare %public function r:random-sequence($length as xs:integer) as xs:double* {
      r:random-sequence($length, fn:random-number-generator())
    };
    
    declare %private function r:random-sequence($length as xs:integer, 
                                                $G as map(xs:string, item())) {
      if ($length eq 0)
      then ()
      else ($G?number, r:random-sequence($length - 1, $G?next()))
    };
    
    r:random-sequence(200);
                
    450Determines the policy for handling duplicate keys: specifically, the action to be taken if two maps in the input sequence
    declare %public function r:random-sequence($length as xs:integer) as xs:double* {
      r:random-sequence($length, fn:random-number-generator())
    };
    
    declare %private function r:random-sequence($length as xs:integer, 
                                                $G as map(xs:string, item())) {
      if ($length eq 0)
      then ()
      else ($G?number, r:random-sequence($length - 1, $G?next()))
    };
    
    r:random-sequence(200);
                
    430 contain entries with key values K1 and K2 where K1 and K2 are the ·same key·.
    • Type:

      let $para := 
      In a hole in the ground there lived a hobbit.
               
      10

    • Default:

      declare %public function r:random-sequence($length as xs:integer) as xs:double* {
        r:random-sequence($length, fn:random-number-generator())
      };
      
      declare %private function r:random-sequence($length as xs:integer, 
                                                  $G as map(xs:string, item())) {
        if ($length eq 0)
        then ()
        else ($G?number, r:random-sequence($length - 1, $G?next()))
      };
      
      r:random-sequence(200);
                  
      453

    declare %public function r:random-sequence($length as xs:integer) as xs:double* {
      r:random-sequence($length, fn:random-number-generator())
    };
    
    declare %private function r:random-sequence($length as xs:integer, 
                                                $G as map(xs:string, item())) {
      if ($length eq 0)
      then ()
      else ($G?number, r:random-sequence($length - 1, $G?next()))
    };
    
    r:random-sequence(200);
                
    454An error is raised [err:FOJS0003] if duplicate keys are encountered.
    declare %public function r:random-sequence($length as xs:integer) as xs:double* {
      r:random-sequence($length, fn:random-number-generator())
    };
    
    declare %private function r:random-sequence($length as xs:integer, 
                                                $G as map(xs:string, item())) {
      if ($length eq 0)
      then ()
      else ($G?number, r:random-sequence($length - 1, $G?next()))
    };
    
    r:random-sequence(200);
                
    453If duplicate keys are present, all but the first of a set of duplicates are ignored, where the ordering is based on the order of maps in the
    declare %public function r:random-sequence($length as xs:integer) as xs:double* {
      r:random-sequence($length, fn:random-number-generator())
    };
    
    declare %private function r:random-sequence($length as xs:integer, 
                                                $G as map(xs:string, item())) {
      if ($length eq 0)
      then ()
      else ($G?number, r:random-sequence($length - 1, $G?next()))
    };
    
    r:random-sequence(200);
                
    430 argument.
    declare %public function r:random-sequence($length as xs:integer) as xs:double* {
      r:random-sequence($length, fn:random-number-generator())
    };
    
    declare %private function r:random-sequence($length as xs:integer, 
                                                $G as map(xs:string, item())) {
      if ($length eq 0)
      then ()
      else ($G?number, r:random-sequence($length - 1, $G?next()))
    };
    
    r:random-sequence(200);
                
    457If duplicate keys are present, all but the last of a set of duplicates are ignored, where the ordering is based on the order of maps in the
    declare %public function r:random-sequence($length as xs:integer) as xs:double* {
      r:random-sequence($length, fn:random-number-generator())
    };
    
    declare %private function r:random-sequence($length as xs:integer, 
                                                $G as map(xs:string, item())) {
      if ($length eq 0)
      then ()
      else ($G?number, r:random-sequence($length - 1, $G?next()))
    };
    
    r:random-sequence(200);
                
    430 argument.
    declare %public function r:random-sequence($length as xs:integer) as xs:double* {
      r:random-sequence($length, fn:random-number-generator())
    };
    
    declare %private function r:random-sequence($length as xs:integer, 
                                                $G as map(xs:string, item())) {
      if ($length eq 0)
      then ()
      else ($G?number, r:random-sequence($length - 1, $G?next()))
    };
    
    r:random-sequence(200);
                
    459If duplicate keys are present, all but one of a set of duplicates are ignored, and it is ·implementation-dependent· which one is retained.
    declare %public function r:random-sequence($length as xs:integer) as xs:double* {
      r:random-sequence($length, fn:random-number-generator())
    };
    
    declare %private function r:random-sequence($length as xs:integer, 
                                                $G as map(xs:string, item())) {
      if ($length eq 0)
      then ()
      else ($G?number, r:random-sequence($length - 1, $G?next()))
    };
    
    r:random-sequence(200);
                
    460If duplicate keys are present, the result map includes an entry for the key whose associated value is the sequence-concatenation of all the values associated with the key, retaining order based on the order of maps in the
    declare %public function r:random-sequence($length as xs:integer) as xs:double* {
      r:random-sequence($length, fn:random-number-generator())
    };
    
    declare %private function r:random-sequence($length as xs:integer, 
                                                $G as map(xs:string, item())) {
      if ($length eq 0)
      then ()
      else ($G?number, r:random-sequence($length - 1, $G?next()))
    };
    
    r:random-sequence(200);
                
    430 argument. The key value in the result map that corresponds to such a set of duplicates must be the ·same key· as each of the duplicates, but it is otherwise unconstrained: for example if the duplicate keys are
    declare %public function r:random-sequence($length as xs:integer) as xs:double* {
      r:random-sequence($length, fn:random-number-generator())
    };
    
    declare %private function r:random-sequence($length as xs:integer, 
                                                $G as map(xs:string, item())) {
      if ($length eq 0)
      then ()
      else ($G?number, r:random-sequence($length - 1, $G?next()))
    };
    
    r:random-sequence(200);
                
    462 and
    declare %public function r:random-sequence($length as xs:integer) as xs:double* {
      r:random-sequence($length, fn:random-number-generator())
    };
    
    declare %private function r:random-sequence($length as xs:integer, 
                                                $G as map(xs:string, item())) {
      if ($length eq 0)
      then ()
      else ($G?number, r:random-sequence($length - 1, $G?next()))
    };
    
    r:random-sequence(200);
                
    463, the key in the result could legitimately be
    declare %public function r:random-sequence($length as xs:integer) as xs:double* {
      r:random-sequence($length, fn:random-number-generator())
    };
    
    declare %private function r:random-sequence($length as xs:integer, 
                                                $G as map(xs:string, item())) {
      if ($length eq 0)
      then ()
      else ($G?number, r:random-sequence($length - 1, $G?next()))
    };
    
    r:random-sequence(200);
                
    464.

The result of the function call

declare %public function r:random-sequence($length as xs:integer) as xs:double* {
  r:random-sequence($length, fn:random-number-generator())
};

declare %private function r:random-sequence($length as xs:integer, 
                                            $G as map(xs:string, item())) {
  if ($length eq 0)
  then ()
  else ($G?number, r:random-sequence($length - 1, $G?next()))
};

r:random-sequence(200);
            
465 is defined to be consistent with the result of the expression:

let $C := 'http://www.w3.org/2013/collation/UCA?strength=primary'
2

Note:

By way of explanation,

declare %public function r:random-sequence($length as xs:integer) as xs:double* {
  r:random-sequence($length, fn:random-number-generator())
};

declare %private function r:random-sequence($length as xs:integer, 
                                            $G as map(xs:string, item())) {
  if ($length eq 0)
  then ()
  else ($G?number, r:random-sequence($length - 1, $G?next()))
};

r:random-sequence(200);
            
466 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
Primo Secondo Terzo Quarto Quinto ...
824 in the
declare %public function r:random-sequence($length as xs:integer) as xs:double* {
  r:random-sequence($length, fn:random-number-generator())
};

declare %private function r:random-sequence($length as xs:integer, 
                                            $G as map(xs:string, item())) {
  if ($length eq 0)
  then ()
  else ($G?number, r:random-sequence($length - 1, $G?next()))
};

r:random-sequence(200);
            
468 clause then iterates over the maps supplied in the call to
declare %public function r:random-sequence($length as xs:integer) as xs:double* {
  r:random-sequence($length, fn:random-number-generator())
};

declare %private function r:random-sequence($length as xs:integer, 
                                            $G as map(xs:string, item())) {
  if ($length eq 0)
  then ()
  else ($G?number, r:random-sequence($length - 1, $G?next()))
};

r:random-sequence(200);
            
323, accumulating a single map that absorbs successive maps in the input sequence by calling
declare %public function r:random-sequence($length as xs:integer) as xs:double* {
  r:random-sequence($length, fn:random-number-generator())
};

declare %private function r:random-sequence($length as xs:integer, 
                                            $G as map(xs:string, item())) {
  if ($length eq 0)
  then ()
  else ($G?number, r:random-sequence($length - 1, $G?next()))
};

r:random-sequence(200);
            
466.

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

The use of

let $para := 
In a hole in the ground there lived a hobbit.
         
992 represents one possible conformant implementation for
declare %public function r:random-sequence($length as xs:integer) as xs:double* {
  r:random-sequence($length, fn:random-number-generator())
};

declare %private function r:random-sequence($length as xs:integer, 
                                            $G as map(xs:string, item())) {
  if ($length eq 0)
  then ()
  else ($G?number, r:random-sequence($length - 1, $G?next()))
};

r:random-sequence(200);
            
472, 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, if the input maps are processed in parallel, then specifying
declare %public function r:random-sequence($length as xs:integer) as xs:double* {
  r:random-sequence($length, fn:random-number-generator())
};

declare %private function r:random-sequence($length as xs:integer, 
                                            $G as map(xs:string, item())) {
  if ($length eq 0)
  then ()
  else ($G?number, r:random-sequence($length - 1, $G?next()))
};

r:random-sequence(200);
            
472 means that the implementation does not need to keep track of the original order of the sequence of input maps.

Error Conditions

An error is raised [err:FOJS0003] if the value of

declare %public function r:random-sequence($length as xs:integer) as xs:double* {
  r:random-sequence($length, fn:random-number-generator())
};

declare %private function r:random-sequence($length as xs:integer, 
                                            $G as map(xs:string, item())) {
  if ($length eq 0)
  then ()
  else ($G?number, r:random-sequence($length - 1, $G?next()))
};

r:random-sequence(200);
            
030 indicates that duplicates are to be rejected, and a duplicate key is encountered.

An error is raised [err:FOJS0005] if the value of

declare %public function r:random-sequence($length as xs:integer) as xs:double* {
  r:random-sequence($length, fn:random-number-generator())
};

declare %private function r:random-sequence($length as xs:integer, 
                                            $G as map(xs:string, item())) {
  if ($length eq 0)
  then ()
  else ($G?number, r:random-sequence($length - 1, $G?next()))
};

r:random-sequence(200);
            
030 includes an entry whose key is defined in this specification, and whose value is not a permitted value for that key.

Notes

If the input is an empty sequence, the result is an empty map.

If the input is a sequence of length one, the result map is indistinguishable from the supplied map.

There is no requirement that the supplied input maps should have the same or compatible types. The type of a map (for example

declare %public function r:random-sequence($length as xs:integer) as xs:double* {
  r:random-sequence($length, fn:random-number-generator())
};

declare %private function r:random-sequence($length as xs:integer, 
                                            $G as map(xs:string, item())) {
  if ($length eq 0)
  then ()
  else ($G?number, r:random-sequence($length - 1, $G?next()))
};

r:random-sequence(200);
            
476) is descriptive of the entries it currently contains, but is not a constraint on how the map may be combined with other maps.

Examples

let $C := 'http://www.w3.org/2013/collation/UCA?strength=primary'
3

The expression

declare %public function r:random-sequence($length as xs:integer) as xs:double* {
  r:random-sequence($length, fn:random-number-generator())
};

declare %private function r:random-sequence($length as xs:integer, 
                                            $G as map(xs:string, item())) {
  if ($length eq 0)
  then ()
  else ($G?number, r:random-sequence($length - 1, $G?next()))
};

r:random-sequence(200);
            
477 returns
Primo Secondo Terzo Quarto Quinto ...
659. (Returns an empty map).

The expression

declare %public function r:random-sequence($length as xs:integer) as xs:double* {
  r:random-sequence($length, fn:random-number-generator())
};

declare %private function r:random-sequence($length as xs:integer, 
                                            $G as map(xs:string, item())) {
  if ($length eq 0)
  then ()
  else ($G?number, r:random-sequence($length - 1, $G?next()))
};

r:random-sequence(200);
            
479 returns
declare %public function r:random-sequence($length as xs:integer) as xs:double* {
  r:random-sequence($length, fn:random-number-generator())
};

declare %private function r:random-sequence($length as xs:integer, 
                                            $G as map(xs:string, item())) {
  if ($length eq 0)
  then ()
  else ($G?number, r:random-sequence($length - 1, $G?next()))
};

r:random-sequence(200);
            
480. (Returns a map with two entries).

The expression

declare %public function r:random-sequence($length as xs:integer) as xs:double* {
  r:random-sequence($length, fn:random-number-generator())
};

declare %private function r:random-sequence($length as xs:integer, 
                                            $G as map(xs:string, item())) {
  if ($length eq 0)
  then ()
  else ($G?number, r:random-sequence($length - 1, $G?next()))
};

r:random-sequence(200);
            
481 returns
declare %public function r:random-sequence($length as xs:integer) as xs:double* {
  r:random-sequence($length, fn:random-number-generator())
};

declare %private function r:random-sequence($length as xs:integer, 
                                            $G as map(xs:string, item())) {
  if ($length eq 0)
  then ()
  else ($G?number, r:random-sequence($length - 1, $G?next()))
};

r:random-sequence(200);
            
482. (The value of the existing map is unchanged; the returned map contains all the entries from
declare %public function r:random-sequence($length as xs:integer) as xs:double* {
  r:random-sequence($length, fn:random-number-generator())
};

declare %private function r:random-sequence($length as xs:integer, 
                                            $G as map(xs:string, item())) {
  if ($length eq 0)
  then ()
  else ($G?number, r:random-sequence($length - 1, $G?next()))
};

r:random-sequence(200);
            
483, supplemented with an additional entry.)

The expression

declare %public function r:random-sequence($length as xs:integer) as xs:double* {
  r:random-sequence($length, fn:random-number-generator())
};

declare %private function r:random-sequence($length as xs:integer, 
                                            $G as map(xs:string, item())) {
  if ($length eq 0)
  then ()
  else ($G?number, r:random-sequence($length - 1, $G?next()))
};

r:random-sequence(200);
            
484 returns
declare %public function r:random-sequence($length as xs:integer) as xs:double* {
  r:random-sequence($length, fn:random-number-generator())
};

declare %private function r:random-sequence($length as xs:integer, 
                                            $G as map(xs:string, item())) {
  if ($length eq 0)
  then ()
  else ($G?number, r:random-sequence($length - 1, $G?next()))
};

r:random-sequence(200);
            
485. (The value of the existing map is unchanged; the returned map contains all the entries from
declare %public function r:random-sequence($length as xs:integer) as xs:double* {
  r:random-sequence($length, fn:random-number-generator())
};

declare %private function r:random-sequence($length as xs:integer, 
                                            $G as map(xs:string, item())) {
  if ($length eq 0)
  then ()
  else ($G?number, r:random-sequence($length - 1, $G?next()))
};

r:random-sequence(200);
            
483, with one entry replaced by a new entry. Both input maps contain an entry with the key
Primo Secondo Terzo Quarto Quinto ...
013; the one used in the result is the one that comes last in the input sequence.)

The expression

declare %public function r:random-sequence($length as xs:integer) as xs:double* {
  r:random-sequence($length, fn:random-number-generator())
};

declare %private function r:random-sequence($length as xs:integer, 
                                            $G as map(xs:string, item())) {
  if ($length eq 0)
  then ()
  else ($G?number, r:random-sequence($length - 1, $G?next()))
};

r:random-sequence(200);
            
488 returns
declare %public function r:random-sequence($length as xs:integer) as xs:double* {
  r:random-sequence($length, fn:random-number-generator())
};

declare %private function r:random-sequence($length as xs:integer, 
                                            $G as map(xs:string, item())) {
  if ($length eq 0)
  then ()
  else ($G?number, r:random-sequence($length - 1, $G?next()))
};

r:random-sequence(200);
            
489. (The value of the existing map is unchanged; the returned map contains all the entries from
declare %public function r:random-sequence($length as xs:integer) as xs:double* {
  r:random-sequence($length, fn:random-number-generator())
};

declare %private function r:random-sequence($length as xs:integer, 
                                            $G as map(xs:string, item())) {
  if ($length eq 0)
  then ()
  else ($G?number, r:random-sequence($length - 1, $G?next()))
};

r:random-sequence(200);
            
483, with one entry replaced by a new entry. Both input maps contain an entry with the key
Primo Secondo Terzo Quarto Quinto ...
013; the one used in the result is the one that comes first in the input sequence.)

The expression

declare %public function r:random-sequence($length as xs:integer) as xs:double* {
  r:random-sequence($length, fn:random-number-generator())
};

declare %private function r:random-sequence($length as xs:integer, 
                                            $G as map(xs:string, item())) {
  if ($length eq 0)
  then ()
  else ($G?number, r:random-sequence($length - 1, $G?next()))
};

r:random-sequence(200);
            
492 returns
declare %public function r:random-sequence($length as xs:integer) as xs:double* {
  r:random-sequence($length, fn:random-number-generator())
};

declare %private function r:random-sequence($length as xs:integer, 
                                            $G as map(xs:string, item())) {
  if ($length eq 0)
  then ()
  else ($G?number, r:random-sequence($length - 1, $G?next()))
};

r:random-sequence(200);
            
493. (The value of the existing map is unchanged; the returned map contains all the entries from
declare %public function r:random-sequence($length as xs:integer) as xs:double* {
  r:random-sequence($length, fn:random-number-generator())
};

declare %private function r:random-sequence($length as xs:integer, 
                                            $G as map(xs:string, item())) {
  if ($length eq 0)
  then ()
  else ($G?number, r:random-sequence($length - 1, $G?next()))
};

r:random-sequence(200);
            
483, with one entry replaced by a new entry. Both input maps contain an entry with the key
Primo Secondo Terzo Quarto Quinto ...
013; the entry that appears in the result is the sequence-concatenation of the entries in the input maps, retaining order.)

17.1.3 map:size

Summary

Returns the number of entries in the supplied map.

Signature

declare %public function r:random-sequence($length as xs:integer) as xs:double* {
  r:random-sequence($length, fn:random-number-generator())
};

declare %private function r:random-sequence($length as xs:integer, 
                                            $G as map(xs:string, item())) {
  if ($length eq 0)
  then ()
  else ($G?number, r:random-sequence($length - 1, $G?next()))
};

r:random-sequence(200);
            
324(
declare %public function r:random-sequence($length as xs:integer) as xs:double* {
  r:random-sequence($length, fn:random-number-generator())
};

declare %private function r:random-sequence($length as xs:integer, 
                                            $G as map(xs:string, item())) {
  if ($length eq 0)
  then ()
  else ($G?number, r:random-sequence($length - 1, $G?next()))
};

r:random-sequence(200);
            
497
let $para := 
In a hole in the ground there lived a hobbit.
         
71
let $para := 
In a hole in the ground there lived a hobbit.
         
32)
let $para := 
In a hole in the ground there lived a hobbit.
         
71
let $para := 
In a hole in the ground there lived a hobbit.
         
85

Properties

This function is ·deterministic·, ·context-independent·, and ·focus-independent·.

Rules

The function

declare %public function r:random-sequence($length as xs:integer) as xs:double* {
  r:random-sequence($length, fn:random-number-generator())
};

declare %private function r:random-sequence($length as xs:integer, 
                                            $G as map(xs:string, item())) {
  if ($length eq 0)
  then ()
  else ($G?number, r:random-sequence($length - 1, $G?next()))
};

r:random-sequence(200);
            
324 takes any ·map· as its
declare %public function r:random-sequence($length as xs:integer) as xs:double* {
  r:random-sequence($length, fn:random-number-generator())
};

declare %private function r:random-sequence($length as xs:integer, 
                                            $G as map(xs:string, item())) {
  if ($length eq 0)
  then ()
  else ($G?number, r:random-sequence($length - 1, $G?next()))
};

r:random-sequence(200);
            
497 argument and returns the number of entries that are present in the map.

Examples

The expression

declare %public function r:random-sequence($length as xs:integer) as xs:double* {
  r:random-sequence($length, fn:random-number-generator())
};

declare %private function r:random-sequence($length as xs:integer, 
                                            $G as map(xs:string, item())) {
  if ($length eq 0)
  then ()
  else ($G?number, r:random-sequence($length - 1, $G?next()))
};

r:random-sequence(200);
            
504 returns
declare %public function r:random-sequence($length as xs:integer) as xs:double* {
  r:random-sequence($length, fn:random-number-generator())
};

declare %private function r:random-sequence($length as xs:integer, 
                                            $G as map(xs:string, item())) {
  if ($length eq 0)
  then ()
  else ($G?number, r:random-sequence($length - 1, $G?next()))
};

r:random-sequence(200);
            
19.

The expression

declare %public function r:random-sequence($length as xs:integer) as xs:double* {
  r:random-sequence($length, fn:random-number-generator())
};

declare %private function r:random-sequence($length as xs:integer, 
                                            $G as map(xs:string, item())) {
  if ($length eq 0)
  then ()
  else ($G?number, r:random-sequence($length - 1, $G?next()))
};

r:random-sequence(200);
            
506 returns
let $para := 
In a hole in the ground there lived a hobbit.
         
226.

17.1.4 map:keys

Summary

Returns a sequence containing all the keys present in a map

Signature

op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
16(
declare %public function r:random-sequence($length as xs:integer) as xs:double* {
  r:random-sequence($length, fn:random-number-generator())
};

declare %private function r:random-sequence($length as xs:integer, 
                                            $G as map(xs:string, item())) {
  if ($length eq 0)
  then ()
  else ($G?number, r:random-sequence($length - 1, $G?next()))
};

r:random-sequence(200);
            
497
let $para := 
In a hole in the ground there lived a hobbit.
         
71
let $para := 
In a hole in the ground there lived a hobbit.
         
32)
let $para := 
In a hole in the ground there lived a hobbit.
         
71
op:operation(fenceHeight, xs:integer) => op:operation(xs:integer, xs:integer)
12

Properties

This function is ·nondeterministic-wrt-ordering·, ·context-independent·, and ·focus-independent·.

Rules

The function

op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
16 takes any ·map· as its
declare %public function r:random-sequence($length as xs:integer) as xs:double* {
  r:random-sequence($length, fn:random-number-generator())
};

declare %private function r:random-sequence($length as xs:integer, 
                                            $G as map(xs:string, item())) {
  if ($length eq 0)
  then ()
  else ($G?number, r:random-sequence($length - 1, $G?next()))
};

r:random-sequence(200);
            
497 argument and returns the keys that are present in the map as a sequence of atomic values, in ·implementation-dependent· order.

The function is non-deterministic with respect to ordering (see 1.7.4 Properties of functions). This means that two calls with the same argument are not guaranteed to produce the results in the same order.

Notes

The number of items in the result will be the same as the number of entries in the map, and the result sequence will contain no duplicate values.

Examples

The expression

declare %public function r:random-sequence($length as xs:integer) as xs:double* {
  r:random-sequence($length, fn:random-number-generator())
};

declare %private function r:random-sequence($length as xs:integer, 
                                            $G as map(xs:string, item())) {
  if ($length eq 0)
  then ()
  else ($G?number, r:random-sequence($length - 1, $G?next()))
};

r:random-sequence(200);
            
516 returns some permutation of
declare %public function r:random-sequence($length as xs:integer) as xs:double* {
  r:random-sequence($length, fn:random-number-generator())
};

declare %private function r:random-sequence($length as xs:integer, 
                                            $G as map(xs:string, item())) {
  if ($length eq 0)
  then ()
  else ($G?number, r:random-sequence($length - 1, $G?next()))
};

r:random-sequence(200);
            
517. (The result is in ·implementation-dependent· order.)

17.1.5 map:contains

Summary

Tests whether a supplied map contains an entry for a given key

Signature

let $para := 
In a hole in the ground there lived a hobbit.
         
37(
declare %public function r:random-sequence($length as xs:integer) as xs:double* {
  r:random-sequence($length, fn:random-number-generator())
};

declare %private function r:random-sequence($length as xs:integer, 
                                            $G as map(xs:string, item())) {
  if ($length eq 0)
  then ()
  else ($G?number, r:random-sequence($length - 1, $G?next()))
};

r:random-sequence(200);
            
497
let $para := 
In a hole in the ground there lived a hobbit.
         
71
let $para := 
In a hole in the ground there lived a hobbit.
         
32,
let $para := 
In a hole in the ground there lived a hobbit.
         
192
let $para := 
In a hole in the ground there lived a hobbit.
         
71
let $para := 
In a hole in the ground there lived a hobbit.
         
34)
let $para := 
In a hole in the ground there lived a hobbit.
         
71
op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
32

Properties

This function is ·deterministic·, ·context-independent·, and ·focus-independent·.

Rules

The function

let $para := 
In a hole in the ground there lived a hobbit.
         
37 returns true if the ·map· supplied as
declare %public function r:random-sequence($length as xs:integer) as xs:double* {
  r:random-sequence($length, fn:random-number-generator())
};

declare %private function r:random-sequence($length as xs:integer, 
                                            $G as map(xs:string, item())) {
  if ($length eq 0)
  then ()
  else ($G?number, r:random-sequence($length - 1, $G?next()))
};

r:random-sequence(200);
            
497 contains an entry with the ·same key· as the supplied value of
let $para := 
In a hole in the ground there lived a hobbit.
         
192; otherwise it returns false.

Examples

let $C := 'http://www.w3.org/2013/collation/UCA?strength=primary'
3

The expression

declare %public function r:random-sequence($length as xs:integer) as xs:double* {
  r:random-sequence($length, fn:random-number-generator())
};

declare %private function r:random-sequence($length as xs:integer, 
                                            $G as map(xs:string, item())) {
  if ($length eq 0)
  then ()
  else ($G?number, r:random-sequence($length - 1, $G?next()))
};

r:random-sequence(200);
            
530 returns
let $para := 
In a hole in the ground there lived a hobbit.
         
182.

The expression

declare %public function r:random-sequence($length as xs:integer) as xs:double* {
  r:random-sequence($length, fn:random-number-generator())
};

declare %private function r:random-sequence($length as xs:integer, 
                                            $G as map(xs:string, item())) {
  if ($length eq 0)
  then ()
  else ($G?number, r:random-sequence($length - 1, $G?next()))
};

r:random-sequence(200);
            
532 returns
let $para := 
In a hole in the ground there lived a hobbit.
         
184.

The expression

declare %public function r:random-sequence($length as xs:integer) as xs:double* {
  r:random-sequence($length, fn:random-number-generator())
};

declare %private function r:random-sequence($length as xs:integer, 
                                            $G as map(xs:string, item())) {
  if ($length eq 0)
  then ()
  else ($G?number, r:random-sequence($length - 1, $G?next()))
};

r:random-sequence(200);
            
534 returns
let $para := 
In a hole in the ground there lived a hobbit.
         
184.

The expression

declare %public function r:random-sequence($length as xs:integer) as xs:double* {
  r:random-sequence($length, fn:random-number-generator())
};

declare %private function r:random-sequence($length as xs:integer, 
                                            $G as map(xs:string, item())) {
  if ($length eq 0)
  then ()
  else ($G?number, r:random-sequence($length - 1, $G?next()))
};

r:random-sequence(200);
            
536 returns
let $para := 
In a hole in the ground there lived a hobbit.
         
182.

The expression

declare %public function r:random-sequence($length as xs:integer) as xs:double* {
  r:random-sequence($length, fn:random-number-generator())
};

declare %private function r:random-sequence($length as xs:integer, 
                                            $G as map(xs:string, item())) {
  if ($length eq 0)
  then ()
  else ($G?number, r:random-sequence($length - 1, $G?next()))
};

r:random-sequence(200);
            
538 returns
let $para := 
In a hole in the ground there lived a hobbit.
         
182.

17.1.6 map:get

Summary

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

Signature

let $para := 
In a hole in the ground there lived a hobbit.
         
38(
declare %public function r:random-sequence($length as xs:integer) as xs:double* {
  r:random-sequence($length, fn:random-number-generator())
};

declare %private function r:random-sequence($length as xs:integer, 
                                            $G as map(xs:string, item())) {
  if ($length eq 0)
  then ()
  else ($G?number, r:random-sequence($length - 1, $G?next()))
};

r:random-sequence(200);
            
497
let $para := 
In a hole in the ground there lived a hobbit.
         
71
let $para := 
In a hole in the ground there lived a hobbit.
         
32,
let $para := 
In a hole in the ground there lived a hobbit.
         
192
let $para := 
In a hole in the ground there lived a hobbit.
         
71
let $para := 
In a hole in the ground there lived a hobbit.
         
34)
let $para := 
In a hole in the ground there lived a hobbit.
         
71
op:operation(fenceHeight, xs:integer) => op:operation(xs:integer, xs:integer)
16

Properties

This function is ·deterministic·, ·context-independent·, and ·focus-independent·.

Rules

The function

let $para := 
In a hole in the ground there lived a hobbit.
         
38 attempts to find an entry within the ·map· supplied as
declare %public function r:random-sequence($length as xs:integer) as xs:double* {
  r:random-sequence($length, fn:random-number-generator())
};

declare %private function r:random-sequence($length as xs:integer, 
                                            $G as map(xs:string, item())) {
  if ($length eq 0)
  then ()
  else ($G?number, r:random-sequence($length - 1, $G?next()))
};

r:random-sequence(200);
            
497 that has the ·same key· as the supplied value of
let $para := 
In a hole in the ground there lived a hobbit.
         
192. If there is such an entry, it returns the associated value; otherwise it returns an empty sequence.

Notes

A return value of

let $para := 
In a hole in the ground there lived a hobbit.
         
96 from
let $para := 
In a hole in the ground there lived a hobbit.
         
38 could indicate that the key is present in the map with an associated value of
let $para := 
In a hole in the ground there lived a hobbit.
         
96, or it could indicate that the key is not present in the map. The two cases can be distinguished by calling
let $para := 
In a hole in the ground there lived a hobbit.
         
37.

Invoking the ·map· as a function item has the same effect as calling

declare %public function r:random-sequence($length as xs:integer) as xs:double* {
  r:random-sequence($length, fn:random-number-generator())
};

declare %private function r:random-sequence($length as xs:integer, 
                                            $G as map(xs:string, item())) {
  if ($length eq 0)
  then ()
  else ($G?number, r:random-sequence($length - 1, $G?next()))
};

r:random-sequence(200);
            
314: that is, when
declare %public function r:random-sequence($length as xs:integer) as xs:double* {
  r:random-sequence($length, fn:random-number-generator())
};

declare %private function r:random-sequence($length as xs:integer, 
                                            $G as map(xs:string, item())) {
  if ($length eq 0)
  then ()
  else ($G?number, r:random-sequence($length - 1, $G?next()))
};

r:random-sequence(200);
            
497 is a map, the expression
declare %public function r:random-sequence($length as xs:integer) as xs:double* {
  r:random-sequence($length, fn:random-number-generator())
};

declare %private function r:random-sequence($length as xs:integer, 
                                            $G as map(xs:string, item())) {
  if ($length eq 0)
  then ()
  else ($G?number, r:random-sequence($length - 1, $G?next()))
};

r:random-sequence(200);
            
558 is equivalent to
declare %public function r:random-sequence($length as xs:integer) as xs:double* {
  r:random-sequence($length, fn:random-number-generator())
};

declare %private function r:random-sequence($length as xs:integer, 
                                            $G as map(xs:string, item())) {
  if ($length eq 0)
  then ()
  else ($G?number, r:random-sequence($length - 1, $G?next()))
};

r:random-sequence(200);
            
559. Similarly, the expression
declare %public function r:random-sequence($length as xs:integer) as xs:double* {
  r:random-sequence($length, fn:random-number-generator())
};

declare %private function r:random-sequence($length as xs:integer, 
                                            $G as map(xs:string, item())) {
  if ($length eq 0)
  then ()
  else ($G?number, r:random-sequence($length - 1, $G?next()))
};

r:random-sequence(200);
            
560 can be written as
declare %public function r:random-sequence($length as xs:integer) as xs:double* {
  r:random-sequence($length, fn:random-number-generator())
};

declare %private function r:random-sequence($length as xs:integer, 
                                            $G as map(xs:string, item())) {
  if ($length eq 0)
  then ()
  else ($G?number, r:random-sequence($length - 1, $G?next()))
};

r:random-sequence(200);
            
561.

Examples

let $C := 'http://www.w3.org/2013/collation/UCA?strength=primary'
3

The expression

declare %public function r:random-sequence($length as xs:integer) as xs:double* {
  r:random-sequence($length, fn:random-number-generator())
};

declare %private function r:random-sequence($length as xs:integer, 
                                            $G as map(xs:string, item())) {
  if ($length eq 0)
  then ()
  else ($G?number, r:random-sequence($length - 1, $G?next()))
};

r:random-sequence(200);
            
562 returns
declare %public function r:random-sequence($length as xs:integer) as xs:double* {
  r:random-sequence($length, fn:random-number-generator())
};

declare %private function r:random-sequence($length as xs:integer, 
                                            $G as map(xs:string, item())) {
  if ($length eq 0)
  then ()
  else ($G?number, r:random-sequence($length - 1, $G?next()))
};

r:random-sequence(200);
            
563.

The expression

declare %public function r:random-sequence($length as xs:integer) as xs:double* {
  r:random-sequence($length, fn:random-number-generator())
};

declare %private function r:random-sequence($length as xs:integer, 
                                            $G as map(xs:string, item())) {
  if ($length eq 0)
  then ()
  else ($G?number, r:random-sequence($length - 1, $G?next()))
};

r:random-sequence(200);
            
564 returns
let $para := 
In a hole in the ground there lived a hobbit.
         
96. (When the key is not present, the function returns an empty sequence.)

The expression

declare %public function r:random-sequence($length as xs:integer) as xs:double* {
  r:random-sequence($length, fn:random-number-generator())
};

declare %private function r:random-sequence($length as xs:integer, 
                                            $G as map(xs:string, item())) {
  if ($length eq 0)
  then ()
  else ($G?number, r:random-sequence($length - 1, $G?next()))
};

r:random-sequence(200);
            
566 returns
let $para := 
In a hole in the ground there lived a hobbit.
         
96. (An empty sequence as the result can also signify that the key is present and the associated value is an empty sequence.)

17.1.7 map:find

Summary

Searches the supplied input sequence and any contained maps and arrays for a map entry with the supplied key, and returns the corresponding values.

Signature

declare %public function r:random-sequence($length as xs:integer) as xs:double* {
  r:random-sequence($length, fn:random-number-generator())
};

declare %private function r:random-sequence($length as xs:integer, 
                                            $G as map(xs:string, item())) {
  if ($length eq 0)
  then ()
  else ($G?number, r:random-sequence($length - 1, $G?next()))
};

r:random-sequence(200);
            
328(
let $para := 
In a hole in the ground there lived a hobbit.
         
232
let $para := 
In a hole in the ground there lived a hobbit.
         
71
op:operation(fenceHeight, xs:integer) => op:operation(xs:integer, xs:integer)
16,
let $para := 
In a hole in the ground there lived a hobbit.
         
192
let $para := 
In a hole in the ground there lived a hobbit.
         
71
let $para := 
In a hole in the ground there lived a hobbit.
         
34)
let $para := 
In a hole in the ground there lived a hobbit.
         
71
declare %public function r:random-sequence($length as xs:integer) as xs:double* {
  r:random-sequence($length, fn:random-number-generator())
};

declare %private function r:random-sequence($length as xs:integer, 
                                            $G as map(xs:string, item())) {
  if ($length eq 0)
  then ()
  else ($G?number, r:random-sequence($length - 1, $G?next()))
};

r:random-sequence(200);
            
001

Properties

This function is ·deterministic·, ·context-independent·, and ·focus-independent·.

Rules

The function

declare %public function r:random-sequence($length as xs:integer) as xs:double* {
  r:random-sequence($length, fn:random-number-generator())
};

declare %private function r:random-sequence($length as xs:integer, 
                                            $G as map(xs:string, item())) {
  if ($length eq 0)
  then ()
  else ($G?number, r:random-sequence($length - 1, $G?next()))
};

r:random-sequence(200);
            
328 searches the sequence supplied as
let $para := 
In a hole in the ground there lived a hobbit.
         
232 looking for map entries whose key is the ·same key· as
let $para := 
In a hole in the ground there lived a hobbit.
         
192. The associated value in any such map entry (each being in general a sequence) is returned as a member of the result array.

The search processes the

let $para := 
In a hole in the ground there lived a hobbit.
         
232 sequence using the following recursively-defined rules (any equivalent algorithm may be used provided it delivers the same result, respecting those rules that constrain the order of the result):

  1. To process a sequence, process each of its items in order.

  2. To process an item that is an array, process each of the array's members in order (each member is, in general, a sequence).

  3. To process an item that is a map, then for each key-value entry (K, V) in the map (in ·implementation-dependent· order) perform both of the following steps, in order:

    1. If K is the ·same key· as

      let $para := 
      In a hole in the ground there lived a hobbit.
               
      192, then add V as a new member to the end of the result array.

    2. Process V (which is, in general, a sequence).

  4. To process an item that is neither a map nor an array, do nothing. (Such items are ignored).

Notes

If

let $para := 
In a hole in the ground there lived a hobbit.
         
232 is an empty sequence, map, or array, or if the requested
let $para := 
In a hole in the ground there lived a hobbit.
         
192 is not found, the result will be a zero-length array.

Examples

let $C := 'http://www.w3.org/2013/collation/UCA?strength=primary'
6

The expression

declare %public function r:random-sequence($length as xs:integer) as xs:double* {
  r:random-sequence($length, fn:random-number-generator())
};

declare %private function r:random-sequence($length as xs:integer, 
                                            $G as map(xs:string, item())) {
  if ($length eq 0)
  then ()
  else ($G?number, r:random-sequence($length - 1, $G?next()))
};

r:random-sequence(200);
            
584 returns
declare %public function r:random-sequence($length as xs:integer) as xs:double* {
  r:random-sequence($length, fn:random-number-generator())
};

declare %private function r:random-sequence($length as xs:integer, 
                                            $G as map(xs:string, item())) {
  if ($length eq 0)
  then ()
  else ($G?number, r:random-sequence($length - 1, $G?next()))
};

r:random-sequence(200);
            
585.

The expression

declare %public function r:random-sequence($length as xs:integer) as xs:double* {
  r:random-sequence($length, fn:random-number-generator())
};

declare %private function r:random-sequence($length as xs:integer, 
                                            $G as map(xs:string, item())) {
  if ($length eq 0)
  then ()
  else ($G?number, r:random-sequence($length - 1, $G?next()))
};

r:random-sequence(200);
            
586 returns
declare %public function r:random-sequence($length as xs:integer) as xs:double* {
  r:random-sequence($length, fn:random-number-generator())
};

declare %private function r:random-sequence($length as xs:integer, 
                                            $G as map(xs:string, item())) {
  if ($length eq 0)
  then ()
  else ($G?number, r:random-sequence($length - 1, $G?next()))
};

r:random-sequence(200);
            
587.

The expression

declare %public function r:random-sequence($length as xs:integer) as xs:double* {
  r:random-sequence($length, fn:random-number-generator())
};

declare %private function r:random-sequence($length as xs:integer, 
                                            $G as map(xs:string, item())) {
  if ($length eq 0)
  then ()
  else ($G?number, r:random-sequence($length - 1, $G?next()))
};

r:random-sequence(200);
            
588 returns
declare %public function r:random-sequence($length as xs:integer) as xs:double* {
  r:random-sequence($length, fn:random-number-generator())
};

declare %private function r:random-sequence($length as xs:integer, 
                                            $G as map(xs:string, item())) {
  if ($length eq 0)
  then ()
  else ($G?number, r:random-sequence($length - 1, $G?next()))
};

r:random-sequence(200);
            
589.

let $C := 'http://www.w3.org/2013/collation/UCA?strength=primary'
7

The expression

declare %public function r:random-sequence($length as xs:integer) as xs:double* {
  r:random-sequence($length, fn:random-number-generator())
};

declare %private function r:random-sequence($length as xs:integer, 
                                            $G as map(xs:string, item())) {
  if ($length eq 0)
  then ()
  else ($G?number, r:random-sequence($length - 1, $G?next()))
};

r:random-sequence(200);
            
590 returns
declare %public function r:random-sequence($length as xs:integer) as xs:double* {
  r:random-sequence($length, fn:random-number-generator())
};

declare %private function r:random-sequence($length as xs:integer, 
                                            $G as map(xs:string, item())) {
  if ($length eq 0)
  then ()
  else ($G?number, r:random-sequence($length - 1, $G?next()))
};

r:random-sequence(200);
            
591.

17.1.8 map:put

Summary

Returns a map containing all the contents of the supplied map, but with an additional entry, which replaces any existing entry for the same key.

Signature

declare %public function r:random-sequence($length as xs:integer) as xs:double* {
  r:random-sequence($length, fn:random-number-generator())
};

declare %private function r:random-sequence($length as xs:integer, 
                                            $G as map(xs:string, item())) {
  if ($length eq 0)
  then ()
  else ($G?number, r:random-sequence($length - 1, $G?next()))
};

r:random-sequence(200);
            
329(
declare %public function r:random-sequence($length as xs:integer) as xs:double* {
  r:random-sequence($length, fn:random-number-generator())
};

declare %private function r:random-sequence($length as xs:integer, 
                                            $G as map(xs:string, item())) {
  if ($length eq 0)
  then ()
  else ($G?number, r:random-sequence($length - 1, $G?next()))
};

r:random-sequence(200);
            
497
let $para := 
In a hole in the ground there lived a hobbit.
         
71
let $para := 
In a hole in the ground there lived a hobbit.
         
32,
let $para := 
In a hole in the ground there lived a hobbit.
         
192
let $para := 
In a hole in the ground there lived a hobbit.
         
71
let $para := 
In a hole in the ground there lived a hobbit.
         
34,
fn:abs($N * $arg2) le fn:abs($arg1) 
               and fn:compare($N * $arg2, 0) eq fn:compare($arg1, 0).
44
let $para := 
In a hole in the ground there lived a hobbit.
         
71
op:operation(fenceHeight, xs:integer) => op:operation(xs:integer, xs:integer)
16)
let $para := 
In a hole in the ground there lived a hobbit.
         
71
let $para := 
In a hole in the ground there lived a hobbit.
         
32

Properties

This function is ·deterministic·, ·context-independent·, and ·focus-independent·.

Rules

The function

declare %public function r:random-sequence($length as xs:integer) as xs:double* {
  r:random-sequence($length, fn:random-number-generator())
};

declare %private function r:random-sequence($length as xs:integer, 
                                            $G as map(xs:string, item())) {
  if ($length eq 0)
  then ()
  else ($G?number, r:random-sequence($length - 1, $G?next()))
};

r:random-sequence(200);
            
329 returns a ·map· that contains all entries from the supplied
declare %public function r:random-sequence($length as xs:integer) as xs:double* {
  r:random-sequence($length, fn:random-number-generator())
};

declare %private function r:random-sequence($length as xs:integer, 
                                            $G as map(xs:string, item())) {
  if ($length eq 0)
  then ()
  else ($G?number, r:random-sequence($length - 1, $G?next()))
};

r:random-sequence(200);
            
497, with the exception of any entry whose key is the ·same key· as
let $para := 
In a hole in the ground there lived a hobbit.
         
192, together with a new entry whose key is
let $para := 
In a hole in the ground there lived a hobbit.
         
192 and whose associated value is
fn:abs($N * $arg2) le fn:abs($arg1) 
               and fn:compare($N * $arg2, 0) eq fn:compare($arg1, 0).
44.

The effect of the function call

declare %public function r:random-sequence($length as xs:integer) as xs:double* {
  r:random-sequence($length, fn:random-number-generator())
};

declare %private function r:random-sequence($length as xs:integer, 
                                            $G as map(xs:string, item())) {
  if ($length eq 0)
  then ()
  else ($G?number, r:random-sequence($length - 1, $G?next()))
};

r:random-sequence(200);
            
609 is equivalent to the result of the following steps:

  1. declare %public function r:random-sequence($length as xs:integer) as xs:double* {
      r:random-sequence($length, fn:random-number-generator())
    };
    
    declare %private function r:random-sequence($length as xs:integer, 
                                                $G as map(xs:string, item())) {
      if ($length eq 0)
      then ()
      else ($G?number, r:random-sequence($length - 1, $G?next()))
    };
    
    r:random-sequence(200);
                
    610

    This returns a map in which all entries with the same key as

    declare %public function r:random-sequence($length as xs:integer) as xs:double* {
      r:random-sequence($length, fn:random-number-generator())
    };
    
    declare %private function r:random-sequence($length as xs:integer, 
                                                $G as map(xs:string, item())) {
      if ($length eq 0)
      then ()
      else ($G?number, r:random-sequence($length - 1, $G?next()))
    };
    
    r:random-sequence(200);
                
    611 have been removed.

  2. Construct and return a map containing:

    1. All the entries (key/value pairs) in

      declare %public function r:random-sequence($length as xs:integer) as xs:double* {
        r:random-sequence($length, fn:random-number-generator())
      };
      
      declare %private function r:random-sequence($length as xs:integer, 
                                                  $G as map(xs:string, item())) {
        if ($length eq 0)
        then ()
        else ($G?number, r:random-sequence($length - 1, $G?next()))
      };
      
      r:random-sequence(200);
                  
      612, and

    2. The entry

      declare %public function r:random-sequence($length as xs:integer) as xs:double* {
        r:random-sequence($length, fn:random-number-generator())
      };
      
      declare %private function r:random-sequence($length as xs:integer, 
                                                  $G as map(xs:string, item())) {
        if ($length eq 0)
        then ()
        else ($G?number, r:random-sequence($length - 1, $G?next()))
      };
      
      r:random-sequence(200);
                  
      613

Notes

There is no requirement that the type of

let $para := 
In a hole in the ground there lived a hobbit.
         
192 and
fn:abs($N * $arg2) le fn:abs($arg1) 
               and fn:compare($N * $arg2, 0) eq fn:compare($arg1, 0).
44 be consistent with the types of any existing keys and values in the supplied map.

Examples

let $C := 'http://www.w3.org/2013/collation/UCA?strength=primary'
8

The expression

declare %public function r:random-sequence($length as xs:integer) as xs:double* {
  r:random-sequence($length, fn:random-number-generator())
};

declare %private function r:random-sequence($length as xs:integer, 
                                            $G as map(xs:string, item())) {
  if ($length eq 0)
  then ()
  else ($G?number, r:random-sequence($length - 1, $G?next()))
};

r:random-sequence(200);
            
616 returns
declare %public function r:random-sequence($length as xs:integer) as xs:double* {
  r:random-sequence($length, fn:random-number-generator())
};

declare %private function r:random-sequence($length as xs:integer, 
                                            $G as map(xs:string, item())) {
  if ($length eq 0)
  then ()
  else ($G?number, r:random-sequence($length - 1, $G?next()))
};

r:random-sequence(200);
            
485.

The expression

declare %public function r:random-sequence($length as xs:integer) as xs:double* {
  r:random-sequence($length, fn:random-number-generator())
};

declare %private function r:random-sequence($length as xs:integer, 
                                            $G as map(xs:string, item())) {
  if ($length eq 0)
  then ()
  else ($G?number, r:random-sequence($length - 1, $G?next()))
};

r:random-sequence(200);
            
618 returns
declare %public function r:random-sequence($length as xs:integer) as xs:double* {
  r:random-sequence($length, fn:random-number-generator())
};

declare %private function r:random-sequence($length as xs:integer, 
                                            $G as map(xs:string, item())) {
  if ($length eq 0)
  then ()
  else ($G?number, r:random-sequence($length - 1, $G?next()))
};

r:random-sequence(200);
            
619.

17.1.9 map:entry

Summary

Returns a map that contains a single entry (a key-value pair).

Signature

declare %public function r:random-sequence($length as xs:integer) as xs:double* {
  r:random-sequence($length, fn:random-number-generator())
};

declare %private function r:random-sequence($length as xs:integer, 
                                            $G as map(xs:string, item())) {
  if ($length eq 0)
  then ()
  else ($G?number, r:random-sequence($length - 1, $G?next()))
};

r:random-sequence(200);
            
330(
let $para := 
In a hole in the ground there lived a hobbit.
         
192
let $para := 
In a hole in the ground there lived a hobbit.
         
71
let $para := 
In a hole in the ground there lived a hobbit.
         
34,
fn:abs($N * $arg2) le fn:abs($arg1) 
               and fn:compare($N * $arg2, 0) eq fn:compare($arg1, 0).
44
let $para := 
In a hole in the ground there lived a hobbit.
         
71
op:operation(fenceHeight, xs:integer) => op:operation(xs:integer, xs:integer)
16)
let $para := 
In a hole in the ground there lived a hobbit.
         
71
let $para := 
In a hole in the ground there lived a hobbit.
         
32

Properties

This function is ·deterministic·, ·context-independent·, and ·focus-independent·.

Rules

The function

declare %public function r:random-sequence($length as xs:integer) as xs:double* {
  r:random-sequence($length, fn:random-number-generator())
};

declare %private function r:random-sequence($length as xs:integer, 
                                            $G as map(xs:string, item())) {
  if ($length eq 0)
  then ()
  else ($G?number, r:random-sequence($length - 1, $G?next()))
};

r:random-sequence(200);
            
330 returns a ·map· which contains a single entry. The key of the entry in the new map is
let $para := 
In a hole in the ground there lived a hobbit.
         
192, and its associated value is
fn:abs($N * $arg2) le fn:abs($arg1) 
               and fn:compare($N * $arg2, 0) eq fn:compare($arg1, 0).
44.

Notes

The function call

declare %public function r:random-sequence($length as xs:integer) as xs:double* {
  r:random-sequence($length, fn:random-number-generator())
};

declare %private function r:random-sequence($length as xs:integer, 
                                            $G as map(xs:string, item())) {
  if ($length eq 0)
  then ()
  else ($G?number, r:random-sequence($length - 1, $G?next()))
};

r:random-sequence(200);
            
632 produces the same result as the expression
declare %public function r:random-sequence($length as xs:integer) as xs:double* {
  r:random-sequence($length, fn:random-number-generator())
};

declare %private function r:random-sequence($length as xs:integer, 
                                            $G as map(xs:string, item())) {
  if ($length eq 0)
  then ()
  else ($G?number, r:random-sequence($length - 1, $G?next()))
};

r:random-sequence(200);
            
633.

The function

declare %public function r:random-sequence($length as xs:integer) as xs:double* {
  r:random-sequence($length, fn:random-number-generator())
};

declare %private function r:random-sequence($length as xs:integer, 
                                            $G as map(xs:string, item())) {
  if ($length eq 0)
  then ()
  else ($G?number, r:random-sequence($length - 1, $G?next()))
};

r:random-sequence(200);
            
330 is intended primarily for use in conjunction with the function
declare %public function r:random-sequence($length as xs:integer) as xs:double* {
  r:random-sequence($length, fn:random-number-generator())
};

declare %private function r:random-sequence($length as xs:integer, 
                                            $G as map(xs:string, item())) {
  if ($length eq 0)
  then ()
  else ($G?number, r:random-sequence($length - 1, $G?next()))
};

r:random-sequence(200);
            
323. For example, a map containing seven entries may be constructed like this:

let $C := 'http://www.w3.org/2013/collation/UCA?strength=primary'
9

The

declare %public function r:random-sequence($length as xs:integer) as xs:double* {
  r:random-sequence($length, fn:random-number-generator())
};

declare %private function r:random-sequence($length as xs:integer, 
                                            $G as map(xs:string, item())) {
  if ($length eq 0)
  then ()
  else ($G?number, r:random-sequence($length - 1, $G?next()))
};

r:random-sequence(200);
            
323 function can be used to construct a map with a variable number of entries, for example:

let $para := 
In a hole in the ground there lived a hobbit.
         
00

Examples

The expression

declare %public function r:random-sequence($length as xs:integer) as xs:double* {
  r:random-sequence($length, fn:random-number-generator())
};

declare %private function r:random-sequence($length as xs:integer, 
                                            $G as map(xs:string, item())) {
  if ($length eq 0)
  then ()
  else ($G?number, r:random-sequence($length - 1, $G?next()))
};

r:random-sequence(200);
            
637 returns
declare %public function r:random-sequence($length as xs:integer) as xs:double* {
  r:random-sequence($length, fn:random-number-generator())
};

declare %private function r:random-sequence($length as xs:integer, 
                                            $G as map(xs:string, item())) {
  if ($length eq 0)
  then ()
  else ($G?number, r:random-sequence($length - 1, $G?next()))
};

r:random-sequence(200);
            
638.

17.1.10 map:remove

Summary

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

Signature

declare %public function r:random-sequence($length as xs:integer) as xs:double* {
  r:random-sequence($length, fn:random-number-generator())
};

declare %private function r:random-sequence($length as xs:integer, 
                                            $G as map(xs:string, item())) {
  if ($length eq 0)
  then ()
  else ($G?number, r:random-sequence($length - 1, $G?next()))
};

r:random-sequence(200);
            
310(
declare %public function r:random-sequence($length as xs:integer) as xs:double* {
  r:random-sequence($length, fn:random-number-generator())
};

declare %private function r:random-sequence($length as xs:integer, 
                                            $G as map(xs:string, item())) {
  if ($length eq 0)
  then ()
  else ($G?number, r:random-sequence($length - 1, $G?next()))
};

r:random-sequence(200);
            
497
let $para := 
In a hole in the ground there lived a hobbit.
         
71
let $para := 
In a hole in the ground there lived a hobbit.
         
32,
declare %public function r:random-sequence($length as xs:integer) as xs:double* {
  r:random-sequence($length, fn:random-number-generator())
};

declare %private function r:random-sequence($length as xs:integer, 
                                            $G as map(xs:string, item())) {
  if ($length eq 0)
  then ()
  else ($G?number, r:random-sequence($length - 1, $G?next()))
};

r:random-sequence(200);
            
643
let $para := 
In a hole in the ground there lived a hobbit.
         
71
op:operation(fenceHeight, xs:integer) => op:operation(xs:integer, xs:integer)
12)
let $para := 
In a hole in the ground there lived a hobbit.
         
71
let $para := 
In a hole in the ground there lived a hobbit.
         
32

Properties

This function is ·deterministic·, ·context-independent·, and ·focus-independent·.

Rules

The function

declare %public function r:random-sequence($length as xs:integer) as xs:double* {
  r:random-sequence($length, fn:random-number-generator())
};

declare %private function r:random-sequence($length as xs:integer, 
                                            $G as map(xs:string, item())) {
  if ($length eq 0)
  then ()
  else ($G?number, r:random-sequence($length - 1, $G?next()))
};

r:random-sequence(200);
            
310 returns a ·map· containing all the entries in
declare %public function r:random-sequence($length as xs:integer) as xs:double* {
  r:random-sequence($length, fn:random-number-generator())
};

declare %private function r:random-sequence($length as xs:integer, 
                                            $G as map(xs:string, item())) {
  if ($length eq 0)
  then ()
  else ($G?number, r:random-sequence($length - 1, $G?next()))
};

r:random-sequence(200);
            
497 except for any entry whose key is the ·same key· as an item in
declare %public function r:random-sequence($length as xs:integer) as xs:double* {
  r:random-sequence($length, fn:random-number-generator())
};

declare %private function r:random-sequence($length as xs:integer, 
                                            $G as map(xs:string, item())) {
  if ($length eq 0)
  then ()
  else ($G?number, r:random-sequence($length - 1, $G?next()))
};

r:random-sequence(200);
            
643.

No failure occurs if an item in

declare %public function r:random-sequence($length as xs:integer) as xs:double* {
  r:random-sequence($length, fn:random-number-generator())
};

declare %private function r:random-sequence($length as xs:integer, 
                                            $G as map(xs:string, item())) {
  if ($length eq 0)
  then ()
  else ($G?number, r:random-sequence($length - 1, $G?next()))
};

r:random-sequence(200);
            
643 does not correspond to any entry in
declare %public function r:random-sequence($length as xs:integer) as xs:double* {
  r:random-sequence($length, fn:random-number-generator())
};

declare %private function r:random-sequence($length as xs:integer, 
                                            $G as map(xs:string, item())) {
  if ($length eq 0)
  then ()
  else ($G?number, r:random-sequence($length - 1, $G?next()))
};

r:random-sequence(200);
            
497; that key value is simply ignored.

The effect of the function call

declare %public function r:random-sequence($length as xs:integer) as xs:double* {
  r:random-sequence($length, fn:random-number-generator())
};

declare %private function r:random-sequence($length as xs:integer, 
                                            $G as map(xs:string, item())) {
  if ($length eq 0)
  then ()
  else ($G?number, r:random-sequence($length - 1, $G?next()))
};

r:random-sequence(200);
            
653 can be described more formally as the result of the expression below:

let $para := 
In a hole in the ground there lived a hobbit.
         
01

Examples

let $C := 'http://www.w3.org/2013/collation/UCA?strength=primary'
8

The expression

declare %public function r:random-sequence($length as xs:integer) as xs:double* {
  r:random-sequence($length, fn:random-number-generator())
};

declare %private function r:random-sequence($length as xs:integer, 
                                            $G as map(xs:string, item())) {
  if ($length eq 0)
  then ()
  else ($G?number, r:random-sequence($length - 1, $G?next()))
};

r:random-sequence(200);
            
654 returns
declare %public function r:random-sequence($length as xs:integer) as xs:double* {
  r:random-sequence($length, fn:random-number-generator())
};

declare %private function r:random-sequence($length as xs:integer, 
                                            $G as map(xs:string, item())) {
  if ($length eq 0)
  then ()
  else ($G?number, r:random-sequence($length - 1, $G?next()))
};

r:random-sequence(200);
            
655.

The expression

declare %public function r:random-sequence($length as xs:integer) as xs:double* {
  r:random-sequence($length, fn:random-number-generator())
};

declare %private function r:random-sequence($length as xs:integer, 
                                            $G as map(xs:string, item())) {
  if ($length eq 0)
  then ()
  else ($G?number, r:random-sequence($length - 1, $G?next()))
};

r:random-sequence(200);
            
656 returns
declare %public function r:random-sequence($length as xs:integer) as xs:double* {
  r:random-sequence($length, fn:random-number-generator())
};

declare %private function r:random-sequence($length as xs:integer, 
                                            $G as map(xs:string, item())) {
  if ($length eq 0)
  then ()
  else ($G?number, r:random-sequence($length - 1, $G?next()))
};

r:random-sequence(200);
            
489.

The expression

declare %public function r:random-sequence($length as xs:integer) as xs:double* {
  r:random-sequence($length, fn:random-number-generator())
};

declare %private function r:random-sequence($length as xs:integer, 
                                            $G as map(xs:string, item())) {
  if ($length eq 0)
  then ()
  else ($G?number, r:random-sequence($length - 1, $G?next()))
};

r:random-sequence(200);
            
658 returns
declare %public function r:random-sequence($length as xs:integer) as xs:double* {
  r:random-sequence($length, fn:random-number-generator())
};

declare %private function r:random-sequence($length as xs:integer, 
                                            $G as map(xs:string, item())) {
  if ($length eq 0)
  then ()
  else ($G?number, r:random-sequence($length - 1, $G?next()))
};

r:random-sequence(200);
            
659.

The expression

declare %public function r:random-sequence($length as xs:integer) as xs:double* {
  r:random-sequence($length, fn:random-number-generator())
};

declare %private function r:random-sequence($length as xs:integer, 
                                            $G as map(xs:string, item())) {
  if ($length eq 0)
  then ()
  else ($G?number, r:random-sequence($length - 1, $G?next()))
};

r:random-sequence(200);
            
660 returns
declare %public function r:random-sequence($length as xs:integer) as xs:double* {
  r:random-sequence($length, fn:random-number-generator())
};

declare %private function r:random-sequence($length as xs:integer, 
                                            $G as map(xs:string, item())) {
  if ($length eq 0)
  then ()
  else ($G?number, r:random-sequence($length - 1, $G?next()))
};

r:random-sequence(200);
            
489.

17.1.11 map:for-each

Summary

Applies a supplied function to every entry in a map, returning the concatenation of the results.

Signature

op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
17(
declare %public function r:random-sequence($length as xs:integer) as xs:double* {
  r:random-sequence($length, fn:random-number-generator())
};

declare %private function r:random-sequence($length as xs:integer, 
                                            $G as map(xs:string, item())) {
  if ($length eq 0)
  then ()
  else ($G?number, r:random-sequence($length - 1, $G?next()))
};

r:random-sequence(200);
            
497
let $para := 
In a hole in the ground there lived a hobbit.
         
71
let $para := 
In a hole in the ground there lived a hobbit.
         
32,
Primo Secondo Terzo Quarto Quinto ...
833
let $para := 
In a hole in the ground there lived a hobbit.
         
71
declare %public function r:random-sequence($length as xs:integer) as xs:double* {
  r:random-sequence($length, fn:random-number-generator())
};

declare %private function r:random-sequence($length as xs:integer, 
                                            $G as map(xs:string, item())) {
  if ($length eq 0)
  then ()
  else ($G?number, r:random-sequence($length - 1, $G?next()))
};

r:random-sequence(200);
            
668)
let $para := 
In a hole in the ground there lived a hobbit.
         
71
op:operation(fenceHeight, xs:integer) => op:operation(xs:integer, xs:integer)
16

Properties

This function is ·nondeterministic-wrt-ordering·, ·context-independent·, ·focus-independent·, and ·higher-order·.

Rules

The function

op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
17 takes any ·map· as its
declare %public function r:random-sequence($length as xs:integer) as xs:double* {
  r:random-sequence($length, fn:random-number-generator())
};

declare %private function r:random-sequence($length as xs:integer, 
                                            $G as map(xs:string, item())) {
  if ($length eq 0)
  then ()
  else ($G?number, r:random-sequence($length - 1, $G?next()))
};

r:random-sequence(200);
            
497 argument and applies the supplied function to each entry in the map, in ·implementation-dependent· order; the result is the sequence obtained by concatenating the results of these function calls.

The function is non-deterministic with respect to ordering (see 1.7.4 Properties of functions). This means that two calls with the same arguments are not guaranteed to process the map entries in the same order.

The function supplied as

Primo Secondo Terzo Quarto Quinto ...
833 takes two arguments. It is called supplying the key of the map entry as the first argument, and the associated value as the second argument.

Examples

The expression

declare %public function r:random-sequence($length as xs:integer) as xs:double* {
  r:random-sequence($length, fn:random-number-generator())
};

declare %private function r:random-sequence($length as xs:integer, 
                                            $G as map(xs:string, item())) {
  if ($length eq 0)
  then ()
  else ($G?number, r:random-sequence($length - 1, $G?next()))
};

r:random-sequence(200);
            
674 returns some permutation of
declare %public function r:random-sequence($length as xs:integer) as xs:double* {
  r:random-sequence($length, fn:random-number-generator())
};

declare %private function r:random-sequence($length as xs:integer, 
                                            $G as map(xs:string, item())) {
  if ($length eq 0)
  then ()
  else ($G?number, r:random-sequence($length - 1, $G?next()))
};

r:random-sequence(200);
            
517. (This function call is equivalent to calling
op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
16. The result is in implementation-dependent order.)

The expression

declare %public function r:random-sequence($length as xs:integer) as xs:double* {
  r:random-sequence($length, fn:random-number-generator())
};

declare %private function r:random-sequence($length as xs:integer, 
                                            $G as map(xs:string, item())) {
  if ($length eq 0)
  then ()
  else ($G?number, r:random-sequence($length - 1, $G?next()))
};

r:random-sequence(200);
            
677 returns some permutation of
declare %public function r:random-sequence($length as xs:integer) as xs:double* {
  r:random-sequence($length, fn:random-number-generator())
};

declare %private function r:random-sequence($length as xs:integer, 
                                            $G as map(xs:string, item())) {
  if ($length eq 0)
  then ()
  else ($G?number, r:random-sequence($length - 1, $G?next()))
};

r:random-sequence(200);
            
678. (This function call returns the distinct values present in the map, in implementation-dependent order.)

The expression

declare %public function r:random-sequence($length as xs:integer) as xs:double* {
  r:random-sequence($length, fn:random-number-generator())
};

declare %private function r:random-sequence($length as xs:integer, 
                                            $G as map(xs:string, item())) {
  if ($length eq 0)
  then ()
  else ($G?number, r:random-sequence($length - 1, $G?next()))
};

r:random-sequence(200);
            
679 returns
declare %public function r:random-sequence($length as xs:integer) as xs:double* {
  r:random-sequence($length, fn:random-number-generator())
};

declare %private function r:random-sequence($length as xs:integer, 
                                            $G as map(xs:string, item())) {
  if ($length eq 0)
  then ()
  else ($G?number, r:random-sequence($length - 1, $G?next()))
};

r:random-sequence(200);
            
680. (This function call returns a map with the same keys as the input map, with the value of each entry increased by one.)

This XQuery example converts the entries in a map to attributes on a newly constructed element node:

let $para := 
In a hole in the ground there lived a hobbit.
         
03

The result is the element

declare %public function r:random-sequence($length as xs:integer) as xs:double* {
  r:random-sequence($length, fn:random-number-generator())
};

declare %private function r:random-sequence($length as xs:integer, 
                                            $G as map(xs:string, item())) {
  if ($length eq 0)
  then ()
  else ($G?number, r:random-sequence($length - 1, $G?next()))
};

r:random-sequence(200);
            
681.

17.2 Other Operations on Maps

Because a map is a function item, functions that apply to functions also apply to maps. A map is an anonymous function, so

let $para := 
In a hole in the ground there lived a hobbit.
         
90 returns the empty sequence;
Primo Secondo Terzo Quarto Quinto ...
763 always returns
declare %public function r:random-sequence($length as xs:integer) as xs:double* {
  r:random-sequence($length, fn:random-number-generator())
};

declare %private function r:random-sequence($length as xs:integer, 
                                            $G as map(xs:string, item())) {
  if ($length eq 0)
  then ()
  else ($G?number, r:random-sequence($length - 1, $G?next()))
};

r:random-sequence(200);
            
13.

Maps may be compared using the

op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
23 function.

There is no function or operator to atomize a map or convert it to a string (other than

Primo Secondo Terzo Quarto Quinto ...
511, which can be used to serialize some maps as JSON texts).

17.3 Functions that Operate on Arrays

An array is an additional kind of item. An array of size N is a mapping from the integers (1 to N) to a set of values, called the members of the array, each of which is an arbitrary sequence. Because an array is an item, and therefore a sequence, arrays can be nested.

The functions defined in this section use a conventional namespace prefix

let $para := 
In a hole in the ground there lived a hobbit.
         
57, which is assumed to be bound to the namespace URI
let $para := 
In a hole in the ground there lived a hobbit.
         
56.

As with all other values, arrays are treated as immutable. For example, the

declare %public function r:random-sequence($length as xs:integer) as xs:double* {
  r:random-sequence($length, fn:random-number-generator())
};

declare %private function r:random-sequence($length as xs:integer, 
                                            $G as map(xs:string, item())) {
  if ($length eq 0)
  then ()
  else ($G?number, r:random-sequence($length - 1, $G?next()))
};

r:random-sequence(200);
            
689 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
declare %public function r:random-sequence($length as xs:integer) as xs:double* {
  r:random-sequence($length, fn:random-number-generator())
};

declare %private function r:random-sequence($length as xs:integer, 
                                            $G as map(xs:string, item())) {
  if ($length eq 0)
  then ()
  else ($G?number, r:random-sequence($length - 1, $G?next()))
};

r:random-sequence(200);
            
689 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.

An array acts as a function from integer positions to associated values, so the function call

declare %public function r:random-sequence($length as xs:integer) as xs:double* {
  r:random-sequence($length, fn:random-number-generator())
};

declare %private function r:random-sequence($length as xs:integer, 
                                            $G as map(xs:string, item())) {
  if ($length eq 0)
  then ()
  else ($G?number, r:random-sequence($length - 1, $G?next()))
};

r:random-sequence(200);
            
691 can be used to retrieve the array member at a given position. The function corresponding to the array has the signature
declare %public function r:random-sequence($length as xs:integer) as xs:double* {
  r:random-sequence($length, fn:random-number-generator())
};

declare %private function r:random-sequence($length as xs:integer, 
                                            $G as map(xs:string, item())) {
  if ($length eq 0)
  then ()
  else ($G?number, r:random-sequence($length - 1, $G?next()))
};

r:random-sequence(200);
            
692. The fact that an array is a function item allows it to be passed as an argument to higher-order functions that expect a function item as one of their arguments.

In the function definitions that follow, all the array functions are defined in terms of five primitives:

  • declare %public function r:random-sequence($length as xs:integer) as xs:double* {
      r:random-sequence($length, fn:random-number-generator())
    };
    
    declare %private function r:random-sequence($length as xs:integer, 
                                                $G as map(xs:string, item())) {
      if ($length eq 0)
      then ()
      else ($G?number, r:random-sequence($length - 1, $G?next()))
    };
    
    r:random-sequence(200);
                
    589 represents the zero-length array (an array with no members).

  • declare %public function r:random-sequence($length as xs:integer) as xs:double* {
      r:random-sequence($length, fn:random-number-generator())
    };
    
    declare %private function r:random-sequence($length as xs:integer, 
                                                $G as map(xs:string, item())) {
      if ($length eq 0)
      then ()
      else ($G?number, r:random-sequence($length - 1, $G?next()))
    };
    
    r:random-sequence(200);
                
    691 returns the member at position
    declare %public function r:random-sequence($length as xs:integer) as xs:double* {
      r:random-sequence($length, fn:random-number-generator())
    };
    
    declare %private function r:random-sequence($length as xs:integer, 
                                                $G as map(xs:string, item())) {
      if ($length eq 0)
      then ()
      else ($G?number, r:random-sequence($length - 1, $G?next()))
    };
    
    r:random-sequence(200);
                
    695.

  • declare %public function r:random-sequence($length as xs:integer) as xs:double* {
      r:random-sequence($length, fn:random-number-generator())
    };
    
    declare %private function r:random-sequence($length as xs:integer, 
                                                $G as map(xs:string, item())) {
      if ($length eq 0)
      then ()
      else ($G?number, r:random-sequence($length - 1, $G?next()))
    };
    
    r:random-sequence(200);
                
    696 returns the number of members in the array.

  • declare %public function r:random-sequence($length as xs:integer) as xs:double* {
      r:random-sequence($length, fn:random-number-generator())
    };
    
    declare %private function r:random-sequence($length as xs:integer, 
                                                $G as map(xs:string, item())) {
      if ($length eq 0)
      then ()
      else ($G?number, r:random-sequence($length - 1, $G?next()))
    };
    
    r:random-sequence(200);
                
    697 returns an array of size one whose single member is the supplied sequence
    let $para := 
    In a hole in the ground there lived a hobbit.
             
    021. This operation is not directly available as a user-visible function, because the effect can easily be achieved using the syntax
    declare %public function r:random-sequence($length as xs:integer) as xs:double* {
      r:random-sequence($length, fn:random-number-generator())
    };
    
    declare %private function r:random-sequence($length as xs:integer, 
                                                $G as map(xs:string, item())) {
      if ($length eq 0)
      then ()
      else ($G?number, r:random-sequence($length - 1, $G?next()))
    };
    
    r:random-sequence(200);
                
    699.

  • declare %public function r:random-sequence($length as xs:integer) as xs:double* {
      r:random-sequence($length, fn:random-number-generator())
    };
    
    declare %private function r:random-sequence($length as xs:integer, 
                                                $G as map(xs:string, item())) {
      if ($length eq 0)
      then ()
      else ($G?number, r:random-sequence($length - 1, $G?next()))
    };
    
    r:random-sequence(200);
                
    700 returns an array whose members are first the members of
    declare %public function r:random-sequence($length as xs:integer) as xs:double* {
      r:random-sequence($length, fn:random-number-generator())
    };
    
    declare %private function r:random-sequence($length as xs:integer, 
                                                $G as map(xs:string, item())) {
      if ($length eq 0)
      then ()
      else ($G?number, r:random-sequence($length - 1, $G?next()))
    };
    
    r:random-sequence(200);
                
    701 and then the members of
    declare %public function r:random-sequence($length as xs:integer) as xs:double* {
      r:random-sequence($length, fn:random-number-generator())
    };
    
    declare %private function r:random-sequence($length as xs:integer, 
                                                $G as map(xs:string, item())) {
      if ($length eq 0)
      then ()
      else ($G?number, r:random-sequence($length - 1, $G?next()))
    };
    
    r:random-sequence(200);
                
    702. This operation is not directly available as a user-visible function, because the effect can easily be achieved using
    declare %public function r:random-sequence($length as xs:integer) as xs:double* {
      r:random-sequence($length, fn:random-number-generator())
    };
    
    declare %private function r:random-sequence($length as xs:integer, 
                                                $G as map(xs:string, item())) {
      if ($length eq 0)
      then ()
      else ($G?number, r:random-sequence($length - 1, $G?next()))
    };
    
    r:random-sequence(200);
                
    703.

There are two operations on arrays for which the XPath language provides custom syntax:

  • declare %public function r:random-sequence($length as xs:integer) as xs:double* {
      r:random-sequence($length, fn:random-number-generator())
    };
    
    declare %private function r:random-sequence($length as xs:integer, 
                                                $G as map(xs:string, item())) {
      if ($length eq 0)
      then ()
      else ($G?number, r:random-sequence($length - 1, $G?next()))
    };
    
    r:random-sequence(200);
                
    704 constructs an array whose members are the items in
    declare %public function r:random-sequence($length as xs:integer) as xs:double* {
      r:random-sequence($length, fn:random-number-generator())
    };
    
    declare %private function r:random-sequence($length as xs:integer, 
                                                $G as map(xs:string, item())) {
      if ($length eq 0)
      then ()
      else ($G?number, r:random-sequence($length - 1, $G?next()))
    };
    
    r:random-sequence(200);
                
    705. Every member of this array will be a singleton item. This can be defined as
    declare %public function r:random-sequence($length as xs:integer) as xs:double* {
      r:random-sequence($length, fn:random-number-generator())
    };
    
    declare %private function r:random-sequence($length as xs:integer, 
                                                $G as map(xs:string, item())) {
      if ($length eq 0)
      then ()
      else ($G?number, r:random-sequence($length - 1, $G?next()))
    };
    
    r:random-sequence(200);
                
    706

  • declare %public function r:random-sequence($length as xs:integer) as xs:double* {
      r:random-sequence($length, fn:random-number-generator())
    };
    
    declare %private function r:random-sequence($length as xs:integer, 
                                                $G as map(xs:string, item())) {
      if ($length eq 0)
      then ()
      else ($G?number, r:random-sequence($length - 1, $G?next()))
    };
    
    r:random-sequence(200);
                
    707 constructs an array in which
    declare %public function r:random-sequence($length as xs:integer) as xs:double* {
      r:random-sequence($length, fn:random-number-generator())
    };
    
    declare %private function r:random-sequence($length as xs:integer, 
                                                $G as map(xs:string, item())) {
      if ($length eq 0)
      then ()
      else ($G?number, r:random-sequence($length - 1, $G?next()))
    };
    
    r:random-sequence(200);
                
    708 is the first member,
    declare %public function r:random-sequence($length as xs:integer) as xs:double* {
      r:random-sequence($length, fn:random-number-generator())
    };
    
    declare %private function r:random-sequence($length as xs:integer, 
                                                $G as map(xs:string, item())) {
      if ($length eq 0)
      then ()
      else ($G?number, r:random-sequence($length - 1, $G?next()))
    };
    
    r:random-sequence(200);
                
    709 is the second member, and so on. If N=0, the value is the empty array
    declare %public function r:random-sequence($length as xs:integer) as xs:double* {
      r:random-sequence($length, fn:random-number-generator())
    };
    
    declare %private function r:random-sequence($length as xs:integer, 
                                                $G as map(xs:string, item())) {
      if ($length eq 0)
      then ()
      else ($G?number, r:random-sequence($length - 1, $G?next()))
    };
    
    r:random-sequence(200);
                
    589; if N=1, the value is
    declare %public function r:random-sequence($length as xs:integer) as xs:double* {
      r:random-sequence($length, fn:random-number-generator())
    };
    
    declare %private function r:random-sequence($length as xs:integer, 
                                                $G as map(xs:string, item())) {
      if ($length eq 0)
      then ()
      else ($G?number, r:random-sequence($length - 1, $G?next()))
    };
    
    r:random-sequence(200);
                
    711, and if N > 1, the value is
    declare %public function r:random-sequence($length as xs:integer) as xs:double* {
      r:random-sequence($length, fn:random-number-generator())
    };
    
    declare %private function r:random-sequence($length as xs:integer, 
                                                $G as map(xs:string, item())) {
      if ($length eq 0)
      then ()
      else ($G?number, r:random-sequence($length - 1, $G?next()))
    };
    
    r:random-sequence(200);
                
    712.

FunctionMeaning
declare %public function r:random-sequence($length as xs:integer) as xs:double* {
  r:random-sequence($length, fn:random-number-generator())
};

declare %private function r:random-sequence($length as xs:integer, 
                                            $G as map(xs:string, item())) {
  if ($length eq 0)
  then ()
  else ($G?number, r:random-sequence($length - 1, $G?next()))
};

r:random-sequence(200);
            
713Returns the number of members in the supplied array.
declare %public function r:random-sequence($length as xs:integer) as xs:double* {
  r:random-sequence($length, fn:random-number-generator())
};

declare %private function r:random-sequence($length as xs:integer, 
                                            $G as map(xs:string, item())) {
  if ($length eq 0)
  then ()
  else ($G?number, r:random-sequence($length - 1, $G?next()))
};

r:random-sequence(200);
            
714Returns the value at the specified position in the supplied array (counting from 1).
declare %public function r:random-sequence($length as xs:integer) as xs:double* {
  r:random-sequence($length, fn:random-number-generator())
};

declare %private function r:random-sequence($length as xs:integer, 
                                            $G as map(xs:string, item())) {
  if ($length eq 0)
  then ()
  else ($G?number, r:random-sequence($length - 1, $G?next()))
};

r:random-sequence(200);
            
715Returns an array containing all the members of a supplied array, except for one member which is replaced with a new value.
declare %public function r:random-sequence($length as xs:integer) as xs:double* {
  r:random-sequence($length, fn:random-number-generator())
};

declare %private function r:random-sequence($length as xs:integer, 
                                            $G as map(xs:string, item())) {
  if ($length eq 0)
  then ()
  else ($G?number, r:random-sequence($length - 1, $G?next()))
};

r:random-sequence(200);
            
716Returns an array containing all the members of a supplied array, plus one additional member at the end.
declare %public function r:random-sequence($length as xs:integer) as xs:double* {
  r:random-sequence($length, fn:random-number-generator())
};

declare %private function r:random-sequence($length as xs:integer, 
                                            $G as map(xs:string, item())) {
  if ($length eq 0)
  then ()
  else ($G?number, r:random-sequence($length - 1, $G?next()))
};

r:random-sequence(200);
            
717Returns an array containing all members from a supplied array starting at a supplied position, up to a specified length.
declare %public function r:random-sequence($length as xs:integer) as xs:double* {
  r:random-sequence($length, fn:random-number-generator())
};

declare %private function r:random-sequence($length as xs:integer, 
                                            $G as map(xs:string, item())) {
  if ($length eq 0)
  then ()
  else ($G?number, r:random-sequence($length - 1, $G?next()))
};

r:random-sequence(200);
            
718Returns an array containing all the members of the supplied array, except for the members at specified positions.
declare %public function r:random-sequence($length as xs:integer) as xs:double* {
  r:random-sequence($length, fn:random-number-generator())
};

declare %private function r:random-sequence($length as xs:integer, 
                                            $G as map(xs:string, item())) {
  if ($length eq 0)
  then ()
  else ($G?number, r:random-sequence($length - 1, $G?next()))
};

r:random-sequence(200);
            
719Returns an array containing all the members of the supplied array, with one additional member at a specified position.
declare %public function r:random-sequence($length as xs:integer) as xs:double* {
  r:random-sequence($length, fn:random-number-generator())
};

declare %private function r:random-sequence($length as xs:integer, 
                                            $G as map(xs:string, item())) {
  if ($length eq 0)
  then ()
  else ($G?number, r:random-sequence($length - 1, $G?next()))
};

r:random-sequence(200);
            
720Returns the first member of an array, that is
declare %public function r:random-sequence($length as xs:integer) as xs:double* {
  r:random-sequence($length, fn:random-number-generator())
};

declare %private function r:random-sequence($length as xs:integer, 
                                            $G as map(xs:string, item())) {
  if ($length eq 0)
  then ()
  else ($G?number, r:random-sequence($length - 1, $G?next()))
};

r:random-sequence(200);
            
721.
declare %public function r:random-sequence($length as xs:integer) as xs:double* {
  r:random-sequence($length, fn:random-number-generator())
};

declare %private function r:random-sequence($length as xs:integer, 
                                            $G as map(xs:string, item())) {
  if ($length eq 0)
  then ()
  else ($G?number, r:random-sequence($length - 1, $G?next()))
};

r:random-sequence(200);
            
722Returns an array containing all members except the first from a supplied array.
declare %public function r:random-sequence($length as xs:integer) as xs:double* {
  r:random-sequence($length, fn:random-number-generator())
};

declare %private function r:random-sequence($length as xs:integer, 
                                            $G as map(xs:string, item())) {
  if ($length eq 0)
  then ()
  else ($G?number, r:random-sequence($length - 1, $G?next()))
};

r:random-sequence(200);
            
689Returns an array containing all the members of a supplied array, but in reverse order.
declare %public function r:random-sequence($length as xs:integer) as xs:double* {
  r:random-sequence($length, fn:random-number-generator())
};

declare %private function r:random-sequence($length as xs:integer, 
                                            $G as map(xs:string, item())) {
  if ($length eq 0)
  then ()
  else ($G?number, r:random-sequence($length - 1, $G?next()))
};

r:random-sequence(200);
            
703Concatenates the contents of several arrays into a single array.
declare %public function r:random-sequence($length as xs:integer) as xs:double* {
  r:random-sequence($length, fn:random-number-generator())
};

declare %private function r:random-sequence($length as xs:integer, 
                                            $G as map(xs:string, item())) {
  if ($length eq 0)
  then ()
  else ($G?number, r:random-sequence($length - 1, $G?next()))
};

r:random-sequence(200);
            
725Returns an array whose size is the same as
declare %public function r:random-sequence($length as xs:integer) as xs:double* {
  r:random-sequence($length, fn:random-number-generator())
};

declare %private function r:random-sequence($length as xs:integer, 
                                            $G as map(xs:string, item())) {
  if ($length eq 0)
  then ()
  else ($G?number, r:random-sequence($length - 1, $G?next()))
};

r:random-sequence(200);
            
696, in which each member is computed by applying
Primo Secondo Terzo Quarto Quinto ...
996 to the corresponding member of
Primo Secondo Terzo Quarto Quinto ...
999.
declare %public function r:random-sequence($length as xs:integer) as xs:double* {
  r:random-sequence($length, fn:random-number-generator())
};

declare %private function r:random-sequence($length as xs:integer, 
                                            $G as map(xs:string, item())) {
  if ($length eq 0)
  then ()
  else ($G?number, r:random-sequence($length - 1, $G?next()))
};

r:random-sequence(200);
            
729Returns an array containing those members of the
Primo Secondo Terzo Quarto Quinto ...
999 for which
Primo Secondo Terzo Quarto Quinto ...
996 returns true.
declare %public function r:random-sequence($length as xs:integer) as xs:double* {
  r:random-sequence($length, fn:random-number-generator())
};

declare %private function r:random-sequence($length as xs:integer, 
                                            $G as map(xs:string, item())) {
  if ($length eq 0)
  then ()
  else ($G?number, r:random-sequence($length - 1, $G?next()))
};

r:random-sequence(200);
            
732Evaluates the supplied function cumulatively on successive members of the supplied array.
declare %public function r:random-sequence($length as xs:integer) as xs:double* {
  r:random-sequence($length, fn:random-number-generator())
};

declare %private function r:random-sequence($length as xs:integer, 
                                            $G as map(xs:string, item())) {
  if ($length eq 0)
  then ()
  else ($G?number, r:random-sequence($length - 1, $G?next()))
};

r:random-sequence(200);
            
733Evaluates the supplied function cumulatively on successive values of the supplied array.
declare %public function r:random-sequence($length as xs:integer) as xs:double* {
  r:random-sequence($length, fn:random-number-generator())
};

declare %private function r:random-sequence($length as xs:integer, 
                                            $G as map(xs:string, item())) {
  if ($length eq 0)
  then ()
  else ($G?number, r:random-sequence($length - 1, $G?next()))
};

r:random-sequence(200);
            
734Returns an array obtained by evaluating the supplied function once for each pair of members at the same position in the two supplied arrays.
declare %public function r:random-sequence($length as xs:integer) as xs:double* {
  r:random-sequence($length, fn:random-number-generator())
};

declare %private function r:random-sequence($length as xs:integer, 
                                            $G as map(xs:string, item())) {
  if ($length eq 0)
  then ()
  else ($G?number, r:random-sequence($length - 1, $G?next()))
};

r:random-sequence(200);
            
735Returns an array containing all the members of the supplied array, sorted according to the value of a sort key supplied as a function.
declare %public function r:random-sequence($length as xs:integer) as xs:double* {
  r:random-sequence($length, fn:random-number-generator())
};

declare %private function r:random-sequence($length as xs:integer, 
                                            $G as map(xs:string, item())) {
  if ($length eq 0)
  then ()
  else ($G?number, r:random-sequence($length - 1, $G?next()))
};

r:random-sequence(200);
            
736Replaces any array appearing in a supplied sequence with the members of the array, recursively.

17.3.1 array:size

Summary

Returns the number of members in the supplied array.

Signature

declare %public function r:random-sequence($length as xs:integer) as xs:double* {
  r:random-sequence($length, fn:random-number-generator())
};

declare %private function r:random-sequence($length as xs:integer, 
                                            $G as map(xs:string, item())) {
  if ($length eq 0)
  then ()
  else ($G?number, r:random-sequence($length - 1, $G?next()))
};

r:random-sequence(200);
            
713(
Primo Secondo Terzo Quarto Quinto ...
999
let $para := 
In a hole in the ground there lived a hobbit.
         
71
declare %public function r:random-sequence($length as xs:integer) as xs:double* {
  r:random-sequence($length, fn:random-number-generator())
};

declare %private function r:random-sequence($length as xs:integer, 
                                            $G as map(xs:string, item())) {
  if ($length eq 0)
  then ()
  else ($G?number, r:random-sequence($length - 1, $G?next()))
};

r:random-sequence(200);
            
001)
let $para := 
In a hole in the ground there lived a hobbit.
         
71
let $para := 
In a hole in the ground there lived a hobbit.
         
85

Properties

This function is ·deterministic·, ·context-independent·, and ·focus-independent·.

Rules

If

Primo Secondo Terzo Quarto Quinto ...
999 is empty the function returns zero.

Otherwise, the function returns the number of members in

Primo Secondo Terzo Quarto Quinto ...
999.

Notes

Note that because an array is an item, the

1º 2º 3º 4º ...
778 function when applied to an array always returns 1 (one).

Examples

The expression

declare %public function r:random-sequence($length as xs:integer) as xs:double* {
  r:random-sequence($length, fn:random-number-generator())
};

declare %private function r:random-sequence($length as xs:integer, 
                                            $G as map(xs:string, item())) {
  if ($length eq 0)
  then ()
  else ($G?number, r:random-sequence($length - 1, $G?next()))
};

r:random-sequence(200);
            
746 returns
declare %public function r:random-sequence($length as xs:integer) as xs:double* {
  r:random-sequence($length, fn:random-number-generator())
};

declare %private function r:random-sequence($length as xs:integer, 
                                            $G as map(xs:string, item())) {
  if ($length eq 0)
  then ()
  else ($G?number, r:random-sequence($length - 1, $G?next()))
};

r:random-sequence(200);
            
07.

The expression

declare %public function r:random-sequence($length as xs:integer) as xs:double* {
  r:random-sequence($length, fn:random-number-generator())
};

declare %private function r:random-sequence($length as xs:integer, 
                                            $G as map(xs:string, item())) {
  if ($length eq 0)
  then ()
  else ($G?number, r:random-sequence($length - 1, $G?next()))
};

r:random-sequence(200);
            
748 returns
let $para := 
In a hole in the ground there lived a hobbit.
         
226.

The expression

declare %public function r:random-sequence($length as xs:integer) as xs:double* {
  r:random-sequence($length, fn:random-number-generator())
};

declare %private function r:random-sequence($length as xs:integer, 
                                            $G as map(xs:string, item())) {
  if ($length eq 0)
  then ()
  else ($G?number, r:random-sequence($length - 1, $G?next()))
};

r:random-sequence(200);
            
750 returns
declare %public function r:random-sequence($length as xs:integer) as xs:double* {
  r:random-sequence($length, fn:random-number-generator())
};

declare %private function r:random-sequence($length as xs:integer, 
                                            $G as map(xs:string, item())) {
  if ($length eq 0)
  then ()
  else ($G?number, r:random-sequence($length - 1, $G?next()))
};

r:random-sequence(200);
            
19.

The expression

declare %public function r:random-sequence($length as xs:integer) as xs:double* {
  r:random-sequence($length, fn:random-number-generator())
};

declare %private function r:random-sequence($length as xs:integer, 
                                            $G as map(xs:string, item())) {
  if ($length eq 0)
  then ()
  else ($G?number, r:random-sequence($length - 1, $G?next()))
};

r:random-sequence(200);
            
752 returns
declare %public function r:random-sequence($length as xs:integer) as xs:double* {
  r:random-sequence($length, fn:random-number-generator())
};

declare %private function r:random-sequence($length as xs:integer, 
                                            $G as map(xs:string, item())) {
  if ($length eq 0)
  then ()
  else ($G?number, r:random-sequence($length - 1, $G?next()))
};

r:random-sequence(200);
            
13.

17.3.2 array:get

Summary

Returns the value at the specified position in the supplied array (counting from 1).

Signature

declare %public function r:random-sequence($length as xs:integer) as xs:double* {
  r:random-sequence($length, fn:random-number-generator())
};

declare %private function r:random-sequence($length as xs:integer, 
                                            $G as map(xs:string, item())) {
  if ($length eq 0)
  then ()
  else ($G?number, r:random-sequence($length - 1, $G?next()))
};

r:random-sequence(200);
            
714(
Primo Secondo Terzo Quarto Quinto ...
999
let $para := 
In a hole in the ground there lived a hobbit.
         
71
declare %public function r:random-sequence($length as xs:integer) as xs:double* {
  r:random-sequence($length, fn:random-number-generator())
};

declare %private function r:random-sequence($length as xs:integer, 
                                            $G as map(xs:string, item())) {
  if ($length eq 0)
  then ()
  else ($G?number, r:random-sequence($length - 1, $G?next()))
};

r:random-sequence(200);
            
001,
1º 2º 3º 4º ...
306
let $para := 
In a hole in the ground there lived a hobbit.
         
71
let $para := 
In a hole in the ground there lived a hobbit.
         
85)
let $para := 
In a hole in the ground there lived a hobbit.
         
71
op:operation(fenceHeight, xs:integer) => op:operation(xs:integer, xs:integer)
16

Properties

This function is ·deterministic·, ·context-independent·, and ·focus-independent·.

Rules

The result is the value of

declare %public function r:random-sequence($length as xs:integer) as xs:double* {
  r:random-sequence($length, fn:random-number-generator())
};

declare %private function r:random-sequence($length as xs:integer, 
                                            $G as map(xs:string, item())) {
  if ($length eq 0)
  then ()
  else ($G?number, r:random-sequence($length - 1, $G?next()))
};

r:random-sequence(200);
            
763.

Error Conditions

A dynamic error occurs [err:FOAY0001] if

1º 2º 3º 4º ...
306 is not in the range
declare %public function r:random-sequence($length as xs:integer) as xs:double* {
  r:random-sequence($length, fn:random-number-generator())
};

declare %private function r:random-sequence($length as xs:integer, 
                                            $G as map(xs:string, item())) {
  if ($length eq 0)
  then ()
  else ($G?number, r:random-sequence($length - 1, $G?next()))
};

r:random-sequence(200);
            
765 inclusive.

Examples

The expression

declare %public function r:random-sequence($length as xs:integer) as xs:double* {
  r:random-sequence($length, fn:random-number-generator())
};

declare %private function r:random-sequence($length as xs:integer, 
                                            $G as map(xs:string, item())) {
  if ($length eq 0)
  then ()
  else ($G?number, r:random-sequence($length - 1, $G?next()))
};

r:random-sequence(200);
            
766 returns
op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
124.

The expression

declare %public function r:random-sequence($length as xs:integer) as xs:double* {
  r:random-sequence($length, fn:random-number-generator())
};

declare %private function r:random-sequence($length as xs:integer, 
                                            $G as map(xs:string, item())) {
  if ($length eq 0)
  then ()
  else ($G?number, r:random-sequence($length - 1, $G?next()))
};

r:random-sequence(200);
            
768 returns
declare %public function r:random-sequence($length as xs:integer) as xs:double* {
  r:random-sequence($length, fn:random-number-generator())
};

declare %private function r:random-sequence($length as xs:integer, 
                                            $G as map(xs:string, item())) {
  if ($length eq 0)
  then ()
  else ($G?number, r:random-sequence($length - 1, $G?next()))
};

r:random-sequence(200);
            
769.

17.3.3 array:put

Summary

Returns an array containing all the members of a supplied array, except for one member which is replaced with a new value.

Signature

declare %public function r:random-sequence($length as xs:integer) as xs:double* {
  r:random-sequence($length, fn:random-number-generator())
};

declare %private function r:random-sequence($length as xs:integer, 
                                            $G as map(xs:string, item())) {
  if ($length eq 0)
  then ()
  else ($G?number, r:random-sequence($length - 1, $G?next()))
};

r:random-sequence(200);
            
715(
Primo Secondo Terzo Quarto Quinto ...
999
let $para := 
In a hole in the ground there lived a hobbit.
         
71
declare %public function r:random-sequence($length as xs:integer) as xs:double* {
  r:random-sequence($length, fn:random-number-generator())
};

declare %private function r:random-sequence($length as xs:integer, 
                                            $G as map(xs:string, item())) {
  if ($length eq 0)
  then ()
  else ($G?number, r:random-sequence($length - 1, $G?next()))
};

r:random-sequence(200);
            
001,
1º 2º 3º 4º ...
306
let $para := 
In a hole in the ground there lived a hobbit.
         
71
let $para := 
In a hole in the ground there lived a hobbit.
         
85,
declare %public function r:random-sequence($length as xs:integer) as xs:double* {
  r:random-sequence($length, fn:random-number-generator())
};

declare %private function r:random-sequence($length as xs:integer, 
                                            $G as map(xs:string, item())) {
  if ($length eq 0)
  then ()
  else ($G?number, r:random-sequence($length - 1, $G?next()))
};

r:random-sequence(200);
            
777
let $para := 
In a hole in the ground there lived a hobbit.
         
71
op:operation(fenceHeight, xs:integer) => op:operation(xs:integer, xs:integer)
16)
let $para := 
In a hole in the ground there lived a hobbit.
         
71
declare %public function r:random-sequence($length as xs:integer) as xs:double* {
  r:random-sequence($length, fn:random-number-generator())
};

declare %private function r:random-sequence($length as xs:integer, 
                                            $G as map(xs:string, item())) {
  if ($length eq 0)
  then ()
  else ($G?number, r:random-sequence($length - 1, $G?next()))
};

r:random-sequence(200);
            
001

Properties

This function is ·deterministic·, ·context-independent·, and ·focus-independent·.

Rules

The result is an array whose size is

declare %public function r:random-sequence($length as xs:integer) as xs:double* {
  r:random-sequence($length, fn:random-number-generator())
};

declare %private function r:random-sequence($length as xs:integer, 
                                            $G as map(xs:string, item())) {
  if ($length eq 0)
  then ()
  else ($G?number, r:random-sequence($length - 1, $G?next()))
};

r:random-sequence(200);
            
696, in which all members in positions other than
1º 2º 3º 4º ...
306 are the same as the members in the corresponding position of
Primo Secondo Terzo Quarto Quinto ...
999, and the member in position
1º 2º 3º 4º ...
306 is
declare %public function r:random-sequence($length as xs:integer) as xs:double* {
  r:random-sequence($length, fn:random-number-generator())
};

declare %private function r:random-sequence($length as xs:integer, 
                                            $G as map(xs:string, item())) {
  if ($length eq 0)
  then ()
  else ($G?number, r:random-sequence($length - 1, $G?next()))
};

r:random-sequence(200);
            
777.

The result is equivalent to the result of the expression

declare %public function r:random-sequence($length as xs:integer) as xs:double* {
  r:random-sequence($length, fn:random-number-generator())
};

declare %private function r:random-sequence($length as xs:integer, 
                                            $G as map(xs:string, item())) {
  if ($length eq 0)
  then ()
  else ($G?number, r:random-sequence($length - 1, $G?next()))
};

r:random-sequence(200);
            
787.

Error Conditions

A dynamic error occurs [err:FOAY0001] if

1º 2º 3º 4º ...
306 is not in the range
declare %public function r:random-sequence($length as xs:integer) as xs:double* {
  r:random-sequence($length, fn:random-number-generator())
};

declare %private function r:random-sequence($length as xs:integer, 
                                            $G as map(xs:string, item())) {
  if ($length eq 0)
  then ()
  else ($G?number, r:random-sequence($length - 1, $G?next()))
};

r:random-sequence(200);
            
765 inclusive.

This error will always occur if

Primo Secondo Terzo Quarto Quinto ...
999 is empty.

Examples

The expression

declare %public function r:random-sequence($length as xs:integer) as xs:double* {
  r:random-sequence($length, fn:random-number-generator())
};

declare %private function r:random-sequence($length as xs:integer, 
                                            $G as map(xs:string, item())) {
  if ($length eq 0)
  then ()
  else ($G?number, r:random-sequence($length - 1, $G?next()))
};

r:random-sequence(200);
            
791 returns
declare %public function r:random-sequence($length as xs:integer) as xs:double* {
  r:random-sequence($length, fn:random-number-generator())
};

declare %private function r:random-sequence($length as xs:integer, 
                                            $G as map(xs:string, item())) {
  if ($length eq 0)
  then ()
  else ($G?number, r:random-sequence($length - 1, $G?next()))
};

r:random-sequence(200);
            
792.

The expression

declare %public function r:random-sequence($length as xs:integer) as xs:double* {
  r:random-sequence($length, fn:random-number-generator())
};

declare %private function r:random-sequence($length as xs:integer, 
                                            $G as map(xs:string, item())) {
  if ($length eq 0)
  then ()
  else ($G?number, r:random-sequence($length - 1, $G?next()))
};

r:random-sequence(200);
            
793 returns
declare %public function r:random-sequence($length as xs:integer) as xs:double* {
  r:random-sequence($length, fn:random-number-generator())
};

declare %private function r:random-sequence($length as xs:integer, 
                                            $G as map(xs:string, item())) {
  if ($length eq 0)
  then ()
  else ($G?number, r:random-sequence($length - 1, $G?next()))
};

r:random-sequence(200);
            
794.

The expression

declare %public function r:random-sequence($length as xs:integer) as xs:double* {
  r:random-sequence($length, fn:random-number-generator())
};

declare %private function r:random-sequence($length as xs:integer, 
                                            $G as map(xs:string, item())) {
  if ($length eq 0)
  then ()
  else ($G?number, r:random-sequence($length - 1, $G?next()))
};

r:random-sequence(200);
            
795 returns
declare %public function r:random-sequence($length as xs:integer) as xs:double* {
  r:random-sequence($length, fn:random-number-generator())
};

declare %private function r:random-sequence($length as xs:integer, 
                                            $G as map(xs:string, item())) {
  if ($length eq 0)
  then ()
  else ($G?number, r:random-sequence($length - 1, $G?next()))
};

r:random-sequence(200);
            
796.

17.3.4 array:append

Summary

Returns an array containing all the members of a supplied array, plus one additional member at the end.

Signature

declare %public function r:random-sequence($length as xs:integer) as xs:double* {
  r:random-sequence($length, fn:random-number-generator())
};

declare %private function r:random-sequence($length as xs:integer, 
                                            $G as map(xs:string, item())) {
  if ($length eq 0)
  then ()
  else ($G?number, r:random-sequence($length - 1, $G?next()))
};

r:random-sequence(200);
            
716(
Primo Secondo Terzo Quarto Quinto ...
999
let $para := 
In a hole in the ground there lived a hobbit.
         
71
declare %public function r:random-sequence($length as xs:integer) as xs:double* {
  r:random-sequence($length, fn:random-number-generator())
};

declare %private function r:random-sequence($length as xs:integer, 
                                            $G as map(xs:string, item())) {
  if ($length eq 0)
  then ()
  else ($G?number, r:random-sequence($length - 1, $G?next()))
};

r:random-sequence(200);
            
001,
declare %public function r:random-sequence($length as xs:integer) as xs:double* {
  r:random-sequence($length, fn:random-number-generator())
};

declare %private function r:random-sequence($length as xs:integer, 
                                            $G as map(xs:string, item())) {
  if ($length eq 0)
  then ()
  else ($G?number, r:random-sequence($length - 1, $G?next()))
};

r:random-sequence(200);
            
801
let $para := 
In a hole in the ground there lived a hobbit.
         
71
op:operation(fenceHeight, xs:integer) => op:operation(xs:integer, xs:integer)
16)
let $para := 
In a hole in the ground there lived a hobbit.
         
71
declare %public function r:random-sequence($length as xs:integer) as xs:double* {
  r:random-sequence($length, fn:random-number-generator())
};

declare %private function r:random-sequence($length as xs:integer, 
                                            $G as map(xs:string, item())) {
  if ($length eq 0)
  then ()
  else ($G?number, r:random-sequence($length - 1, $G?next()))
};

r:random-sequence(200);
            
001

Properties

This function is ·deterministic·, ·context-independent·, and ·focus-independent·.

Rules

The result is an array whose size is

declare %public function r:random-sequence($length as xs:integer) as xs:double* {
  r:random-sequence($length, fn:random-number-generator())
};

declare %private function r:random-sequence($length as xs:integer, 
                                            $G as map(xs:string, item())) {
  if ($length eq 0)
  then ()
  else ($G?number, r:random-sequence($length - 1, $G?next()))
};

r:random-sequence(200);
            
806, in which all members in positions 1 to
declare %public function r:random-sequence($length as xs:integer) as xs:double* {
  r:random-sequence($length, fn:random-number-generator())
};

declare %private function r:random-sequence($length as xs:integer, 
                                            $G as map(xs:string, item())) {
  if ($length eq 0)
  then ()
  else ($G?number, r:random-sequence($length - 1, $G?next()))
};

r:random-sequence(200);
            
696 are the same as the members in the corresponding position of
Primo Secondo Terzo Quarto Quinto ...
999, and the member in position
declare %public function r:random-sequence($length as xs:integer) as xs:double* {
  r:random-sequence($length, fn:random-number-generator())
};

declare %private function r:random-sequence($length as xs:integer, 
                                            $G as map(xs:string, item())) {
  if ($length eq 0)
  then ()
  else ($G?number, r:random-sequence($length - 1, $G?next()))
};

r:random-sequence(200);
            
806 is
declare %public function r:random-sequence($length as xs:integer) as xs:double* {
  r:random-sequence($length, fn:random-number-generator())
};

declare %private function r:random-sequence($length as xs:integer, 
                                            $G as map(xs:string, item())) {
  if ($length eq 0)
  then ()
  else ($G?number, r:random-sequence($length - 1, $G?next()))
};

r:random-sequence(200);
            
801.

The result is equivalent to the result of the expression

declare %public function r:random-sequence($length as xs:integer) as xs:double* {
  r:random-sequence($length, fn:random-number-generator())
};

declare %private function r:random-sequence($length as xs:integer, 
                                            $G as map(xs:string, item())) {
  if ($length eq 0)
  then ()
  else ($G?number, r:random-sequence($length - 1, $G?next()))
};

r:random-sequence(200);
            
811.

Examples

The expression

declare %public function r:random-sequence($length as xs:integer) as xs:double* {
  r:random-sequence($length, fn:random-number-generator())
};

declare %private function r:random-sequence($length as xs:integer, 
                                            $G as map(xs:string, item())) {
  if ($length eq 0)
  then ()
  else ($G?number, r:random-sequence($length - 1, $G?next()))
};

r:random-sequence(200);
            
812 returns
declare %public function r:random-sequence($length as xs:integer) as xs:double* {
  r:random-sequence($length, fn:random-number-generator())
};

declare %private function r:random-sequence($length as xs:integer, 
                                            $G as map(xs:string, item())) {
  if ($length eq 0)
  then ()
  else ($G?number, r:random-sequence($length - 1, $G?next()))
};

r:random-sequence(200);
            
813.

The expression

declare %public function r:random-sequence($length as xs:integer) as xs:double* {
  r:random-sequence($length, fn:random-number-generator())
};

declare %private function r:random-sequence($length as xs:integer, 
                                            $G as map(xs:string, item())) {
  if ($length eq 0)
  then ()
  else ($G?number, r:random-sequence($length - 1, $G?next()))
};

r:random-sequence(200);
            
814 returns
declare %public function r:random-sequence($length as xs:integer) as xs:double* {
  r:random-sequence($length, fn:random-number-generator())
};

declare %private function r:random-sequence($length as xs:integer, 
                                            $G as map(xs:string, item())) {
  if ($length eq 0)
  then ()
  else ($G?number, r:random-sequence($length - 1, $G?next()))
};

r:random-sequence(200);
            
815.

The expression

declare %public function r:random-sequence($length as xs:integer) as xs:double* {
  r:random-sequence($length, fn:random-number-generator())
};

declare %private function r:random-sequence($length as xs:integer, 
                                            $G as map(xs:string, item())) {
  if ($length eq 0)
  then ()
  else ($G?number, r:random-sequence($length - 1, $G?next()))
};

r:random-sequence(200);
            
816 returns
declare %public function r:random-sequence($length as xs:integer) as xs:double* {
  r:random-sequence($length, fn:random-number-generator())
};

declare %private function r:random-sequence($length as xs:integer, 
                                            $G as map(xs:string, item())) {
  if ($length eq 0)
  then ()
  else ($G?number, r:random-sequence($length - 1, $G?next()))
};

r:random-sequence(200);
            
817.

17.3.5 array:subarray

Summary

Returns an array containing all members from a supplied array starting at a supplied position, up to a specified length.

Signatures

declare %public function r:random-sequence($length as xs:integer) as xs:double* {
  r:random-sequence($length, fn:random-number-generator())
};

declare %private function r:random-sequence($length as xs:integer, 
                                            $G as map(xs:string, item())) {
  if ($length eq 0)
  then ()
  else ($G?number, r:random-sequence($length - 1, $G?next()))
};

r:random-sequence(200);
            
717(
Primo Secondo Terzo Quarto Quinto ...
999
let $para := 
In a hole in the ground there lived a hobbit.
         
71
declare %public function r:random-sequence($length as xs:integer) as xs:double* {
  r:random-sequence($length, fn:random-number-generator())
};

declare %private function r:random-sequence($length as xs:integer, 
                                            $G as map(xs:string, item())) {
  if ($length eq 0)
  then ()
  else ($G?number, r:random-sequence($length - 1, $G?next()))
};

r:random-sequence(200);
            
001,
let $para := 
In a hole in the ground there lived a hobbit.
         
274
let $para := 
In a hole in the ground there lived a hobbit.
         
71
let $para := 
In a hole in the ground there lived a hobbit.
         
85)
let $para := 
In a hole in the ground there lived a hobbit.
         
71
declare %public function r:random-sequence($length as xs:integer) as xs:double* {
  r:random-sequence($length, fn:random-number-generator())
};

declare %private function r:random-sequence($length as xs:integer, 
                                            $G as map(xs:string, item())) {
  if ($length eq 0)
  then ()
  else ($G?number, r:random-sequence($length - 1, $G?next()))
};

r:random-sequence(200);
            
001

declare %public function r:random-sequence($length as xs:integer) as xs:double* {
  r:random-sequence($length, fn:random-number-generator())
};

declare %private function r:random-sequence($length as xs:integer, 
                                            $G as map(xs:string, item())) {
  if ($length eq 0)
  then ()
  else ($G?number, r:random-sequence($length - 1, $G?next()))
};

r:random-sequence(200);
            
717(
Primo Secondo Terzo Quarto Quinto ...
999
let $para := 
In a hole in the ground there lived a hobbit.
         
71
declare %public function r:random-sequence($length as xs:integer) as xs:double* {
  r:random-sequence($length, fn:random-number-generator())
};

declare %private function r:random-sequence($length as xs:integer, 
                                            $G as map(xs:string, item())) {
  if ($length eq 0)
  then ()
  else ($G?number, r:random-sequence($length - 1, $G?next()))
};

r:random-sequence(200);
            
001,
let $para := 
In a hole in the ground there lived a hobbit.
         
274
let $para := 
In a hole in the ground there lived a hobbit.
         
71
let $para := 
In a hole in the ground there lived a hobbit.
         
85,
let $para := 
In a hole in the ground there lived a hobbit.
         
275
let $para := 
In a hole in the ground there lived a hobbit.
         
71
let $para := 
In a hole in the ground there lived a hobbit.
         
85)
let $para := 
In a hole in the ground there lived a hobbit.
         
71
declare %public function r:random-sequence($length as xs:integer) as xs:double* {
  r:random-sequence($length, fn:random-number-generator())
};

declare %private function r:random-sequence($length as xs:integer, 
                                            $G as map(xs:string, item())) {
  if ($length eq 0)
  then ()
  else ($G?number, r:random-sequence($length - 1, $G?next()))
};

r:random-sequence(200);
            
001

Properties

This function is ·deterministic·, ·context-independent·, and ·focus-independent·.

Rules

Except in error cases, the two-argument version of the function returns the same result as the three-argument version when called with

let $para := 
In a hole in the ground there lived a hobbit.
         
275 equal to the value of
declare %public function r:random-sequence($length as xs:integer) as xs:double* {
  r:random-sequence($length, fn:random-number-generator())
};

declare %private function r:random-sequence($length as xs:integer, 
                                            $G as map(xs:string, item())) {
  if ($length eq 0)
  then ()
  else ($G?number, r:random-sequence($length - 1, $G?next()))
};

r:random-sequence(200);
            
840.

The result of the three-argument version of the function is given by the expression

declare %public function r:random-sequence($length as xs:integer) as xs:double* {
  r:random-sequence($length, fn:random-number-generator())
};

declare %private function r:random-sequence($length as xs:integer, 
                                            $G as map(xs:string, item())) {
  if ($length eq 0)
  then ()
  else ($G?number, r:random-sequence($length - 1, $G?next()))
};

r:random-sequence(200);
            
841

Error Conditions

A dynamic error is raised [err:FOAY0001] if

let $para := 
In a hole in the ground there lived a hobbit.
         
274 is less than one or greater than
declare %public function r:random-sequence($length as xs:integer) as xs:double* {
  r:random-sequence($length, fn:random-number-generator())
};

declare %private function r:random-sequence($length as xs:integer, 
                                            $G as map(xs:string, item())) {
  if ($length eq 0)
  then ()
  else ($G?number, r:random-sequence($length - 1, $G?next()))
};

r:random-sequence(200);
            
806
.

For the three-argument version of the function:

  • A dynamic error is raised [err:FOAY0002] if

    let $para := 
    In a hole in the ground there lived a hobbit.
             
    275 is less than zero.

  • A dynamic error is raised [err:FOAY0001] if

    declare %public function r:random-sequence($length as xs:integer) as xs:double* {
      r:random-sequence($length, fn:random-number-generator())
    };
    
    declare %private function r:random-sequence($length as xs:integer, 
                                                $G as map(xs:string, item())) {
      if ($length eq 0)
      then ()
      else ($G?number, r:random-sequence($length - 1, $G?next()))
    };
    
    r:random-sequence(200);
                
    845 is greater than
    declare %public function r:random-sequence($length as xs:integer) as xs:double* {
      r:random-sequence($length, fn:random-number-generator())
    };
    
    declare %private function r:random-sequence($length as xs:integer, 
                                                $G as map(xs:string, item())) {
      if ($length eq 0)
      then ()
      else ($G?number, r:random-sequence($length - 1, $G?next()))
    };
    
    r:random-sequence(200);
                
    806.

Notes

The value of

let $para := 
In a hole in the ground there lived a hobbit.
         
274 can be equal to
declare %public function r:random-sequence($length as xs:integer) as xs:double* {
  r:random-sequence($length, fn:random-number-generator())
};

declare %private function r:random-sequence($length as xs:integer, 
                                            $G as map(xs:string, item())) {
  if ($length eq 0)
  then ()
  else ($G?number, r:random-sequence($length - 1, $G?next()))
};

r:random-sequence(200);
            
806 provided that
let $para := 
In a hole in the ground there lived a hobbit.
         
275 is either equal to zero or omitted. In this case the result will be an empty array.

Examples

The expression

declare %public function r:random-sequence($length as xs:integer) as xs:double* {
  r:random-sequence($length, fn:random-number-generator())
};

declare %private function r:random-sequence($length as xs:integer, 
                                            $G as map(xs:string, item())) {
  if ($length eq 0)
  then ()
  else ($G?number, r:random-sequence($length - 1, $G?next()))
};

r:random-sequence(200);
            
850 returns
declare %public function r:random-sequence($length as xs:integer) as xs:double* {
  r:random-sequence($length, fn:random-number-generator())
};

declare %private function r:random-sequence($length as xs:integer, 
                                            $G as map(xs:string, item())) {
  if ($length eq 0)
  then ()
  else ($G?number, r:random-sequence($length - 1, $G?next()))
};

r:random-sequence(200);
            
851.

The expression

declare %public function r:random-sequence($length as xs:integer) as xs:double* {
  r:random-sequence($length, fn:random-number-generator())
};

declare %private function r:random-sequence($length as xs:integer, 
                                            $G as map(xs:string, item())) {
  if ($length eq 0)
  then ()
  else ($G?number, r:random-sequence($length - 1, $G?next()))
};

r:random-sequence(200);
            
852 returns
declare %public function r:random-sequence($length as xs:integer) as xs:double* {
  r:random-sequence($length, fn:random-number-generator())
};

declare %private function r:random-sequence($length as xs:integer, 
                                            $G as map(xs:string, item())) {
  if ($length eq 0)
  then ()
  else ($G?number, r:random-sequence($length - 1, $G?next()))
};

r:random-sequence(200);
            
853.

The expression

declare %public function r:random-sequence($length as xs:integer) as xs:double* {
  r:random-sequence($length, fn:random-number-generator())
};

declare %private function r:random-sequence($length as xs:integer, 
                                            $G as map(xs:string, item())) {
  if ($length eq 0)
  then ()
  else ($G?number, r:random-sequence($length - 1, $G?next()))
};

r:random-sequence(200);
            
854 returns
declare %public function r:random-sequence($length as xs:integer) as xs:double* {
  r:random-sequence($length, fn:random-number-generator())
};

declare %private function r:random-sequence($length as xs:integer, 
                                            $G as map(xs:string, item())) {
  if ($length eq 0)
  then ()
  else ($G?number, r:random-sequence($length - 1, $G?next()))
};

r:random-sequence(200);
            
853.

The expression

declare %public function r:random-sequence($length as xs:integer) as xs:double* {
  r:random-sequence($length, fn:random-number-generator())
};

declare %private function r:random-sequence($length as xs:integer, 
                                            $G as map(xs:string, item())) {
  if ($length eq 0)
  then ()
  else ($G?number, r:random-sequence($length - 1, $G?next()))
};

r:random-sequence(200);
            
856 returns
declare %public function r:random-sequence($length as xs:integer) as xs:double* {
  r:random-sequence($length, fn:random-number-generator())
};

declare %private function r:random-sequence($length as xs:integer, 
                                            $G as map(xs:string, item())) {
  if ($length eq 0)
  then ()
  else ($G?number, r:random-sequence($length - 1, $G?next()))
};

r:random-sequence(200);
            
857.

The expression

declare %public function r:random-sequence($length as xs:integer) as xs:double* {
  r:random-sequence($length, fn:random-number-generator())
};

declare %private function r:random-sequence($length as xs:integer, 
                                            $G as map(xs:string, item())) {
  if ($length eq 0)
  then ()
  else ($G?number, r:random-sequence($length - 1, $G?next()))
};

r:random-sequence(200);
            
858 returns
declare %public function r:random-sequence($length as xs:integer) as xs:double* {
  r:random-sequence($length, fn:random-number-generator())
};

declare %private function r:random-sequence($length as xs:integer, 
                                            $G as map(xs:string, item())) {
  if ($length eq 0)
  then ()
  else ($G?number, r:random-sequence($length - 1, $G?next()))
};

r:random-sequence(200);
            
769.

The expression

declare %public function r:random-sequence($length as xs:integer) as xs:double* {
  r:random-sequence($length, fn:random-number-generator())
};

declare %private function r:random-sequence($length as xs:integer, 
                                            $G as map(xs:string, item())) {
  if ($length eq 0)
  then ()
  else ($G?number, r:random-sequence($length - 1, $G?next()))
};

r:random-sequence(200);
            
860 returns
declare %public function r:random-sequence($length as xs:integer) as xs:double* {
  r:random-sequence($length, fn:random-number-generator())
};

declare %private function r:random-sequence($length as xs:integer, 
                                            $G as map(xs:string, item())) {
  if ($length eq 0)
  then ()
  else ($G?number, r:random-sequence($length - 1, $G?next()))
};

r:random-sequence(200);
            
853.

The expression

declare %public function r:random-sequence($length as xs:integer) as xs:double* {
  r:random-sequence($length, fn:random-number-generator())
};

declare %private function r:random-sequence($length as xs:integer, 
                                            $G as map(xs:string, item())) {
  if ($length eq 0)
  then ()
  else ($G?number, r:random-sequence($length - 1, $G?next()))
};

r:random-sequence(200);
            
862 returns
declare %public function r:random-sequence($length as xs:integer) as xs:double* {
  r:random-sequence($length, fn:random-number-generator())
};

declare %private function r:random-sequence($length as xs:integer, 
                                            $G as map(xs:string, item())) {
  if ($length eq 0)
  then ()
  else ($G?number, r:random-sequence($length - 1, $G?next()))
};

r:random-sequence(200);
            
853.

17.3.6 array:remove

Summary

Returns an array containing all the members of the supplied array, except for the members at specified positions.

Signature

declare %public function r:random-sequence($length as xs:integer) as xs:double* {
  r:random-sequence($length, fn:random-number-generator())
};

declare %private function r:random-sequence($length as xs:integer, 
                                            $G as map(xs:string, item())) {
  if ($length eq 0)
  then ()
  else ($G?number, r:random-sequence($length - 1, $G?next()))
};

r:random-sequence(200);
            
718(
Primo Secondo Terzo Quarto Quinto ...
999
let $para := 
In a hole in the ground there lived a hobbit.
         
71
declare %public function r:random-sequence($length as xs:integer) as xs:double* {
  r:random-sequence($length, fn:random-number-generator())
};

declare %private function r:random-sequence($length as xs:integer, 
                                            $G as map(xs:string, item())) {
  if ($length eq 0)
  then ()
  else ($G?number, r:random-sequence($length - 1, $G?next()))
};

r:random-sequence(200);
            
001,
declare %public function r:random-sequence($length as xs:integer) as xs:double* {
  r:random-sequence($length, fn:random-number-generator())
};

declare %private function r:random-sequence($length as xs:integer, 
                                            $G as map(xs:string, item())) {
  if ($length eq 0)
  then ()
  else ($G?number, r:random-sequence($length - 1, $G?next()))
};

r:random-sequence(200);
            
868
let $para := 
In a hole in the ground there lived a hobbit.
         
71
let $para := 
In a hole in the ground there lived a hobbit.
         
033)
let $para := 
In a hole in the ground there lived a hobbit.
         
71
declare %public function r:random-sequence($length as xs:integer) as xs:double* {
  r:random-sequence($length, fn:random-number-generator())
};

declare %private function r:random-sequence($length as xs:integer, 
                                            $G as map(xs:string, item())) {
  if ($length eq 0)
  then ()
  else ($G?number, r:random-sequence($length - 1, $G?next()))
};

r:random-sequence(200);
            
001

Properties

This function is ·deterministic·, ·context-independent·, and ·focus-independent·.

Rules

The function returns an array of size

declare %public function r:random-sequence($length as xs:integer) as xs:double* {
  r:random-sequence($length, fn:random-number-generator())
};

declare %private function r:random-sequence($length as xs:integer, 
                                            $G as map(xs:string, item())) {
  if ($length eq 0)
  then ()
  else ($G?number, r:random-sequence($length - 1, $G?next()))
};

r:random-sequence(200);
            
873 containing all members from
Primo Secondo Terzo Quarto Quinto ...
999 except the members whose position (counting from 1) is present in the sequence
declare %public function r:random-sequence($length as xs:integer) as xs:double* {
  r:random-sequence($length, fn:random-number-generator())
};

declare %private function r:random-sequence($length as xs:integer, 
                                            $G as map(xs:string, item())) {
  if ($length eq 0)
  then ()
  else ($G?number, r:random-sequence($length - 1, $G?next()))
};

r:random-sequence(200);
            
868. The order of the remaining members is preserved.

The result of the function, except in error cases, is given by the expression

declare %public function r:random-sequence($length as xs:integer) as xs:double* {
  r:random-sequence($length, fn:random-number-generator())
};

declare %private function r:random-sequence($length as xs:integer, 
                                            $G as map(xs:string, item())) {
  if ($length eq 0)
  then ()
  else ($G?number, r:random-sequence($length - 1, $G?next()))
};

r:random-sequence(200);
            
876

Error Conditions

A dynamic error is raised [err:FOAY0001] if any integer in

declare %public function r:random-sequence($length as xs:integer) as xs:double* {
  r:random-sequence($length, fn:random-number-generator())
};

declare %private function r:random-sequence($length as xs:integer, 
                                            $G as map(xs:string, item())) {
  if ($length eq 0)
  then ()
  else ($G?number, r:random-sequence($length - 1, $G?next()))
};

r:random-sequence(200);
            
868 is not in the range
declare %public function r:random-sequence($length as xs:integer) as xs:double* {
  r:random-sequence($length, fn:random-number-generator())
};

declare %private function r:random-sequence($length as xs:integer, 
                                            $G as map(xs:string, item())) {
  if ($length eq 0)
  then ()
  else ($G?number, r:random-sequence($length - 1, $G?next()))
};

r:random-sequence(200);
            
765 inclusive. By implication, an error occurs if
Primo Secondo Terzo Quarto Quinto ...
999 is empty, unless
declare %public function r:random-sequence($length as xs:integer) as xs:double* {
  r:random-sequence($length, fn:random-number-generator())
};

declare %private function r:random-sequence($length as xs:integer, 
                                            $G as map(xs:string, item())) {
  if ($length eq 0)
  then ()
  else ($G?number, r:random-sequence($length - 1, $G?next()))
};

r:random-sequence(200);
            
868 is also empty.

Examples

The expression

declare %public function r:random-sequence($length as xs:integer) as xs:double* {
  r:random-sequence($length, fn:random-number-generator())
};

declare %private function r:random-sequence($length as xs:integer, 
                                            $G as map(xs:string, item())) {
  if ($length eq 0)
  then ()
  else ($G?number, r:random-sequence($length - 1, $G?next()))
};

r:random-sequence(200);
            
881 returns
declare %public function r:random-sequence($length as xs:integer) as xs:double* {
  r:random-sequence($length, fn:random-number-generator())
};

declare %private function r:random-sequence($length as xs:integer, 
                                            $G as map(xs:string, item())) {
  if ($length eq 0)
  then ()
  else ($G?number, r:random-sequence($length - 1, $G?next()))
};

r:random-sequence(200);
            
851.

The expression

declare %public function r:random-sequence($length as xs:integer) as xs:double* {
  r:random-sequence($length, fn:random-number-generator())
};

declare %private function r:random-sequence($length as xs:integer, 
                                            $G as map(xs:string, item())) {
  if ($length eq 0)
  then ()
  else ($G?number, r:random-sequence($length - 1, $G?next()))
};

r:random-sequence(200);
            
883 returns
declare %public function r:random-sequence($length as xs:integer) as xs:double* {
  r:random-sequence($length, fn:random-number-generator())
};

declare %private function r:random-sequence($length as xs:integer, 
                                            $G as map(xs:string, item())) {
  if ($length eq 0)
  then ()
  else ($G?number, r:random-sequence($length - 1, $G?next()))
};

r:random-sequence(200);
            
884.

The expression

declare %public function r:random-sequence($length as xs:integer) as xs:double* {
  r:random-sequence($length, fn:random-number-generator())
};

declare %private function r:random-sequence($length as xs:integer, 
                                            $G as map(xs:string, item())) {
  if ($length eq 0)
  then ()
  else ($G?number, r:random-sequence($length - 1, $G?next()))
};

r:random-sequence(200);
            
885 returns
declare %public function r:random-sequence($length as xs:integer) as xs:double* {
  r:random-sequence($length, fn:random-number-generator())
};

declare %private function r:random-sequence($length as xs:integer, 
                                            $G as map(xs:string, item())) {
  if ($length eq 0)
  then ()
  else ($G?number, r:random-sequence($length - 1, $G?next()))
};

r:random-sequence(200);
            
853.

The expression

declare %public function r:random-sequence($length as xs:integer) as xs:double* {
  r:random-sequence($length, fn:random-number-generator())
};

declare %private function r:random-sequence($length as xs:integer, 
                                            $G as map(xs:string, item())) {
  if ($length eq 0)
  then ()
  else ($G?number, r:random-sequence($length - 1, $G?next()))
};

r:random-sequence(200);
            
887 returns
declare %public function r:random-sequence($length as xs:integer) as xs:double* {
  r:random-sequence($length, fn:random-number-generator())
};

declare %private function r:random-sequence($length as xs:integer, 
                                            $G as map(xs:string, item())) {
  if ($length eq 0)
  then ()
  else ($G?number, r:random-sequence($length - 1, $G?next()))
};

r:random-sequence(200);
            
888.

The expression

declare %public function r:random-sequence($length as xs:integer) as xs:double* {
  r:random-sequence($length, fn:random-number-generator())
};

declare %private function r:random-sequence($length as xs:integer, 
                                            $G as map(xs:string, item())) {
  if ($length eq 0)
  then ()
  else ($G?number, r:random-sequence($length - 1, $G?next()))
};

r:random-sequence(200);
            
889 returns
declare %public function r:random-sequence($length as xs:integer) as xs:double* {
  r:random-sequence($length, fn:random-number-generator())
};

declare %private function r:random-sequence($length as xs:integer, 
                                            $G as map(xs:string, item())) {
  if ($length eq 0)
  then ()
  else ($G?number, r:random-sequence($length - 1, $G?next()))
};

r:random-sequence(200);
            
813.

17.3.7 array:insert-before

Summary

Returns an array containing all the members of the supplied array, with one additional member at a specified position.

Signature

declare %public function r:random-sequence($length as xs:integer) as xs:double* {
  r:random-sequence($length, fn:random-number-generator())
};

declare %private function r:random-sequence($length as xs:integer, 
                                            $G as map(xs:string, item())) {
  if ($length eq 0)
  then ()
  else ($G?number, r:random-sequence($length - 1, $G?next()))
};

r:random-sequence(200);
            
719(
Primo Secondo Terzo Quarto Quinto ...
999
let $para := 
In a hole in the ground there lived a hobbit.
         
71
declare %public function r:random-sequence($length as xs:integer) as xs:double* {
  r:random-sequence($length, fn:random-number-generator())
};

declare %private function r:random-sequence($length as xs:integer, 
                                            $G as map(xs:string, item())) {
  if ($length eq 0)
  then ()
  else ($G?number, r:random-sequence($length - 1, $G?next()))
};

r:random-sequence(200);
            
001,
1º 2º 3º 4º ...
306
let $para := 
In a hole in the ground there lived a hobbit.
         
71
let $para := 
In a hole in the ground there lived a hobbit.
         
85,
declare %public function r:random-sequence($length as xs:integer) as xs:double* {
  r:random-sequence($length, fn:random-number-generator())
};

declare %private function r:random-sequence($length as xs:integer, 
                                            $G as map(xs:string, item())) {
  if ($length eq 0)
  then ()
  else ($G?number, r:random-sequence($length - 1, $G?next()))
};

r:random-sequence(200);
            
777
let $para := 
In a hole in the ground there lived a hobbit.
         
71
op:operation(fenceHeight, xs:integer) => op:operation(xs:integer, xs:integer)
16)
let $para := 
In a hole in the ground there lived a hobbit.
         
71
declare %public function r:random-sequence($length as xs:integer) as xs:double* {
  r:random-sequence($length, fn:random-number-generator())
};

declare %private function r:random-sequence($length as xs:integer, 
                                            $G as map(xs:string, item())) {
  if ($length eq 0)
  then ()
  else ($G?number, r:random-sequence($length - 1, $G?next()))
};

r:random-sequence(200);
            
001

Properties

This function is ·deterministic·, ·context-independent·, and ·focus-independent·.

Rules

The function returns an array of size

declare %public function r:random-sequence($length as xs:integer) as xs:double* {
  r:random-sequence($length, fn:random-number-generator())
};

declare %private function r:random-sequence($length as xs:integer, 
                                            $G as map(xs:string, item())) {
  if ($length eq 0)
  then ()
  else ($G?number, r:random-sequence($length - 1, $G?next()))
};

r:random-sequence(200);
            
806 containing all members from
Primo Secondo Terzo Quarto Quinto ...
999 whose position is less than
1º 2º 3º 4º ...
306, then a new member given by
declare %public function r:random-sequence($length as xs:integer) as xs:double* {
  r:random-sequence($length, fn:random-number-generator())
};

declare %private function r:random-sequence($length as xs:integer, 
                                            $G as map(xs:string, item())) {
  if ($length eq 0)
  then ()
  else ($G?number, r:random-sequence($length - 1, $G?next()))
};

r:random-sequence(200);
            
777, and then all members from
Primo Secondo Terzo Quarto Quinto ...
999 whose position is greater than or equal to
1º 2º 3º 4º ...
306. Positions are counted from 1.

The result is equivalent to the result of the expression

declare %public function r:random-sequence($length as xs:integer) as xs:double* {
  r:random-sequence($length, fn:random-number-generator())
};

declare %private function r:random-sequence($length as xs:integer, 
                                            $G as map(xs:string, item())) {
  if ($length eq 0)
  then ()
  else ($G?number, r:random-sequence($length - 1, $G?next()))
};

r:random-sequence(200);
            
909

Error Conditions

A dynamic error occurs [err:FOAY0001] if

1º 2º 3º 4º ...
306 is not in the range
declare %public function r:random-sequence($length as xs:integer) as xs:double* {
  r:random-sequence($length, fn:random-number-generator())
};

declare %private function r:random-sequence($length as xs:integer, 
                                            $G as map(xs:string, item())) {
  if ($length eq 0)
  then ()
  else ($G?number, r:random-sequence($length - 1, $G?next()))
};

r:random-sequence(200);
            
911 inclusive.

Notes

Setting

1º 2º 3º 4º ...
306 to 1 has the effect of prepending the new member at the start of the array. Setting
1º 2º 3º 4º ...
306 to the value
declare %public function r:random-sequence($length as xs:integer) as xs:double* {
  r:random-sequence($length, fn:random-number-generator())
};

declare %private function r:random-sequence($length as xs:integer, 
                                            $G as map(xs:string, item())) {
  if ($length eq 0)
  then ()
  else ($G?number, r:random-sequence($length - 1, $G?next()))
};

r:random-sequence(200);
            
806 delivers the same result as
declare %public function r:random-sequence($length as xs:integer) as xs:double* {
  r:random-sequence($length, fn:random-number-generator())
};

declare %private function r:random-sequence($length as xs:integer, 
                                            $G as map(xs:string, item())) {
  if ($length eq 0)
  then ()
  else ($G?number, r:random-sequence($length - 1, $G?next()))
};

r:random-sequence(200);
            
915.

Examples

The expression

declare %public function r:random-sequence($length as xs:integer) as xs:double* {
  r:random-sequence($length, fn:random-number-generator())
};

declare %private function r:random-sequence($length as xs:integer, 
                                            $G as map(xs:string, item())) {
  if ($length eq 0)
  then ()
  else ($G?number, r:random-sequence($length - 1, $G?next()))
};

r:random-sequence(200);
            
916 returns
declare %public function r:random-sequence($length as xs:integer) as xs:double* {
  r:random-sequence($length, fn:random-number-generator())
};

declare %private function r:random-sequence($length as xs:integer, 
                                            $G as map(xs:string, item())) {
  if ($length eq 0)
  then ()
  else ($G?number, r:random-sequence($length - 1, $G?next()))
};

r:random-sequence(200);
            
917.

The expression

declare %public function r:random-sequence($length as xs:integer) as xs:double* {
  r:random-sequence($length, fn:random-number-generator())
};

declare %private function r:random-sequence($length as xs:integer, 
                                            $G as map(xs:string, item())) {
  if ($length eq 0)
  then ()
  else ($G?number, r:random-sequence($length - 1, $G?next()))
};

r:random-sequence(200);
            
918 returns
declare %public function r:random-sequence($length as xs:integer) as xs:double* {
  r:random-sequence($length, fn:random-number-generator())
};

declare %private function r:random-sequence($length as xs:integer, 
                                            $G as map(xs:string, item())) {
  if ($length eq 0)
  then ()
  else ($G?number, r:random-sequence($length - 1, $G?next()))
};

r:random-sequence(200);
            
919.

The expression

declare %public function r:random-sequence($length as xs:integer) as xs:double* {
  r:random-sequence($length, fn:random-number-generator())
};

declare %private function r:random-sequence($length as xs:integer, 
                                            $G as map(xs:string, item())) {
  if ($length eq 0)
  then ()
  else ($G?number, r:random-sequence($length - 1, $G?next()))
};

r:random-sequence(200);
            
920 returns
declare %public function r:random-sequence($length as xs:integer) as xs:double* {
  r:random-sequence($length, fn:random-number-generator())
};

declare %private function r:random-sequence($length as xs:integer, 
                                            $G as map(xs:string, item())) {
  if ($length eq 0)
  then ()
  else ($G?number, r:random-sequence($length - 1, $G?next()))
};

r:random-sequence(200);
            
921.

17.3.8 array:head

Summary

Returns the first member of an array, that is

declare %public function r:random-sequence($length as xs:integer) as xs:double* {
  r:random-sequence($length, fn:random-number-generator())
};

declare %private function r:random-sequence($length as xs:integer, 
                                            $G as map(xs:string, item())) {
  if ($length eq 0)
  then ()
  else ($G?number, r:random-sequence($length - 1, $G?next()))
};

r:random-sequence(200);
            
721.

Signature

declare %public function r:random-sequence($length as xs:integer) as xs:double* {
  r:random-sequence($length, fn:random-number-generator())
};

declare %private function r:random-sequence($length as xs:integer, 
                                            $G as map(xs:string, item())) {
  if ($length eq 0)
  then ()
  else ($G?number, r:random-sequence($length - 1, $G?next()))
};

r:random-sequence(200);
            
720(
Primo Secondo Terzo Quarto Quinto ...
999
let $para := 
In a hole in the ground there lived a hobbit.
         
71
declare %public function r:random-sequence($length as xs:integer) as xs:double* {
  r:random-sequence($length, fn:random-number-generator())
};

declare %private function r:random-sequence($length as xs:integer, 
                                            $G as map(xs:string, item())) {
  if ($length eq 0)
  then ()
  else ($G?number, r:random-sequence($length - 1, $G?next()))
};

r:random-sequence(200);
            
001)
let $para := 
In a hole in the ground there lived a hobbit.
         
71
op:operation(fenceHeight, xs:integer) => op:operation(xs:integer, xs:integer)
16

Properties

This function is ·deterministic·, ·context-independent·, and ·focus-independent·.

Rules

The function returns first member of

Primo Secondo Terzo Quarto Quinto ...
999, that is the value of
declare %public function r:random-sequence($length as xs:integer) as xs:double* {
  r:random-sequence($length, fn:random-number-generator())
};

declare %private function r:random-sequence($length as xs:integer, 
                                            $G as map(xs:string, item())) {
  if ($length eq 0)
  then ()
  else ($G?number, r:random-sequence($length - 1, $G?next()))
};

r:random-sequence(200);
            
721.

Error Conditions

A dynamic error occurs [err:FOAY0001] if

Primo Secondo Terzo Quarto Quinto ...
999 is empty.

Examples

The expression

declare %public function r:random-sequence($length as xs:integer) as xs:double* {
  r:random-sequence($length, fn:random-number-generator())
};

declare %private function r:random-sequence($length as xs:integer, 
                                            $G as map(xs:string, item())) {
  if ($length eq 0)
  then ()
  else ($G?number, r:random-sequence($length - 1, $G?next()))
};

r:random-sequence(200);
            
932 returns
declare %public function r:random-sequence($length as xs:integer) as xs:double* {
  r:random-sequence($length, fn:random-number-generator())
};

declare %private function r:random-sequence($length as xs:integer, 
                                            $G as map(xs:string, item())) {
  if ($length eq 0)
  then ()
  else ($G?number, r:random-sequence($length - 1, $G?next()))
};

r:random-sequence(200);
            
21.

The expression

declare %public function r:random-sequence($length as xs:integer) as xs:double* {
  r:random-sequence($length, fn:random-number-generator())
};

declare %private function r:random-sequence($length as xs:integer, 
                                            $G as map(xs:string, item())) {
  if ($length eq 0)
  then ()
  else ($G?number, r:random-sequence($length - 1, $G?next()))
};

r:random-sequence(200);
            
934 returns
declare %public function r:random-sequence($length as xs:integer) as xs:double* {
  r:random-sequence($length, fn:random-number-generator())
};

declare %private function r:random-sequence($length as xs:integer, 
                                            $G as map(xs:string, item())) {
  if ($length eq 0)
  then ()
  else ($G?number, r:random-sequence($length - 1, $G?next()))
};

r:random-sequence(200);
            
935.

The expression

declare %public function r:random-sequence($length as xs:integer) as xs:double* {
  r:random-sequence($length, fn:random-number-generator())
};

declare %private function r:random-sequence($length as xs:integer, 
                                            $G as map(xs:string, item())) {
  if ($length eq 0)
  then ()
  else ($G?number, r:random-sequence($length - 1, $G?next()))
};

r:random-sequence(200);
            
936 returns
declare %public function r:random-sequence($length as xs:integer) as xs:double* {
  r:random-sequence($length, fn:random-number-generator())
};

declare %private function r:random-sequence($length as xs:integer, 
                                            $G as map(xs:string, item())) {
  if ($length eq 0)
  then ()
  else ($G?number, r:random-sequence($length - 1, $G?next()))
};

r:random-sequence(200);
            
937.

17.3.9 array:tail

Summary

Returns an array containing all members except the first from a supplied array.

Signature

declare %public function r:random-sequence($length as xs:integer) as xs:double* {
  r:random-sequence($length, fn:random-number-generator())
};

declare %private function r:random-sequence($length as xs:integer, 
                                            $G as map(xs:string, item())) {
  if ($length eq 0)
  then ()
  else ($G?number, r:random-sequence($length - 1, $G?next()))
};

r:random-sequence(200);
            
722(
Primo Secondo Terzo Quarto Quinto ...
999
let $para := 
In a hole in the ground there lived a hobbit.
         
71
declare %public function r:random-sequence($length as xs:integer) as xs:double* {
  r:random-sequence($length, fn:random-number-generator())
};

declare %private function r:random-sequence($length as xs:integer, 
                                            $G as map(xs:string, item())) {
  if ($length eq 0)
  then ()
  else ($G?number, r:random-sequence($length - 1, $G?next()))
};

r:random-sequence(200);
            
001)
let $para := 
In a hole in the ground there lived a hobbit.
         
71
declare %public function r:random-sequence($length as xs:integer) as xs:double* {
  r:random-sequence($length, fn:random-number-generator())
};

declare %private function r:random-sequence($length as xs:integer, 
                                            $G as map(xs:string, item())) {
  if ($length eq 0)
  then ()
  else ($G?number, r:random-sequence($length - 1, $G?next()))
};

r:random-sequence(200);
            
001

Properties

This function is ·deterministic·, ·context-independent·, and ·focus-independent·.

Rules

The function returns an array containing all members of the supplied array except the first, that is

declare %public function r:random-sequence($length as xs:integer) as xs:double* {
  r:random-sequence($length, fn:random-number-generator())
};

declare %private function r:random-sequence($length as xs:integer, 
                                            $G as map(xs:string, item())) {
  if ($length eq 0)
  then ()
  else ($G?number, r:random-sequence($length - 1, $G?next()))
};

r:random-sequence(200);
            
944.

Error Conditions

A dynamic error occurs [err:FOAY0001] if

Primo Secondo Terzo Quarto Quinto ...
999 is empty.

Notes

If the supplied array contains exactly one member, the result will be an empty array.

Examples

The expression

declare %public function r:random-sequence($length as xs:integer) as xs:double* {
  r:random-sequence($length, fn:random-number-generator())
};

declare %private function r:random-sequence($length as xs:integer, 
                                            $G as map(xs:string, item())) {
  if ($length eq 0)
  then ()
  else ($G?number, r:random-sequence($length - 1, $G?next()))
};

r:random-sequence(200);
            
946 returns
declare %public function r:random-sequence($length as xs:integer) as xs:double* {
  r:random-sequence($length, fn:random-number-generator())
};

declare %private function r:random-sequence($length as xs:integer, 
                                            $G as map(xs:string, item())) {
  if ($length eq 0)
  then ()
  else ($G?number, r:random-sequence($length - 1, $G?next()))
};

r:random-sequence(200);
            
947.

The expression

declare %public function r:random-sequence($length as xs:integer) as xs:double* {
  r:random-sequence($length, fn:random-number-generator())
};

declare %private function r:random-sequence($length as xs:integer, 
                                            $G as map(xs:string, item())) {
  if ($length eq 0)
  then ()
  else ($G?number, r:random-sequence($length - 1, $G?next()))
};

r:random-sequence(200);
            
948 returns
declare %public function r:random-sequence($length as xs:integer) as xs:double* {
  r:random-sequence($length, fn:random-number-generator())
};

declare %private function r:random-sequence($length as xs:integer, 
                                            $G as map(xs:string, item())) {
  if ($length eq 0)
  then ()
  else ($G?number, r:random-sequence($length - 1, $G?next()))
};

r:random-sequence(200);
            
853.

17.3.10 array:reverse

Summary

Returns an array containing all the members of a supplied array, but in reverse order.

Signature

declare %public function r:random-sequence($length as xs:integer) as xs:double* {
  r:random-sequence($length, fn:random-number-generator())
};

declare %private function r:random-sequence($length as xs:integer, 
                                            $G as map(xs:string, item())) {
  if ($length eq 0)
  then ()
  else ($G?number, r:random-sequence($length - 1, $G?next()))
};

r:random-sequence(200);
            
689(
Primo Secondo Terzo Quarto Quinto ...
999
let $para := 
In a hole in the ground there lived a hobbit.
         
71
declare %public function r:random-sequence($length as xs:integer) as xs:double* {
  r:random-sequence($length, fn:random-number-generator())
};

declare %private function r:random-sequence($length as xs:integer, 
                                            $G as map(xs:string, item())) {
  if ($length eq 0)
  then ()
  else ($G?number, r:random-sequence($length - 1, $G?next()))
};

r:random-sequence(200);
            
001)
let $para := 
In a hole in the ground there lived a hobbit.
         
71
declare %public function r:random-sequence($length as xs:integer) as xs:double* {
  r:random-sequence($length, fn:random-number-generator())
};

declare %private function r:random-sequence($length as xs:integer, 
                                            $G as map(xs:string, item())) {
  if ($length eq 0)
  then ()
  else ($G?number, r:random-sequence($length - 1, $G?next()))
};

r:random-sequence(200);
            
001

Properties

This function is ·deterministic·, ·context-independent·, and ·focus-independent·.

Rules

The function returns the result of the expression:

declare %public function r:random-sequence($length as xs:integer) as xs:double* {
  r:random-sequence($length, fn:random-number-generator())
};

declare %private function r:random-sequence($length as xs:integer, 
                                            $G as map(xs:string, item())) {
  if ($length eq 0)
  then ()
  else ($G?number, r:random-sequence($length - 1, $G?next()))
};

r:random-sequence(200);
            
956

Examples

The expression

declare %public function r:random-sequence($length as xs:integer) as xs:double* {
  r:random-sequence($length, fn:random-number-generator())
};

declare %private function r:random-sequence($length as xs:integer, 
                                            $G as map(xs:string, item())) {
  if ($length eq 0)
  then ()
  else ($G?number, r:random-sequence($length - 1, $G?next()))
};

r:random-sequence(200);
            
957 returns
declare %public function r:random-sequence($length as xs:integer) as xs:double* {
  r:random-sequence($length, fn:random-number-generator())
};

declare %private function r:random-sequence($length as xs:integer, 
                                            $G as map(xs:string, item())) {
  if ($length eq 0)
  then ()
  else ($G?number, r:random-sequence($length - 1, $G?next()))
};

r:random-sequence(200);
            
958.

The expression

declare %public function r:random-sequence($length as xs:integer) as xs:double* {
  r:random-sequence($length, fn:random-number-generator())
};

declare %private function r:random-sequence($length as xs:integer, 
                                            $G as map(xs:string, item())) {
  if ($length eq 0)
  then ()
  else ($G?number, r:random-sequence($length - 1, $G?next()))
};

r:random-sequence(200);
            
959 returns
declare %public function r:random-sequence($length as xs:integer) as xs:double* {
  r:random-sequence($length, fn:random-number-generator())
};

declare %private function r:random-sequence($length as xs:integer, 
                                            $G as map(xs:string, item())) {
  if ($length eq 0)
  then ()
  else ($G?number, r:random-sequence($length - 1, $G?next()))
};

r:random-sequence(200);
            
960.

The expression

declare %public function r:random-sequence($length as xs:integer) as xs:double* {
  r:random-sequence($length, fn:random-number-generator())
};

declare %private function r:random-sequence($length as xs:integer, 
                                            $G as map(xs:string, item())) {
  if ($length eq 0)
  then ()
  else ($G?number, r:random-sequence($length - 1, $G?next()))
};

r:random-sequence(200);
            
961 returns
declare %public function r:random-sequence($length as xs:integer) as xs:double* {
  r:random-sequence($length, fn:random-number-generator())
};

declare %private function r:random-sequence($length as xs:integer, 
                                            $G as map(xs:string, item())) {
  if ($length eq 0)
  then ()
  else ($G?number, r:random-sequence($length - 1, $G?next()))
};

r:random-sequence(200);
            
962.

The expression

declare %public function r:random-sequence($length as xs:integer) as xs:double* {
  r:random-sequence($length, fn:random-number-generator())
};

declare %private function r:random-sequence($length as xs:integer, 
                                            $G as map(xs:string, item())) {
  if ($length eq 0)
  then ()
  else ($G?number, r:random-sequence($length - 1, $G?next()))
};

r:random-sequence(200);
            
963 returns
declare %public function r:random-sequence($length as xs:integer) as xs:double* {
  r:random-sequence($length, fn:random-number-generator())
};

declare %private function r:random-sequence($length as xs:integer, 
                                            $G as map(xs:string, item())) {
  if ($length eq 0)
  then ()
  else ($G?number, r:random-sequence($length - 1, $G?next()))
};

r:random-sequence(200);
            
589.

17.3.11 array:join

Summary

Concatenates the contents of several arrays into a single array.

Signature

declare %public function r:random-sequence($length as xs:integer) as xs:double* {
  r:random-sequence($length, fn:random-number-generator())
};

declare %private function r:random-sequence($length as xs:integer, 
                                            $G as map(xs:string, item())) {
  if ($length eq 0)
  then ()
  else ($G?number, r:random-sequence($length - 1, $G?next()))
};

r:random-sequence(200);
            
703(
declare %public function r:random-sequence($length as xs:integer) as xs:double* {
  r:random-sequence($length, fn:random-number-generator())
};

declare %private function r:random-sequence($length as xs:integer, 
                                            $G as map(xs:string, item())) {
  if ($length eq 0)
  then ()
  else ($G?number, r:random-sequence($length - 1, $G?next()))
};

r:random-sequence(200);
            
966
let $para := 
In a hole in the ground there lived a hobbit.
         
71
declare %public function r:random-sequence($length as xs:integer) as xs:double* {
  r:random-sequence($length, fn:random-number-generator())
};

declare %private function r:random-sequence($length as xs:integer, 
                                            $G as map(xs:string, item())) {
  if ($length eq 0)
  then ()
  else ($G?number, r:random-sequence($length - 1, $G?next()))
};

r:random-sequence(200);
            
968)
let $para := 
In a hole in the ground there lived a hobbit.
         
71
declare %public function r:random-sequence($length as xs:integer) as xs:double* {
  r:random-sequence($length, fn:random-number-generator())
};

declare %private function r:random-sequence($length as xs:integer, 
                                            $G as map(xs:string, item())) {
  if ($length eq 0)
  then ()
  else ($G?number, r:random-sequence($length - 1, $G?next()))
};

r:random-sequence(200);
            
001

Properties

This function is ·deterministic·, ·context-independent·, and ·focus-independent·.

Rules

The function can be expressed as follows in XQuery:

let $para := 
In a hole in the ground there lived a hobbit.
         
04

Examples

The expression

declare %public function r:random-sequence($length as xs:integer) as xs:double* {
  r:random-sequence($length, fn:random-number-generator())
};

declare %private function r:random-sequence($length as xs:integer, 
                                            $G as map(xs:string, item())) {
  if ($length eq 0)
  then ()
  else ($G?number, r:random-sequence($length - 1, $G?next()))
};

r:random-sequence(200);
            
971 returns
declare %public function r:random-sequence($length as xs:integer) as xs:double* {
  r:random-sequence($length, fn:random-number-generator())
};

declare %private function r:random-sequence($length as xs:integer, 
                                            $G as map(xs:string, item())) {
  if ($length eq 0)
  then ()
  else ($G?number, r:random-sequence($length - 1, $G?next()))
};

r:random-sequence(200);
            
853.

The expression

declare %public function r:random-sequence($length as xs:integer) as xs:double* {
  r:random-sequence($length, fn:random-number-generator())
};

declare %private function r:random-sequence($length as xs:integer, 
                                            $G as map(xs:string, item())) {
  if ($length eq 0)
  then ()
  else ($G?number, r:random-sequence($length - 1, $G?next()))
};

r:random-sequence(200);
            
973 returns
declare %public function r:random-sequence($length as xs:integer) as xs:double* {
  r:random-sequence($length, fn:random-number-generator())
};

declare %private function r:random-sequence($length as xs:integer, 
                                            $G as map(xs:string, item())) {
  if ($length eq 0)
  then ()
  else ($G?number, r:random-sequence($length - 1, $G?next()))
};

r:random-sequence(200);
            
974.

The expression

declare %public function r:random-sequence($length as xs:integer) as xs:double* {
  r:random-sequence($length, fn:random-number-generator())
};

declare %private function r:random-sequence($length as xs:integer, 
                                            $G as map(xs:string, item())) {
  if ($length eq 0)
  then ()
  else ($G?number, r:random-sequence($length - 1, $G?next()))
};

r:random-sequence(200);
            
975 returns
declare %public function r:random-sequence($length as xs:integer) as xs:double* {
  r:random-sequence($length, fn:random-number-generator())
};

declare %private function r:random-sequence($length as xs:integer, 
                                            $G as map(xs:string, item())) {
  if ($length eq 0)
  then ()
  else ($G?number, r:random-sequence($length - 1, $G?next()))
};

r:random-sequence(200);
            
813.

The expression

declare %public function r:random-sequence($length as xs:integer) as xs:double* {
  r:random-sequence($length, fn:random-number-generator())
};

declare %private function r:random-sequence($length as xs:integer, 
                                            $G as map(xs:string, item())) {
  if ($length eq 0)
  then ()
  else ($G?number, r:random-sequence($length - 1, $G?next()))
};

r:random-sequence(200);
            
977 returns
declare %public function r:random-sequence($length as xs:integer) as xs:double* {
  r:random-sequence($length, fn:random-number-generator())
};

declare %private function r:random-sequence($length as xs:integer, 
                                            $G as map(xs:string, item())) {
  if ($length eq 0)
  then ()
  else ($G?number, r:random-sequence($length - 1, $G?next()))
};

r:random-sequence(200);
            
813.

The expression

declare %public function r:random-sequence($length as xs:integer) as xs:double* {
  r:random-sequence($length, fn:random-number-generator())
};

declare %private function r:random-sequence($length as xs:integer, 
                                            $G as map(xs:string, item())) {
  if ($length eq 0)
  then ()
  else ($G?number, r:random-sequence($length - 1, $G?next()))
};

r:random-sequence(200);
            
979 returns
declare %public function r:random-sequence($length as xs:integer) as xs:double* {
  r:random-sequence($length, fn:random-number-generator())
};

declare %private function r:random-sequence($length as xs:integer, 
                                            $G as map(xs:string, item())) {
  if ($length eq 0)
  then ()
  else ($G?number, r:random-sequence($length - 1, $G?next()))
};

r:random-sequence(200);
            
980.

17.3.12 array:for-each

Summary

Returns an array whose size is the same as

declare %public function r:random-sequence($length as xs:integer) as xs:double* {
  r:random-sequence($length, fn:random-number-generator())
};

declare %private function r:random-sequence($length as xs:integer, 
                                            $G as map(xs:string, item())) {
  if ($length eq 0)
  then ()
  else ($G?number, r:random-sequence($length - 1, $G?next()))
};

r:random-sequence(200);
            
696, in which each member is computed by applying
Primo Secondo Terzo Quarto Quinto ...
996 to the corresponding member of
Primo Secondo Terzo Quarto Quinto ...
999.

Signature

declare %public function r:random-sequence($length as xs:integer) as xs:double* {
  r:random-sequence($length, fn:random-number-generator())
};

declare %private function r:random-sequence($length as xs:integer, 
                                            $G as map(xs:string, item())) {
  if ($length eq 0)
  then ()
  else ($G?number, r:random-sequence($length - 1, $G?next()))
};

r:random-sequence(200);
            
725(
Primo Secondo Terzo Quarto Quinto ...
999
let $para := 
In a hole in the ground there lived a hobbit.
         
71
declare %public function r:random-sequence($length as xs:integer) as xs:double* {
  r:random-sequence($length, fn:random-number-generator())
};

declare %private function r:random-sequence($length as xs:integer, 
                                            $G as map(xs:string, item())) {
  if ($length eq 0)
  then ()
  else ($G?number, r:random-sequence($length - 1, $G?next()))
};

r:random-sequence(200);
            
001,
Primo Secondo Terzo Quarto Quinto ...
833
let $para := 
In a hole in the ground there lived a hobbit.
         
71
declare %public function r:random-sequence($length as xs:integer) as xs:double* {
  r:random-sequence($length, fn:random-number-generator())
};

declare %private function r:random-sequence($length as xs:integer, 
                                            $G as map(xs:string, item())) {
  if ($length eq 0)
  then ()
  else ($G?number, r:random-sequence($length - 1, $G?next()))
};

r:random-sequence(200);
            
990)
let $para := 
In a hole in the ground there lived a hobbit.
         
71
declare %public function r:random-sequence($length as xs:integer) as xs:double* {
  r:random-sequence($length, fn:random-number-generator())
};

declare %private function r:random-sequence($length as xs:integer, 
                                            $G as map(xs:string, item())) {
  if ($length eq 0)
  then ()
  else ($G?number, r:random-sequence($length - 1, $G?next()))
};

r:random-sequence(200);
            
001

Properties

This function is ·deterministic·, ·context-independent·, ·focus-independent·, and ·higher-order·.

Rules

Returns the result of the expression:

declare %public function r:random-sequence($length as xs:integer) as xs:double* {
  r:random-sequence($length, fn:random-number-generator())
};

declare %private function r:random-sequence($length as xs:integer, 
                                            $G as map(xs:string, item())) {
  if ($length eq 0)
  then ()
  else ($G?number, r:random-sequence($length - 1, $G?next()))
};

r:random-sequence(200);
            
993

Examples

The expression

declare %public function r:random-sequence($length as xs:integer) as xs:double* {
  r:random-sequence($length, fn:random-number-generator())
};

declare %private function r:random-sequence($length as xs:integer, 
                                            $G as map(xs:string, item())) {
  if ($length eq 0)
  then ()
  else ($G?number, r:random-sequence($length - 1, $G?next()))
};

r:random-sequence(200);
            
994 returns
declare %public function r:random-sequence($length as xs:integer) as xs:double* {
  r:random-sequence($length, fn:random-number-generator())
};

declare %private function r:random-sequence($length as xs:integer, 
                                            $G as map(xs:string, item())) {
  if ($length eq 0)
  then ()
  else ($G?number, r:random-sequence($length - 1, $G?next()))
};

r:random-sequence(200);
            
995.

The expression

declare %public function r:random-sequence($length as xs:integer) as xs:double* {
  r:random-sequence($length, fn:random-number-generator())
};

declare %private function r:random-sequence($length as xs:integer, 
                                            $G as map(xs:string, item())) {
  if ($length eq 0)
  then ()
  else ($G?number, r:random-sequence($length - 1, $G?next()))
};

r:random-sequence(200);
            
996 returns
declare %public function r:random-sequence($length as xs:integer) as xs:double* {
  r:random-sequence($length, fn:random-number-generator())
};

declare %private function r:random-sequence($length as xs:integer, 
                                            $G as map(xs:string, item())) {
  if ($length eq 0)
  then ()
  else ($G?number, r:random-sequence($length - 1, $G?next()))
};

r:random-sequence(200);
            
997.

17.3.13 array:filter

Summary

Returns an array containing those members of the

Primo Secondo Terzo Quarto Quinto ...
999 for which
Primo Secondo Terzo Quarto Quinto ...
996 returns true.

Signature

declare %public function r:random-sequence($length as xs:integer) as xs:double* {
  r:random-sequence($length, fn:random-number-generator())
};

declare %private function r:random-sequence($length as xs:integer, 
                                            $G as map(xs:string, item())) {
  if ($length eq 0)
  then ()
  else ($G?number, r:random-sequence($length - 1, $G?next()))
};

r:random-sequence(200);
            
729(
Primo Secondo Terzo Quarto Quinto ...
999
let $para := 
In a hole in the ground there lived a hobbit.
         
71
declare %public function r:random-sequence($length as xs:integer) as xs:double* {
  r:random-sequence($length, fn:random-number-generator())
};

declare %private function r:random-sequence($length as xs:integer, 
                                            $G as map(xs:string, item())) {
  if ($length eq 0)
  then ()
  else ($G?number, r:random-sequence($length - 1, $G?next()))
};

r:random-sequence(200);
            
001,
Primo Secondo Terzo Quarto Quinto ...
996
let $para := 
In a hole in the ground there lived a hobbit.
         
71
let $C := 'http://www.w3.org/2013/collation/UCA?strength=primary'
006)
let $para := 
In a hole in the ground there lived a hobbit.
         
71
declare %public function r:random-sequence($length as xs:integer) as xs:double* {
  r:random-sequence($length, fn:random-number-generator())
};

declare %private function r:random-sequence($length as xs:integer, 
                                            $G as map(xs:string, item())) {
  if ($length eq 0)
  then ()
  else ($G?number, r:random-sequence($length - 1, $G?next()))
};

r:random-sequence(200);
            
001

Properties

This function is ·deterministic·, ·context-independent·, ·focus-independent·, and ·higher-order·.

Rules

The effect of the function is equivalent to the following recursive definition:

let $para := 
In a hole in the ground there lived a hobbit.
         
05

Error Conditions

As a consequence of the function signature and the function calling rules, a type error occurs if the supplied function

Primo Secondo Terzo Quarto Quinto ...
996 returns anything other than a single
op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
32 item; there is no conversion to an effective boolean value.

Examples

The expression

let $C := 'http://www.w3.org/2013/collation/UCA?strength=primary'
011 returns
let $C := 'http://www.w3.org/2013/collation/UCA?strength=primary'
012.

The expression

let $C := 'http://www.w3.org/2013/collation/UCA?strength=primary'
013 returns
let $C := 'http://www.w3.org/2013/collation/UCA?strength=primary'
014.

The expression

let $C := 'http://www.w3.org/2013/collation/UCA?strength=primary'
015 returns
let $C := 'http://www.w3.org/2013/collation/UCA?strength=primary'
016.

17.3.14 array:fold-left

Summary

Evaluates the supplied function cumulatively on successive members of the supplied array.

Signature

declare %public function r:random-sequence($length as xs:integer) as xs:double* {
  r:random-sequence($length, fn:random-number-generator())
};

declare %private function r:random-sequence($length as xs:integer, 
                                            $G as map(xs:string, item())) {
  if ($length eq 0)
  then ()
  else ($G?number, r:random-sequence($length - 1, $G?next()))
};

r:random-sequence(200);
            
732(
Primo Secondo Terzo Quarto Quinto ...
999
let $para := 
In a hole in the ground there lived a hobbit.
         
71
declare %public function r:random-sequence($length as xs:integer) as xs:double* {
  r:random-sequence($length, fn:random-number-generator())
};

declare %private function r:random-sequence($length as xs:integer, 
                                            $G as map(xs:string, item())) {
  if ($length eq 0)
  then ()
  else ($G?number, r:random-sequence($length - 1, $G?next()))
};

r:random-sequence(200);
            
001,
1º 2º 3º 4º ...
975
let $para := 
In a hole in the ground there lived a hobbit.
         
71
op:operation(fenceHeight, xs:integer) => op:operation(xs:integer, xs:integer)
16,
Primo Secondo Terzo Quarto Quinto ...
996
let $para := 
In a hole in the ground there lived a hobbit.
         
71
let $C := 'http://www.w3.org/2013/collation/UCA?strength=primary'
026)
let $para := 
In a hole in the ground there lived a hobbit.
         
71
op:operation(fenceHeight, xs:integer) => op:operation(xs:integer, xs:integer)
16

Properties

This function is ·deterministic·, ·context-independent·, ·focus-independent·, and ·higher-order·.

Rules

The effect of the function is equivalent to the following recursive definition:

let $para := 
In a hole in the ground there lived a hobbit.
         
06

Notes

If the supplied array is empty, the function returns

1º 2º 3º 4º ...
975.

If the supplied array contains a single member

let $C := 'http://www.w3.org/2013/collation/UCA?strength=primary'
030, the function returns
let $C := 'http://www.w3.org/2013/collation/UCA?strength=primary'
031.

If the supplied array contains two members

let $C := 'http://www.w3.org/2013/collation/UCA?strength=primary'
030 and
let $C := 'http://www.w3.org/2013/collation/UCA?strength=primary'
033, the function returns
let $C := 'http://www.w3.org/2013/collation/UCA?strength=primary'
034; and similarly for an input array with more than two members.

Examples

The expression

let $C := 'http://www.w3.org/2013/collation/UCA?strength=primary'
035 returns
let $para := 
In a hole in the ground there lived a hobbit.
         
184. (Returns true if every member of the input array has an effective boolean value of
let $para := 
In a hole in the ground there lived a hobbit.
         
182.)

The expression

let $C := 'http://www.w3.org/2013/collation/UCA?strength=primary'
038 returns
let $para := 
In a hole in the ground there lived a hobbit.
         
182. (Returns true if at least one member of the input array has an effective boolean value of
let $para := 
In a hole in the ground there lived a hobbit.
         
182.)

The expression

let $C := 'http://www.w3.org/2013/collation/UCA?strength=primary'
041 returns
let $C := 'http://www.w3.org/2013/collation/UCA?strength=primary'
042.

17.3.15 array:fold-right

Summary

Evaluates the supplied function cumulatively on successive values of the supplied array.

Signature

declare %public function r:random-sequence($length as xs:integer) as xs:double* {
  r:random-sequence($length, fn:random-number-generator())
};

declare %private function r:random-sequence($length as xs:integer, 
                                            $G as map(xs:string, item())) {
  if ($length eq 0)
  then ()
  else ($G?number, r:random-sequence($length - 1, $G?next()))
};

r:random-sequence(200);
            
733(
Primo Secondo Terzo Quarto Quinto ...
999
let $para := 
In a hole in the ground there lived a hobbit.
         
71
declare %public function r:random-sequence($length as xs:integer) as xs:double* {
  r:random-sequence($length, fn:random-number-generator())
};

declare %private function r:random-sequence($length as xs:integer, 
                                            $G as map(xs:string, item())) {
  if ($length eq 0)
  then ()
  else ($G?number, r:random-sequence($length - 1, $G?next()))
};

r:random-sequence(200);
            
001,
1º 2º 3º 4º ...
975
let $para := 
In a hole in the ground there lived a hobbit.
         
71
op:operation(fenceHeight, xs:integer) => op:operation(xs:integer, xs:integer)
16,
Primo Secondo Terzo Quarto Quinto ...
996
let $para := 
In a hole in the ground there lived a hobbit.
         
71
let $C := 'http://www.w3.org/2013/collation/UCA?strength=primary'
026)
let $para := 
In a hole in the ground there lived a hobbit.
         
71
op:operation(fenceHeight, xs:integer) => op:operation(xs:integer, xs:integer)
16

Properties

This function is ·deterministic·, ·context-independent·, ·focus-independent·, and ·higher-order·.

Rules

The effect of the function is equivalent to the following recursive definition:

let $para := 
In a hole in the ground there lived a hobbit.
         
07

Notes

If the supplied array is empty, the function returns

1º 2º 3º 4º ...
975.

If the supplied array contains a single member

let $C := 'http://www.w3.org/2013/collation/UCA?strength=primary'
030, the function returns
let $C := 'http://www.w3.org/2013/collation/UCA?strength=primary'
057.

If the supplied array contains two members

let $C := 'http://www.w3.org/2013/collation/UCA?strength=primary'
030 and
let $C := 'http://www.w3.org/2013/collation/UCA?strength=primary'
033, the function returns
let $C := 'http://www.w3.org/2013/collation/UCA?strength=primary'
060; and similarly for an input array with more than two members.

Examples

The expression

let $C := 'http://www.w3.org/2013/collation/UCA?strength=primary'
061 returns
let $para := 
In a hole in the ground there lived a hobbit.
         
184. (Returns true if every member of the input array has an effective boolean value of
let $para := 
In a hole in the ground there lived a hobbit.
         
182.)

The expression

let $C := 'http://www.w3.org/2013/collation/UCA?strength=primary'
064 returns
let $para := 
In a hole in the ground there lived a hobbit.
         
182. (Returns true if at least one member of the input array has an effective boolean value of
let $para := 
In a hole in the ground there lived a hobbit.
         
182.)

The expression

let $C := 'http://www.w3.org/2013/collation/UCA?strength=primary'
067 returns
let $C := 'http://www.w3.org/2013/collation/UCA?strength=primary'
068.

17.3.16 array:for-each-pair

Summary

Returns an array obtained by evaluating the supplied function once for each pair of members at the same position in the two supplied arrays.

Signature

declare %public function r:random-sequence($length as xs:integer) as xs:double* {
  r:random-sequence($length, fn:random-number-generator())
};

declare %private function r:random-sequence($length as xs:integer, 
                                            $G as map(xs:string, item())) {
  if ($length eq 0)
  then ()
  else ($G?number, r:random-sequence($length - 1, $G?next()))
};

r:random-sequence(200);
            
734(
declare %public function r:random-sequence($length as xs:integer) as xs:double* {
  r:random-sequence($length, fn:random-number-generator())
};

declare %private function r:random-sequence($length as xs:integer, 
                                            $G as map(xs:string, item())) {
  if ($length eq 0)
  then ()
  else ($G?number, r:random-sequence($length - 1, $G?next()))
};

r:random-sequence(200);
            
701
let $para := 
In a hole in the ground there lived a hobbit.
         
71
declare %public function r:random-sequence($length as xs:integer) as xs:double* {
  r:random-sequence($length, fn:random-number-generator())
};

declare %private function r:random-sequence($length as xs:integer, 
                                            $G as map(xs:string, item())) {
  if ($length eq 0)
  then ()
  else ($G?number, r:random-sequence($length - 1, $G?next()))
};

r:random-sequence(200);
            
001,
declare %public function r:random-sequence($length as xs:integer) as xs:double* {
  r:random-sequence($length, fn:random-number-generator())
};

declare %private function r:random-sequence($length as xs:integer, 
                                            $G as map(xs:string, item())) {
  if ($length eq 0)
  then ()
  else ($G?number, r:random-sequence($length - 1, $G?next()))
};

r:random-sequence(200);
            
702
let $para := 
In a hole in the ground there lived a hobbit.
         
71
declare %public function r:random-sequence($length as xs:integer) as xs:double* {
  r:random-sequence($length, fn:random-number-generator())
};

declare %private function r:random-sequence($length as xs:integer, 
                                            $G as map(xs:string, item())) {
  if ($length eq 0)
  then ()
  else ($G?number, r:random-sequence($length - 1, $G?next()))
};

r:random-sequence(200);
            
001,
Primo Secondo Terzo Quarto Quinto ...
996
let $para := 
In a hole in the ground there lived a hobbit.
         
71
let $C := 'http://www.w3.org/2013/collation/UCA?strength=primary'
026)
let $para := 
In a hole in the ground there lived a hobbit.
         
71
declare %public function r:random-sequence($length as xs:integer) as xs:double* {
  r:random-sequence($length, fn:random-number-generator())
};

declare %private function r:random-sequence($length as xs:integer, 
                                            $G as map(xs:string, item())) {
  if ($length eq 0)
  then ()
  else ($G?number, r:random-sequence($length - 1, $G?next()))
};

r:random-sequence(200);
            
001

Properties

This function is ·deterministic·, ·context-independent·, ·focus-independent·, and ·higher-order·.

Rules

Returns the result of the recursive expression:

let $para := 
In a hole in the ground there lived a hobbit.
         
08

Notes

If the arrays have different size, excess members in the longer array are ignored.

Examples

The expression

let $C := 'http://www.w3.org/2013/collation/UCA?strength=primary'
081 returns
let $C := 'http://www.w3.org/2013/collation/UCA?strength=primary'
082.

The expression

let $C := 'http://www.w3.org/2013/collation/UCA?strength=primary'
083 returns
let $C := 'http://www.w3.org/2013/collation/UCA?strength=primary'
084.

17.3.17 array:sort

Summary

Returns an array containing all the members of the supplied array, sorted according to the value of a sort key supplied as a function.

Signatures

declare %public function r:random-sequence($length as xs:integer) as xs:double* {
  r:random-sequence($length, fn:random-number-generator())
};

declare %private function r:random-sequence($length as xs:integer, 
                                            $G as map(xs:string, item())) {
  if ($length eq 0)
  then ()
  else ($G?number, r:random-sequence($length - 1, $G?next()))
};

r:random-sequence(200);
            
735(
Primo Secondo Terzo Quarto Quinto ...
999
let $para := 
In a hole in the ground there lived a hobbit.
         
71
declare %public function r:random-sequence($length as xs:integer) as xs:double* {
  r:random-sequence($length, fn:random-number-generator())
};

declare %private function r:random-sequence($length as xs:integer, 
                                            $G as map(xs:string, item())) {
  if ($length eq 0)
  then ()
  else ($G?number, r:random-sequence($length - 1, $G?next()))
};

r:random-sequence(200);
            
001)
let $para := 
In a hole in the ground there lived a hobbit.
         
71
declare %public function r:random-sequence($length as xs:integer) as xs:double* {
  r:random-sequence($length, fn:random-number-generator())
};

declare %private function r:random-sequence($length as xs:integer, 
                                            $G as map(xs:string, item())) {
  if ($length eq 0)
  then ()
  else ($G?number, r:random-sequence($length - 1, $G?next()))
};

r:random-sequence(200);
            
001

declare %public function r:random-sequence($length as xs:integer) as xs:double* {
  r:random-sequence($length, fn:random-number-generator())
};

declare %private function r:random-sequence($length as xs:integer, 
                                            $G as map(xs:string, item())) {
  if ($length eq 0)
  then ()
  else ($G?number, r:random-sequence($length - 1, $G?next()))
};

r:random-sequence(200);
            
735(
Primo Secondo Terzo Quarto Quinto ...
999
let $para := 
In a hole in the ground there lived a hobbit.
         
71
declare %public function r:random-sequence($length as xs:integer) as xs:double* {
  r:random-sequence($length, fn:random-number-generator())
};

declare %private function r:random-sequence($length as xs:integer, 
                                            $G as map(xs:string, item())) {
  if ($length eq 0)
  then ()
  else ($G?number, r:random-sequence($length - 1, $G?next()))
};

r:random-sequence(200);
            
001,
let $para := 
In a hole in the ground there lived a hobbit.
         
128
let $para := 
In a hole in the ground there lived a hobbit.
         
71
let $para := 
In a hole in the ground there lived a hobbit.
         
244)
let $para := 
In a hole in the ground there lived a hobbit.
         
71
declare %public function r:random-sequence($length as xs:integer) as xs:double* {
  r:random-sequence($length, fn:random-number-generator())
};

declare %private function r:random-sequence($length as xs:integer, 
                                            $G as map(xs:string, item())) {
  if ($length eq 0)
  then ()
  else ($G?number, r:random-sequence($length - 1, $G?next()))
};

r:random-sequence(200);
            
001

declare %public function r:random-sequence($length as xs:integer) as xs:double* {
  r:random-sequence($length, fn:random-number-generator())
};

declare %private function r:random-sequence($length as xs:integer, 
                                            $G as map(xs:string, item())) {
  if ($length eq 0)
  then ()
  else ($G?number, r:random-sequence($length - 1, $G?next()))
};

r:random-sequence(200);
            
735(
Primo Secondo Terzo Quarto Quinto ...
999
let $para := 
In a hole in the ground there lived a hobbit.
         
71
declare %public function r:random-sequence($length as xs:integer) as xs:double* {
  r:random-sequence($length, fn:random-number-generator())
};

declare %private function r:random-sequence($length as xs:integer, 
                                            $G as map(xs:string, item())) {
  if ($length eq 0)
  then ()
  else ($G?number, r:random-sequence($length - 1, $G?next()))
};

r:random-sequence(200);
            
001,
let $para := 
In a hole in the ground there lived a hobbit.
         
128
let $para := 
In a hole in the ground there lived a hobbit.
         
71
let $para := 
In a hole in the ground there lived a hobbit.
         
244,
let $para := 
In a hole in the ground there lived a hobbit.
         
192
let $para := 
In a hole in the ground there lived a hobbit.
         
71
let $C := 'http://www.w3.org/2013/collation/UCA?strength=primary'
109)
let $para := 
In a hole in the ground there lived a hobbit.
         
71
declare %public function r:random-sequence($length as xs:integer) as xs:double* {
  r:random-sequence($length, fn:random-number-generator())
};

declare %private function r:random-sequence($length as xs:integer, 
                                            $G as map(xs:string, item())) {
  if ($length eq 0)
  then ()
  else ($G?number, r:random-sequence($length - 1, $G?next()))
};

r:random-sequence(200);
            
001

Properties

The one-argument form of this function is ·deterministic·, ·context-dependent·, and ·focus-independent·. It depends on collations.

The two-argument form of this function is ·deterministic·, ·context-dependent·, and ·focus-independent·. It depends on collations.

The two-argument form of this function is ·deterministic·, ·context-independent·, ·focus-independent·, and ·higher-order·.

Rules

Calling the single-argument version of the function is equivalent to calling the two-argument form with

Primo Secondo Terzo Quarto Quinto ...
960 as the second argument: that is, it sorts the members of an array according to the typed value of the items, using the default collation to compare strings.

Calling the two-argument version of the function is equivalent to calling the three-argument form with

Primo Secondo Terzo Quarto Quinto ...
961 as the third argument: that is, it sorts the members of an array according to the typed value of the items, using a specified collation to compare strings.

In the case of both

let $C := 'http://www.w3.org/2013/collation/UCA?strength=primary'
114 and
let $C := 'http://www.w3.org/2013/collation/UCA?strength=primary'
115, supplying an empty sequence as the second argument is equivalent to supplying
Primo Secondo Terzo Quarto Quinto ...
964. For more information on collations see 5.3.5 Choosing a collation.

The result of the function is obtained as follows:

  • For each member of the array

    Primo Secondo Terzo Quarto Quinto ...
    999, the function supplied as
    let $para := 
    In a hole in the ground there lived a hobbit.
             
    192 is evaluated with that member as its argument. The resulting values are the sort keys of the members of the array.

  • The result array contains the same members as the input array

    Primo Secondo Terzo Quarto Quinto ...
    999, but generally in a different order.

  • Let $C be the selected collation, or the default collation where applicable.

  • The order of items in the result is such that, given two items

    let $para := 
    In a hole in the ground there lived a hobbit.
             
    080 and
    let $para := 
    In a hole in the ground there lived a hobbit.
             
    081:

    • If

      Primo Secondo Terzo Quarto Quinto ...
      970, then the relative order of
      let $para := 
      In a hole in the ground there lived a hobbit.
               
      080 and
      let $para := 
      In a hole in the ground there lived a hobbit.
               
      081 in the output is the same as their relative order in the input (that is, the sort is stable)

    • Otherwise, if

      Primo Secondo Terzo Quarto Quinto ...
      973, then
      let $para := 
      In a hole in the ground there lived a hobbit.
               
      080 precedes
      let $para := 
      In a hole in the ground there lived a hobbit.
               
      081 in the output. The function
      Primo Secondo Terzo Quarto Quinto ...
      976 is defined as the boolean result of the expression:

      declare %public function r:random-sequence($length as xs:integer) as xs:double* {
        r:random-sequence($length, fn:random-number-generator())
      };
      
      declare %private function r:random-sequence($length as xs:integer, 
                                                  $G as map(xs:string, item())) {
        if ($length eq 0)
        then ()
        else ($G?number, r:random-sequence($length - 1, $G?next()))
      };
      
      r:random-sequence(200);
                  
      8

      where the function

      Primo Secondo Terzo Quarto Quinto ...
      977 returns true if and only if
      Primo Secondo Terzo Quarto Quinto ...
      978 is an instance of
      let $para := 
      In a hole in the ground there lived a hobbit.
               
      10,
      let $para := 
      In a hole in the ground there lived a hobbit.
               
      30, or
      let $para := 
      In a hole in the ground there lived a hobbit.
               
      00.

      This ordering of sequences is referred to by mathematicians as "lexicographic ordering".

Error Conditions

If the set of computed sort keys contains values that are not comparable using the

1º 2º 3º 4º ...
871 operator then the sort operation will fail with a dynamic error.

Examples

The expression

let $C := 'http://www.w3.org/2013/collation/UCA?strength=primary'
135 returns
let $C := 'http://www.w3.org/2013/collation/UCA?strength=primary'
136.

The expression

let $C := 'http://www.w3.org/2013/collation/UCA?strength=primary'
137 returns
let $C := 'http://www.w3.org/2013/collation/UCA?strength=primary'
138.

The expression

let $C := 'http://www.w3.org/2013/collation/UCA?strength=primary'
139 returns
let $C := 'http://www.w3.org/2013/collation/UCA?strength=primary'
140.

To sort an array of strings

1º 2º 3º 4º ...
336 using Swedish collation:

let $para := 
In a hole in the ground there lived a hobbit.
         
10

To sort an array of maps representing employees, using last name as the major sort key and first name as the minor sort key, with the default collation:

let $para := 
In a hole in the ground there lived a hobbit.
         
11

17.3.18 array:flatten

Summary

Replaces any array appearing in a supplied sequence with the members of the array, recursively.

Signature

declare %public function r:random-sequence($length as xs:integer) as xs:double* {
  r:random-sequence($length, fn:random-number-generator())
};

declare %private function r:random-sequence($length as xs:integer, 
                                            $G as map(xs:string, item())) {
  if ($length eq 0)
  then ()
  else ($G?number, r:random-sequence($length - 1, $G?next()))
};

r:random-sequence(200);
            
736(
let $para := 
In a hole in the ground there lived a hobbit.
         
232
let $para := 
In a hole in the ground there lived a hobbit.
         
71
op:operation(fenceHeight, xs:integer) => op:operation(xs:integer, xs:integer)
16)
let $para := 
In a hole in the ground there lived a hobbit.
         
71
op:operation(fenceHeight, xs:integer) => op:operation(xs:integer, xs:integer)
16

Properties

This function is ·deterministic·, ·context-independent·, and ·focus-independent·.

Rules

The function processes the items in the supplied sequence

let $para := 
In a hole in the ground there lived a hobbit.
         
232 as follows:

  • An item that is an array is replaced by its members, retaining order.

  • Any other item is retained unchanged.

The process is then repeated so long as the sequence contains an array among its items.

The function is equivalent to the following XQuery implementation (assuming static typing is not in force):

let $para := 
In a hole in the ground there lived a hobbit.
         
12

Notes

The argument to the function will often be a single array item, but this is not essential.

Unlike atomization, this function retains any nodes contained in the array.

Examples

The expression

let $C := 'http://www.w3.org/2013/collation/UCA?strength=primary'
149 returns
let $C := 'http://www.w3.org/2013/collation/UCA?strength=primary'
150.

The expression

let $C := 'http://www.w3.org/2013/collation/UCA?strength=primary'
151 returns
let $C := 'http://www.w3.org/2013/collation/UCA?strength=primary'
152.

The expression

let $C := 'http://www.w3.org/2013/collation/UCA?strength=primary'
153 returns
let $C := 'http://www.w3.org/2013/collation/UCA?strength=primary'
154.

17.4 Conversion to and from JSON

JSON is a popular format for exchange of structured data on the web: it is specified in [RFC 7159]. This section describes facilities allowing JSON data to be converted to and from XDM values.

This specification describes two ways of representing JSON data losslessly using XDM constructs. The first method uses XDM maps to represent JSON objects, and XDM arrays to represent JSON arrays. The second method represents all JSON constructs using XDM element and attribute nodes.

17.4.1 Representing JSON using maps and arrays

This section defines a mapping from JSON data to XDM maps and arrays. Two functions are available to support this mapping:

Primo Secondo Terzo Quarto Quinto ...
760 and
Primo Secondo Terzo Quarto Quinto ...
511 (with options selecting JSON as the output method). The
Primo Secondo Terzo Quarto Quinto ...
760 function will accept any JSON text as input, and converts it to XDM data values. The
Primo Secondo Terzo Quarto Quinto ...
511 function (with JSON as the output method) will accept any XDM value produced using
Primo Secondo Terzo Quarto Quinto ...
760 and convert it back to the original JSON text (subject to insignificant variations such as reordering the properties in a JSON object).

Note:

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

Primo Secondo Terzo Quarto Quinto ...
760 function has been chosen with ease of manipulation as a design aim. For example, a simple JSON object such as
let $C := 'http://www.w3.org/2013/collation/UCA?strength=primary'
161 produces a simple map, so if the result of parsing is held in
let $C := 'http://www.w3.org/2013/collation/UCA?strength=primary'
162, the number for a given weekday can be extracted using an expression such as
let $C := 'http://www.w3.org/2013/collation/UCA?strength=primary'
163. Similarly, a simple array such as
let $C := 'http://www.w3.org/2013/collation/UCA?strength=primary'
164 produces an array that can be addressed as, for example,
let $C := 'http://www.w3.org/2013/collation/UCA?strength=primary'
165. A more deeply nested structure can be addressed in a similar way: for example if the JSON text is an array of person objects, each of which has a property named "phones" which is an array of strings containing phone numbers, then the first phone number of each person in the data can be addressed as
let $C := 'http://www.w3.org/2013/collation/UCA?strength=primary'
166.

17.4.2 XML Representation of JSON

This section defines a mapping from JSON data to XML (specifically, to XDM element and attribute nodes). A function

op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
21 is provided to take a JSON string as input and convert it to the XML representation, and a second function
let $para := 
In a hole in the ground there lived a hobbit.
         
30 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, distinct JSON texts convert to distinct XML representations. When converting JSON to XML, options are provided to reject unsupported characters, to replace them with a substitute character, or to leave them in backslash-escaped form.

Note:

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 following example demonstrates the correspondence of a JSON text and the corresponding XML representation.

Example: A JSON Text and its XML Representation

Consider the following JSON text:

let $para := 
In a hole in the ground there lived a hobbit.
         
13

The XML representation of this text is as follows. Whitespace is included in the XML representation for purposes of illustration, but it will not necessarily be present in the output of the

let $C := 'http://www.w3.org/2013/collation/UCA?strength=primary'
169 function.

let $para := 
In a hole in the ground there lived a hobbit.
         
14

An XSD 1.0 schema for the XML representation is provided in C.2 Schema for the result of fn:json-to-xml. It is not necessary to import this schema into the static context unless the stylesheet or query makes explicit reference to the components defined in the schema. If the stylesheet or query does import a schema for the namespace

let $para := 
In a hole in the ground there lived a hobbit.
         
37, then:

  1. Unless the host language specifies otherwise, the processor (if it is schema-aware) must recognize an import declaration for this namespace, whether or not a schema location is supplied.

  2. If a schema location is provided, then the schema document at that location must be equivalent to the schema document at C.2 Schema for the result of fn:json-to-xml; the effect if it is not equivalent is ·implementation-dependent·

The rules governing the mapping from JSON to XML are as follows. In these rules, the phrase "an element named N" is to be interpreted as meaning "an element node whose local name is N and whose namespace URI is

let $para := 
In a hole in the ground there lived a hobbit.
         
37".

  1. The JSON value

    let $C := 'http://www.w3.org/2013/collation/UCA?strength=primary'
    172 is represented by an element named
    let $C := 'http://www.w3.org/2013/collation/UCA?strength=primary'
    172, with empty content.

  2. The JSON values

    op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
    76 and
    let $C := 'http://www.w3.org/2013/collation/UCA?strength=primary'
    07 are represented by an element named
    let $C := 'http://www.w3.org/2013/collation/UCA?strength=primary'
    176, with content conforming to the type
    op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
    32. When the element is created by the
    op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
    21 function, the string value of the element will be
    op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
    76 or
    let $C := 'http://www.w3.org/2013/collation/UCA?strength=primary'
    07. The
    let $para := 
    In a hole in the ground there lived a hobbit.
             
    30 function also recognizes other strings that validate as
    op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
    32, for example
    declare %public function r:random-sequence($length as xs:integer) as xs:double* {
      r:random-sequence($length, fn:random-number-generator())
    };
    
    declare %private function r:random-sequence($length as xs:integer, 
                                                $G as map(xs:string, item())) {
      if ($length eq 0)
      then ()
      else ($G?number, r:random-sequence($length - 1, $G?next()))
    };
    
    r:random-sequence(200);
                
    13 and
    declare %public function r:random-sequence($length as xs:integer) as xs:double* {
      r:random-sequence($length, fn:random-number-generator())
    };
    
    declare %private function r:random-sequence($length as xs:integer, 
                                                $G as map(xs:string, item())) {
      if ($length eq 0)
      then ()
      else ($G?number, r:random-sequence($length - 1, $G?next()))
    };
    
    r:random-sequence(200);
                
    19. Leading and trailing whitespace is accepted.

  3. A JSON number is represented by an element named

    let $para := 
    In a hole in the ground there lived a hobbit.
             
    012, with content conforming to the type
    let $para := 
    In a hole in the ground there lived a hobbit.
             
    26, with the additional restriction that the value must not be positive or negative infinity, nor
    fn:abs($N * $arg2) le fn:abs($arg1) 
                   and fn:compare($N * $arg2, 0) eq fn:compare($arg1, 0).
    90. The
    op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
    21 function creates an element whose string value is lexically the same as the JSON representation of the number. The
    let $para := 
    In a hole in the ground there lived a hobbit.
             
    30 function generates a JSON representation that is the result of casting the (typed or untyped) value of the node to
    let $para := 
    In a hole in the ground there lived a hobbit.
             
    26 and then casting the result to
    let $para := 
    In a hole in the ground there lived a hobbit.
             
    10. Leading and trailing whitespace is accepted. Since JSON does not impose limits on the range or precision of numbers, these rules mean that conversion from JSON to XML will always succeed, and will retain full precision in the lexical representation unless the data model implementation is one that reconstructs the string value from the typed value. In the reverse direction, conversion from XML to JSON may fail if the value is infinity or
    fn:abs($N * $arg2) le fn:abs($arg1) 
                   and fn:compare($N * $arg2, 0) eq fn:compare($arg1, 0).
    90, or if the string value is such that casting to
    let $para := 
    In a hole in the ground there lived a hobbit.
             
    26 produces positive or negative infinity.

  4. A JSON string is represented by an element named

    let $para := 
    In a hole in the ground there lived a hobbit.
             
    56, with content conforming to the type
    let $para := 
    In a hole in the ground there lived a hobbit.
             
    10. The
    let $para := 
    In a hole in the ground there lived a hobbit.
             
    56 element has two alternative representations: escaped form, and unescaped form.

  5. A JSON array is represented by an element named

    let $para := 
    In a hole in the ground there lived a hobbit.
             
    57. The content is a sequence of child elements representing the members of the array in order, each such element being the representation of the array member obtained by applying these rules recursively.

  6. A JSON object is represented by an element named

    let $para := 
    In a hole in the ground there lived a hobbit.
             
    53. The content is a sequence 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
    let $C := 'http://www.w3.org/2013/collation/UCA?strength=primary'
    199 (in no namespace), whose value is N as an instance of
    let $para := 
    In a hole in the ground there lived a hobbit.
             
    10. The functions
    op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
    21 and
    let $para := 
    In a hole in the ground there lived a hobbit.
             
    30 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.

The attribute

let $C := 'http://www.w3.org/2013/collation/UCA?strength=primary'
203 may be specified on a
let $para := 
In a hole in the ground there lived a hobbit.
         
56 element to indicate that the string value contains backslash-escaped characters that are to be interpreted according to the JSON rules. The attribute
let $C := 'http://www.w3.org/2013/collation/UCA?strength=primary'
205 may be specified on any element with a
let $C := 'http://www.w3.org/2013/collation/UCA?strength=primary'
199 attribute to indicate that the key contains backslash-escaped characters that are to be interpreted according to the JSON rules. Both attributes have the default value
let $C := 'http://www.w3.org/2013/collation/UCA?strength=primary'
07, signifying that the relevant value is in unescaped form. In unescaped form, the backslash character has no special significance (it represents itself).

The JSON grammar for

let $para := 
In a hole in the ground there lived a hobbit.
         
012 is a subset of the lexical space of the XSD type
let $para := 
In a hole in the ground there lived a hobbit.
         
26. The mapping from JSON
let $para := 
In a hole in the ground there lived a hobbit.
         
012 values to
let $para := 
In a hole in the ground there lived a hobbit.
         
26 values is defined by the XPath rules for casting from
let $para := 
In a hole in the ground there lived a hobbit.
         
10 to
let $para := 
In a hole in the ground there lived a hobbit.
         
26. Note that these rules will never generate an error for out-of-range values; instead very large or very small values will be converted to
let $para := 
In a hole in the ground there lived a hobbit.
         
27 or
1º 2º 3º 4º ...
57. Since JSON does not impose limits on the range or precision of numbers, the conversion is not guaranteed to retain full precision.

Although the order of entries in a JSON object is generally considered to have no significance, the functions

let $C := 'http://www.w3.org/2013/collation/UCA?strength=primary'
169 and
let $C := 'http://www.w3.org/2013/collation/UCA?strength=primary'
169 both retain order.

The XDM representation of a JSON value may either be untyped (all elements annotated as

let $C := 'http://www.w3.org/2013/collation/UCA?strength=primary'
218, attributes as
let $para := 
In a hole in the ground there lived a hobbit.
         
00), or it may be typed. If it is typed, then it must have the type annotations obtained by validating the untyped representation against the schema given in C.2 Schema for the result of fn:json-to-xml. If it is untyped, then it must be an XDM instance such that validation against this schema would succeed; with the proviso that all attributes other than those in no namespace or in namespace
let $para := 
In a hole in the ground there lived a hobbit.
         
37 are ignored, including attributes such as
let $C := 'http://www.w3.org/2013/collation/UCA?strength=primary'
221 and
let $C := 'http://www.w3.org/2013/collation/UCA?strength=primary'
222 that would normally influence the process of schema validation.

The namespace prefix associated with the namespace

let $para := 
In a hole in the ground there lived a hobbit.
         
37 (if any) is immaterial. The effect of the
let $para := 
In a hole in the ground there lived a hobbit.
         
30 function does not depend on the choice of prefix, and the prefix (if any) generated by the
op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
21 function is ·implementation-dependent·.

17.5 Functions on JSON Data

The functions listed parse or serialize JSON data.

FunctionMeaning
Primo Secondo Terzo Quarto Quinto ...
760Parses a string supplied in the form of a JSON text, returning the results typically in the form of a map or array.
let $para := 
In a hole in the ground there lived a hobbit.
         
40Reads an external resource containing JSON, and returns the result of parsing the resource as JSON.
op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
21Parses a string supplied in the form of a JSON text, returning the results in the form of an XML document node.
let $para := 
In a hole in the ground there lived a hobbit.
         
30Converts an XML tree, whose format corresponds to the XML representation of JSON defined in this specification, into a string conforming to the JSON grammar.

Note also that the function

Primo Secondo Terzo Quarto Quinto ...
511 has an option to act as the inverse function to
Primo Secondo Terzo Quarto Quinto ...
760.

17.5.1 fn:parse-json

Summary

Parses a string supplied in the form of a JSON text, returning the results typically in the form of a map or array.

Signatures

Primo Secondo Terzo Quarto Quinto ...
760(
let $C := 'http://www.w3.org/2013/collation/UCA?strength=primary'
233
let $para := 
In a hole in the ground there lived a hobbit.
         
71
let $para := 
In a hole in the ground there lived a hobbit.
         
244)
let $para := 
In a hole in the ground there lived a hobbit.
         
71
let $para := 
In a hole in the ground there lived a hobbit.
         
79

Primo Secondo Terzo Quarto Quinto ...
760(
let $C := 'http://www.w3.org/2013/collation/UCA?strength=primary'
233
let $para := 
In a hole in the ground there lived a hobbit.
         
71
let $para := 
In a hole in the ground there lived a hobbit.
         
244,
declare %public function r:random-sequence($length as xs:integer) as xs:double* {
  r:random-sequence($length, fn:random-number-generator())
};

declare %private function r:random-sequence($length as xs:integer, 
                                            $G as map(xs:string, item())) {
  if ($length eq 0)
  then ()
  else ($G?number, r:random-sequence($length - 1, $G?next()))
};

r:random-sequence(200);
            
030
let $para := 
In a hole in the ground there lived a hobbit.
         
71
let $para := 
In a hole in the ground there lived a hobbit.
         
32)
let $para := 
In a hole in the ground there lived a hobbit.
         
71
let $para := 
In a hole in the ground there lived a hobbit.
         
79

Properties

This function is ·deterministic·, ·context-independent·, and ·focus-independent·.

Rules

The effect of the one-argument form of this function is the same as calling the two-argument form with an empty map as the value of the

declare %public function r:random-sequence($length as xs:integer) as xs:double* {
  r:random-sequence($length, fn:random-number-generator())
};

declare %private function r:random-sequence($length as xs:integer, 
                                            $G as map(xs:string, item())) {
  if ($length eq 0)
  then ()
  else ($G?number, r:random-sequence($length - 1, $G?next()))
};

r:random-sequence(200);
            
030 argument.

The first argument is a JSON text as defined in [RFC 7159], in the form of a string. The function parses this string to return an XDM value.

If the value of

let $C := 'http://www.w3.org/2013/collation/UCA?strength=primary'
233 is the empty sequence, the function returns the empty sequence.

Note:

The result will also be an empty sequence if

let $C := 'http://www.w3.org/2013/collation/UCA?strength=primary'
233 is the string
let $C := 'http://www.w3.org/2013/collation/UCA?strength=primary'
250.

The

declare %public function r:random-sequence($length as xs:integer) as xs:double* {
  r:random-sequence($length, fn:random-number-generator())
};

declare %private function r:random-sequence($length as xs:integer, 
                                            $G as map(xs:string, item())) {
  if ($length eq 0)
  then ()
  else ($G?number, r:random-sequence($length - 1, $G?next()))
};

r:random-sequence(200);
            
030 argument can be used to control the way in which the parsing takes place. The ·option parameter conventions· apply.

The entries that may appear in the

declare %public function r:random-sequence($length as xs:integer) as xs:double* {
  r:random-sequence($length, fn:random-number-generator())
};

declare %private function r:random-sequence($length as xs:integer, 
                                            $G as map(xs:string, item())) {
  if ($length eq 0)
  then ()
  else ($G?number, r:random-sequence($length - 1, $G?next()))
};

r:random-sequence(200);
            
030 map are as follows:

KeyValueMeaning
let $C := 'http://www.w3.org/2013/collation/UCA?strength=primary'
253Determines whether deviations from the syntax of RFC7159 are permitted.
  • Type:

    op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
    32

  • Default:

    let $C := 'http://www.w3.org/2013/collation/UCA?strength=primary'
    07

let $C := 'http://www.w3.org/2013/collation/UCA?strength=primary'
07The input must consist of an optional byte order mark (which is ignored) followed by a string that conforms to the grammar of
let $C := 'http://www.w3.org/2013/collation/UCA?strength=primary'
257 in [RFC 7159]. An error must be raised [err:FOJS0001] if the input does not conform to the grammar.
op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
76The input may contain deviations from the grammar of [RFC 7159], which are handled in an ·implementation-defined· way. (Note: some popular extensions include allowing quotes on keys to be omitted, allowing a comma to appear after the last item in an array, allowing leading zeroes in numbers, and allowing control characters such as tab and newline to be present in unescaped form.) Since the extensions accepted are implementation-defined, an error may be raised [err:FOJS0001] if the input does not conform to the grammar.
declare %public function r:random-sequence($length as xs:integer) as xs:double* {
  r:random-sequence($length, fn:random-number-generator())
};

declare %private function r:random-sequence($length as xs:integer, 
                                            $G as map(xs:string, item())) {
  if ($length eq 0)
  then ()
  else ($G?number, r:random-sequence($length - 1, $G?next()))
};

r:random-sequence(200);
            
450Determines the policy for handling duplicate keys in a JSON object. To determine whether keys are duplicates, they are compared using the Unicode codepoint collation, after expanding escape sequences, unless the
let $C := 'http://www.w3.org/2013/collation/UCA?strength=primary'
260 option is set to
op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
76
, in which case keys are compared in escaped form.
  • Type:

    let $para := 
    In a hole in the ground there lived a hobbit.
             
    10

  • Default:

    declare %public function r:random-sequence($length as xs:integer) as xs:double* {
      r:random-sequence($length, fn:random-number-generator())
    };
    
    declare %private function r:random-sequence($length as xs:integer, 
                                                $G as map(xs:string, item())) {
      if ($length eq 0)
      then ()
      else ($G?number, r:random-sequence($length - 1, $G?next()))
    };
    
    r:random-sequence(200);
                
    453

declare %public function r:random-sequence($length as xs:integer) as xs:double* {
  r:random-sequence($length, fn:random-number-generator())
};

declare %private function r:random-sequence($length as xs:integer, 
                                            $G as map(xs:string, item())) {
  if ($length eq 0)
  then ()
  else ($G?number, r:random-sequence($length - 1, $G?next()))
};

r:random-sequence(200);
            
454An error is raised [err:FOJS0003] if duplicate keys are encountered.
declare %public function r:random-sequence($length as xs:integer) as xs:double* {
  r:random-sequence($length, fn:random-number-generator())
};

declare %private function r:random-sequence($length as xs:integer, 
                                            $G as map(xs:string, item())) {
  if ($length eq 0)
  then ()
  else ($G?number, r:random-sequence($length - 1, $G?next()))
};

r:random-sequence(200);
            
453If duplicate keys are present in a JSON object, all but the first of a set of duplicates are ignored.
declare %public function r:random-sequence($length as xs:integer) as xs:double* {
  r:random-sequence($length, fn:random-number-generator())
};

declare %private function r:random-sequence($length as xs:integer, 
                                            $G as map(xs:string, item())) {
  if ($length eq 0)
  then ()
  else ($G?number, r:random-sequence($length - 1, $G?next()))
};

r:random-sequence(200);
            
457If duplicate keys are present in a JSON object, all but the last of a set of duplicates are ignored.
let $C := 'http://www.w3.org/2013/collation/UCA?strength=primary'
260Determines whether special characters are represented in the XDM output in backslash-escaped form.
  • Type:

    op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
    32

  • Default:

    op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
    76

let $C := 'http://www.w3.org/2013/collation/UCA?strength=primary'
07All characters in the input that are valid in the version of XML supported by the implementation, whether or not they are represented in the input by means of an escape sequence, are represented as unescaped characters in the result. Any characters or codepoints that are not valid XML characters (for example, unpaired surrogates) are passed to the
let $para := 
In a hole in the ground there lived a hobbit.
         
094 function as described below; in the absence of a fallback function, they are replaced by the Unicode
let $C := 'http://www.w3.org/2013/collation/UCA?strength=primary'
272 (
let $C := 'http://www.w3.org/2013/collation/UCA?strength=primary'
273)
.
op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
76JSON escape sequences are used in the result to represent special characters in the JSON input, as defined below, whether or not they were represented using JSON escape sequences in the input. The characters that are considered "special" for this purpose are:
  • all codepoints in the range

    let $C := 'http://www.w3.org/2013/collation/UCA?strength=primary'
    275 to
    let $C := 'http://www.w3.org/2013/collation/UCA?strength=primary'
    276 or
    let $C := 'http://www.w3.org/2013/collation/UCA?strength=primary'
    277 to
    let $C := 'http://www.w3.org/2013/collation/UCA?strength=primary'
    278;

  • all codepoints that do not represent characters that are valid in the version of XML supported by the processor, including codepoints representing unpaired surrogates;

  • the backslash character itself (

    let $C := 'http://www.w3.org/2013/collation/UCA?strength=primary'
    279).

Such characters are represented using a two-character escape sequence where available (for example,
let $C := 'http://www.w3.org/2013/collation/UCA?strength=primary'
280), or a six-character escape sequence otherwise (for example
let $C := 'http://www.w3.org/2013/collation/UCA?strength=primary'
281). Characters other than these are not escaped in the result, even if they were escaped in the input.
let $para := 
In a hole in the ground there lived a hobbit.
         
094Provides a function which is called when the input contains an escape sequence that represents a character that is not valid in the version of XML supported by the implementation. It is an error to supply the
let $para := 
In a hole in the ground there lived a hobbit.
         
094 option if the
let $C := 'http://www.w3.org/2013/collation/UCA?strength=primary'
260 option is present with the value
op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
76.
  • Type:

    let $C := 'http://www.w3.org/2013/collation/UCA?strength=primary'
    286

  • Default:

    let $C := 'http://www.w3.org/2013/collation/UCA?strength=primary'
    287

let $C := 'http://www.w3.org/2013/collation/UCA?strength=primary'
288The function is called when the JSON input contains a special character (as defined under the
let $C := 'http://www.w3.org/2013/collation/UCA?strength=primary'
260 option) that is valid according to the JSON grammar, whether the special character is represented in the input directly or as an escape sequence. The function is called once for any surrogate that is not properly paired with another surrogate. The string supplied as the argument will always be a two- or six- character escape sequence, starting with a backslash, that conforms to the rules in the JSON grammar (as extended by the implementation if
let $C := 'http://www.w3.org/2013/collation/UCA?strength=primary'
290 is specified): for example
let $C := 'http://www.w3.org/2013/collation/UCA?strength=primary'
291 or
let $C := 'http://www.w3.org/2013/collation/UCA?strength=primary'
292 or
let $C := 'http://www.w3.org/2013/collation/UCA?strength=primary'
281. The function is not called for an escape sequence that is invalid against the grammar (for example
let $C := 'http://www.w3.org/2013/collation/UCA?strength=primary'
294). The function returns a string which is inserted into the result in place of the invalid character. The function also has the option of raising a dynamic error by calling
op:operation(fenceHeight, xs:integer) => op:operation(xs:integer, xs:integer)
78.

The various structures that can occur in JSON are transformed recursively to XDM values as follows:

  1. A JSON object is converted to a map. The entries in the map correspond to the key/value pairs in the JSON object. The key is always of type

    let $para := 
    In a hole in the ground there lived a hobbit.
             
    10; the associated value may be of any type, and is the result of converting the JSON value by recursive application of these rules. For example, the JSON text
    let $C := 'http://www.w3.org/2013/collation/UCA?strength=primary'
    297 is transformed to the value
    let $C := 'http://www.w3.org/2013/collation/UCA?strength=primary'
    298.

    If duplicate keys are encountered in a JSON object, they are handled as determined by the

    declare %public function r:random-sequence($length as xs:integer) as xs:double* {
      r:random-sequence($length, fn:random-number-generator())
    };
    
    declare %private function r:random-sequence($length as xs:integer, 
                                                $G as map(xs:string, item())) {
      if ($length eq 0)
      then ()
      else ($G?number, r:random-sequence($length - 1, $G?next()))
    };
    
    r:random-sequence(200);
                
    450 option defined above.

  2. A JSON array is transformed to an array whose members are the result of converting the corresponding member of the array by recursive application of these rules. For example, the JSON text

    let $C := 'http://www.w3.org/2013/collation/UCA?strength=primary'
    300 is transformed to the value
    let $C := 'http://www.w3.org/2013/collation/UCA?strength=primary'
    301.

  3. A JSON string is converted to an

    let $para := 
    In a hole in the ground there lived a hobbit.
             
    10 value. The handling of special characters depends on the
    let $C := 'http://www.w3.org/2013/collation/UCA?strength=primary'
    260 and
    let $para := 
    In a hole in the ground there lived a hobbit.
             
    094 options, as described in the table above.

  4. A JSON number is converted to an

    let $para := 
    In a hole in the ground there lived a hobbit.
             
    26 value using the rules for casting from
    let $para := 
    In a hole in the ground there lived a hobbit.
             
    10 to
    let $para := 
    In a hole in the ground there lived a hobbit.
             
    26.

  5. The JSON boolean values

    op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
    76 and
    let $C := 'http://www.w3.org/2013/collation/UCA?strength=primary'
    07 are converted to the corresponding
    op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
    32 values.

  6. The JSON value null is converted to the empty sequence.

Error Conditions

A dynamic error [err:FOJS0001] occurs if the value of

let $para := 
In a hole in the ground there lived a hobbit.
         
232 does not conform to the JSON grammar, unless the option
let $C := 'http://www.w3.org/2013/collation/UCA?strength=primary'
312 is present and the processor chooses to accept the deviation.

A dynamic error [err:FOJS0003] occurs if the option

let $C := 'http://www.w3.org/2013/collation/UCA?strength=primary'
313 is present and the value of
let $para := 
In a hole in the ground there lived a hobbit.
         
232 contains a JSON object with duplicate keys.

A dynamic error [err:FOJS0005] occurs if the

declare %public function r:random-sequence($length as xs:integer) as xs:double* {
  r:random-sequence($length, fn:random-number-generator())
};

declare %private function r:random-sequence($length as xs:integer, 
                                            $G as map(xs:string, item())) {
  if ($length eq 0)
  then ()
  else ($G?number, r:random-sequence($length - 1, $G?next()))
};

r:random-sequence(200);
            
030 map contains an entry whose key is defined in this specification and whose value is not valid for that key, or if it contains an entry with the key
let $para := 
In a hole in the ground there lived a hobbit.
         
094 when the option
let $C := 'http://www.w3.org/2013/collation/UCA?strength=primary'
317 is also present.

Notes

The result of the function will be an instance of one of the following types. An

let $C := 'http://www.w3.org/2013/collation/UCA?strength=primary'
318 test (or in XQuery,
let $C := 'http://www.w3.org/2013/collation/UCA?strength=primary'
319) can be used to distinguish them:

  • let $C := 'http://www.w3.org/2013/collation/UCA?strength=primary'
    320 for a JSON object

  • let $C := 'http://www.w3.org/2013/collation/UCA?strength=primary'
    321 for a JSON array

  • let $para := 
    In a hole in the ground there lived a hobbit.
             
    10 for a JSON string

  • let $para := 
    In a hole in the ground there lived a hobbit.
             
    26 for a JSON number

  • op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
    32 for a JSON boolean

  • let $C := 'http://www.w3.org/2013/collation/UCA?strength=primary'
    325 for a JSON null (or for empty input)

If the input starts with a byte order mark, this function ignores it. The byte order mark may have been added to the data stream in order to facilitate decoding of an octet stream to a character string, but since this function takes a character string as input, the byte order mark serves no useful purpose.

The possibility of the input containing characters that are not valid in XML (for example, unpaired surrogates) arises only when such characters are expressed using JSON escape sequences. The is because the input to the function is an instance of

let $para := 
In a hole in the ground there lived a hobbit.
         
10, which by definition can only contain characters that are valid in XML.

Examples

The expression

let $C := 'http://www.w3.org/2013/collation/UCA?strength=primary'
327 returns
let $C := 'http://www.w3.org/2013/collation/UCA?strength=primary'
328.

The expression

let $C := 'http://www.w3.org/2013/collation/UCA?strength=primary'
329 returns
Primo Secondo Terzo Quarto Quinto ...
529.

The expression

let $C := 'http://www.w3.org/2013/collation/UCA?strength=primary'
331 returns
let $C := 'http://www.w3.org/2013/collation/UCA?strength=primary'
332.

The expression

let $C := 'http://www.w3.org/2013/collation/UCA?strength=primary'
333 returns
let $C := 'http://www.w3.org/2013/collation/UCA?strength=primary'
334.

The expression

let $C := 'http://www.w3.org/2013/collation/UCA?strength=primary'
335 returns
let $C := 'http://www.w3.org/2013/collation/UCA?strength=primary'
336.

The expression

let $C := 'http://www.w3.org/2013/collation/UCA?strength=primary'
337 returns
let $C := 'http://www.w3.org/2013/collation/UCA?strength=primary'
338.

The expression

let $C := 'http://www.w3.org/2013/collation/UCA?strength=primary'
339 returns
let $C := 'http://www.w3.org/2013/collation/UCA?strength=primary'
340.

17.5.2 fn:json-doc

Summary

Reads an external resource containing JSON, and returns the result of parsing the resource as JSON.

Signatures

let $para := 
In a hole in the ground there lived a hobbit.
         
40(
Primo Secondo Terzo Quarto Quinto ...
400
let $para := 
In a hole in the ground there lived a hobbit.
         
71
let $para := 
In a hole in the ground there lived a hobbit.
         
244)
let $para := 
In a hole in the ground there lived a hobbit.
         
71
let $para := 
In a hole in the ground there lived a hobbit.
         
79

let $para := 
In a hole in the ground there lived a hobbit.
         
40(
Primo Secondo Terzo Quarto Quinto ...
400
let $para := 
In a hole in the ground there lived a hobbit.
         
71
let $para := 
In a hole in the ground there lived a hobbit.
         
244,
declare %public function r:random-sequence($length as xs:integer) as xs:double* {
  r:random-sequence($length, fn:random-number-generator())
};

declare %private function r:random-sequence($length as xs:integer, 
                                            $G as map(xs:string, item())) {
  if ($length eq 0)
  then ()
  else ($G?number, r:random-sequence($length - 1, $G?next()))
};

r:random-sequence(200);
            
030
let $para := 
In a hole in the ground there lived a hobbit.
         
71
let $para := 
In a hole in the ground there lived a hobbit.
         
32)
let $para := 
In a hole in the ground there lived a hobbit.
         
71
let $para := 
In a hole in the ground there lived a hobbit.
         
79

Properties

This function is ·deterministic·, ·context-dependent·, and ·focus-independent·. It depends on static base URI.

Rules

The effect of the single-argument call

let $C := 'http://www.w3.org/2013/collation/UCA?strength=primary'
356 is the same as the effect of the two-argument call
let $C := 'http://www.w3.org/2013/collation/UCA?strength=primary'
357 where an empty map is supplied as the second argument.

The effect of the two-argument function call

let $C := 'http://www.w3.org/2013/collation/UCA?strength=primary'
358is equivalent to the function composition
let $C := 'http://www.w3.org/2013/collation/UCA?strength=primary'
359; except that:

  1. The function may accept a resource in any encoding. [RFC 7159] requires UTF-8, UTF-16, or UTF-32 to be accepted, but it is not an error if a different encoding is used. Unless external encoding information is available, the function must assume that the encoding is one of UTF-8, UTF-16, or UTF-32, and must distinguish these cases by examination of the initial octets of the resource.

  2. If the resource contains characters that are not valid in the version of XML used by the processor, then rather than raising an error as

    let $C := 'http://www.w3.org/2013/collation/UCA?strength=primary'
    360 does, the function replaces such characters by the equivalent JSON escape sequence prior to parsing.

    Note:

    Equivalently, the implementation can use some other internal representation of strings that allows non-XML characters to be manipulated.

If the value of

Primo Secondo Terzo Quarto Quinto ...
400 is the empty sequence, the function returns the empty sequence.

Error Conditions

The function may raise any error defined for the

Primo Secondo Terzo Quarto Quinto ...
311 or
Primo Secondo Terzo Quarto Quinto ...
760 functions.

Notes

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

Primo Secondo Terzo Quarto Quinto ...
311 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,

let $C := 'http://www.w3.org/2013/collation/UCA?strength=primary'
292), and the JSON escape sequence is then passed to the fallback function specified in the
declare %public function r:random-sequence($length as xs:integer) as xs:double* {
  r:random-sequence($length, fn:random-number-generator())
};

declare %private function r:random-sequence($length as xs:integer, 
                                            $G as map(xs:string, item())) {
  if ($length eq 0)
  then ()
  else ($G?number, r:random-sequence($length - 1, $G?next()))
};

r:random-sequence(200);
            
030 argument, which in turn defaults to a function that returns the Unicode
let $C := 'http://www.w3.org/2013/collation/UCA?strength=primary'
272 (
let $C := 'http://www.w3.org/2013/collation/UCA?strength=primary'
273).

17.5.3 fn:json-to-xml

Summary

Parses a string supplied in the form of a JSON text, returning the results in the form of an XML document node.

Signatures

op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
21(
let $C := 'http://www.w3.org/2013/collation/UCA?strength=primary'
233
let $para := 
In a hole in the ground there lived a hobbit.
         
71
let $para := 
In a hole in the ground there lived a hobbit.
         
244)
let $para := 
In a hole in the ground there lived a hobbit.
         
71
Primo Secondo Terzo Quarto Quinto ...
326

op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
21(
let $C := 'http://www.w3.org/2013/collation/UCA?strength=primary'
233
let $para := 
In a hole in the ground there lived a hobbit.
         
71
let $para := 
In a hole in the ground there lived a hobbit.
         
244,
declare %public function r:random-sequence($length as xs:integer) as xs:double* {
  r:random-sequence($length, fn:random-number-generator())
};

declare %private function r:random-sequence($length as xs:integer, 
                                            $G as map(xs:string, item())) {
  if ($length eq 0)
  then ()
  else ($G?number, r:random-sequence($length - 1, $G?next()))
};

r:random-sequence(200);
            
030
let $para := 
In a hole in the ground there lived a hobbit.
         
71
let $para := 
In a hole in the ground there lived a hobbit.
         
32)
let $para := 
In a hole in the ground there lived a hobbit.
         
71
Primo Secondo Terzo Quarto Quinto ...
326

Properties

This function is ·nondeterministic·, ·context-dependent·, and ·focus-independent·. It depends on static base URI.

Rules

The effect of the one-argument form of this function is the same as calling the two-argument form with an empty map as the value of the

declare %public function r:random-sequence($length as xs:integer) as xs:double* {
  r:random-sequence($length, fn:random-number-generator())
};

declare %private function r:random-sequence($length as xs:integer, 
                                            $G as map(xs:string, item())) {
  if ($length eq 0)
  then ()
  else ($G?number, r:random-sequence($length - 1, $G?next()))
};

r:random-sequence(200);
            
030 argument.

The first argument is a JSON-text as defined in [RFC 7159], in the form of a string. The function parses this string to return an XDM node.

If

let $C := 'http://www.w3.org/2013/collation/UCA?strength=primary'
233 is an empty sequence, the function returns the empty sequence.

The

declare %public function r:random-sequence($length as xs:integer) as xs:double* {
  r:random-sequence($length, fn:random-number-generator())
};

declare %private function r:random-sequence($length as xs:integer, 
                                            $G as map(xs:string, item())) {
  if ($length eq 0)
  then ()
  else ($G?number, r:random-sequence($length - 1, $G?next()))
};

r:random-sequence(200);
            
030 argument can be used to control the way in which the parsing takes place. The ·option parameter conventions· apply.

The entries that may appear in the

declare %public function r:random-sequence($length as xs:integer) as xs:double* {
  r:random-sequence($length, fn:random-number-generator())
};

declare %private function r:random-sequence($length as xs:integer, 
                                            $G as map(xs:string, item())) {
  if ($length eq 0)
  then ()
  else ($G?number, r:random-sequence($length - 1, $G?next()))
};

r:random-sequence(200);
            
030 map are as follows:

KeyValueMeaning
let $C := 'http://www.w3.org/2013/collation/UCA?strength=primary'
253Determines whether deviations from the syntax of RFC7159 are permitted.
  • Type:

    op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
    32

  • Default:

    let $C := 'http://www.w3.org/2013/collation/UCA?strength=primary'
    07

let $C := 'http://www.w3.org/2013/collation/UCA?strength=primary'
07The input must consist of an optional byte order mark (which is ignored) followed by a string that conforms to the grammar of
let $C := 'http://www.w3.org/2013/collation/UCA?strength=primary'
257 in [RFC 7159]. An error must be raised (see below) if the input does not conform to the grammar.
op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
76The input may contain deviations from the grammar of [RFC 7159], which are handled in an ·implementation-defined· way. (Note: some popular extensions include allowing quotes on keys to be omitted, allowing a comma to appear after the last item in an array, allowing leading zeroes in numbers, and allowing control characters such as tab and newline to be present in unescaped form.) Since the extensions accepted are implementation-defined, an error may be raised (see below) if the input does not conform to the grammar.
declare %public function r:random-sequence($length as xs:integer) as xs:double* {
  r:random-sequence($length, fn:random-number-generator())
};

declare %private function r:random-sequence($length as xs:integer, 
                                            $G as map(xs:string, item())) {
  if ($length eq 0)
  then ()
  else ($G?number, r:random-sequence($length - 1, $G?next()))
};

r:random-sequence(200);
            
450Determines the policy for handling duplicate keys in a JSON object. To determine whether keys are duplicates, they are compared using the Unicode codepoint collation, after expanding escape sequences, unless the
let $C := 'http://www.w3.org/2013/collation/UCA?strength=primary'
260 option is set to
op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
76
, in which case keys are compared in escaped form.
  • Type:

    let $para := 
    In a hole in the ground there lived a hobbit.
             
    10

  • Default:

    let $C := 'http://www.w3.org/2013/collation/UCA?strength=primary'
    398

declare %public function r:random-sequence($length as xs:integer) as xs:double* {
  r:random-sequence($length, fn:random-number-generator())
};

declare %private function r:random-sequence($length as xs:integer, 
                                            $G as map(xs:string, item())) {
  if ($length eq 0)
  then ()
  else ($G?number, r:random-sequence($length - 1, $G?next()))
};

r:random-sequence(200);
            
454An error is raised [err:FOJS0003] if duplicate keys are encountered.
declare %public function r:random-sequence($length as xs:integer) as xs:double* {
  r:random-sequence($length, fn:random-number-generator())
};

declare %private function r:random-sequence($length as xs:integer, 
                                            $G as map(xs:string, item())) {
  if ($length eq 0)
  then ()
  else ($G?number, r:random-sequence($length - 1, $G?next()))
};

r:random-sequence(200);
            
453If duplicate keys are present in a JSON object, all but the first of a set of duplicates are ignored.
let $C := 'http://www.w3.org/2013/collation/UCA?strength=primary'
401If duplicate keys are present in a JSON object, the XML result of the function will also contain duplicates (making it invalid against the schema). This value is therefore incompatible with the option
let $C := 'http://www.w3.org/2013/collation/UCA?strength=primary'
402 [err:FOJS0005]
let $C := 'http://www.w3.org/2013/collation/UCA?strength=primary'
403Determines whether the generated XML tree is schema-validated.
  • Type:

    op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
    32

  • Default:

    let $C := 'http://www.w3.org/2013/collation/UCA?strength=primary'
    405

op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
76Indicates that the resulting XDM instance must be typed; that is, the element and attribute nodes must carry the type annotations that result from validation against the schema given at C.2 Schema for the result of fn:json-to-xml, or against an ·implementation-defined· schema if the
let $C := 'http://www.w3.org/2013/collation/UCA?strength=primary'
253 option has the value
op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
76.
let $C := 'http://www.w3.org/2013/collation/UCA?strength=primary'
07Indicates that the resulting XDM instance must be untyped.
let $C := 'http://www.w3.org/2013/collation/UCA?strength=primary'
260Determines whether special characters are represented in the XDM output in backslash-escaped form.
  • Type:

    op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
    32

  • Default:

    let $C := 'http://www.w3.org/2013/collation/UCA?strength=primary'
    07

let $C := 'http://www.w3.org/2013/collation/UCA?strength=primary'
07All characters in the input that are valid in the version of XML supported by the implementation, whether or not they are represented in the input by means of an escape sequence, are represented as unescaped characters in the result. Any characters or codepoints that are not valid XML characters (for example, unpaired surrogates) are passed to the
let $para := 
In a hole in the ground there lived a hobbit.
         
094 function as described below; in the absence of a fallback function, they are replaced by the Unicode
let $C := 'http://www.w3.org/2013/collation/UCA?strength=primary'
272 (
let $C := 'http://www.w3.org/2013/collation/UCA?strength=primary'
273)
. The attributes
let $C := 'http://www.w3.org/2013/collation/UCA?strength=primary'
417 and
let $C := 'http://www.w3.org/2013/collation/UCA?strength=primary'
418 will not be present in the XDM output.
op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
76JSON escape sequences are used in the result to represent special characters in the JSON input, as defined below, whether or not they were represented using JSON escape sequences in the input. The characters that are considered "special" for this purpose are:
  • all codepoints in the range

    let $C := 'http://www.w3.org/2013/collation/UCA?strength=primary'
    275 to
    let $C := 'http://www.w3.org/2013/collation/UCA?strength=primary'
    276 or
    let $C := 'http://www.w3.org/2013/collation/UCA?strength=primary'
    277 to
    let $C := 'http://www.w3.org/2013/collation/UCA?strength=primary'
    278;

  • all codepoints that do not represent characters that are valid in the version of XML supported by the processor, including codepoints representing unpaired surrogates;

  • the backslash character itself (

    let $C := 'http://www.w3.org/2013/collation/UCA?strength=primary'
    279).

Such characters are represented using a two-character escape sequence where available (for example,
let $C := 'http://www.w3.org/2013/collation/UCA?strength=primary'
280), or a six-character escape sequence otherwise (for example
let $C := 'http://www.w3.org/2013/collation/UCA?strength=primary'
281). Characters other than these will not be escaped in the result, even if they were escaped in the input. In the result:
  • Any

    let $para := 
    In a hole in the ground there lived a hobbit.
             
    56 element whose string value contains a backslash character must have the attribute value
    let $C := 'http://www.w3.org/2013/collation/UCA?strength=primary'
    203.

  • Any element that contains a

    let $C := 'http://www.w3.org/2013/collation/UCA?strength=primary'
    199 attribute whose string value contains a backslash character must have the attribute
    let $C := 'http://www.w3.org/2013/collation/UCA?strength=primary'
    205.

  • The values of the

    let $C := 'http://www.w3.org/2013/collation/UCA?strength=primary'
    417 and
    let $C := 'http://www.w3.org/2013/collation/UCA?strength=primary'
    418 attributes are immaterial when there is no backslash present, and it is never necessary to include either attribute when its value is
    let $C := 'http://www.w3.org/2013/collation/UCA?strength=primary'
    07.

let $para := 
In a hole in the ground there lived a hobbit.
         
094Provides a function which is called when the input contains an escape sequence that represents a character that is not valid in the version of XML supported by the implementation. It is an error to supply the
let $para := 
In a hole in the ground there lived a hobbit.
         
094 option if the
let $C := 'http://www.w3.org/2013/collation/UCA?strength=primary'
260 option is present with the value
op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
76.
  • Type:

    let $C := 'http://www.w3.org/2013/collation/UCA?strength=primary'
    286

  • Default:

    let $C := 'http://www.w3.org/2013/collation/UCA?strength=primary'
    287

let $C := 'http://www.w3.org/2013/collation/UCA?strength=primary'
288The function is called when the JSON input contains an escape sequence that is valid according to the JSON grammar, but which does not represent a character that is valid in the version of XML supported by the processor. In the case of surrogates, the function is called once for any six-character escape sequence that is not properly paired with another surrogate. The string supplied as the argument will always be a two- or six- character escape sequence, starting with a backslash, that conforms to the rules in the JSON grammar (as extended by the implementation if
let $C := 'http://www.w3.org/2013/collation/UCA?strength=primary'
290 is specified): for example
let $C := 'http://www.w3.org/2013/collation/UCA?strength=primary'
291 or
let $C := 'http://www.w3.org/2013/collation/UCA?strength=primary'
292 or
let $C := 'http://www.w3.org/2013/collation/UCA?strength=primary'
281. The function is not called for an escape sequence that is invalid against the grammar (for example
let $C := 'http://www.w3.org/2013/collation/UCA?strength=primary'
294). The function returns a string which is inserted into the result in place of the invalid character. The function also has the option of raising a dynamic error by calling
op:operation(fenceHeight, xs:integer) => op:operation(xs:integer, xs:integer)
78.

The various structures that can occur in JSON are transformed recursively to XDM values according to the rules given in 17.4.2 XML Representation of JSON.

The function returns a document node, whose only child is the element node representing the outermost construct in the JSON text.

The function is ·non-deterministic with respect to node identity·: that is, if the function is called twice with the same arguments, it is ·implementation-dependent· whether the same node is returned on both occasions.

The base URI of the returned document node is taken from the static base URI of the function call.

The choice of namespace prefix (or absence of a prefix) in the names of constructed nodes is ·implementation-dependant·.

The XDM tree returned by the function does not contain any unnecessary (albeit valid) nodes such as whitespace text nodes, comments, or processing instructions. It does not include any whitespace in the value of

let $para := 
In a hole in the ground there lived a hobbit.
         
012 or
let $C := 'http://www.w3.org/2013/collation/UCA?strength=primary'
176 element nodes, or in the value of
let $C := 'http://www.w3.org/2013/collation/UCA?strength=primary'
417 or
let $C := 'http://www.w3.org/2013/collation/UCA?strength=primary'
418 attribute nodes.

If the result is typed, every element named

let $para := 
In a hole in the ground there lived a hobbit.
         
56 will have an attribute named
let $C := 'http://www.w3.org/2013/collation/UCA?strength=primary'
417 whose value is either
op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
76 or
let $C := 'http://www.w3.org/2013/collation/UCA?strength=primary'
07, and every element having an attribute named
let $C := 'http://www.w3.org/2013/collation/UCA?strength=primary'
199 will also have an attribute named
let $C := 'http://www.w3.org/2013/collation/UCA?strength=primary'
418 whose value is either
op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
76 or
let $C := 'http://www.w3.org/2013/collation/UCA?strength=primary'
07.

If the result is untyped, the attributes

let $C := 'http://www.w3.org/2013/collation/UCA?strength=primary'
417 and
let $C := 'http://www.w3.org/2013/collation/UCA?strength=primary'
418 will either be present with the value
op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
76, or will be absent. They will never be present with the value
let $C := 'http://www.w3.org/2013/collation/UCA?strength=primary'
07.

Error Conditions

An error is raised [err:FOJS0001] if the value of

let $para := 
In a hole in the ground there lived a hobbit.
         
232 does not conform to the JSON grammar as defined by [RFC 7159], unless the option
let $C := 'http://www.w3.org/2013/collation/UCA?strength=primary'
312 is present and the processor chooses to accept the deviation.

An error is raised [err:FOJS0004] if the value of the

let $C := 'http://www.w3.org/2013/collation/UCA?strength=primary'
403 option is
op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
76 and the processor does not support schema validation or typed data.

An error is raised [err:FOJS0005] if the value of

declare %public function r:random-sequence($length as xs:integer) as xs:double* {
  r:random-sequence($length, fn:random-number-generator())
};

declare %private function r:random-sequence($length as xs:integer, 
                                            $G as map(xs:string, item())) {
  if ($length eq 0)
  then ()
  else ($G?number, r:random-sequence($length - 1, $G?next()))
};

r:random-sequence(200);
            
030 includes an entry whose key is defined in this specification, and whose value is not a permitted value for that key.

Notes

To read a JSON file, this function can be used in conjunction with the

Primo Secondo Terzo Quarto Quinto ...
311 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

let $C := 'http://www.w3.org/2013/collation/UCA?strength=primary'
469 is provided to allow such deviations from the specification to be accepted. Some JSON implementations also allow constructors such as
let $C := 'http://www.w3.org/2013/collation/UCA?strength=primary'
470 to appear as values: specifying
let $C := 'http://www.w3.org/2013/collation/UCA?strength=primary'
469 allows such extensions to be accepted, but does not guarantee it. If such extensions are accepted, the resulting value is implementation-defined, and will not necessarily conform to the schema at C.2 Schema for the result of fn:json-to-xml.

If the input starts with a byte order mark, this function ignores it. The byte order mark may have been added to the data stream in order to facilitate decoding of an octet stream to a character string, but since this function takes a character string as input, the byte order mark serves no useful purpose.

The possibility of the input containing characters that are not valid in XML (for example, unpaired surrogates) arises only when such characters are expressed using JSON escape sequences. The is because the input to the function is an instance of

let $para := 
In a hole in the ground there lived a hobbit.
         
10, which by definition can only contain characters that are valid in XML.

Examples

The expression

let $C := 'http://www.w3.org/2013/collation/UCA?strength=primary'
473 returns (with whitespace added for legibility):

let $para := 
In a hole in the ground there lived a hobbit.
         
15

The expression

let $C := 'http://www.w3.org/2013/collation/UCA?strength=primary'
474 returns
let $C := 'http://www.w3.org/2013/collation/UCA?strength=primary'
475.

The expression

let $C := 'http://www.w3.org/2013/collation/UCA?strength=primary'
476 returns (with whitespace added for legibility):

let $para := 
In a hole in the ground there lived a hobbit.
         
16

The expression

let $C := 'http://www.w3.org/2013/collation/UCA?strength=primary'
477 returns (with whitespace added for legibility):

let $para := 
In a hole in the ground there lived a hobbit.
         
17

The following example illustrates use of the

let $para := 
In a hole in the ground there lived a hobbit.
         
094 function to handle characters that are invalid in XML.

let $para := 
In a hole in the ground there lived a hobbit.
         
18

17.5.4 fn:xml-to-json

Summary

Converts an XML tree, whose format corresponds to the XML representation of JSON defined in this specification, into a string conforming to the JSON grammar.

Signatures

let $para := 
In a hole in the ground there lived a hobbit.
         
30(
let $para := 
In a hole in the ground there lived a hobbit.
         
232
let $para := 
In a hole in the ground there lived a hobbit.
         
71
op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
51)
let $para := 
In a hole in the ground there lived a hobbit.
         
71
let $para := 
In a hole in the ground there lived a hobbit.
         
244

let $para := 
In a hole in the ground there lived a hobbit.
         
30(
let $para := 
In a hole in the ground there lived a hobbit.
         
232
let $para := 
In a hole in the ground there lived a hobbit.
         
71
op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
51,
declare %public function r:random-sequence($length as xs:integer) as xs:double* {
  r:random-sequence($length, fn:random-number-generator())
};

declare %private function r:random-sequence($length as xs:integer, 
                                            $G as map(xs:string, item())) {
  if ($length eq 0)
  then ()
  else ($G?number, r:random-sequence($length - 1, $G?next()))
};

r:random-sequence(200);
            
030
let $para := 
In a hole in the ground there lived a hobbit.
         
71
let $para := 
In a hole in the ground there lived a hobbit.
         
32)
let $para := 
In a hole in the ground there lived a hobbit.
         
71
let $para := 
In a hole in the ground there lived a hobbit.
         
244

Properties

This function is ·deterministic·, ·context-independent·, and ·focus-independent·.

Rules

The effect of the one-argument form of this function is the same as calling the two-argument form with an empty map as the value of the

declare %public function r:random-sequence($length as xs:integer) as xs:double* {
  r:random-sequence($length, fn:random-number-generator())
};

declare %private function r:random-sequence($length as xs:integer, 
                                            $G as map(xs:string, item())) {
  if ($length eq 0)
  then ()
  else ($G?number, r:random-sequence($length - 1, $G?next()))
};

r:random-sequence(200);
            
030 argument.

The first argument

let $para := 
In a hole in the ground there lived a hobbit.
         
232 is a node; the subtree rooted at this node will typically be the XML representation of a JSON document as defined in 17.4.2 XML Representation of JSON.

If

let $para := 
In a hole in the ground there lived a hobbit.
         
232 is the empty sequence, the function returns the empty sequence.

The

declare %public function r:random-sequence($length as xs:integer) as xs:double* {
  r:random-sequence($length, fn:random-number-generator())
};

declare %private function r:random-sequence($length as xs:integer, 
                                            $G as map(xs:string, item())) {
  if ($length eq 0)
  then ()
  else ($G?number, r:random-sequence($length - 1, $G?next()))
};

r:random-sequence(200);
            
030 argument can be used to control the way in which the conversion takes place. The ·option parameter conventions· apply.

The entries that may appear in the

declare %public function r:random-sequence($length as xs:integer) as xs:double* {
  r:random-sequence($length, fn:random-number-generator())
};

declare %private function r:random-sequence($length as xs:integer, 
                                            $G as map(xs:string, item())) {
  if ($length eq 0)
  then ()
  else ($G?number, r:random-sequence($length - 1, $G?next()))
};

r:random-sequence(200);
            
030 map are as follows:

KeyValueMeaning
Primo Secondo Terzo Quarto Quinto ...
619Determines whether additional whitespace should be added to the output to improve readability.
  • Type:

    op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
    32

  • Default:

    let $C := 'http://www.w3.org/2013/collation/UCA?strength=primary'
    07

let $C := 'http://www.w3.org/2013/collation/UCA?strength=primary'
07The processor must not insert any insignificant whitespace between JSON tokens.
op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
76The processor may insert whitespace between JSON tokens in order to improve readability. The specification imposes no constraints on how this is done.

The node supplied as

let $para := 
In a hole in the ground there lived a hobbit.
         
232 must be one of the following: [err:FOJS0006]

  1. An element node whose name matches the name of a global element declaration in the schema given in C.2 Schema for the result of fn:json-to-xml ("the schema") and that is valid as defined below:

    1. If the type annotation of the element matches the type of the relevant element declaration in the schema (indicating that the element has been validated against the schema), then the element is considered valid.

    2. Otherwise, the processor may attempt to validate the element against the schema, in which case it is treated as valid if and only if the outcome of validation is valid.

    3. Otherwise (if the processor does not attempt validation using the schema), the processor must ensure that the content of the element, after stripping all attributes (at any depth) in namespaces other than

      let $para := 
      In a hole in the ground there lived a hobbit.
               
      37, is such that validation against the schema would have an outcome of valid.

      Note:

      The process described here is not precisely equivalent to schema validation. For example, schema validation will fail if there is an invalid

      let $C := 'http://www.w3.org/2013/collation/UCA?strength=primary'
      221 or
      let $C := 'http://www.w3.org/2013/collation/UCA?strength=primary'
      222 attribute, whereas this process will ignore such attributes.

  2. An element node E having a

    let $C := 'http://www.w3.org/2013/collation/UCA?strength=primary'
    199 attribute and/or an
    let $C := 'http://www.w3.org/2013/collation/UCA?strength=primary'
    418 attribute provided that E would satisfy one of the above conditions if the
    let $C := 'http://www.w3.org/2013/collation/UCA?strength=primary'
    199 and/or
    let $C := 'http://www.w3.org/2013/collation/UCA?strength=primary'
    418 attributes were removed.

  3. A document node having exactly one element child and no text node children, where the element child satisfies one of the conditions above.

Furthermore,

let $para := 
In a hole in the ground there lived a hobbit.
         
232 must satisfy the following constraint (which cannot be conveniently expressed in the schema). Every element M that is a descendant-or-self of
let $para := 
In a hole in the ground there lived a hobbit.
         
232 and has local name
let $para := 
In a hole in the ground there lived a hobbit.
         
53 and namespace URI
let $para := 
In a hole in the ground there lived a hobbit.
         
37 must satisfy the following rule: there must not be two distinct children of M (say C1 and C2) such that the normalized key of C1 is equal to the normalized key of C2. The normalized key of an element C is as follows:

  • If C has the attribute value

    let $C := 'http://www.w3.org/2013/collation/UCA?strength=primary'
    205, then the value of the
    let $C := 'http://www.w3.org/2013/collation/UCA?strength=primary'
    199 attribute of C, with all JSON escape sequences replaced by the corresponding Unicode characters according to the JSON escaping rules.

  • Otherwise (the

    let $C := 'http://www.w3.org/2013/collation/UCA?strength=primary'
    418 attribute of C is absent or set to false), the value of the
    let $C := 'http://www.w3.org/2013/collation/UCA?strength=primary'
    199 attribute of C.

Nodes in the input tree are handled by applying the following rules, recursively. In these rules the term "an element named N" means "an element node whose local name is N and whose namespace URI is

let $para := 
In a hole in the ground there lived a hobbit.
         
37".

  1. A document node having a single element node child is processed by processing that child.

  2. An element named

    let $C := 'http://www.w3.org/2013/collation/UCA?strength=primary'
    172 results in the output
    let $C := 'http://www.w3.org/2013/collation/UCA?strength=primary'
    172.

  3. An element

    let $C := 'http://www.w3.org/2013/collation/UCA?strength=primary'
    523 named
    let $C := 'http://www.w3.org/2013/collation/UCA?strength=primary'
    176 results in the output
    op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
    76 or
    let $C := 'http://www.w3.org/2013/collation/UCA?strength=primary'
    07 depending on the result of
    let $C := 'http://www.w3.org/2013/collation/UCA?strength=primary'
    527
    .

  4. An element

    let $C := 'http://www.w3.org/2013/collation/UCA?strength=primary'
    523 named
    let $para := 
    In a hole in the ground there lived a hobbit.
             
    012 results in the output of the string result of
    let $C := 'http://www.w3.org/2013/collation/UCA?strength=primary'
    530

  5. An element named

    let $para := 
    In a hole in the ground there lived a hobbit.
             
    56 results in the output of the string value of the element, enclosed in quotation marks, with any special characters in the string escaped as described below.

  6. An element named

    let $para := 
    In a hole in the ground there lived a hobbit.
             
    57 results in the output of the children of the
    let $para := 
    In a hole in the ground there lived a hobbit.
             
    57 element, each processed by applying these rules recursively: the items in the resulting list are enclosed between square brackets, and separated by commas.

  7. An element named

    let $para := 
    In a hole in the ground there lived a hobbit.
             
    53 results in the output of a sequence of map entries corresponding to the children of the
    let $para := 
    In a hole in the ground there lived a hobbit.
             
    53 element, enclosed between curly braces and separated by commas. Each entry comprises the value of the
    let $C := 'http://www.w3.org/2013/collation/UCA?strength=primary'
    199 attribute of the child element, enclosed in quotation marks and escaped as described below, followed by a colon, followed by the result of processing the child element by applying these rules recursively.

  8. Comments, processing instructions, and whitespace text node children of

    let $para := 
    In a hole in the ground there lived a hobbit.
             
    53 and
    let $para := 
    In a hole in the ground there lived a hobbit.
             
    57 are ignored.

Strings are escaped as follows:

  1. If the attribute

    let $C := 'http://www.w3.org/2013/collation/UCA?strength=primary'
    203 is present for a string value, or
    let $C := 'http://www.w3.org/2013/collation/UCA?strength=primary'
    205 for a key value, then:

    1. any valid JSON escape sequence present in the string is copied unchanged to the output;

    2. any invalid JSON escape sequence results in a dynamic error [err:FOJS0007];

    3. any unescaped occurrence of quotation mark, backspace, form-feed, newline, carriage return, tab, or solidus is replaced by

      let $C := 'http://www.w3.org/2013/collation/UCA?strength=primary'
      541,
      let $C := 'http://www.w3.org/2013/collation/UCA?strength=primary'
      291,
      let $C := 'http://www.w3.org/2013/collation/UCA?strength=primary'
      543,
      let $C := 'http://www.w3.org/2013/collation/UCA?strength=primary'
      544,
      let $C := 'http://www.w3.org/2013/collation/UCA?strength=primary'
      545,
      let $C := 'http://www.w3.org/2013/collation/UCA?strength=primary'
      280, or
      let $C := 'http://www.w3.org/2013/collation/UCA?strength=primary'
      547
      respectively;

    4. any other codepoint in the range 1-31 or 127-159 is replaced by an escape in the form \uHHHH where HHHH is the upper-case hexadecimal representation of the codepoint value.

  2. Otherwise (that is, in the absence of the attribute

    let $C := 'http://www.w3.org/2013/collation/UCA?strength=primary'
    203 for a string value, or
    let $C := 'http://www.w3.org/2013/collation/UCA?strength=primary'
    205 for a key value):

    1. any occurrence of backslash is replaced by

      op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
      096

    2. any occurrence of quotation mark, backspace, form-feed, newline, carriage return, or tab is replaced by

      let $C := 'http://www.w3.org/2013/collation/UCA?strength=primary'
      541,
      let $C := 'http://www.w3.org/2013/collation/UCA?strength=primary'
      291,
      let $C := 'http://www.w3.org/2013/collation/UCA?strength=primary'
      543,
      let $C := 'http://www.w3.org/2013/collation/UCA?strength=primary'
      544,
      let $C := 'http://www.w3.org/2013/collation/UCA?strength=primary'
      545, or
      let $C := 'http://www.w3.org/2013/collation/UCA?strength=primary'
      280 respectively;

    3. any other codepoint in the range 1-31 or 127-159 is replaced by an escape in the form

      let $C := 'http://www.w3.org/2013/collation/UCA?strength=primary'
      557 where
      let $C := 'http://www.w3.org/2013/collation/UCA?strength=primary'
      558 is the upper-case hexadecimal representation of the codepoint value.

Error Conditions

A dynamic error is raised [err:FOJS0005] if the value of

declare %public function r:random-sequence($length as xs:integer) as xs:double* {
  r:random-sequence($length, fn:random-number-generator())
};

declare %private function r:random-sequence($length as xs:integer, 
                                            $G as map(xs:string, item())) {
  if ($length eq 0)
  then ()
  else ($G?number, r:random-sequence($length - 1, $G?next()))
};

r:random-sequence(200);
            
030 includes an entry whose key is defined in this specification, and whose value is not a permitted value for that key.

A dynamic error is raised [err:FOJS0006] if the value of

let $para := 
In a hole in the ground there lived a hobbit.
         
232 is not a document or element node or is not valid according to the schema for the XML representation of JSON, or if a
let $para := 
In a hole in the ground there lived a hobbit.
         
53 element has two children whose normalized key values are the same.

A dynamic error is raised [err:FOJS0007] if the value of

let $para := 
In a hole in the ground there lived a hobbit.
         
232 includes a string labeled with
let $C := 'http://www.w3.org/2013/collation/UCA?strength=primary'
203, or a key labeled with
let $C := 'http://www.w3.org/2013/collation/UCA?strength=primary'
205, where the content of the string or key contains an invalid JSON escape sequence: specifically, where it contains a backslash (
let $para := 
In a hole in the ground there lived a hobbit.
         
921) that is not followed by one of the characters
let $C := 'http://www.w3.org/2013/collation/UCA?strength=primary'
566,
let $para := 
In a hole in the ground there lived a hobbit.
         
921,
let $C := 'http://www.w3.org/2013/collation/UCA?strength=primary'
568,
declare %public function r:random-sequence($length as xs:integer) as xs:double* {
  r:random-sequence($length, fn:random-number-generator())
};

declare %private function r:random-sequence($length as xs:integer, 
                                            $G as map(xs:string, item())) {
  if ($length eq 0)
  then ()
  else ($G?number, r:random-sequence($length - 1, $G?next()))
};

r:random-sequence(200);
            
40,
fn:abs($N * $arg2) le fn:abs($arg1) 
               and fn:compare($N * $arg2, 0) eq fn:compare($arg1, 0).
501,
fn:abs($N * $arg2) le fn:abs($arg1) 
               and fn:compare($N * $arg2, 0) eq fn:compare($arg1, 0).
464,
let $C := 'http://www.w3.org/2013/collation/UCA?strength=primary'
572,
let $para := 
In a hole in the ground there lived a hobbit.
         
303, or
let $C := 'http://www.w3.org/2013/collation/UCA?strength=primary'
574, or where it contains the characters
let $C := 'http://www.w3.org/2013/collation/UCA?strength=primary'
575 not followed by four hexadecimal digits (that is
let $C := 'http://www.w3.org/2013/collation/UCA?strength=primary'
576).

Notes

The rule requiring schema validity has a number of consequences, including the following:

  1. The input cannot contain no-namespace attributes, or attributes in the namespace

    let $para := 
    In a hole in the ground there lived a hobbit.
             
    37, except where explicitly allowed by the schema. Attributes in other namespaces, however, are ignored.

  2. Nodes that do not affect schema validity, such as comments, processing instructions, namespace nodes, and whitespace text node children of

    let $para := 
    In a hole in the ground there lived a hobbit.
             
    53 and
    let $para := 
    In a hole in the ground there lived a hobbit.
             
    57, are ignored.

  3. Numeric values are restricted to those that are valid in JSON: the schema disallows positive and negative infinity and NaN.

  4. Duplicate key values are not permitted. Most cases of duplicate keys are prevented by the rules in the schema; additional cases (where the keys are equal only after expanding JSON escape sequences) are prevented by the prose rules of this function. For example, the key values

    let $C := 'http://www.w3.org/2013/collation/UCA?strength=primary'
    544 and
    let $C := 'http://www.w3.org/2013/collation/UCA?strength=primary'
    581 are treated as duplicates even though the rules in the schema do not treat them as such.

The rule allowing the top-level element to have a

let $C := 'http://www.w3.org/2013/collation/UCA?strength=primary'
199 attribute (which is ignored) allows any element in the output of the
op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
21 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
let $C := 'http://www.w3.org/2013/collation/UCA?strength=primary'
199 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 accepted if it has been validated against one of the types
let $C := 'http://www.w3.org/2013/collation/UCA?strength=primary'
585,
let $C := 'http://www.w3.org/2013/collation/UCA?strength=primary'
586,
let $C := 'http://www.w3.org/2013/collation/UCA?strength=primary'
587,
let $C := 'http://www.w3.org/2013/collation/UCA?strength=primary'
588,
let $C := 'http://www.w3.org/2013/collation/UCA?strength=primary'
589, or
let $C := 'http://www.w3.org/2013/collation/UCA?strength=primary'
590.

Examples

The input

let $C := 'http://www.w3.org/2013/collation/UCA?strength=primary'
591 produces the result
let $C := 'http://www.w3.org/2013/collation/UCA?strength=primary'
592.

The input

let $C := 'http://www.w3.org/2013/collation/UCA?strength=primary'
593 produces the result
let $C := 'http://www.w3.org/2013/collation/UCA?strength=primary'
594.

18 Constructor functions

This section describes constructor functions corresponding to simple types defined in [XML Schema Part 2: Datatypes Second Edition]. Constructor functions are used to convert a supplied value to a given type. They always take a single argument, and the name of the function is the same as the name of the target type.

Constructor functions are defined for all user-defined named simple types, and for most built-in atomic, list, and union types. The only named simple types that have no constructor function are those that have no instances other than instances of their derived types: specifically,

let $C := 'http://www.w3.org/2013/collation/UCA?strength=primary'
595,
let $para := 
In a hole in the ground there lived a hobbit.
         
34, and
1º 2º 3º 4º ...
021.

18.1 Constructor functions for XML Schema built-in atomic types

Every built-in atomic type that is defined in [XML Schema Part 2: Datatypes Second Edition], except

let $para := 
In a hole in the ground there lived a hobbit.
         
34 and
1º 2º 3º 4º ...
021, has an associated constructor function. The type
let $para := 
In a hole in the ground there lived a hobbit.
         
00, defined in Section 2.7 Schema Information DM31 and the two derived types
let $para := 
In a hole in the ground there lived a hobbit.
         
24 and
let $para := 
In a hole in the ground there lived a hobbit.
         
25 defined in Section 2.7 Schema Information DM31 also have associated constructor functions. Implementations may additionally provide a constructor functions for the new datatype
let $para := 
In a hole in the ground there lived a hobbit.
         
23 introduced in [Schema 1.1 Part 2].

A constructor function is not defined for

let $para := 
In a hole in the ground there lived a hobbit.
         
34 as there are no atomic values with type annotation
let $para := 
In a hole in the ground there lived a hobbit.
         
34 at runtime, although this can be a statically inferred type. A constructor function is not defined for
1º 2º 3º 4º ...
021 since it is defined as an abstract type in [XML Schema Part 2: Datatypes Second Edition]. If the static context (See Section 2.1.1 Static Context XP31) contains a type derived from
1º 2º 3º 4º ...
021 then a constructor function is defined for it. See 18.5 Constructor functions for user-defined types.

The form of the constructor function for an atomic type eg:TYPE is:

let $C := 'http://www.w3.org/2013/collation/UCA?strength=primary'
608(
let $para := 
In a hole in the ground there lived a hobbit.
         
25
let $para := 
In a hole in the ground there lived a hobbit.
         
71
let $para := 
In a hole in the ground there lived a hobbit.
         
196)
let $para := 
In a hole in the ground there lived a hobbit.
         
71
let $C := 'http://www.w3.org/2013/collation/UCA?strength=primary'
613

If

let $para := 
In a hole in the ground there lived a hobbit.
         
25 is the empty sequence, the empty sequence is returned. For example, the signature of the constructor function corresponding to the
let $C := 'http://www.w3.org/2013/collation/UCA?strength=primary'
615 type defined in [XML Schema Part 2: Datatypes Second Edition] is:

let $C := 'http://www.w3.org/2013/collation/UCA?strength=primary'
615(
let $para := 
In a hole in the ground there lived a hobbit.
         
25
let $para := 
In a hole in the ground there lived a hobbit.
         
71
let $para := 
In a hole in the ground there lived a hobbit.
         
196)
let $para := 
In a hole in the ground there lived a hobbit.
         
71
let $C := 'http://www.w3.org/2013/collation/UCA?strength=primary'
621

Calling the constructor function

let $C := 'http://www.w3.org/2013/collation/UCA?strength=primary'
622 returns the
let $C := 'http://www.w3.org/2013/collation/UCA?strength=primary'
615 value 12. Another call of that constructor function that returns the same
let $C := 'http://www.w3.org/2013/collation/UCA?strength=primary'
615 value is
let $C := 'http://www.w3.org/2013/collation/UCA?strength=primary'
625. The same result would also be returned if the constructor function were to be called with a node that had a typed value equal to the
let $C := 'http://www.w3.org/2013/collation/UCA?strength=primary'
615 12. The standard features described in Section 2.4.2 Atomization XP31 would atomize the node to extract its typed value and then call the constructor with that value. If the value passed to a constructor is not in the lexical space of the datatype to be constructed, and cannot be converted to a value in the value space of the datatype under the rules in this specification, then an dynamic error is raised [err:FORG0001].

The semantics of the constructor function

let $C := 'http://www.w3.org/2013/collation/UCA?strength=primary'
627 are identical to the semantics of
let $C := 'http://www.w3.org/2013/collation/UCA?strength=primary'
628 cast as
let $C := 'http://www.w3.org/2013/collation/UCA?strength=primary'
629 . See 19 Casting.

If the argument to a constructor function is a literal, the result of the function may be evaluated statically; if an error is found during such evaluation, it may be reported as a static error.

Special rules apply to constructor functions for

let $para := 
In a hole in the ground there lived a hobbit.
         
36 and types derived from
let $para := 
In a hole in the ground there lived a hobbit.
         
36 and
1º 2º 3º 4º ...
021. See 18.2 Constructor functions for xs:QName and xs:NOTATION.

The following constructor functions for the built-in atomic types are supported:

  • let $para := 
    In a hole in the ground there lived a hobbit.
             
    10(
    let $para := 
    In a hole in the ground there lived a hobbit.
             
    25
    let $para := 
    In a hole in the ground there lived a hobbit.
             
    71
    let $para := 
    In a hole in the ground there lived a hobbit.
             
    196)
    let $para := 
    In a hole in the ground there lived a hobbit.
             
    71
    let $para := 
    In a hole in the ground there lived a hobbit.
             
    244

  • op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
    32(
    let $para := 
    In a hole in the ground there lived a hobbit.
             
    25
    let $para := 
    In a hole in the ground there lived a hobbit.
             
    71
    let $para := 
    In a hole in the ground there lived a hobbit.
             
    196)
    let $para := 
    In a hole in the ground there lived a hobbit.
             
    71
    op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
    63

  • let $para := 
    In a hole in the ground there lived a hobbit.
             
    82(
    let $para := 
    In a hole in the ground there lived a hobbit.
             
    25
    let $para := 
    In a hole in the ground there lived a hobbit.
             
    71
    let $para := 
    In a hole in the ground there lived a hobbit.
             
    196)
    let $para := 
    In a hole in the ground there lived a hobbit.
             
    71
    op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
    728

  • let $para := 
    In a hole in the ground there lived a hobbit.
             
    83(
    let $para := 
    In a hole in the ground there lived a hobbit.
             
    25
    let $para := 
    In a hole in the ground there lived a hobbit.
             
    71
    let $para := 
    In a hole in the ground there lived a hobbit.
             
    196)
    let $para := 
    In a hole in the ground there lived a hobbit.
             
    71
    let $C := 'http://www.w3.org/2013/collation/UCA?strength=primary'
    656

    Implementations should return negative zero for

    let $C := 'http://www.w3.org/2013/collation/UCA?strength=primary'
    657. But because [XML Schema Part 2: Datatypes Second Edition] does not distinguish between the values positive zero and negative zero, implementations may return positive zero in this case.

  • let $para := 
    In a hole in the ground there lived a hobbit.
             
    26(
    let $para := 
    In a hole in the ground there lived a hobbit.
             
    25
    let $para := 
    In a hole in the ground there lived a hobbit.
             
    71
    let $para := 
    In a hole in the ground there lived a hobbit.
             
    196)
    let $para := 
    In a hole in the ground there lived a hobbit.
             
    71
    let $para := 
    In a hole in the ground there lived a hobbit.
             
    29

    Implementations should return negative zero for

    let $C := 'http://www.w3.org/2013/collation/UCA?strength=primary'
    664. But because [XML Schema Part 2: Datatypes Second Edition] does not distinguish between the values positive zero and negative zero, implementations may return positive zero in this case.

  • op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
    489(
    let $para := 
    In a hole in the ground there lived a hobbit.
             
    25
    let $para := 
    In a hole in the ground there lived a hobbit.
             
    71
    let $para := 
    In a hole in the ground there lived a hobbit.
             
    196)
    let $para := 
    In a hole in the ground there lived a hobbit.
             
    71
    op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
    626

  • let $para := 
    In a hole in the ground there lived a hobbit.
             
    29(
    let $para := 
    In a hole in the ground there lived a hobbit.
             
    25
    let $para := 
    In a hole in the ground there lived a hobbit.
             
    71
    let $para := 
    In a hole in the ground there lived a hobbit.
             
    196)
    let $para := 
    In a hole in the ground there lived a hobbit.
             
    71
    op:operation(fenceHeight, xs:integer) => op:operation(xs:integer, xs:integer)
    038

  • op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
    965(
    let $para := 
    In a hole in the ground there lived a hobbit.
             
    25
    let $para := 
    In a hole in the ground there lived a hobbit.
             
    71
    let $para := 
    In a hole in the ground there lived a hobbit.
             
    196)
    let $para := 
    In a hole in the ground there lived a hobbit.
             
    71
    op:operation(fenceHeight, xs:integer) => op:operation(xs:integer, xs:integer)
    036

  • op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
    964(
    let $para := 
    In a hole in the ground there lived a hobbit.
             
    25
    let $para := 
    In a hole in the ground there lived a hobbit.
             
    71
    let $para := 
    In a hole in the ground there lived a hobbit.
             
    196)
    let $para := 
    In a hole in the ground there lived a hobbit.
             
    71
    op:operation(fenceHeight, xs:integer) => op:operation(xs:integer, xs:integer)
    033

  • op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
    966(
    let $para := 
    In a hole in the ground there lived a hobbit.
             
    25
    let $para := 
    In a hole in the ground there lived a hobbit.
             
    71
    let $para := 
    In a hole in the ground there lived a hobbit.
             
    196)
    let $para := 
    In a hole in the ground there lived a hobbit.
             
    71
    let $C := 'http://www.w3.org/2013/collation/UCA?strength=primary'
    694

  • op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
    967(
    let $para := 
    In a hole in the ground there lived a hobbit.
             
    25
    let $para := 
    In a hole in the ground there lived a hobbit.
             
    71
    let $para := 
    In a hole in the ground there lived a hobbit.
             
    196)
    let $para := 
    In a hole in the ground there lived a hobbit.
             
    71
    let $C := 'http://www.w3.org/2013/collation/UCA?strength=primary'
    700

  • op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
    968(
    let $para := 
    In a hole in the ground there lived a hobbit.
             
    25
    let $para := 
    In a hole in the ground there lived a hobbit.
             
    71
    let $para := 
    In a hole in the ground there lived a hobbit.
             
    196)
    let $para := 
    In a hole in the ground there lived a hobbit.
             
    71
    let $C := 'http://www.w3.org/2013/collation/UCA?strength=primary'
    706

  • op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
    970(
    let $para := 
    In a hole in the ground there lived a hobbit.
             
    25
    let $para := 
    In a hole in the ground there lived a hobbit.
             
    71
    let $para := 
    In a hole in the ground there lived a hobbit.
             
    196)
    let $para := 
    In a hole in the ground there lived a hobbit.
             
    71
    let $C := 'http://www.w3.org/2013/collation/UCA?strength=primary'
    712

  • op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
    969(
    let $para := 
    In a hole in the ground there lived a hobbit.
             
    25
    let $para := 
    In a hole in the ground there lived a hobbit.
             
    71
    let $para := 
    In a hole in the ground there lived a hobbit.
             
    196)
    let $para := 
    In a hole in the ground there lived a hobbit.
             
    71
    let $C := 'http://www.w3.org/2013/collation/UCA?strength=primary'
    718

  • let $para := 
    In a hole in the ground there lived a hobbit.
             
    219(
    let $para := 
    In a hole in the ground there lived a hobbit.
             
    25
    let $para := 
    In a hole in the ground there lived a hobbit.
             
    71
    let $para := 
    In a hole in the ground there lived a hobbit.
             
    196)
    let $para := 
    In a hole in the ground there lived a hobbit.
             
    71
    let $C := 'http://www.w3.org/2013/collation/UCA?strength=primary'
    724

  • let $para := 
    In a hole in the ground there lived a hobbit.
             
    196(
    let $para := 
    In a hole in the ground there lived a hobbit.
             
    25
    let $para := 
    In a hole in the ground there lived a hobbit.
             
    71
    let $para := 
    In a hole in the ground there lived a hobbit.
             
    196)
    let $para := 
    In a hole in the ground there lived a hobbit.
             
    71
    let $C := 'http://www.w3.org/2013/collation/UCA?strength=primary'
    730

  • let $para := 
    In a hole in the ground there lived a hobbit.
             
    30(
    let $para := 
    In a hole in the ground there lived a hobbit.
             
    25
    let $para := 
    In a hole in the ground there lived a hobbit.
             
    71
    let $para := 
    In a hole in the ground there lived a hobbit.
             
    196)
    let $para := 
    In a hole in the ground there lived a hobbit.
             
    71
    op:operation(fenceHeight, xs:integer) => op:operation(xs:integer, xs:integer)
    44

  • let $para := 
    In a hole in the ground there lived a hobbit.
             
    36(
    let $para := 
    In a hole in the ground there lived a hobbit.
             
    25
    let $para := 
    In a hole in the ground there lived a hobbit.
             
    71
    let $para := 
    In a hole in the ground there lived a hobbit.
             
    196)
    let $para := 
    In a hole in the ground there lived a hobbit.
             
    71
    op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
    47

    See 18.2 Constructor functions for xs:QName and xs:NOTATION for special rules.

  • let $C := 'http://www.w3.org/2013/collation/UCA?strength=primary'
    743(
    let $para := 
    In a hole in the ground there lived a hobbit.
             
    25
    let $para := 
    In a hole in the ground there lived a hobbit.
             
    71
    let $para := 
    In a hole in the ground there lived a hobbit.
             
    196)
    let $para := 
    In a hole in the ground there lived a hobbit.
             
    71
    let $C := 'http://www.w3.org/2013/collation/UCA?strength=primary'
    748

  • let $C := 'http://www.w3.org/2013/collation/UCA?strength=primary'
    749(
    let $para := 
    In a hole in the ground there lived a hobbit.
             
    25
    let $para := 
    In a hole in the ground there lived a hobbit.
             
    71
    let $para := 
    In a hole in the ground there lived a hobbit.
             
    196)
    let $para := 
    In a hole in the ground there lived a hobbit.
             
    71
    let $C := 'http://www.w3.org/2013/collation/UCA?strength=primary'
    754

  • let $para := 
    In a hole in the ground there lived a hobbit.
             
    101(
    let $para := 
    In a hole in the ground there lived a hobbit.
             
    25
    let $para := 
    In a hole in the ground there lived a hobbit.
             
    71
    let $para := 
    In a hole in the ground there lived a hobbit.
             
    196)
    let $para := 
    In a hole in the ground there lived a hobbit.
             
    71
    let $C := 'http://www.w3.org/2013/collation/UCA?strength=primary'
    760

  • 1º 2º 3º 4º ...
    642(
    let $para := 
    In a hole in the ground there lived a hobbit.
             
    25
    let $para := 
    In a hole in the ground there lived a hobbit.
             
    71
    let $para := 
    In a hole in the ground there lived a hobbit.
             
    196)
    let $para := 
    In a hole in the ground there lived a hobbit.
             
    71
    let $C := 'http://www.w3.org/2013/collation/UCA?strength=primary'
    766

  • let $para := 
    In a hole in the ground there lived a hobbit.
             
    28(
    let $para := 
    In a hole in the ground there lived a hobbit.
             
    25
    let $para := 
    In a hole in the ground there lived a hobbit.
             
    71
    let $para := 
    In a hole in the ground there lived a hobbit.
             
    196)
    let $para := 
    In a hole in the ground there lived a hobbit.
             
    71
    let $C := 'http://www.w3.org/2013/collation/UCA?strength=primary'
    772

  • let $para := 
    In a hole in the ground there lived a hobbit.
             
    35(
    let $para := 
    In a hole in the ground there lived a hobbit.
             
    25
    let $para := 
    In a hole in the ground there lived a hobbit.
             
    71
    let $para := 
    In a hole in the ground there lived a hobbit.
             
    196)
    let $para := 
    In a hole in the ground there lived a hobbit.
             
    71
    fn:abs($N * $arg2) le fn:abs($arg1) 
                   and fn:compare($N * $arg2, 0) eq fn:compare($arg1, 0).
    845

  • Primo Secondo Terzo Quarto Quinto ...
    089(
    let $para := 
    In a hole in the ground there lived a hobbit.
             
    25
    let $para := 
    In a hole in the ground there lived a hobbit.
             
    71
    let $para := 
    In a hole in the ground there lived a hobbit.
             
    196)
    let $para := 
    In a hole in the ground there lived a hobbit.
             
    71
    let $C := 'http://www.w3.org/2013/collation/UCA?strength=primary'
    784

  • Primo Secondo Terzo Quarto Quinto ...
    095(
    let $para := 
    In a hole in the ground there lived a hobbit.
             
    25
    let $para := 
    In a hole in the ground there lived a hobbit.
             
    71
    let $para := 
    In a hole in the ground there lived a hobbit.
             
    196)
    let $para := 
    In a hole in the ground there lived a hobbit.
             
    71
    let $C := 'http://www.w3.org/2013/collation/UCA?strength=primary'
    790

  • let $C := 'http://www.w3.org/2013/collation/UCA?strength=primary'
    791(
    let $para := 
    In a hole in the ground there lived a hobbit.
             
    25
    let $para := 
    In a hole in the ground there lived a hobbit.
             
    71
    let $para := 
    In a hole in the ground there lived a hobbit.
             
    196)
    let $para := 
    In a hole in the ground there lived a hobbit.
             
    71
    let $C := 'http://www.w3.org/2013/collation/UCA?strength=primary'
    796

    See 19.1.9 Casting to xs:ENTITY for rules related to constructing values of type

    let $C := 'http://www.w3.org/2013/collation/UCA?strength=primary'
    791 and types derived from it.

  • let $para := 
    In a hole in the ground there lived a hobbit.
             
    85(
    let $para := 
    In a hole in the ground there lived a hobbit.
             
    25
    let $para := 
    In a hole in the ground there lived a hobbit.
             
    71
    let $para := 
    In a hole in the ground there lived a hobbit.
             
    196)
    let $para := 
    In a hole in the ground there lived a hobbit.
             
    71
    let $para := 
    In a hole in the ground there lived a hobbit.
             
    229

  • let $C := 'http://www.w3.org/2013/collation/UCA?strength=primary'
    804(
    let $para := 
    In a hole in the ground there lived a hobbit.
             
    25
    let $para := 
    In a hole in the ground there lived a hobbit.
             
    71
    let $para := 
    In a hole in the ground there lived a hobbit.
             
    196)
    let $para := 
    In a hole in the ground there lived a hobbit.
             
    71
    let $C := 'http://www.w3.org/2013/collation/UCA?strength=primary'
    809

  • let $C := 'http://www.w3.org/2013/collation/UCA?strength=primary'
    810(
    let $para := 
    In a hole in the ground there lived a hobbit.
             
    25
    let $para := 
    In a hole in the ground there lived a hobbit.
             
    71
    let $para := 
    In a hole in the ground there lived a hobbit.
             
    196)
    let $para := 
    In a hole in the ground there lived a hobbit.
             
    71
    let $C := 'http://www.w3.org/2013/collation/UCA?strength=primary'
    815

  • let $C := 'http://www.w3.org/2013/collation/UCA?strength=primary'
    816(
    let $para := 
    In a hole in the ground there lived a hobbit.
             
    25
    let $para := 
    In a hole in the ground there lived a hobbit.
             
    71
    let $para := 
    In a hole in the ground there lived a hobbit.
             
    196)
    let $para := 
    In a hole in the ground there lived a hobbit.
             
    71
    let $C := 'http://www.w3.org/2013/collation/UCA?strength=primary'
    821

  • 1º 2º 3º 4º ...
    32(
    let $para := 
    In a hole in the ground there lived a hobbit.
             
    25
    let $para := 
    In a hole in the ground there lived a hobbit.
             
    71
    let $para := 
    In a hole in the ground there lived a hobbit.
             
    196)
    let $para := 
    In a hole in the ground there lived a hobbit.
             
    71
    let $C := 'http://www.w3.org/2013/collation/UCA?strength=primary'
    827

  • let $C := 'http://www.w3.org/2013/collation/UCA?strength=primary'
    828(
    let $para := 
    In a hole in the ground there lived a hobbit.
             
    25
    let $para := 
    In a hole in the ground there lived a hobbit.
             
    71
    let $para := 
    In a hole in the ground there lived a hobbit.
             
    196)
    let $para := 
    In a hole in the ground there lived a hobbit.
             
    71
    let $C := 'http://www.w3.org/2013/collation/UCA?strength=primary'
    833

  • let $C := 'http://www.w3.org/2013/collation/UCA?strength=primary'
    834(
    let $para := 
    In a hole in the ground there lived a hobbit.
             
    25
    let $para := 
    In a hole in the ground there lived a hobbit.
             
    71
    let $para := 
    In a hole in the ground there lived a hobbit.
             
    196)
    let $para := 
    In a hole in the ground there lived a hobbit.
             
    71
    let $C := 'http://www.w3.org/2013/collation/UCA?strength=primary'
    839

  • let $C := 'http://www.w3.org/2013/collation/UCA?strength=primary'
    840(
    let $para := 
    In a hole in the ground there lived a hobbit.
             
    25
    let $para := 
    In a hole in the ground there lived a hobbit.
             
    71
    let $para := 
    In a hole in the ground there lived a hobbit.
             
    196)
    let $para := 
    In a hole in the ground there lived a hobbit.
             
    71
    let $C := 'http://www.w3.org/2013/collation/UCA?strength=primary'
    845

  • let $C := 'http://www.w3.org/2013/collation/UCA?strength=primary'
    846(
    let $para := 
    In a hole in the ground there lived a hobbit.
             
    25
    let $para := 
    In a hole in the ground there lived a hobbit.
             
    71
    let $para := 
    In a hole in the ground there lived a hobbit.
             
    196)
    let $para := 
    In a hole in the ground there lived a hobbit.
             
    71
    let $C := 'http://www.w3.org/2013/collation/UCA?strength=primary'
    851

  • let $C := 'http://www.w3.org/2013/collation/UCA?strength=primary'
    615(
    let $para := 
    In a hole in the ground there lived a hobbit.
             
    25
    let $para := 
    In a hole in the ground there lived a hobbit.
             
    71
    let $para := 
    In a hole in the ground there lived a hobbit.
             
    196)
    let $para := 
    In a hole in the ground there lived a hobbit.
             
    71
    let $C := 'http://www.w3.org/2013/collation/UCA?strength=primary'
    621

  • let $C := 'http://www.w3.org/2013/collation/UCA?strength=primary'
    858(
    let $para := 
    In a hole in the ground there lived a hobbit.
             
    25
    let $para := 
    In a hole in the ground there lived a hobbit.
             
    71
    let $para := 
    In a hole in the ground there lived a hobbit.
             
    196)
    let $para := 
    In a hole in the ground there lived a hobbit.
             
    71
    let $C := 'http://www.w3.org/2013/collation/UCA?strength=primary'
    863

  • let $C := 'http://www.w3.org/2013/collation/UCA?strength=primary'
    864(
    let $para := 
    In a hole in the ground there lived a hobbit.
             
    25
    let $para := 
    In a hole in the ground there lived a hobbit.
             
    71
    let $para := 
    In a hole in the ground there lived a hobbit.
             
    196)
    let $para := 
    In a hole in the ground there lived a hobbit.
             
    71
    let $C := 'http://www.w3.org/2013/collation/UCA?strength=primary'
    869

  • let $para := 
    In a hole in the ground there lived a hobbit.
             
    005(
    let $para := 
    In a hole in the ground there lived a hobbit.
             
    25
    let $para := 
    In a hole in the ground there lived a hobbit.
             
    71
    let $para := 
    In a hole in the ground there lived a hobbit.
             
    196)
    let $para := 
    In a hole in the ground there lived a hobbit.
             
    71
    let $C := 'http://www.w3.org/2013/collation/UCA?strength=primary'
    875

  • let $para := 
    In a hole in the ground there lived a hobbit.
             
    24(
    let $para := 
    In a hole in the ground there lived a hobbit.
             
    25
    let $para := 
    In a hole in the ground there lived a hobbit.
             
    71
    let $para := 
    In a hole in the ground there lived a hobbit.
             
    196)
    let $para := 
    In a hole in the ground there lived a hobbit.
             
    71
    let $C := 'http://www.w3.org/2013/collation/UCA?strength=primary'
    881

  • let $para := 
    In a hole in the ground there lived a hobbit.
             
    25(
    let $para := 
    In a hole in the ground there lived a hobbit.
             
    25
    let $para := 
    In a hole in the ground there lived a hobbit.
             
    71
    let $para := 
    In a hole in the ground there lived a hobbit.
             
    196)
    let $para := 
    In a hole in the ground there lived a hobbit.
             
    71
    op:operation(fenceHeight, xs:integer) => op:operation(xs:integer, xs:integer)
    665

  • let $para := 
    In a hole in the ground there lived a hobbit.
             
    00(
    let $para := 
    In a hole in the ground there lived a hobbit.
             
    25
    let $para := 
    In a hole in the ground there lived a hobbit.
             
    71
    let $para := 
    In a hole in the ground there lived a hobbit.
             
    196)
    let $para := 
    In a hole in the ground there lived a hobbit.
             
    71
    let $C := 'http://www.w3.org/2013/collation/UCA?strength=primary'
    893

  • let $para := 
    In a hole in the ground there lived a hobbit.
             
    23(
    let $para := 
    In a hole in the ground there lived a hobbit.
             
    25
    let $para := 
    In a hole in the ground there lived a hobbit.
             
    71
    let $para := 
    In a hole in the ground there lived a hobbit.
             
    196)
    let $para := 
    In a hole in the ground there lived a hobbit.
             
    71
    let $C := 'http://www.w3.org/2013/collation/UCA?strength=primary'
    899

    Available only if the implementation supports XSD 1.1.

18.2 Constructor functions for xs:QName and xs:NOTATION

Special rules apply to constructor functions for the types

let $para := 
In a hole in the ground there lived a hobbit.
         
36 and
1º 2º 3º 4º ...
021, for two reasons:

  • Values cannot belong directly to the type

    1º 2º 3º 4º ...
    021, only to its subtypes.

  • The lexical representation of these types uses namespace prefixes, whose meaning is context-dependent.

These constraints result in the following rules:

  1. There is no constructor function for

    1º 2º 3º 4º ...
    021. Constructors are defined, however, for
    let $para := 
    In a hole in the ground there lived a hobbit.
             
    36, for types derived or constructed from
    let $para := 
    In a hole in the ground there lived a hobbit.
             
    36, and for types derived or constructed from
    1º 2º 3º 4º ...
    021.

  2. When converting from an

    let $para := 
    In a hole in the ground there lived a hobbit.
             
    10, the prefix within the lexical
    let $para := 
    In a hole in the ground there lived a hobbit.
             
    36 supplied as the argument is resolved to a namespace URI using the statically known namespaces from the static context. If the lexical
    let $para := 
    In a hole in the ground there lived a hobbit.
             
    36 has no prefix, the namespace URI of the resulting expanded-QName is the default element/type namespace from the static context. Components of the static context are defined in Section 2.1.1 Static Context XP31. A dynamic error is raised [err:FONS0004] if the prefix is not bound in the static context. As described in Section 2.1 Terminology DM31, the supplied prefix is retained as part of the expanded-QName value.

When a constructor function for a namespace-sensitive type is used as a literal function item or in a partial function application (for example,

let $C := 'http://www.w3.org/2013/collation/UCA?strength=primary'
910 or
let $C := 'http://www.w3.org/2013/collation/UCA?strength=primary'
911) 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
let $para := 
In a hole in the ground there lived a hobbit.
         
77 function, the relevant namespace bindings are those from the static context of the call on
let $para := 
In a hole in the ground there lived a hobbit.
         
77.

Note:

When the supplied argument to the

let $para := 
In a hole in the ground there lived a hobbit.
         
36 constructor function is a node, the node is atomized in the usual way, and if the result is
let $para := 
In a hole in the ground there lived a hobbit.
         
00 it is then converted as if a string had been supplied. The effect might not be what is desired. For example, given the attribute
let $C := 'http://www.w3.org/2013/collation/UCA?strength=primary'
916, the expression
let $C := 'http://www.w3.org/2013/collation/UCA?strength=primary'
917 might fail on the grounds that the prefix
let $C := 'http://www.w3.org/2013/collation/UCA?strength=primary'
918 is undeclared. This is because the namespace bindings are taken from the static context (that is, from the query or stylesheet), and not from the source document containing the
let $C := 'http://www.w3.org/2013/collation/UCA?strength=primary'
919 attribute. The solution to this problem is to use the function call
let $C := 'http://www.w3.org/2013/collation/UCA?strength=primary'
920 instead.

18.3 Constructor functions for XML Schema built-in list types

Each of the three built-in list types defined in [XML Schema Part 2: Datatypes Second Edition], namely

let $para := 
In a hole in the ground there lived a hobbit.
         
42,
let $para := 
In a hole in the ground there lived a hobbit.
         
43, and
let $para := 
In a hole in the ground there lived a hobbit.
         
41, has an associated constructor function.

The function signatures are as follows:

  • let $para := 
    In a hole in the ground there lived a hobbit.
             
    42(
    let $para := 
    In a hole in the ground there lived a hobbit.
             
    25
    let $para := 
    In a hole in the ground there lived a hobbit.
             
    71
    let $para := 
    In a hole in the ground there lived a hobbit.
             
    196)
    let $para := 
    In a hole in the ground there lived a hobbit.
             
    71
    let $C := 'http://www.w3.org/2013/collation/UCA?strength=primary'
    929

  • let $para := 
    In a hole in the ground there lived a hobbit.
             
    43(
    let $para := 
    In a hole in the ground there lived a hobbit.
             
    25
    let $para := 
    In a hole in the ground there lived a hobbit.
             
    71
    let $para := 
    In a hole in the ground there lived a hobbit.
             
    196)
    let $para := 
    In a hole in the ground there lived a hobbit.
             
    71
    let $C := 'http://www.w3.org/2013/collation/UCA?strength=primary'
    935

  • let $para := 
    In a hole in the ground there lived a hobbit.
             
    41(
    let $para := 
    In a hole in the ground there lived a hobbit.
             
    25
    let $para := 
    In a hole in the ground there lived a hobbit.
             
    71
    let $para := 
    In a hole in the ground there lived a hobbit.
             
    196)
    let $para := 
    In a hole in the ground there lived a hobbit.
             
    71
    let $C := 'http://www.w3.org/2013/collation/UCA?strength=primary'
    941

The semantics are equivalent to casting to the corresponding types from

let $para := 
In a hole in the ground there lived a hobbit.
         
10.

All three of these types have the facet

let $C := 'http://www.w3.org/2013/collation/UCA?strength=primary'
943 meaning that there must always be at least one item in the list. The return type, however, allows for the fact that when the argument to the function is an empty sequence, the result is an empty sequence.

Note:

In the case of atomic types, it is possible to use an expression such as

let $C := 'http://www.w3.org/2013/collation/UCA?strength=primary'
944 to convert an attribute value to an instance of
op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
964, knowing that this will work both in the case where the attribute is already annotated as
op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
964, and also in the case where it is
let $para := 
In a hole in the ground there lived a hobbit.
         
00. This approach does not work with list types, because it is not permitted to use a value of type
let $C := 'http://www.w3.org/2013/collation/UCA?strength=primary'
929 as input to the constructor function
let $para := 
In a hole in the ground there lived a hobbit.
         
42. Instead, it is necessary to use conditional logic that performs the conversion only in the case where the input is untyped:
let $C := 'http://www.w3.org/2013/collation/UCA?strength=primary'
950

18.4 Constructor functions for XML Schema built-in union types

There is a constructor function for the union type

let $para := 
In a hole in the ground there lived a hobbit.
         
72 defined in [XQuery and XPath Data Model (XDM) 3.1]. The function signature is:

  • let $para := 
    In a hole in the ground there lived a hobbit.
             
    72(
    let $para := 
    In a hole in the ground there lived a hobbit.
             
    25
    let $para := 
    In a hole in the ground there lived a hobbit.
             
    71
    let $para := 
    In a hole in the ground there lived a hobbit.
             
    196)
    let $para := 
    In a hole in the ground there lived a hobbit.
             
    71
    let $C := 'http://www.w3.org/2013/collation/UCA?strength=primary'
    93

The semantics are determined by the rules in 19.3.5 Casting to union types. These rules have the effect that:

  1. If the argument is an instance of

    let $para := 
    In a hole in the ground there lived a hobbit.
             
    26,
    let $para := 
    In a hole in the ground there lived a hobbit.
             
    83, or
    let $para := 
    In a hole in the ground there lived a hobbit.
             
    82, then the result is an instance of the same primitive type, with the same value;

  2. If the argument is an instance of

    op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
    32, the result is the
    let $para := 
    In a hole in the ground there lived a hobbit.
             
    26 value
    let $para := 
    In a hole in the ground there lived a hobbit.
             
    169 or
    let $para := 
    In a hole in the ground there lived a hobbit.
             
    506;

  3. If the argument is an instance of

    let $para := 
    In a hole in the ground there lived a hobbit.
             
    10 or
    let $para := 
    In a hole in the ground there lived a hobbit.
             
    00, then:

    1. If the value is in the lexical space of

      let $para := 
      In a hole in the ground there lived a hobbit.
               
      26, the result will be the corresponding
      let $para := 
      In a hole in the ground there lived a hobbit.
               
      26 value;

    2. Otherwise, a dynamic error [err:FORG0001] occurs;

    Note:

    The result will never be an instance of

    let $para := 
    In a hole in the ground there lived a hobbit.
             
    83,
    let $para := 
    In a hole in the ground there lived a hobbit.
             
    82, or
    let $para := 
    In a hole in the ground there lived a hobbit.
             
    85. This is because
    let $para := 
    In a hole in the ground there lived a hobbit.
             
    26 appears first in the list of member types of
    let $para := 
    In a hole in the ground there lived a hobbit.
             
    72, 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
    let $C := 'http://www.w3.org/2013/collation/UCA?strength=primary'
    73 and
    let $C := 'http://www.w3.org/2013/collation/UCA?strength=primary'
    82 are declared to expect an instance of
    let $para := 
    In a hole in the ground there lived a hobbit.
             
    72 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 value (or untyped node) is supplied as the argument, it is converted to an
    let $para := 
    In a hole in the ground there lived a hobbit.
             
    26 value even if its lexical form is that (say) of an integer.

  4. In all other cases, a dynamic error [err:FORG0001] occurs.

In the case of an implementation that supports XSD 1.1, there is a constructor function associated with the built-in union type

let $C := 'http://www.w3.org/2013/collation/UCA?strength=primary'
978.

The function signature is as follows:

  • let $C := 'http://www.w3.org/2013/collation/UCA?strength=primary'
    978(
    let $para := 
    In a hole in the ground there lived a hobbit.
             
    25
    let $para := 
    In a hole in the ground there lived a hobbit.
             
    71
    let $para := 
    In a hole in the ground there lived a hobbit.
             
    196)
    let $para := 
    In a hole in the ground there lived a hobbit.
             
    71
    let $C := 'http://www.w3.org/2013/collation/UCA?strength=primary'
    984

The semantics are equivalent to casting to the corresponding union type (see 19.3.5 Casting to union types).

Note:

Because

let $C := 'http://www.w3.org/2013/collation/UCA?strength=primary'
978 has no member types, and therefore has an empty value space, casting will always fail with a dynamic error except in the case where the supplied argument is an empty sequence, in which case the result is also an empty sequence.

18.5 Constructor functions for user-defined types

For every user-defined simple type in the static context (See Section 2.1.1 Static Context XP31), there is a constructor function whose name is the same as the name of the type and whose effect is to create a value of that type from the supplied argument. The rules for constructing user-defined types are defined in the same way as the rules for constructing built-in derived types defined in 18.1 Constructor functions for XML Schema built-in atomic types.

Special rules apply to constructor functions for namespace-sensitive types, that is, atomic types derived from

let $para := 
In a hole in the ground there lived a hobbit.
         
36 and
1º 2º 3º 4º ...
021, list types that have a namespace-sensitive item type, and union types that have a namespace-sensitive member type. See 18.2 Constructor functions for xs:QName and xs:NOTATION.

Consider a situation where the static context contains an atomic type called

let $C := 'http://www.w3.org/2013/collation/UCA?strength=primary'
988 defined in a schema whose target namespace is bound to the prefix
fn:abs($N * $arg2) le fn:abs($arg1) 
               and fn:compare($N * $arg2, 0) eq fn:compare($arg1, 0).
782. In such a case the following constructor function is available to users:

let $C := 'http://www.w3.org/2013/collation/UCA?strength=primary'
990(
let $para := 
In a hole in the ground there lived a hobbit.
         
25
let $para := 
In a hole in the ground there lived a hobbit.
         
71
let $para := 
In a hole in the ground there lived a hobbit.
         
196)
let $para := 
In a hole in the ground there lived a hobbit.
         
71
let $C := 'http://www.w3.org/2013/collation/UCA?strength=primary'
995

In the case of an atomic type A, the return type of the function is

let $C := 'http://www.w3.org/2013/collation/UCA?strength=primary'
996, reflecting the fact that the result will be an empty sequence if the input is an empty sequence. For a union or list type, the return type of the function is specified only as
op:operation(fenceHeight, xs:integer) => op:operation(xs:integer, xs:integer)
12. Implementations performing static type checking will often be able to compute a more specific result type. For example, if the target type is a list type whose item type is the atomic type A, the result will always be an instance of A*; if the target type is a pure union type U then the result will always be an instance of U?. In general, however, applications needing interoperable behavior on implementations that do strict static type checking will need to use a
let $C := 'http://www.w3.org/2013/collation/UCA?strength=primary'
998 expression to assert the specific type of the result.

To construct an instance of a user-defined type that is not in a namespace, it is possible to use an

let $para := 
In a hole in the ground there lived a hobbit.
         
403 (for example
let $para := 
In a hole in the ground there lived a hobbit.
         
0000). Alternatives are to use a cast expression (
let $para := 
In a hole in the ground there lived a hobbit.
         
0001) or (if the host language allows it) to undeclare the default function namespace.

19 Casting

Constructor functions and cast expressions accept an expression and return a value of a given type. They both convert a source value, SV, of a source type, ST, to a target value, TV, of the given target type, TT, with identical semantics and different syntax. The name of the constructor function is the same as the name of the built-in [XML Schema Part 2: Datatypes Second Edition] datatype or the datatype defined in Section 2.7 Schema Information DM31 of [XQuery and XPath Data Model (XDM) 3.1] (see 18.1 Constructor functions for XML Schema built-in atomic types) or the user-derived datatype (see 18.5 Constructor functions for user-defined types) that is the target for the conversion, and the semantics are exactly the same as for a cast expression; for example,

let $para := 
In a hole in the ground there lived a hobbit.
         
0002 means exactly the same as
let $para := 
In a hole in the ground there lived a hobbit.
         
0003 cast as
op:operation(fenceHeight, xs:integer) => op:operation(xs:integer, xs:integer)
033.

The cast expression takes a type name to indicate the target type of the conversion. See Section 3.14.2 Cast XP31. If the type name allows the empty sequence and the expression to be cast is the empty sequence, the empty sequence is returned. If the type name does not allow the empty sequence and the expression to be cast is the empty sequence, a type error is raised [err:XPTY0004]XP31.

Where the argument to a cast is a literal, the result of the function may be evaluated statically; if an error is encountered during such evaluation, it may be reported as a static error.

The general rules for casting from primitive types to primitive types are defined in 19.1 Casting from primitive types to primitive types, and subsections describe the rules for specific target types. The general rules for casting from

let $para := 
In a hole in the ground there lived a hobbit.
         
10 (and
let $para := 
In a hole in the ground there lived a hobbit.
         
00) follow in 19.2 Casting from xs:string and xs:untypedAtomic. Casting to non-primitive types, including atomic types derived by resctriction, union types, and list types, is described in 19.3 Casting involving non-primitive types. Casting from derived types is defined in 19.3.2 Casting from derived types to parent types, 19.3.3 Casting within a branch of the type hierarchy and 19.3.4 Casting across the type hierarchy.

[Definition] Throughout this section (19 Casting), the term primitive type means either one of the 19 primitive types defined in [XML Schema Part 2: Datatypes Second Edition], or one of the types

let $para := 
In a hole in the ground there lived a hobbit.
         
00,
let $para := 
In a hole in the ground there lived a hobbit.
         
85,
let $para := 
In a hole in the ground there lived a hobbit.
         
24 and
let $para := 
In a hole in the ground there lived a hobbit.
         
25; and where the text refers to types derived from a particular primitive type T, the reference is to types for which T is the nearest ancestor-or-self primitive type in the type hierarchy.

When casting from

let $para := 
In a hole in the ground there lived a hobbit.
         
10 or
let $para := 
In a hole in the ground there lived a hobbit.
         
00 the semantics in 19.2 Casting from xs:string and xs:untypedAtomic apply, regardless of target type.

19.1 Casting from primitive types to primitive types

This section defines casting between ·primitive types· (specifically, the 19 primitive types defined in [XML Schema Part 2: Datatypes Second Edition] as well as

let $para := 
In a hole in the ground there lived a hobbit.
         
00,
let $para := 
In a hole in the ground there lived a hobbit.
         
85 and the two derived types of
op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
489:
let $para := 
In a hole in the ground there lived a hobbit.
         
24 and
let $para := 
In a hole in the ground there lived a hobbit.
         
25 which are treated as primitive types in this section. The type conversions that are supported between primitive atomic types are indicated in the table below; casts between other (non-primitive) types are defined in terms of these primitives.

In this table, there is a row for each ·primitive type· acting as the source of the conversion and there is a column for each ·primitive type· acting as the target of the conversion. The intersections of rows and columns contain one of three characters:

let $para := 
In a hole in the ground there lived a hobbit.
         
0018 indicates that a conversion from values of the type to which the row applies to the type to which the column applies is supported;
let $para := 
In a hole in the ground there lived a hobbit.
         
911 indicates that there are no supported conversions from values of the type to which the row applies to the type to which the column applies; and
let $para := 
In a hole in the ground there lived a hobbit.
         
0020 indicates that a conversion from values of the type to which the row applies to the type to which the column applies may succeed for some values in the value space and fail for others.

[XML Schema Part 2: Datatypes Second Edition] defines

1º 2º 3º 4º ...
021 as an abstract type. Thus, casting to
1º 2º 3º 4º ...
021 from any other type including
1º 2º 3º 4º ...
021 is not permitted and raises a static error [err:XPST0080]XP31. However, casting from one subtype of
1º 2º 3º 4º ...
021 to another subtype of
1º 2º 3º 4º ...
021 is permitted.

Casting is not supported to or from

let $C := 'http://www.w3.org/2013/collation/UCA?strength=primary'
595. Thus, there is no row or column for this type in the table below. For any node that has not been validated or has been validated as
let $C := 'http://www.w3.org/2013/collation/UCA?strength=primary'
595, the typed value of the node is an atomic value of type
let $para := 
In a hole in the ground there lived a hobbit.
         
00. There are no atomic values with the type annotation
let $C := 'http://www.w3.org/2013/collation/UCA?strength=primary'
595 at runtime. Casting to
let $C := 'http://www.w3.org/2013/collation/UCA?strength=primary'
595 is not permitted and raises a static error: [err:XPST0080]XP31.

Similarly, casting is not supported to or from

let $para := 
In a hole in the ground there lived a hobbit.
         
34 and will raise a static error: [err:XPST0080]XP31. There are no atomic values with the type annotation
let $para := 
In a hole in the ground there lived a hobbit.
         
34 at runtime, although this can be a statically inferred type.

If casting is attempted from an ST to a TT for which casting is not supported, as defined in the table below, a type error is raised [err:XPTY0004]XP31.

In the following table, the columns and rows are identified by short codes that identify simple types as follows:

uA = xs:untypedAtomic
aURI = xs:anyURI
b64 = xs:base64Binary
bool = xs:boolean
dat = xs:date
gDay = xs:gDay
dbl = xs:double
dec = xs:decimal
dT = xs:dateTime
dTD = xs:dayTimeDuration
dur = xs:duration
flt = xs:float
hxB = xs:hexBinary
gMD = xs:gMonthDay
gMon = xs:gMonth
int = xs:integer
NOT = xs:NOTATION
QN = xs:QName
str = xs:string
tim = xs:time
gYM = xs:gYearMonth
yMD = xs:yearMonthDuration
gYr = xs:gYear

In the following table, the notation "S\T" indicates that the source ("S") of the conversion is indicated in the column below the notation and that the target ("T") is indicated in the row to the right of the notation.

S\TuAstrfltdbldecintduryMDdTDdTtimdatgYMgYrgMDgDaygMonboolb64hxBaURIQNNOTuAYYMMMMMMMMMMMMMMMMMMMMMstrYYMMMMMMMMMMMMMMMMMMMMMfltYYYYMMNNNNNNNNNNNYNNNNNdblYYYYMMNNNNNNNNNNNYNNNNNdecYYYYYYNNNNNNNNNNNYNNNNNintYYYYYYNNNNNNNNNNNYNNNNNdurYYNNNNYYYNNNNNNNNNNNNNNyMDYYNNNNYYYNNNNNNNNNNNNNNdTDYYNNNNYYYNNNNNNNNNNNNNNdTYYNNNNNNNYYYYYYYYNNNNNNtimYYNNNNNNNNYNNNNNNNNNNNNdatYYNNNNNNNYNYYYYYYNNNNNNgYMYYNNNNNNNNNNYNNNNNNNNNNgYrYYNNNNNNNNNNNYNNNNNNNNNgMDYYNNNNNNNNNNNNYNNNNNNNNgDayYYNNNNNNNNNNNNNYNNNNNNNgMonYYNNNNNNNNNNNNNNYNNNNNNboolYYYYYYNNNNNNNNNNNYNNNNNb64YYNNNNNNNNNNNNNNNNYYNNNhxBYYNNNNNNNNNNNNNNNNYYNNNaURIYYNNNNNNNNNNNNNNNNNNYNNQNYYNNNNNNNNNNNNNNNNNNNYMNOTYYNNNNNNNNNNNNNNNNNNNYM

19.1.1 Casting to xs:string and xs:untypedAtomic

Casting is permitted from any ·primitive type· to the ·primitive types·

let $para := 
In a hole in the ground there lived a hobbit.
         
10 and
let $para := 
In a hole in the ground there lived a hobbit.
         
00.

When a value of any simple type is cast as

let $para := 
In a hole in the ground there lived a hobbit.
         
10, the derivation of the
let $para := 
In a hole in the ground there lived a hobbit.
         
10 value TV depends on the ST and on the SV, as follows.

  • If ST is

    let $para := 
    In a hole in the ground there lived a hobbit.
             
    10 or a type derived from
    let $para := 
    In a hole in the ground there lived a hobbit.
             
    10, TV is SV.

  • If ST is

    let $para := 
    In a hole in the ground there lived a hobbit.
             
    30, the type conversion is performed without escaping any characters.

  • If ST is

    let $para := 
    In a hole in the ground there lived a hobbit.
             
    36 or
    1º 2º 3º 4º ...
    021:

    • if the qualified name has a prefix, then TV is the concatenation of the prefix of SV, a single colon (:), and the local name of SV.

    • otherwise TV is the local-name.

  • If ST is a numeric type, the following rules apply:

    • If ST is

      let $para := 
      In a hole in the ground there lived a hobbit.
               
      85, TV is the canonical lexical representation of SV as defined in [XML Schema Part 2: Datatypes Second Edition]. There is no decimal point.

    • If ST is

      let $para := 
      In a hole in the ground there lived a hobbit.
               
      82, then:

      • If SV is in the value space of

        let $para := 
        In a hole in the ground there lived a hobbit.
                 
        85, that is, if there are no significant digits after the decimal point, then the value is converted from an
        let $para := 
        In a hole in the ground there lived a hobbit.
                 
        82 to an
        let $para := 
        In a hole in the ground there lived a hobbit.
                 
        85 and the resulting
        let $para := 
        In a hole in the ground there lived a hobbit.
                 
        85 is converted to an
        let $para := 
        In a hole in the ground there lived a hobbit.
                 
        10 using the rule above.

      • Otherwise, the canonical lexical representation of SV is returned, as defined in [XML Schema Part 2: Datatypes Second Edition].

    • If ST is

      let $para := 
      In a hole in the ground there lived a hobbit.
               
      83 or
      let $para := 
      In a hole in the ground there lived a hobbit.
               
      26, then:

      • TV will be an

        let $para := 
        In a hole in the ground there lived a hobbit.
                 
        10 in the lexical space of
        let $para := 
        In a hole in the ground there lived a hobbit.
                 
        26 or
        let $para := 
        In a hole in the ground there lived a hobbit.
                 
        83 that when converted to an
        let $para := 
        In a hole in the ground there lived a hobbit.
                 
        26 or
        let $para := 
        In a hole in the ground there lived a hobbit.
                 
        83 under the rules of 19.2 Casting from xs:string and xs:untypedAtomic produces a value that is equal to SV, or is
        fn:abs($N * $arg2) le fn:abs($arg1) 
                       and fn:compare($N * $arg2, 0) eq fn:compare($arg1, 0).
        90 if SV is
        fn:abs($N * $arg2) le fn:abs($arg1) 
                       and fn:compare($N * $arg2, 0) eq fn:compare($arg1, 0).
        90. In addition, TV must satisfy the constraints in the following sub-bullets.

        • If SV has an absolute value that is greater than or equal to 0.000001 (one millionth) and less than 1000000 (one million), then the value is converted to an

          let $para := 
          In a hole in the ground there lived a hobbit.
                   
          82 and the resulting
          let $para := 
          In a hole in the ground there lived a hobbit.
                   
          82 is converted to an
          let $para := 
          In a hole in the ground there lived a hobbit.
                   
          10 according to the rules above, as though using an implementation of
          let $para := 
          In a hole in the ground there lived a hobbit.
                   
          82 that imposes no limits on the
          let $para := 
          In a hole in the ground there lived a hobbit.
                   
          454 or
          let $para := 
          In a hole in the ground there lived a hobbit.
                   
          455 facets.

        • If SV has the value positive or negative zero, TV is "0" or "-0" respectively.

        • If SV is positive or negative infinity, TV is the string "

          1º 2º 3º 4º ...
          56" or "
          1º 2º 3º 4º ...
          57" respectively.

        • In other cases, the result consists of a mantissa, which has the lexical form of an

          let $para := 
          In a hole in the ground there lived a hobbit.
                   
          82, followed by the letter "E", followed by an exponent which has the lexical form of an
          let $para := 
          In a hole in the ground there lived a hobbit.
                   
          85. Leading zeroes and "+" signs are prohibited in the exponent. For the mantissa, there must be a decimal point, and there must be exactly one digit before the decimal point, which must be non-zero. The "+" sign is prohibited. There must be at least one digit after the decimal point. Apart from this mandatory digit, trailing zero digits are prohibited.

      Note:

      The above rules allow more than one representation of the same value. For example, the

      let $para := 
      In a hole in the ground there lived a hobbit.
               
      83 value whose exact decimal representation is 1.26743223E15 might be represented by any of the strings "1.26743223E15", "1.26743222E15" or "1.26743224E15" (inter alia). It is implementation-dependent which of these representations is chosen.

  • If ST is

    let $para := 
    In a hole in the ground there lived a hobbit.
             
    29,
    op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
    964 or
    op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
    965, TV is the local value. The components of TV are individually cast to
    let $para := 
    In a hole in the ground there lived a hobbit.
             
    10 using the functions described in [casting-to-datetimes] and the results are concatenated together. The
    op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
    984 component is cast to
    let $para := 
    In a hole in the ground there lived a hobbit.
             
    10 using
    let $para := 
    In a hole in the ground there lived a hobbit.
             
    0075. The
    op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
    985,
    op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
    986,
    op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
    987 and
    op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
    988 components are cast to
    let $para := 
    In a hole in the ground there lived a hobbit.
             
    10 using
    let $para := 
    In a hole in the ground there lived a hobbit.
             
    0081. The
    op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
    989 component is cast to
    let $para := 
    In a hole in the ground there lived a hobbit.
             
    10 using
    let $para := 
    In a hole in the ground there lived a hobbit.
             
    0084. The timezone component, if present, is cast to
    let $para := 
    In a hole in the ground there lived a hobbit.
             
    10 using
    let $para := 
    In a hole in the ground there lived a hobbit.
             
    0086.

    Note that the hours component of the resulting string will never be

    let $para := 
    In a hole in the ground there lived a hobbit.
             
    0087. Midnight is always represented as
    op:operation(fenceHeight, xs:integer) => op:operation(xs:integer, xs:integer)
    049.

  • If ST is

    let $para := 
    In a hole in the ground there lived a hobbit.
             
    24 or
    let $para := 
    In a hole in the ground there lived a hobbit.
             
    25, TV is the canonical representation of SV as defined in [Schema 1.1 Part 2].

  • If ST is

    op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
    489 then let SYM be
    let $para := 
    In a hole in the ground there lived a hobbit.
             
    0092
    let $para := 
    In a hole in the ground there lived a hobbit.
             
    0093, and let SDT be
    let $para := 
    In a hole in the ground there lived a hobbit.
             
    0092
    let $para := 
    In a hole in the ground there lived a hobbit.
             
    0095; Now, let the next intermediate value, TYM, be
    let $para := 
    In a hole in the ground there lived a hobbit.
             
    0096
    let $para := 
    In a hole in the ground there lived a hobbit.
             
    0097
    let $para := 
    In a hole in the ground there lived a hobbit.
             
    0098 , and let TDT be
    let $para := 
    In a hole in the ground there lived a hobbit.
             
    0099
    let $para := 
    In a hole in the ground there lived a hobbit.
             
    0097
    let $para := 
    In a hole in the ground there lived a hobbit.
             
    0098 . If TYM is "P0M", then TV is TDT. Otherwise, TYM and TDT are merged according to the following rules:

    1. If TDT is "PT0S", then TV is TYM.

    2. Otherwise, TV is the concatenation of all the characters in TYM and all the characters except the first "P" and the optional negative sign in TDT.

  • In all other cases, TV is the [XML Schema Part 2: Datatypes Second Edition] canonical representation of SV. For datatypes that do not have a canonical lexical representation defined an ·implementation-dependent· canonical representation may be used.

To cast as

let $para := 
In a hole in the ground there lived a hobbit.
         
00 the value is cast as
let $para := 
In a hole in the ground there lived a hobbit.
         
10, as described above, and the type annotation changed to
let $para := 
In a hole in the ground there lived a hobbit.
         
00.

Note:

The string representations of numeric values are backwards compatible with XPath 1.0 except for the special values positive and negative infinity, negative zero and values outside the range

let $para := 
In a hole in the ground there lived a hobbit.
         
0105 to
let $para := 
In a hole in the ground there lived a hobbit.
         
0106.

19.1.2 Casting to numeric types

19.1.2.1 Casting to xs:float

When a value of any simple type is cast as

let $para := 
In a hole in the ground there lived a hobbit.
         
83, the
let $para := 
In a hole in the ground there lived a hobbit.
         
83 TV is derived from the ST and the SV as follows:

  • If ST is

    let $para := 
    In a hole in the ground there lived a hobbit.
             
    83, then TV is SV and the conversion is complete.

  • If ST is

    let $para := 
    In a hole in the ground there lived a hobbit.
             
    26, then TV is obtained as follows:

    • if SV is the

      let $para := 
      In a hole in the ground there lived a hobbit.
               
      26 value
      1º 2º 3º 4º ...
      56,
      1º 2º 3º 4º ...
      57,
      fn:abs($N * $arg2) le fn:abs($arg1) 
                     and fn:compare($N * $arg2, 0) eq fn:compare($arg1, 0).
      90, positive zero, or negative zero, then TV is the
      let $para := 
      In a hole in the ground there lived a hobbit.
               
      83 value
      1º 2º 3º 4º ...
      56,
      1º 2º 3º 4º ...
      57,
      fn:abs($N * $arg2) le fn:abs($arg1) 
                     and fn:compare($N * $arg2, 0) eq fn:compare($arg1, 0).
      90, positive zero, or negative zero respectively.

    • otherwise, SV can be expressed in the form

      let $para := 
      In a hole in the ground there lived a hobbit.
               
      0119 where the mantissa
      let $para := 
      In a hole in the ground there lived a hobbit.
               
      931 and exponent
      let $para := 
      In a hole in the ground there lived a hobbit.
               
      0121 are signed
      let $para := 
      In a hole in the ground there lived a hobbit.
               
      85s whose value range is defined in [XML Schema Part 2: Datatypes Second Edition], and the following rules apply:

      • if

        let $para := 
        In a hole in the ground there lived a hobbit.
                 
        931 (the mantissa of SV) is outside the permitted range for the mantissa of an
        let $para := 
        In a hole in the ground there lived a hobbit.
                 
        83 value
        let $para := 
        In a hole in the ground there lived a hobbit.
                 
        0125, then it is divided by
        let $para := 
        In a hole in the ground there lived a hobbit.
                 
        0126 where
        let $para := 
        In a hole in the ground there lived a hobbit.
                 
        911 is the lowest positive
        let $para := 
        In a hole in the ground there lived a hobbit.
                 
        85 that brings the result of the division within the permitted range, and the exponent
        let $para := 
        In a hole in the ground there lived a hobbit.
                 
        0121 is increased by
        let $para := 
        In a hole in the ground there lived a hobbit.
                 
        911. This is integer division (in effect, the binary value of the mantissa is truncated on the right). Let
        let $para := 
        In a hole in the ground there lived a hobbit.
                 
        0020 be the mantissa and
        fn:abs($N * $arg2) le fn:abs($arg1) 
                       and fn:compare($N * $arg2, 0) eq fn:compare($arg1, 0).
        547 the exponent after this adjustment.

      • if

        fn:abs($N * $arg2) le fn:abs($arg1) 
                       and fn:compare($N * $arg2, 0) eq fn:compare($arg1, 0).
        547 exceeds
        let $para := 
        In a hole in the ground there lived a hobbit.
                 
        0134 (the maximum exponent value in the value space of
        let $para := 
        In a hole in the ground there lived a hobbit.
                 
        83) then TV is the
        let $para := 
        In a hole in the ground there lived a hobbit.
                 
        83 value
        1º 2º 3º 4º ...
        56 or
        1º 2º 3º 4º ...
        57 depending on the sign of
        let $para := 
        In a hole in the ground there lived a hobbit.
                 
        0020.

      • if

        fn:abs($N * $arg2) le fn:abs($arg1) 
                       and fn:compare($N * $arg2, 0) eq fn:compare($arg1, 0).
        547 is less than
        let $para := 
        In a hole in the ground there lived a hobbit.
                 
        0141 (the minimum exponent value in the value space of
        let $para := 
        In a hole in the ground there lived a hobbit.
                 
        83) then TV is the
        let $para := 
        In a hole in the ground there lived a hobbit.
                 
        83 value positive or negative zero depending on the sign of
        let $para := 
        In a hole in the ground there lived a hobbit.
                 
        0020

      • otherwise, TV is the

        let $para := 
        In a hole in the ground there lived a hobbit.
                 
        83 value
        let $para := 
        In a hole in the ground there lived a hobbit.
                 
        0146.

  • If ST is

    let $para := 
    In a hole in the ground there lived a hobbit.
             
    82, or
    let $para := 
    In a hole in the ground there lived a hobbit.
             
    85, then TV is
    let $para := 
    In a hole in the ground there lived a hobbit.
             
    0149 SV
    let $para := 
    In a hole in the ground there lived a hobbit.
             
    0150 and the conversion is complete.

  • If ST is

    op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
    32, SV is converted to
    let $para := 
    In a hole in the ground there lived a hobbit.
             
    0152 if SV is
    op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
    76 and to
    1º 2º 3º 4º ...
    60 if SV is
    let $C := 'http://www.w3.org/2013/collation/UCA?strength=primary'
    07 and the conversion is complete.

  • If ST is

    let $para := 
    In a hole in the ground there lived a hobbit.
             
    00 or
    let $para := 
    In a hole in the ground there lived a hobbit.
             
    10, see 19.2 Casting from xs:string and xs:untypedAtomic.

    Note:

    XSD 1.1 adds the value

    let $para := 
    In a hole in the ground there lived a hobbit.
             
    27 to the lexical space, as an alternative to
    1º 2º 3º 4º ...
    56. XSD 1.1 also adds negative zero to the value space.

Note:

Implementations should return negative zero for

let $C := 'http://www.w3.org/2013/collation/UCA?strength=primary'
657. But because [XML Schema Part 2: Datatypes Second Edition] does not distinguish between the values positive zero and negative zero. Implementations may return positive zero in this case.

19.1.2.2 Casting to xs:double

When a value of any simple type is cast as

let $para := 
In a hole in the ground there lived a hobbit.
         
26, the
let $para := 
In a hole in the ground there lived a hobbit.
         
26 value TV is derived from the ST and the SV as follows:

  • If ST is

    let $para := 
    In a hole in the ground there lived a hobbit.
             
    26, then TV is SV and the conversion is complete.

  • If ST is

    let $para := 
    In a hole in the ground there lived a hobbit.
             
    83 or a type derived from
    let $para := 
    In a hole in the ground there lived a hobbit.
             
    83, then TV is obtained as follows:

    • if SV is the

      let $para := 
      In a hole in the ground there lived a hobbit.
               
      83 value
      1º 2º 3º 4º ...
      56,
      1º 2º 3º 4º ...
      57,
      fn:abs($N * $arg2) le fn:abs($arg1) 
                     and fn:compare($N * $arg2, 0) eq fn:compare($arg1, 0).
      90, positive zero, or negative zero, then TV is the
      let $para := 
      In a hole in the ground there lived a hobbit.
               
      26 value
      1º 2º 3º 4º ...
      56,
      1º 2º 3º 4º ...
      57,
      fn:abs($N * $arg2) le fn:abs($arg1) 
                     and fn:compare($N * $arg2, 0) eq fn:compare($arg1, 0).
      90, positive zero, or negative zero respectively.

    • otherwise, SV can be expressed in the form

      let $para := 
      In a hole in the ground there lived a hobbit.
               
      0119 where the mantissa
      let $para := 
      In a hole in the ground there lived a hobbit.
               
      931 and exponent
      let $para := 
      In a hole in the ground there lived a hobbit.
               
      0121 are signed
      let $para := 
      In a hole in the ground there lived a hobbit.
               
      85 values whose value range is defined in [XML Schema Part 2: Datatypes Second Edition], and TV is the
      let $para := 
      In a hole in the ground there lived a hobbit.
               
      26 value
      let $para := 
      In a hole in the ground there lived a hobbit.
               
      0119.

  • If ST is

    let $para := 
    In a hole in the ground there lived a hobbit.
             
    82 or
    let $para := 
    In a hole in the ground there lived a hobbit.
             
    85, then TV is
    let $para := 
    In a hole in the ground there lived a hobbit.
             
    0182 SV
    let $para := 
    In a hole in the ground there lived a hobbit.
             
    0150 and the conversion is complete.

  • If ST is

    op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
    32, SV is converted to
    let $para := 
    In a hole in the ground there lived a hobbit.
             
    0152 if SV is
    op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
    76 and to
    1º 2º 3º 4º ...
    60 if SV is
    let $C := 'http://www.w3.org/2013/collation/UCA?strength=primary'
    07 and the conversion is complete.

  • If ST is

    let $para := 
    In a hole in the ground there lived a hobbit.
             
    00 or
    let $para := 
    In a hole in the ground there lived a hobbit.
             
    10, see 19.2 Casting from xs:string and xs:untypedAtomic.

    Note:

    XSD 1.1 adds the value

    let $para := 
    In a hole in the ground there lived a hobbit.
             
    27 to the lexical space, as an alternative to
    1º 2º 3º 4º ...
    56. XSD 1.1 also adds negative zero to the value space.

Note:

Implementations should return negative zero for

let $C := 'http://www.w3.org/2013/collation/UCA?strength=primary'
664. But because [XML Schema Part 2: Datatypes Second Edition] does not distinguish between the values positive zero and negative zero. Implementations may return positive zero in this case.

19.1.2.3 Casting to xs:decimal

When a value of any simple type is cast as

let $para := 
In a hole in the ground there lived a hobbit.
         
82, the
let $para := 
In a hole in the ground there lived a hobbit.
         
82 value TV is derived from ST and SV as follows:

  • If ST is

    let $para := 
    In a hole in the ground there lived a hobbit.
             
    82,
    let $para := 
    In a hole in the ground there lived a hobbit.
             
    85 or a type derived from them, then TV is SV, converted to an
    let $para := 
    In a hole in the ground there lived a hobbit.
             
    82 value if need be, and the conversion is complete.

  • If ST is

    let $para := 
    In a hole in the ground there lived a hobbit.
             
    83 or
    let $para := 
    In a hole in the ground there lived a hobbit.
             
    26, then TV is the
    let $para := 
    In a hole in the ground there lived a hobbit.
             
    82 value, within the set of
    let $para := 
    In a hole in the ground there lived a hobbit.
             
    82 values that the implementation is capable of representing, that is numerically closest to SV. If two values are equally close, then the one that is closest to zero is chosen. If SV is too large to be accommodated as an
    let $para := 
    In a hole in the ground there lived a hobbit.
             
    82, (see [XML Schema Part 2: Datatypes Second Edition] for ·implementation-defined· limits on numeric values) a dynamic error is raised [err:FOCA0001]. If SV is one of the special
    let $para := 
    In a hole in the ground there lived a hobbit.
             
    83 or
    let $para := 
    In a hole in the ground there lived a hobbit.
             
    26 values
    fn:abs($N * $arg2) le fn:abs($arg1) 
                   and fn:compare($N * $arg2, 0) eq fn:compare($arg1, 0).
    90,
    1º 2º 3º 4º ...
    56, or
    1º 2º 3º 4º ...
    57, a dynamic error is raised [err:FOCA0002].

  • If ST is

    op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
    32, SV is converted to
    Primo Secondo Terzo Quarto Quinto ...
    662 if SV is
    declare %public function r:random-sequence($length as xs:integer) as xs:double* {
      r:random-sequence($length, fn:random-number-generator())
    };
    
    declare %private function r:random-sequence($length as xs:integer, 
                                                $G as map(xs:string, item())) {
      if ($length eq 0)
      then ()
      else ($G?number, r:random-sequence($length - 1, $G?next()))
    };
    
    r:random-sequence(200);
                
    13 or
    op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
    76 and to
    1º 2º 3º 4º ...
    66 if SV is
    declare %public function r:random-sequence($length as xs:integer) as xs:double* {
      r:random-sequence($length, fn:random-number-generator())
    };
    
    declare %private function r:random-sequence($length as xs:integer, 
                                                $G as map(xs:string, item())) {
      if ($length eq 0)
      then ()
      else ($G?number, r:random-sequence($length - 1, $G?next()))
    };
    
    r:random-sequence(200);
                
    19 or
    let $C := 'http://www.w3.org/2013/collation/UCA?strength=primary'
    07 and the conversion is complete.

  • If ST is

    let $para := 
    In a hole in the ground there lived a hobbit.
             
    00 or
    let $para := 
    In a hole in the ground there lived a hobbit.
             
    10, see 19.2 Casting from xs:string and xs:untypedAtomic.

19.1.2.4 Casting to xs:integer

When a value of any simple type is cast as

let $para := 
In a hole in the ground there lived a hobbit.
         
85, the
let $para := 
In a hole in the ground there lived a hobbit.
         
85 value TV is derived from ST and SV as follows:

  • If ST is

    let $para := 
    In a hole in the ground there lived a hobbit.
             
    85, or a type derived from
    let $para := 
    In a hole in the ground there lived a hobbit.
             
    85, then TV is SV, converted to an
    let $para := 
    In a hole in the ground there lived a hobbit.
             
    85 value if need be, and the conversion is complete.

  • If ST is

    let $para := 
    In a hole in the ground there lived a hobbit.
             
    82,
    let $para := 
    In a hole in the ground there lived a hobbit.
             
    83 or
    let $para := 
    In a hole in the ground there lived a hobbit.
             
    26, then TV is SV with the fractional part discarded and the value converted to
    let $para := 
    In a hole in the ground there lived a hobbit.
             
    85. Thus, casting
    let $para := 
    In a hole in the ground there lived a hobbit.
             
    0227 returns
    declare %public function r:random-sequence($length as xs:integer) as xs:double* {
      r:random-sequence($length, fn:random-number-generator())
    };
    
    declare %private function r:random-sequence($length as xs:integer, 
                                                $G as map(xs:string, item())) {
      if ($length eq 0)
      then ()
      else ($G?number, r:random-sequence($length - 1, $G?next()))
    };
    
    r:random-sequence(200);
                
    07 and
    let $para := 
    In a hole in the ground there lived a hobbit.
             
    0229 returns
    let $para := 
    In a hole in the ground there lived a hobbit.
             
    0230. Casting
    let $para := 
    In a hole in the ground there lived a hobbit.
             
    0231 returns
    op:operation(fenceHeight, xs:integer) => op:operation(xs:integer, xs:integer)
    608. If SV is too large to be accommodated as an integer, (see [XML Schema Part 2: Datatypes Second Edition] for ·implementation-defined· limits on numeric values) a dynamic error is raised [err:FOCA0003]. If SV is one of the special
    let $para := 
    In a hole in the ground there lived a hobbit.
             
    83 or
    let $para := 
    In a hole in the ground there lived a hobbit.
             
    26 values
    fn:abs($N * $arg2) le fn:abs($arg1) 
                   and fn:compare($N * $arg2, 0) eq fn:compare($arg1, 0).
    90,
    1º 2º 3º 4º ...
    56, or
    1º 2º 3º 4º ...
    57, a dynamic error is raised [err:FOCA0002].

  • If ST is

    op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
    32, SV is converted to
    declare %public function r:random-sequence($length as xs:integer) as xs:double* {
      r:random-sequence($length, fn:random-number-generator())
    };
    
    declare %private function r:random-sequence($length as xs:integer, 
                                                $G as map(xs:string, item())) {
      if ($length eq 0)
      then ()
      else ($G?number, r:random-sequence($length - 1, $G?next()))
    };
    
    r:random-sequence(200);
                
    13 if SV is
    declare %public function r:random-sequence($length as xs:integer) as xs:double* {
      r:random-sequence($length, fn:random-number-generator())
    };
    
    declare %private function r:random-sequence($length as xs:integer, 
                                                $G as map(xs:string, item())) {
      if ($length eq 0)
      then ()
      else ($G?number, r:random-sequence($length - 1, $G?next()))
    };
    
    r:random-sequence(200);
                
    13 or
    op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
    76 and to
    declare %public function r:random-sequence($length as xs:integer) as xs:double* {
      r:random-sequence($length, fn:random-number-generator())
    };
    
    declare %private function r:random-sequence($length as xs:integer, 
                                                $G as map(xs:string, item())) {
      if ($length eq 0)
      then ()
      else ($G?number, r:random-sequence($length - 1, $G?next()))
    };
    
    r:random-sequence(200);
                
    19 if SV is
    declare %public function r:random-sequence($length as xs:integer) as xs:double* {
      r:random-sequence($length, fn:random-number-generator())
    };
    
    declare %private function r:random-sequence($length as xs:integer, 
                                                $G as map(xs:string, item())) {
      if ($length eq 0)
      then ()
      else ($G?number, r:random-sequence($length - 1, $G?next()))
    };
    
    r:random-sequence(200);
                
    19 or
    let $C := 'http://www.w3.org/2013/collation/UCA?strength=primary'
    07 and the conversion is complete.

  • If ST is

    let $para := 
    In a hole in the ground there lived a hobbit.
             
    00 or
    let $para := 
    In a hole in the ground there lived a hobbit.
             
    10, see 19.2 Casting from xs:string and xs:untypedAtomic.

19.1.3 Casting to duration types

When a value of type

let $para := 
In a hole in the ground there lived a hobbit.
         
00,
let $para := 
In a hole in the ground there lived a hobbit.
         
10, a type derived from
let $para := 
In a hole in the ground there lived a hobbit.
         
10,
let $para := 
In a hole in the ground there lived a hobbit.
         
24 or
let $para := 
In a hole in the ground there lived a hobbit.
         
25 is cast as
op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
489,
let $para := 
In a hole in the ground there lived a hobbit.
         
24 or
let $para := 
In a hole in the ground there lived a hobbit.
         
25, TV is derived from ST and SV as follows:

  • If ST is the same as TT, then TV is SV.

  • If ST is

    op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
    489, or a type derived from
    op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
    489, but not
    let $para := 
    In a hole in the ground there lived a hobbit.
             
    25 or a type derived from
    let $para := 
    In a hole in the ground there lived a hobbit.
             
    25, and TT is
    let $para := 
    In a hole in the ground there lived a hobbit.
             
    24, then TV is derived from SV by removing the day, hour, minute and second components from SV.

  • If ST is

    op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
    489, or a type derived from
    let $para := 
    In a hole in the ground there lived a hobbit.
             
    0261, but not
    let $para := 
    In a hole in the ground there lived a hobbit.
             
    24 or a type derived from
    let $para := 
    In a hole in the ground there lived a hobbit.
             
    24, and TT is
    let $para := 
    In a hole in the ground there lived a hobbit.
             
    25, then TV is derived from SV by removing the year and month components from SV.

  • If ST is

    let $para := 
    In a hole in the ground there lived a hobbit.
             
    24 or
    let $para := 
    In a hole in the ground there lived a hobbit.
             
    25, and TT is
    op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
    489, then TV is derived from SV as defined in 19.3.2 Casting from derived types to parent types.

  • If ST is

    let $para := 
    In a hole in the ground there lived a hobbit.
             
    24 and TT is
    let $para := 
    In a hole in the ground there lived a hobbit.
             
    25, the cast is permitted and returns a
    let $para := 
    In a hole in the ground there lived a hobbit.
             
    25 with value 0.0 seconds.

  • If ST is

    let $para := 
    In a hole in the ground there lived a hobbit.
             
    25 and TT is
    let $para := 
    In a hole in the ground there lived a hobbit.
             
    24, the cast is permitted and returns a
    let $para := 
    In a hole in the ground there lived a hobbit.
             
    24 with value 0 months.

  • If ST is

    let $para := 
    In a hole in the ground there lived a hobbit.
             
    00 or
    let $para := 
    In a hole in the ground there lived a hobbit.
             
    10, see 19.2 Casting from xs:string and xs:untypedAtomic.

Note that casting from

op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
489 to
let $para := 
In a hole in the ground there lived a hobbit.
         
24 or
let $para := 
In a hole in the ground there lived a hobbit.
         
25 loses information. To avoid this, users can cast the
op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
489 value to both an
let $para := 
In a hole in the ground there lived a hobbit.
         
24 and an
let $para := 
In a hole in the ground there lived a hobbit.
         
25 and work with both values.

19.1.4 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

let $para := 
In a hole in the ground there lived a hobbit.
         
69 and converting it to an
let $para := 
In a hole in the ground there lived a hobbit.
         
10. These conversions must follow certain rules. For example, converting an
let $para := 
In a hole in the ground there lived a hobbit.
         
85 year value requires converting to an
let $para := 
In a hole in the ground there lived a hobbit.
         
10 with four or more characters, preceded by a minus sign if the value is negative.

This document defines four functions to perform these conversions. These functions are for illustrative purposes only and make no recommendations as to style or efficiency. References to these functions from the following text are not normative.

The arguments to these functions come from functions defined in this document. Thus, the functions below assume that they are correct and do no range checking on them.

let $para := 
In a hole in the ground there lived a hobbit.
         
19

let $para := 
In a hole in the ground there lived a hobbit.
         
20

let $para := 
In a hole in the ground there lived a hobbit.
         
21

let $para := 
In a hole in the ground there lived a hobbit.
         
22

Conversion from ·primitive types· to date and time types follows the rules below.

  1. When a value of any primitive type is cast as

    let $para := 
    In a hole in the ground there lived a hobbit.
             
    29, the
    let $para := 
    In a hole in the ground there lived a hobbit.
             
    29 value TV is derived from ST and SV as follows:

    • If ST is

      let $para := 
      In a hole in the ground there lived a hobbit.
               
      29, then TV is SV.

    • If ST is

      op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
      964, then let SYR be
      let $para := 
      In a hole in the ground there lived a hobbit.
               
      0290 SV
      let $para := 
      In a hole in the ground there lived a hobbit.
               
      0291, let SMO be
      let $para := 
      In a hole in the ground there lived a hobbit.
               
      0292 SV
      let $para := 
      In a hole in the ground there lived a hobbit.
               
      0291, let SDA be
      let $para := 
      In a hole in the ground there lived a hobbit.
               
      0294 SV
      let $para := 
      In a hole in the ground there lived a hobbit.
               
      0291 and let STZ be
      let $para := 
      In a hole in the ground there lived a hobbit.
               
      0296 SV
      let $para := 
      In a hole in the ground there lived a hobbit.
               
      0291; TV is
      let $para := 
      In a hole in the ground there lived a hobbit.
               
      0298 SYR
      let $para := 
      In a hole in the ground there lived a hobbit.
               
      0299 SMO
      let $para := 
      In a hole in the ground there lived a hobbit.
               
      0299 SDA
      let $para := 
      In a hole in the ground there lived a hobbit.
               
      0301, STZ
      let $para := 
      In a hole in the ground there lived a hobbit.
               
      0302.

    • If ST is

      let $para := 
      In a hole in the ground there lived a hobbit.
               
      00 or
      let $para := 
      In a hole in the ground there lived a hobbit.
               
      10, see 19.2 Casting from xs:string and xs:untypedAtomic.

  2. When a value of any primitive type is cast as

    op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
    965, the
    op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
    965 value TV is derived from ST and SV as follows:

    • If ST is

      op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
      965, then TV is SV.

    • If ST is

      let $para := 
      In a hole in the ground there lived a hobbit.
               
      29, then TV is
      let $para := 
      In a hole in the ground there lived a hobbit.
               
      0309 SV
      let $para := 
      In a hole in the ground there lived a hobbit.
               
      0310 SV
      let $para := 
      In a hole in the ground there lived a hobbit.
               
      0311 SV
      let $para := 
      In a hole in the ground there lived a hobbit.
               
      0312 SV
      let $para := 
      In a hole in the ground there lived a hobbit.
               
      0313.

    • If ST is

      let $para := 
      In a hole in the ground there lived a hobbit.
               
      00 or
      let $para := 
      In a hole in the ground there lived a hobbit.
               
      10, see 19.2 Casting from xs:string and xs:untypedAtomic.

  3. When a value of any primitive type is cast as

    op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
    964, the
    op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
    964 value TV is derived from ST and SV as follows:

    • If ST is

      op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
      964, then TV is SV.

    • If ST is

      let $para := 
      In a hole in the ground there lived a hobbit.
               
      29, then let SYR be
      let $para := 
      In a hole in the ground there lived a hobbit.
               
      0320 SV
      let $para := 
      In a hole in the ground there lived a hobbit.
               
      0291, let SMO be
      let $para := 
      In a hole in the ground there lived a hobbit.
               
      0322 SV
      let $para := 
      In a hole in the ground there lived a hobbit.
               
      0291, let SDA be
      let $para := 
      In a hole in the ground there lived a hobbit.
               
      0324 SV
      let $para := 
      In a hole in the ground there lived a hobbit.
               
      0291 and let STZ be
      let $para := 
      In a hole in the ground there lived a hobbit.
               
      0326 SV
      let $para := 
      In a hole in the ground there lived a hobbit.
               
      0291; TV is
      let $para := 
      In a hole in the ground there lived a hobbit.
               
      0328 SYR
      let $para := 
      In a hole in the ground there lived a hobbit.
               
      0299 SMO
      let $para := 
      In a hole in the ground there lived a hobbit.
               
      0299 SDA, STZ
      let $para := 
      In a hole in the ground there lived a hobbit.
               
      0302.

    • If ST is

      let $para := 
      In a hole in the ground there lived a hobbit.
               
      00 or
      let $para := 
      In a hole in the ground there lived a hobbit.
               
      10, see 19.2 Casting from xs:string and xs:untypedAtomic.

  4. When a value of any primitive type is cast as

    op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
    966, the
    op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
    966 value TV is derived from ST and SV as follows:

    • If ST is

      op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
      966, then TV is SV.

    • If ST is

      let $para := 
      In a hole in the ground there lived a hobbit.
               
      29, then let SYR be
      let $para := 
      In a hole in the ground there lived a hobbit.
               
      0320 SV
      let $para := 
      In a hole in the ground there lived a hobbit.
               
      0291, let SMO be
      let $para := 
      In a hole in the ground there lived a hobbit.
               
      0322 SV
      let $para := 
      In a hole in the ground there lived a hobbit.
               
      0291 and let STZ be
      let $para := 
      In a hole in the ground there lived a hobbit.
               
      0342 SV
      let $para := 
      In a hole in the ground there lived a hobbit.
               
      0291; TV is
      let $para := 
      In a hole in the ground there lived a hobbit.
               
      0344 SYR
      let $para := 
      In a hole in the ground there lived a hobbit.
               
      0299 SMO, STZ
      let $para := 
      In a hole in the ground there lived a hobbit.
               
      0302.

    • If ST is

      op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
      964, then let SYR be
      let $para := 
      In a hole in the ground there lived a hobbit.
               
      0290 SV
      let $para := 
      In a hole in the ground there lived a hobbit.
               
      0291, let SMO be
      let $para := 
      In a hole in the ground there lived a hobbit.
               
      0292 SV
      let $para := 
      In a hole in the ground there lived a hobbit.
               
      0291 and let STZ be
      let $para := 
      In a hole in the ground there lived a hobbit.
               
      0296 SV
      let $para := 
      In a hole in the ground there lived a hobbit.
               
      0291; TV is
      let $para := 
      In a hole in the ground there lived a hobbit.
               
      0344 SYR
      let $para := 
      In a hole in the ground there lived a hobbit.
               
      0299 SMO, STZ
      let $para := 
      In a hole in the ground there lived a hobbit.
               
      0302.

    • If ST is

      let $para := 
      In a hole in the ground there lived a hobbit.
               
      00 or
      let $para := 
      In a hole in the ground there lived a hobbit.
               
      10, see 19.2 Casting from xs:string and xs:untypedAtomic.

  5. When a value of any primitive type is cast as

    op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
    967, the
    op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
    967 value TV is derived from ST and SV as follows:

    • If ST is

      op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
      967, then TV is SV.

    • If ST is

      let $para := 
      In a hole in the ground there lived a hobbit.
               
      29, let SYR be
      let $para := 
      In a hole in the ground there lived a hobbit.
               
      0320 SV
      let $para := 
      In a hole in the ground there lived a hobbit.
               
      0291 and let STZ be
      let $para := 
      In a hole in the ground there lived a hobbit.
               
      0342 SV
      let $para := 
      In a hole in the ground there lived a hobbit.
               
      0291; TV is
      let $para := 
      In a hole in the ground there lived a hobbit.
               
      0367 SYR, STZ
      let $para := 
      In a hole in the ground there lived a hobbit.
               
      0291.

    • If ST is

      op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
      964, let SYR be
      let $para := 
      In a hole in the ground there lived a hobbit.
               
      0290 SV
      let $para := 
      In a hole in the ground there lived a hobbit.
               
      0291; and let STZ be
      let $para := 
      In a hole in the ground there lived a hobbit.
               
      0296 SV
      let $para := 
      In a hole in the ground there lived a hobbit.
               
      0291; TV is
      let $para := 
      In a hole in the ground there lived a hobbit.
               
      0367 SYR, STZ
      let $para := 
      In a hole in the ground there lived a hobbit.
               
      0291.

    • If ST is

      let $para := 
      In a hole in the ground there lived a hobbit.
               
      00 or
      let $para := 
      In a hole in the ground there lived a hobbit.
               
      10, see 19.2 Casting from xs:string and xs:untypedAtomic.

  6. When a value of any primitive type is cast as

    op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
    968, the
    op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
    968 value TV is derived from ST and SV as follows:

    • If ST is

      op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
      968, then TV is SV.

    • If ST is

      let $para := 
      In a hole in the ground there lived a hobbit.
               
      29, then let SMO be
      let $para := 
      In a hole in the ground there lived a hobbit.
               
      0322 SV
      let $para := 
      In a hole in the ground there lived a hobbit.
               
      0291, let SDA be
      let $para := 
      In a hole in the ground there lived a hobbit.
               
      0324 SV
      let $para := 
      In a hole in the ground there lived a hobbit.
               
      0291 and let STZ be
      let $para := 
      In a hole in the ground there lived a hobbit.
               
      0342 SV
      let $para := 
      In a hole in the ground there lived a hobbit.
               
      0291; TV is
      let $para := 
      In a hole in the ground there lived a hobbit.
               
      0344
      let $para := 
      In a hole in the ground there lived a hobbit.
               
      0389 SMO
      let $para := 
      In a hole in the ground there lived a hobbit.
               
      0390 SDA, STZ
      let $para := 
      In a hole in the ground there lived a hobbit.
               
      0302.

    • If ST is

      op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
      964, then let SMO be
      let $para := 
      In a hole in the ground there lived a hobbit.
               
      0292 SV
      let $para := 
      In a hole in the ground there lived a hobbit.
               
      0291, let SDA be
      let $para := 
      In a hole in the ground there lived a hobbit.
               
      0294 SV
      let $para := 
      In a hole in the ground there lived a hobbit.
               
      0291 and let STZ be
      let $para := 
      In a hole in the ground there lived a hobbit.
               
      0296 SV
      let $para := 
      In a hole in the ground there lived a hobbit.
               
      0291; TV is
      let $para := 
      In a hole in the ground there lived a hobbit.
               
      0344
      let $para := 
      In a hole in the ground there lived a hobbit.
               
      0389 SMO
      let $para := 
      In a hole in the ground there lived a hobbit.
               
      0299 SDA, STZ
      let $para := 
      In a hole in the ground there lived a hobbit.
               
      0302.

    • If ST is

      let $para := 
      In a hole in the ground there lived a hobbit.
               
      00 or
      let $para := 
      In a hole in the ground there lived a hobbit.
               
      10, see 19.2 Casting from xs:string and xs:untypedAtomic.

  7. When a value of any primitive type is cast as

    op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
    970, the
    op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
    970 value TV is derived from ST and SV as follows:

    • If ST is

      op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
      970, then TV is SV.

    • If ST is

      let $para := 
      In a hole in the ground there lived a hobbit.
               
      29, then let SDA be
      let $para := 
      In a hole in the ground there lived a hobbit.
               
      0324 SV
      let $para := 
      In a hole in the ground there lived a hobbit.
               
      0291 and let STZ be
      let $para := 
      In a hole in the ground there lived a hobbit.
               
      0342 SV
      let $para := 
      In a hole in the ground there lived a hobbit.
               
      0291; TV is
      let $para := 
      In a hole in the ground there lived a hobbit.
               
      0413, SDA, STZ
      let $para := 
      In a hole in the ground there lived a hobbit.
               
      0291.

    • If ST is

      op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
      964, then let SDA be
      let $para := 
      In a hole in the ground there lived a hobbit.
               
      0294 SV
      let $para := 
      In a hole in the ground there lived a hobbit.
               
      0291 and let STZ be
      let $para := 
      In a hole in the ground there lived a hobbit.
               
      0296 SV
      let $para := 
      In a hole in the ground there lived a hobbit.
               
      0291; TV is
      let $para := 
      In a hole in the ground there lived a hobbit.
               
      0413, SDA, STZ
      let $para := 
      In a hole in the ground there lived a hobbit.
               
      0291.

    • If ST is

      let $para := 
      In a hole in the ground there lived a hobbit.
               
      00 or
      let $para := 
      In a hole in the ground there lived a hobbit.
               
      10, see 19.2 Casting from xs:string and xs:untypedAtomic.

  8. When a value of any primitive type is cast as

    op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
    969, the
    op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
    969 value TV is derived from ST and SV as follows:

    • If ST is

      op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
      969, then TV is SV.

    • If ST is

      let $para := 
      In a hole in the ground there lived a hobbit.
               
      29, then let SMO be
      let $para := 
      In a hole in the ground there lived a hobbit.
               
      0322 SV
      let $para := 
      In a hole in the ground there lived a hobbit.
               
      0291 and let STZ be
      let $para := 
      In a hole in the ground there lived a hobbit.
               
      0342 SV
      let $para := 
      In a hole in the ground there lived a hobbit.
               
      0291; TV is
      let $para := 
      In a hole in the ground there lived a hobbit.
               
      0432, SMO, STZ
      let $para := 
      In a hole in the ground there lived a hobbit.
               
      0291.

    • If ST is

      op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
      964, then let SMO be
      let $para := 
      In a hole in the ground there lived a hobbit.
               
      0292 SV
      let $para := 
      In a hole in the ground there lived a hobbit.
               
      0291 and let STZ be
      let $para := 
      In a hole in the ground there lived a hobbit.
               
      0296 SV
      let $para := 
      In a hole in the ground there lived a hobbit.
               
      0291; TV is
      let $para := 
      In a hole in the ground there lived a hobbit.
               
      0432, SMO, STZ
      let $para := 
      In a hole in the ground there lived a hobbit.
               
      0291.

    • If ST is

      let $para := 
      In a hole in the ground there lived a hobbit.
               
      00 or
      let $para := 
      In a hole in the ground there lived a hobbit.
               
      10, see 19.2 Casting from xs:string and xs:untypedAtomic.

19.1.5 Casting to xs:boolean

When a value of any ·primitive type· is cast as

op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
32, the
op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
32 value TV is derived from ST and SV as follows:

  • If ST is

    op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
    32, then TV is SV.

  • If ST is

    let $para := 
    In a hole in the ground there lived a hobbit.
             
    83,
    let $para := 
    In a hole in the ground there lived a hobbit.
             
    26,
    let $para := 
    In a hole in the ground there lived a hobbit.
             
    82 or
    let $para := 
    In a hole in the ground there lived a hobbit.
             
    85 and SV is
    declare %public function r:random-sequence($length as xs:integer) as xs:double* {
      r:random-sequence($length, fn:random-number-generator())
    };
    
    declare %private function r:random-sequence($length as xs:integer, 
                                                $G as map(xs:string, item())) {
      if ($length eq 0)
      then ()
      else ($G?number, r:random-sequence($length - 1, $G?next()))
    };
    
    r:random-sequence(200);
                
    19,
    let $para := 
    In a hole in the ground there lived a hobbit.
             
    0451,
    fn:abs($N * $arg2) le fn:abs($arg1) 
                   and fn:compare($N * $arg2, 0) eq fn:compare($arg1, 0).
    94,
    1º 2º 3º 4º ...
    66,
    1º 2º 3º 4º ...
    60 or
    fn:abs($N * $arg2) le fn:abs($arg1) 
                   and fn:compare($N * $arg2, 0) eq fn:compare($arg1, 0).
    90, then TV is
    let $C := 'http://www.w3.org/2013/collation/UCA?strength=primary'
    07.

  • If ST is

    let $para := 
    In a hole in the ground there lived a hobbit.
             
    83,
    let $para := 
    In a hole in the ground there lived a hobbit.
             
    26,
    let $para := 
    In a hole in the ground there lived a hobbit.
             
    82 or
    let $para := 
    In a hole in the ground there lived a hobbit.
             
    85 and SV is not one of the above values, then TV is
    op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
    76.

  • If ST is

    let $para := 
    In a hole in the ground there lived a hobbit.
             
    00 or
    let $para := 
    In a hole in the ground there lived a hobbit.
             
    10, see 19.2 Casting from xs:string and xs:untypedAtomic.

19.1.6 Casting to xs:base64Binary and xs:hexBinary

Values of type

let $para := 
In a hole in the ground there lived a hobbit.
         
196 can be cast as
let $para := 
In a hole in the ground there lived a hobbit.
         
219 and vice versa, since the two types have the same value space. Casting to
let $para := 
In a hole in the ground there lived a hobbit.
         
196 and
let $para := 
In a hole in the ground there lived a hobbit.
         
219 is also supported from the same type and from
let $para := 
In a hole in the ground there lived a hobbit.
         
00,
let $para := 
In a hole in the ground there lived a hobbit.
         
10 and subtypes of
let $para := 
In a hole in the ground there lived a hobbit.
         
10 using [XML Schema Part 2: Datatypes Second Edition] semantics.

19.1.7 Casting to xs:anyURI

Casting to

let $para := 
In a hole in the ground there lived a hobbit.
         
30 is supported only from the same type,
let $para := 
In a hole in the ground there lived a hobbit.
         
00 or
let $para := 
In a hole in the ground there lived a hobbit.
         
10.

When a value of any ·primitive type· is cast as

let $para := 
In a hole in the ground there lived a hobbit.
         
30, the
let $para := 
In a hole in the ground there lived a hobbit.
         
30 value TV is derived from the ST and SV as follows:

  • If ST is

    let $para := 
    In a hole in the ground there lived a hobbit.
             
    00 or
    let $para := 
    In a hole in the ground there lived a hobbit.
             
    10 see 19.2 Casting from xs:string and xs:untypedAtomic.

19.1.8 Casting to xs:QName and xs:NOTATION

Casting from

let $para := 
In a hole in the ground there lived a hobbit.
         
10 or
let $para := 
In a hole in the ground there lived a hobbit.
         
00 to
let $para := 
In a hole in the ground there lived a hobbit.
         
36 or
1º 2º 3º 4º ...
021 is described in 19.2 Casting from xs:string and xs:untypedAtomic.

It is also possible to cast from

1º 2º 3º 4º ...
021 to
let $para := 
In a hole in the ground there lived a hobbit.
         
36, or from
let $para := 
In a hole in the ground there lived a hobbit.
         
36 to any type derived by restriction from
1º 2º 3º 4º ...
021. (Casting to
1º 2º 3º 4º ...
021 itself is not allowed, because
1º 2º 3º 4º ...
021 is an abstract type.) The resulting
let $para := 
In a hole in the ground there lived a hobbit.
         
36 or
1º 2º 3º 4º ...
021 has the same prefix, local name, and namespace URI parts as the supplied value.

Note:

See 18.2 Constructor functions for xs:QName and xs:NOTATION for a discussion of how the combination of atomization and casting might not produce the desired effect.

19.1.9 Casting to xs:ENTITY

[XML Schema Part 2: Datatypes Second Edition] says that "The value space of ENTITY is the set of all strings that match the NCName production ... and have been declared as an unparsed entity in a document type definition." However, [XSL Transformations (XSLT) Version 3.0] and [XQuery 3.1: An XML Query Language] do not check that constructed values of type

let $C := 'http://www.w3.org/2013/collation/UCA?strength=primary'
791 match declared unparsed entities. Thus, this rule is relaxed in this specification and, in casting to
let $C := 'http://www.w3.org/2013/collation/UCA?strength=primary'
791 and types derived from it, no check is made that the values correspond to declared unparsed entities.

19.2 Casting from xs:string and xs:untypedAtomic

This section applies when the supplied value SV is an instance of

let $para := 
In a hole in the ground there lived a hobbit.
         
10 or
let $para := 
In a hole in the ground there lived a hobbit.
         
00, including types derived from these by restriction. If the value is
let $para := 
In a hole in the ground there lived a hobbit.
         
00, it is treated in exactly the same way as a string containing the same sequence of characters.

The supplied string is mapped to a typed value of the target type as defined in [XML Schema Part 2: Datatypes Second Edition]. Whitespace normalization is applied as indicated by the

let $para := 
In a hole in the ground there lived a hobbit.
         
0495 facet for the datatype. The resulting whitespace-normalized string must be a valid lexical form for the datatype. The semantics of casting follow the rules of XML Schema validation. For example,
let $para := 
In a hole in the ground there lived a hobbit.
         
0496 returns the
let $C := 'http://www.w3.org/2013/collation/UCA?strength=primary'
615 typed value
let $para := 
In a hole in the ground there lived a hobbit.
         
0498. This could also be written
let $para := 
In a hole in the ground there lived a hobbit.
         
0499.

The target type can be any simple type other than an abstract type. Specifically, it can be a type whose variety is atomic, union, or list. In each case the effect of casting to the target type is the same as constructing an element with the supplied value as its content, validating the element using the target type as the governing type, and atomizing the element to obtain its typed value.

When the target type is a derived type that is restricted by a pattern facet, the lexical form is first checked against the pattern before further casting is attempted (See 19.3.1 Casting to derived types). If the lexical form does not conform to the pattern, a dynamic error [err:FORG0001] is raised.

For example, consider a user-defined type

let $para := 
In a hole in the ground there lived a hobbit.
         
0500 which is derived by restriction from
op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
32 and specifies the pattern facet
let $para := 
In a hole in the ground there lived a hobbit.
         
0502. The expression
let $para := 
In a hole in the ground there lived a hobbit.
         
0503 would fail with a dynamic error [err:FORG0001].

Facets other than

let $para := 
In a hole in the ground there lived a hobbit.
         
0504 are checked after the conversion. For example if there is a user-defined datatype called
let $para := 
In a hole in the ground there lived a hobbit.
         
0505 defined as a restriction of
let $para := 
In a hole in the ground there lived a hobbit.
         
85 with the facet
let $para := 
In a hole in the ground there lived a hobbit.
         
0507, then the expression
let $para := 
In a hole in the ground there lived a hobbit.
         
0508 would fail with a dynamic error [err:FORG0001].

Casting to the types

1º 2º 3º 4º ...
021,
let $C := 'http://www.w3.org/2013/collation/UCA?strength=primary'
595, or
let $para := 
In a hole in the ground there lived a hobbit.
         
34 is not permitted because these types are abstract (they have no immediate instances).

Special rules apply when casting to namespace-sensitive types. The types

let $para := 
In a hole in the ground there lived a hobbit.
         
36 and
1º 2º 3º 4º ...
021 are namespace-sensitive. Any type derived by restriction from a namespace-sensitive type is itself namespace-sensitive, as is any union type having a namespace-sensitive type among its members, and any list type having a namespace-sensitive type as its item type. For details, see 18.2 Constructor functions for xs:QName and xs:NOTATION.

Note:

This version of the specification allows casting between

let $para := 
In a hole in the ground there lived a hobbit.
         
36 and
1º 2º 3º 4º ...
021 in either direction; this was not permitted in the previous Recommendation. This version also removes the rule that only a string literal (rather than a dynamic string) may be cast to an
let $para := 
In a hole in the ground there lived a hobbit.
         
36

When casting to a numeric type:

  • If the value is too large or too small to be accurately represented by the implementation, it is handled as an overflow or underflow as defined in 4.2 Arithmetic operators on numeric values.

  • If the target type is

    let $para := 
    In a hole in the ground there lived a hobbit.
             
    83 or
    let $para := 
    In a hole in the ground there lived a hobbit.
             
    26, the string
    fn:abs($N * $arg2) le fn:abs($arg1) 
                   and fn:compare($N * $arg2, 0) eq fn:compare($arg1, 0).
    94 (and equivalents such as
    let $para := 
    In a hole in the ground there lived a hobbit.
             
    0520 or
    let $para := 
    In a hole in the ground there lived a hobbit.
             
    0521) should be converted to the value negative zero. However, if the implementation is reliant on an implementation of XML Schema 1.0 in which negative zero is not part of the value space for these types, these lexical forms may be converted to positive zero.

In casting to

let $para := 
In a hole in the ground there lived a hobbit.
         
82 or to a type derived from
let $para := 
In a hole in the ground there lived a hobbit.
         
82, if the value is not too large or too small but nevertheless cannot be represented accurately with the number of decimal digits available to the implementation, the implementation may round to the nearest representable value or may raise a dynamic error [err:FOCA0006]. The choice of rounding algorithm and the choice between rounding and error behavior and is ·implementation-defined·.

In casting to

op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
964,
let $para := 
In a hole in the ground there lived a hobbit.
         
29,
op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
967, or
op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
966 (or types derived from these), if the value is too large or too small to be represented by the implementation, a dynamic error [err:FODT0001] is raised.

In casting to a duration value, if the value is too large or too small to be represented by the implementation, a dynamic error [err:FODT0002] is raised.

For

let $para := 
In a hole in the ground there lived a hobbit.
         
30, the extent to which an implementation validates the lexical form of
let $para := 
In a hole in the ground there lived a hobbit.
         
30 is ·implementation-dependent·.

If the cast fails for any other reason, a dynamic error [err:FORG0001] is raised.

19.3 Casting involving non-primitive types

Casting from

let $para := 
In a hole in the ground there lived a hobbit.
         
10 and
let $para := 
In a hole in the ground there lived a hobbit.
         
00 to any other type (primitive or non-primitive) has been described in 19.2 Casting from xs:string and xs:untypedAtomic. This section defines how other casts to non-primitive types operate, including casting to types derived by restriction, to union types, and to list types.

Note:

A non-primitive type here means any type that is not a ·primitive type· according to the extended definition used in 19 Casting.

19.3.1 Casting to derived types

Casting a value to a derived type can be separated into four cases. In these rules:

  • The types

    let $para := 
    In a hole in the ground there lived a hobbit.
             
    00,
    let $para := 
    In a hole in the ground there lived a hobbit.
             
    85,
    let $para := 
    In a hole in the ground there lived a hobbit.
             
    24, and
    let $para := 
    In a hole in the ground there lived a hobbit.
             
    25 are treated as primitive types (alongside the 19 primitive types defined in XSD).

  • For any atomic type T, let P(T) denote the most specific primitive type such that

    let $para := 
    In a hole in the ground there lived a hobbit.
             
    0536 is true.

The rules are then:

  1. When ST is the same type as TT: this case always succeeds, returning SV unchanged.

  2. When

    let $para := 
    In a hole in the ground there lived a hobbit.
             
    0537 is true: This case is described in 19.3.2 Casting from derived types to parent types.

  3. When P(ST) is the same type as P(TT): This case is described in 19.3.3 Casting within a branch of the type hierarchy.

  4. Otherwise (P(ST) is not the same type as P(TT)): This case is described in 19.3.4 Casting across the type hierarchy.

19.3.2 Casting from derived types to parent types

It is always possible to cast an atomic value A to a type T if the relation

let $para := 
In a hole in the ground there lived a hobbit.
         
0538 is true, provided that T is not an abstract type.

For example, it is possible to cast an

let $C := 'http://www.w3.org/2013/collation/UCA?strength=primary'
858 to an
let $C := 'http://www.w3.org/2013/collation/UCA?strength=primary'
615, to an
let $para := 
In a hole in the ground there lived a hobbit.
         
85, to an
let $para := 
In a hole in the ground there lived a hobbit.
         
82, or to a union type whose member types are
let $para := 
In a hole in the ground there lived a hobbit.
         
85 and
let $para := 
In a hole in the ground there lived a hobbit.
         
26.

Since the value space of the original type is a subset of the value space of the target type, such a cast is always successful.

For the expression

let $para := 
In a hole in the ground there lived a hobbit.
         
0538 to be true, T must be either an atomic type, or a union type that has no constraining facets. It cannot be a list type, nor a union type derived by restriction from another union type, nor a union type that has a list type among its member types.

The result will have the same value as the original, but will have a new type annotation:

  • If T is an atomic type, then the type annotation of the result is

    let $para := 
    In a hole in the ground there lived a hobbit.
             
    0546.

  • If T is a union type, then the type of the result is an atomic type

    let $para := 
    In a hole in the ground there lived a hobbit.
             
    0020 such that M is one of the atomic types in the transitive membership of the union type T and
    let $para := 
    In a hole in the ground there lived a hobbit.
             
    0548 is true; if there is more than one type M that satisfies these conditions (which could happen, for example, if T is the union of two overlapping types such as
    1º 2º 3º 4º ...
    32 and
    let $para := 
    In a hole in the ground there lived a hobbit.
             
    005) then the first one is used, taking the member types in the order in which they appear within the definition of the union type.

19.3.3 Casting within a branch of the type hierarchy

It is possible to cast an SV to a TT if the type of the SV and the TT type are both derived by restriction (directly or indirectly) from the same ·primitive type·, provided that the supplied value conforms to the constraints implied by the facets of the target type. This includes the case where the target type is derived from the type of the supplied value, as well as the case where the type of the supplied value is derived from the target type. For example, an instance of

let $C := 'http://www.w3.org/2013/collation/UCA?strength=primary'
834 can be cast as
let $C := 'http://www.w3.org/2013/collation/UCA?strength=primary'
858, provided the value is not negative.

If the value does not conform to the facets defined for the target type, then a dynamic error is raised [err:FORG0001]. See [XML Schema Part 2: Datatypes Second Edition]. In the case of the pattern facet (which applies to the lexical space rather than the value space), the pattern is tested against the canonical lexical representation of the value, as defined for the source type (or the result of casting the value to an

let $para := 
In a hole in the ground there lived a hobbit.
         
10, in the case of types that have no canonical lexical representation defined for them).

Note that this will cause casts to fail if the pattern excludes the canonical lexical representation of the source type. For example, if the type

let $para := 
In a hole in the ground there lived a hobbit.
         
0554 is defined as a restriction of
let $para := 
In a hole in the ground there lived a hobbit.
         
82 with a pattern that requires two digits after the decimal point, casting of an
let $para := 
In a hole in the ground there lived a hobbit.
         
85 to
let $para := 
In a hole in the ground there lived a hobbit.
         
0554 will always fail, because the canonical representation of an
let $para := 
In a hole in the ground there lived a hobbit.
         
85 does not conform to this pattern.

In some cases, casting from a parent type to a derived type requires special rules. See 19.1.3 Casting to duration types for rules regarding casting to

let $para := 
In a hole in the ground there lived a hobbit.
         
24 and
let $para := 
In a hole in the ground there lived a hobbit.
         
25. See 19.1.9 Casting to xs:ENTITY, below, for casting to
let $C := 'http://www.w3.org/2013/collation/UCA?strength=primary'
791 and types derived from it.

19.3.4 Casting across the type hierarchy

When the ST and the TT are derived, directly or indirectly, from different ·primitive types·, this is called casting across the type hierarchy. Casting across the type hierarchy is logically equivalent to three separate steps performed in order. Errors can occur in either of the latter two steps.

  1. Cast the SV, up the hierarchy, to the ·primitive type· of the source, as described in 19.3.2 Casting from derived types to parent types.

    1. If SV is an instance of

      let $para := 
      In a hole in the ground there lived a hobbit.
               
      10 or
      let $para := 
      In a hole in the ground there lived a hobbit.
               
      00, check its value against the pattern facet of TT, and raise a dynamic error [err:FORG0001] if the check fails.

  2. Cast the value to the ·primitive type· of TT, as described in 19.1 Casting from primitive types to primitive types.

    • If TT is derived from

      1º 2º 3º 4º ...
      021, assume for the purposes of this rule that casting to
      1º 2º 3º 4º ...
      021 succeeds.

  3. Cast the value down to the TT, as described in 19.3.3 Casting within a branch of the type hierarchy

19.3.5 Casting to union types

If the target type of a cast expression (or a constructor function) is a type with variety union, the supplied value must be one of the following:

  1. A value of type

    let $para := 
    In a hole in the ground there lived a hobbit.
             
    10 or
    let $para := 
    In a hole in the ground there lived a hobbit.
             
    00. This case follows the general rules for casting from strings, and has already been described in 19.2 Casting from xs:string and xs:untypedAtomic.

    If the union type has a pattern facet, the pattern is tested against the supplied value after whitespace normalization, using the

    let $para := 
    In a hole in the ground there lived a hobbit.
             
    0495 normalization rules of the member datatype against which validation succeeds.

  2. A value that is an instance of one of the atomic types in the transitive membership of the union type, and of the union type itself. This case has already been described in 19.3.2 Casting from derived types to parent types

    This situation only applies when the value is an instance of the union type, which means it will never apply when the union is derived by facet-based restriction from another union type.

  3. A value that is castable to one or more of the atomic types in the transitive membership of the union type (in the sense that the

    let $para := 
    In a hole in the ground there lived a hobbit.
             
    0569 operator returns true).

    In this case the supplied value is cast to each atomic type in the transitive membership of the union type in turn (in the order in which the member types appear in the declaration) until one of these casts is successful; if none of them is successful, a dynamic error occurs [err:FORG0001]. If the union type has constraining facets then the resulting value must satisfy these facets, otherwise a dynamic error occurs [err:FORG0001].

    If the union type has a pattern facet, the pattern is tested against the canonical representation of the result value.

    Only the atomic types in the transitive membership of the union type are considered. The union type may have list types in its transitive membership, but (unless the supplied value is of type

    let $para := 
    In a hole in the ground there lived a hobbit.
             
    10 or
    let $para := 
    In a hole in the ground there lived a hobbit.
             
    00, in which case the rules in 19.2 Casting from xs:string and xs:untypedAtomic apply), any list types in the membership are effectively ignored.

If more than one of these conditions applies, then the casting is done according to the rules for the first condition that applies.

If none of these conditions applies, the cast fails with a dynamic error [err:FORG0001].

Example: consider a type U whose member types are

let $para := 
In a hole in the ground there lived a hobbit.
         
85 and
op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
964.

  • The expression

    let $para := 
    In a hole in the ground there lived a hobbit.
             
    0574 returns the
    let $para := 
    In a hole in the ground there lived a hobbit.
             
    85 value
    op:operation(fenceHeight, xs:integer) => op:operation(xs:integer, xs:integer)
    31.

  • The expression

    let $para := 
    In a hole in the ground there lived a hobbit.
             
    0577 returns the current date as an instance of
    op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
    964.

  • The expression

    let $para := 
    In a hole in the ground there lived a hobbit.
             
    0579 returns the
    let $para := 
    In a hole in the ground there lived a hobbit.
             
    85 value
    let $para := 
    In a hole in the ground there lived a hobbit.
             
    0581.

Example: consider a type V whose member types are

let $C := 'http://www.w3.org/2013/collation/UCA?strength=primary'
828 and
let $C := 'http://www.w3.org/2013/collation/UCA?strength=primary'
810.

  • The expression

    let $para := 
    In a hole in the ground there lived a hobbit.
             
    0584 returns the
    let $C := 'http://www.w3.org/2013/collation/UCA?strength=primary'
    828 value
    let $para := 
    In a hole in the ground there lived a hobbit.
             
    0586.

  • The expression

    let $para := 
    In a hole in the ground there lived a hobbit.
             
    0587 returns the
    let $C := 'http://www.w3.org/2013/collation/UCA?strength=primary'
    810 value
    let $para := 
    In a hole in the ground there lived a hobbit.
             
    0589.

  • The expression

    let $para := 
    In a hole in the ground there lived a hobbit.
             
    0590 returns the
    let $C := 'http://www.w3.org/2013/collation/UCA?strength=primary'
    828 value
    let $para := 
    In a hole in the ground there lived a hobbit.
             
    0592.

  • The expression

    let $para := 
    In a hole in the ground there lived a hobbit.
             
    0593 raises a dynamic error [err:FORG0001] on the grounds that the string
    let $para := 
    In a hole in the ground there lived a hobbit.
             
    0594 is not in the lexical space of the union type.

Example: consider a type W that is derived from the above type V by restriction, with a pattern facet of

let $para := 
In a hole in the ground there lived a hobbit.
         
0595.

  • The expression

    let $para := 
    In a hole in the ground there lived a hobbit.
             
    0596 returns the
    let $C := 'http://www.w3.org/2013/collation/UCA?strength=primary'
    828 value
    op:operation(xs:int, xs:double) => op:operation(xs:double, xs:double)
    700.

  • The expression

    let $para := 
    In a hole in the ground there lived a hobbit.
             
    0599 raises an dynamic error [err:FORG0001] on the grounds that the string
    let $para := 
    In a hole in the ground there lived a hobbit.
             
    0600 does not match the pattern facet.

19.3.6 Casting to list types

If the target type of a cast expression (or a constructor function) is a type with variety

let $para := 
In a hole in the ground there lived a hobbit.
         
0601, the supplied value must be of type
let $para := 
In a hole in the ground there lived a hobbit.
         
10 or
let $para := 
In a hole in the ground there lived a hobbit.
         
00. The rules follow the general principle for all casts from
let $para := 
In a hole in the ground there lived a hobbit.
         
10 outlined in 19.2 Casting from xs:string and xs:untypedAtomic.

The semantics of the operation are consistent with validation: that is, the effect of casting a string S to a list type L is the same as constructing an element or attribute node whose string value is S, validating it using L as the governing type, and atomizing the resulting node. The result will always be either failure, or a sequence of zero or more atomic values each of which is an instance of the item type of L (or if the item type of L is a union type, an instance of one of the atomic types in its transitive membership).

If the item type of the list type is namespace-sensitive, then the namespace bindings in the static context will be used to resolve any namespace prefix, in the same way as when the target type is

let $para := 
In a hole in the ground there lived a hobbit.
         
36.

If the list type has a

let $para := 
In a hole in the ground there lived a hobbit.
         
0504 facet, the pattern must match the supplied value after collapsing whitespace (an operation equivalent to the use of the
let $para := 
In a hole in the ground there lived a hobbit.
         
215 function).

For example, the expression

let $para := 
In a hole in the ground there lived a hobbit.
         
0608 produces a sequence of four
1º 2º 3º 4º ...
642 values,
let $para := 
In a hole in the ground there lived a hobbit.
         
0610.

For example, given a user-defined type

let $para := 
In a hole in the ground there lived a hobbit.
         
0611 defined as a list of
let $para := 
In a hole in the ground there lived a hobbit.
         
85 with the facet
let $para := 
In a hole in the ground there lived a hobbit.
         
0613, the expression
let $para := 
In a hole in the ground there lived a hobbit.
         
0614 will return a sequence of two xs:integer values
let $para := 
In a hole in the ground there lived a hobbit.
         
0615, while the expression
let $para := 
In a hole in the ground there lived a hobbit.
         
0616 will result in a dynamic error because the length of the list does not conform to the
let $para := 
In a hole in the ground there lived a hobbit.
         
0617 facet. The expression
let $para := 
In a hole in the ground there lived a hobbit.
         
0618 will also fail because the strings
Primo Secondo Terzo Quarto Quinto ...
662 and
let $para := 
In a hole in the ground there lived a hobbit.
         
104 are not in the lexical space of
let $para := 
In a hole in the ground there lived a hobbit.
         
85.

How many 3 digit numbers have the property that the sum of their digits is even?

If you allow leading zeroes, there are 1000 three-digit numbers, if you are strict, there are 900 three-digit numbers, so the final answer is 500 or 450, depending on your definition.

How many 3 digit numbers are there in which all the digits are even?

The total 3 digit numbers are 999 including preceding zeros and there are 999/2 even numbers. so total three digit even numbers are 499.

How many 3 digit numbers are there whose sum of digits is equal to product of digits?

Answer: 123, 321, 213 are the three-digit numbers whose sum of the digit is equal to the product of the digit.

How many 3 digit whole numbers whose digit sum is 24 are even?

The answer is 4 three-digit integers.