XQuery Function Documentation

Search and Browse

http://www.w3.org/2005/xpath-functions

java:org.exist.xquery.functions.fn.FnModule

A module with the XQuery/XPath Core Library Functions

QName

QName($uri as xs:string?, $qname as xs:string) as xs:QName

Returns an xs:QName with the namespace URI given in $uri. If $uri is the zero-length string or the empty sequence, it represents "no namespace"; in this case, if the value of $qname contains a colon (:), an error is raised [err:FOCA0002]. The prefix (or absence of a prefix) in $qname is retained in the returned xs:QName value. The local name in the result is taken from the local part of $qname.
If $qname does not have the correct lexical form for xs:QName an error is raised [err:FOCA0002].
Note that unlike xs:QName this function does not require a xs:string literal as the argument.

Parameters:
$uri? The namespace URI
$qname The prefix
Returns:
xs:QName : the xs:QName with the namespace URI given in $uri

abs

abs($number as xs:numeric?) as xs:numeric?

Returns the absolute value of the argument $number.If the argument is negative returns -$number otherwise returns $number.

Parameters:
$number? The number
Returns:
xs:numeric? : The absolute value of the argument

adjust-date-to-timezone

adjust-date-to-timezone($date as xs:date?) as xs:date?

Adjusts the xs:date value $date to the implicit timezone of the current locale.

Parameters:
$date? The date
Returns:
xs:date? : the adjusted date

adjust-date-to-timezone

adjust-date-to-timezone($date as xs:date?, $duration as xs:dayTimeDuration?) as xs:date?

Adjusts the xs:date value $date to a specific timezone, or to no timezone at all. If $duration is the empty sequence, returns an xs:date without a timezone.

Parameters:
$date? The date
$duration? The duration
Returns:
xs:date? : the adjusted date

adjust-dateTime-to-timezone

adjust-dateTime-to-timezone($date-time as xs:dateTime?) as xs:dateTime?

Adjusts the xs:dateTime value $date-time to the implicit timezone of the current locale.

Parameters:
$date-time? The date-time
Returns:
xs:dateTime? : the adjusted date-time

adjust-dateTime-to-timezone

adjust-dateTime-to-timezone($date-time as xs:dateTime?, $duration as xs:dayTimeDuration?) as xs:dateTime?

Adjusts the xs:dateTime value $date-time to a specific timezone, or to no timezone at all. If $duration is the empty sequence, returns an xs:dateTime without a timezone.

Parameters:
$date-time? The date-time
$duration? The duration
Returns:
xs:dateTime? : the adjusted date-time

adjust-time-to-timezone

adjust-time-to-timezone($time as xs:time?) as xs:time?

Adjusts the xs:time value $time to the implicit timezone of the current locale.

Parameters:
$time? The time
Returns:
xs:time? : the adjusted time

adjust-time-to-timezone

adjust-time-to-timezone($time as xs:time?, $duration as xs:dayTimeDuration?) as xs:time?

Adjusts the xs:time value $time to a specific timezone, or to no timezone at all. If $duration is the empty sequence, returns an xs:time without a timezone.

Parameters:
$time? The time
$duration? The duration
Returns:
xs:time? : the adjusted time

analyze-string

analyze-string($input as xs:string?, $pattern as xs:string) as element()

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.

Parameters:
$input? The input string
$pattern The pattern
Returns:
element() : The result of the analysis

analyze-string

analyze-string($input as xs:string?, $pattern as xs:string, $flags as xs:string) as element()

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.

Parameters:
$input? The input string
$pattern The pattern
$flags Flags
Returns:
element() : The result of the analysis

apply

apply($function as function(*), $array as array(*)) as item()*

Processes the supplied sequence from right to left, applying the supplied function repeatedly to each item in turn, together with an accumulated result value.

Parameters:
$function the function to call
$array an array containing the arguments to pass to the function
Returns:
item()* : return value of the function call

available-environment-variables

available-environment-variables() as xs:string*

Returns a list of environment variable names.

Returns:
xs:string* : Returns a sequence of strings, being the names of the environment variables. User must be DBA.

avg

avg($values as xs:anyAtomicType*) as xs:anyAtomicType?

Returns the average of the values in the input sequence $values, that is, the sum of the values divided by the number of values.

Parameters:
$values* The values
Returns:
xs:anyAtomicType? : The average of the values in the input sequence

base-uri

base-uri() as xs:anyURI?

Returns the base URI of the context node. It is equivalent to calling fn:base-uri(.).

Returns:
xs:anyURI? : The base URI from the context node.

base-uri

base-uri($arg as node()?) as xs:anyURI?

Returns the base URI of a node.If $arg is the empty sequence, the empty sequence is returned.

Parameters:
$arg? The node.
Returns:
xs:anyURI? : The base URI from $arg.

boolean

boolean($items as item()*) as xs:boolean

Computes the xs:boolean value of the sequence items.

Parameters:
$items* The items
Returns:
xs:boolean : The boolean value, ebv, of the items

ceiling

ceiling($number as xs:numeric?) as xs:numeric?

Returns a value of the same type as the argument. Specifically, returns the smallest (closest to negative infinity) number with no fractional part that is not less than the value of the argument, $number.

Parameters:
$number? The number
Returns:
xs:numeric? : The non-fractional number not less than $number

codepoint-equal

codepoint-equal($string-1 as xs:string?, $string-2 as xs:string?) as xs:boolean?

Returns true or false depending on whether the value of $string-1 is equal to the value of $string-2, according to the Unicode code point collation.

Parameters:
$string-1? The first string
$string-2? The second string
Returns:
xs:boolean? : true() if the codepoints are equal, false() otherwise

codepoints-to-string

codepoints-to-string($codepoints as xs:integer*) as xs:string

Creates an xs:string from a sequence of code points. Returns the zero-length string if $codepoints is the empty sequence. If any of the code points in $codepoints is not a legal XML character, an error is raised

Parameters:
$codepoints* The codepoints as a sequence of xs:integer values
Returns:
xs:string : The string constructed from the codepoints if valid

collection

collection($collection-uris as xs:string*) as item()*

Returns the documents contained in the collections specified in the input sequence. Collection URIs can be specified either as a simple collection path or an XMLDB URI. Documents contained in sub-collections are also included. If no value is supplied, the statically know documents are used, for the REST Server this could be the addressed collection.

Parameters:
$collection-uris* The collection-URIs for which to include the documents
Returns:
item()* : The document nodes contained in or under the given collections

compare

compare($string-1 as xs:string?, $string-2 as xs:string?) as xs:integer?

Returns the collatable comparison between $string-1 and $string-2, using $collation-uri. -1 if $string-1 is inferior to $string-2, 0 if $string-1 is equal to $string-2, 1 if $string-1 is superior to $string-2. If either comparand is the empty sequence, the empty sequence is returned. Please remember to specify the collation in the context or use, the three argument version if you don't want the system default.

Parameters:
$string-1? The first string
$string-2? The second string
Returns:
xs:integer? : -1 if $string-1 is inferior to $string-2, 0 if $string-1 is equal to $string-2, 1 if $string-1 is superior to $string-2. If either comparand is the empty sequence, the empty sequence is returned.

compare

compare($string-1 as xs:string?, $string-2 as xs:string?, $collation-uri as xs:string) as xs:integer?

Returns the collatable comparison between $string-1 and $string-2, using $collation-uri. -1 if $string-1 is inferior to $string-2, 0 if $string-1 is equal to $string-2, 1 if $string-1 is superior to $string-2. If either comparand is the empty sequence, the empty sequence is returned. The third argument $collation-uri is either: 1) the full URI e.g. "http://www.w3.org/2013/collation/UCA?lang=en;strength=secondary", or 2) relative where you only need to specify the last part of a valid full collation-uri, e.g. "?lang=sv-SE", "lang=sv-SE;strength=primary;decomposition=standard" or "swedish".

Parameters:
$string-1? The first string
$string-2? The second string
$collation-uri The relative collation URI
Returns:
xs:integer? : -1 if $string-1 is inferior to $string-2, 0 if $string-1 is equal to $string-2, 1 if $string-1 is superior to $string-2. If either comparand is the empty sequence, the empty sequence is returned.

concat

concat($atomizable-values as xs:anyAtomicType?) as xs:string

Accepts two or more xdt:anyAtomicType arguments, $atomizable-values, and converts them to xs:string. Returns the xs:string that is the concatenation of the values of its arguments after conversion. If any of the arguments is the empty sequence, the argument is treated as the zero-length string.

Parameters:
$atomizable-values? The atomizable values
Returns:
xs:string : The concatenated values

contains

contains($source-string as xs:string?, $substring as xs:string?) as xs:boolean

Returns an xs:boolean indicating whether or not the value of $source-string 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 $substring, according to the default collation.

Parameters:
$source-string? The source-string
$substring? The substring
Returns:
xs:boolean : true() if $source-string contains $substring, false() otherwise

contains

contains($source-string as xs:string?, $substring as xs:string?, $collation-uri as xs:string) as xs:boolean

Returns an xs:boolean indicating whether or not the value of $source-string 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 $substring, according to the collation that is specified in $collation-uri.The third argument $collation-uri is either: 1) the full URI e.g. "http://www.w3.org/2013/collation/UCA?lang=en;strength=secondary", or 2) relative where you only need to specify the last part of a valid full collation-uri, e.g. "?lang=sv-SE", "lang=sv-SE;strength=primary;decomposition=standard" or "swedish".

Parameters:
$source-string? The source-string
$substring? The substring
$collation-uri The collation URI
Returns:
xs:boolean : true() if $source-string contains $substring, false() otherwise

contains-token

contains-token($input as xs:string*, $token as xs:string) as xs:boolean

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.

Parameters:
$input* The input string
$token The token to be searched for
Returns:
xs:boolean : The function returns true if and only if there is string in $input which, after tokenizing at whitespace boundaries, contains a token that is equal to the trimmed value of $token under the rules of the selected collation.

contains-token

contains-token($input as xs:string*, $token as xs:string, $pattern as xs:string?) as xs:boolean

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.

Parameters:
$input* The input string
$token The token to be searched for
$pattern? Collation to use
Returns:
xs:boolean : The function returns true if and only if there is string in $input which, after tokenizing at whitespace boundaries, contains a token that is equal to the trimmed value of $token under the rules of the selected collation.

count

count($items as item()*) as xs:integer

Returns the number of items in the argument sequence, $items.

Parameters:
$items* The items
Returns:
xs:integer : The number of items in the argument sequence

current-date

current-date() as xs:date

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

Returns:
xs:date : the date current within the query execution time span

current-dateTime

current-dateTime() as xs:dateTime

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

Returns:
xs:dateTime : the date-time current within query execution time span

current-time

current-time() as xs:time

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

Returns:
xs:time : the time current within query execution time span

data

data() as xs:anyAtomicType*

Atomizes the context item, replacing all nodes in the sequence by their typed values.

Returns:
xs:anyAtomicType* : the atomic values of the items in $items

data

data($items as item()*) as xs:anyAtomicType*

Atomizes the sequence $items, replacing all nodes in the sequence by their typed values.

Parameters:
$items* The items
Returns:
xs:anyAtomicType* : the atomic values of the items in $items

dateTime

dateTime($date as xs:date?, $time as xs:time?) as xs:dateTime?

Creates an xs:dateTime from an xs:date, $date, and an xs:time, $time.

Parameters:
$date? The date as xs:date
$time? The time as xs:time
Returns:
xs:dateTime? : the combined date and time as xs:dateTime

day-from-date

day-from-date($date as xs:date?) as xs:integer?

Returns an xs:integer between 1 and 31, both inclusive, representing the day component in the localized value of $date.

Parameters:
$date? The date as xs:date
Returns:
xs:integer? : the day component from $date

day-from-dateTime

day-from-dateTime($date-time as xs:dateTime?) as xs:integer?

Returns an xs:integer between 1 and 31, both inclusive, representing the day component in the localized value of $date-time.

Parameters:
$date-time? The date-time as xs:dateTime
Returns:
xs:integer? : the day component from $date-time

days-from-duration

days-from-duration($duration as xs:duration?) as xs:integer?

Returns an xs:integer representing the days component in the canonical lexical representation of the value of $duration. The result may be negative.

Parameters:
$duration? The duration as xs:duration
Returns:
xs:integer? : the days component of $duration

deep-equal

deep-equal($items-1 as item()*, $items-2 as item()*) as xs:boolean

Returns true() iff every item in $items-1 is deep-equal to the item at the same position in $items-2, false() otherwise. If both $items-1 and $items-2 are the empty sequence, returns true().

Parameters:
$items-1* The first item sequence
$items-2* The second item sequence
Returns:
xs:boolean : true() if the sequences are deep-equal, false() otherwise

deep-equal

deep-equal($items-1 as item()*, $items-2 as item()*, $collation-uri as xs:string) as xs:boolean

Returns true() iff every item in $items-1 is deep-equal to the item at the same position in $items-2, false() otherwise. If both $items-1 and $items-2 are the empty sequence, returns true(). Comparison collation is specified by $collation-uri. The third argument $collation-uri is either: 1) the full URI e.g. "http://www.w3.org/2013/collation/UCA?lang=en;strength=secondary", or 2) relative where you only need to specify the last part of a valid full collation-uri, e.g. "?lang=sv-SE", "lang=sv-SE;strength=primary;decomposition=standard" or "swedish".

Parameters:
$items-1* The first item sequence
$items-2* The second item sequence
$collation-uri The collation URI
Returns:
xs:boolean : true() if the sequences are deep-equal, false() otherwise

default-collation

default-collation() as xs:string

Returns the context's default collation. E.g. http://www.w3.org/2005/xpath-functions/collation/codepoint.

Returns:
xs:string : the default collation from the context

distinct-values

distinct-values($atomic-values as xs:anyAtomicType*) as xs:anyAtomicType*

Returns a sequence where duplicate values of $atomic-values, based on value equality, have been deleted.

Parameters:
$atomic-values* The atomic values
Returns:
xs:anyAtomicType* : the distinct values sequence

distinct-values

distinct-values($atomic-values as xs:anyAtomicType*, $collation-uri as xs:string) as xs:anyAtomicType*

Returns a sequence where duplicate values of $atomic-values, based on value equality specified by collation $collation-uri, have been deleted.

Parameters:
$atomic-values* The atomic values
$collation-uri The collation URI
Returns:
xs:anyAtomicType* : the distinct values sequence

doc

doc($document-uri as xs:string?) as document-node()?

Returns the document node of $document-uri. Resource URIs can be specified either as a simple collection path, an XMLDB URI or any URI.

Parameters:
$document-uri? The document URI
Returns:
document-node()? : the document node of $document-uri

doc-available

doc-available($document-uri as xs:string?) as xs:boolean

Returns whether or not the document, $document-uri, specified in the input sequence is available. Resource URIs can be specified either as a simple collection path, an XMLDB URI or any URI.

Parameters:
$document-uri? The document URI
Returns:
xs:boolean : true() if the document is available, false() otherwise

document-uri

document-uri() as xs:anyURI?

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

Returns:
xs:anyURI? : The URI of a resource.

document-uri

document-uri($value as node()*) as xs:anyURI?

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

Parameters:
$value* The document node.
Returns:
xs:anyURI? : The URI of a resource.

empty

empty($items as item()*) as xs:boolean

Returns true() if the value of $items is the empty sequence, false() otherwise.

Parameters:
$items* The item sequence
Returns:
xs:boolean : true() if the empty sequence, false() otherwise

encode-for-uri

encode-for-uri($uri-part as xs:string?) as xs:string

Escapes reserved characters in $uri-part by replacing it with its percent-encoded form as described in [RFC 3986]. If $uri-part is the empty sequence, returns the zero-length string.

Parameters:
$uri-part? The URI part to encode
Returns:
xs:string : the URI part with reserved characters percent encoded

ends-with

ends-with($source-string as xs:string?, $suffix as xs:string?) as xs:boolean

Returns true() if the string value of $suffix is a suffix of the string value of $source-string, false() otherwise. If either $source-string or $suffix is the empty sequence, the empty sequence is returned.

Parameters:
$source-string? The source-string
$suffix? The suffix
Returns:
xs:boolean : true() if $suffix is suffix of $source-string, false() otherwise

ends-with

ends-with($source-string as xs:string?, $suffix as xs:string?, $collation-uri as xs:string) as xs:boolean

Returns true() if the string value of $suffix is a suffix of the string value of $source-string using collation $collation-uri, false() otherwise. If either $source-string or $suffix is the empty sequence, the empty sequence is returned. The third argument $collation-uri is either: 1) the full URI e.g. "http://www.w3.org/2013/collation/UCA?lang=en;strength=secondary", or 2) relative where you only need to specify the last part of a valid full collation-uri, e.g. "?lang=sv-SE", "lang=sv-SE;strength=primary;decomposition=standard" or "swedish".

Parameters:
$source-string? The source string
$suffix? The suffix
$collation-uri The collation URI
Returns:
xs:boolean : true() if $suffix is suffix of $source-string, false() otherwise

environment-variable

environment-variable($name as xs:string) as xs:string?

Returns the value of a system environment variable, if it exists.

Parameters:
$name Name of environment variable.
Returns:
xs:string? : Corrensponding value of the environment variable, if there is no environment variable with a matching name, the function returns the empty sequence. User must be DBA.

equals

equals($source-string as xs:string?, $substring as xs:string?) as xs:boolean

Returns an xs:boolean indicating whether or not the value of $source-string equals the collation units in the value of $substring, according to the default collation. This function is similar to the '=' expression, except that it uses the default collation for comparisons.

Parameters:
$source-string? The source-string
$substring? The substring
Returns:
xs:boolean : true() if $source-string equals $substring, false() otherwise

equals

equals($source-string as xs:string?, $substring as xs:string?, $collation-uri as xs:string) as xs:boolean

Returns an xs:boolean indicating whether or not the value of $source-string equals the collation units in the value of $substring, according to the collation that is specified in $collation-uri. This function is similar to the '=' expression, except that it uses the specified collation for comparisons.The third argument $collation-uri is either: 1) the full URI e.g. "http://www.w3.org/2013/collation/UCA?lang=en;strength=secondary", or 2) relative where you only need to specify the last part of a valid full collation-uri, e.g. "?lang=sv-SE", "lang=sv-SE;strength=primary;decomposition=standard" or "swedish".

Parameters:
$source-string? The source-string
$substring? The substring
$collation-uri The collation URI
Returns:
xs:boolean : true() if $source-string equals $substring, false() otherwise

error

error() as empty-sequence()

Indicates that an irrecoverable error has occurred. The script will terminate immediately with an exception using the default qname, 'http://www.w3.org/2004/07/xqt-errors#err:FOER0000', and the default error message, 'An error has been raised by the query'.

Returns:
empty-sequence()

error

error($qname as xs:QName?) as empty-sequence()

Indicates that an irrecoverable error has occurred. The script will terminate immediately with an exception using $qname and the default message, 'An error has been raised by the query'.

Parameters:
$qname? The qname
Returns:
empty-sequence()

error

error($qname as xs:QName?, $message as xs:string) as empty-sequence()

Indicates that an irrecoverable error has occurred. The script will terminate immediately with an exception using $qname and $message.

Parameters:
$qname? The qname
$message The message
Returns:
empty-sequence()

error

error($qname as xs:QName?, $message as xs:string, $error-object as item()*) as empty-sequence()

Indicates that an irrecoverable error has occurred. The script will terminate immediately with an exception using $qname and $message with $error-object appended.

Parameters:
$qname? The qname
$message The message
$error-object* The error object
Returns:
empty-sequence()

escape-html-uri

escape-html-uri($html-uri as xs:string?) as xs:string

Replaces all non-printable ASCII characters in the string value of $html-uri by an escape sequence represented as a hexadecimal octet in the form %XX. If $html-uri is the empty sequence, returns the zero-length string.

Parameters:
$html-uri? The html URI
Returns:
xs:string : all nonprintable ASCII characters in $html-uri encoded by escape sequences

escape-uri

escape-uri($uri as xs:string?, $escape-reserved as xs:boolean) as xs:string

This function applies the URI escaping rules defined in section 2 of [RFC 2396] as amended by [RFC 2732], with one exception, to the string supplied as $uri, which typically represents all or part of a URI. The effect of the function is to escape a set of identified characters in the string. Each such character is replaced in the string 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. $escape-reserved indicates whether to escape reserved characters.

Parameters:
$uri? The URI
$escape-reserved The escaped-reserved
Returns:
xs:string : the identified characters in $uri encoded with escape sequences

exactly-one

exactly-one($items as item()*) as item()

Returns the argument sequence, $items, if it contains exactly one item. Otherwise, raises an error.

Parameters:
$items* The item sequence
Returns:
item() : the sole item in $items if it contains exactly one item. Otherwise, an error is raised.

exists

exists($items as item()*) as xs:boolean

Returns true if the argument $items is not the empty sequence, false otherwise.

Parameters:
$items* The item sequence
Returns:
xs:boolean : true() if not the empty-sequence, false() otherwise

false

false() as xs:boolean

Always returns the boolean value false

Returns:
xs:boolean : false

filter

filter($sequence as item()*, $function as function(*)) as item()*

Returns those items from the sequence $sequence for which the supplied function $function returns true.

Parameters:
$sequence* the sequence to filter
$function the function to call
Returns:
item()* : result of filtering the sequence

floor

floor($number as xs:numeric?) as xs:numeric?

Returns the largest number not greater than the value of $number. If $number is the empty sequence, returns the empty sequence.

Parameters:
$number? The number
Returns:
xs:numeric? : the largest number without fraction part not greater than the value of $number

fold-left

fold-left($sequence as item()*, $zero as item()*, $function as function(*)) as item()*

Processes the supplied sequence from left to right, applying the supplied function repeatedly to each item in turn, together with an accumulated result value.

Parameters:
$sequence* the sequence to filter
$zero* initial value to start with
$function the function to call
Returns:
item()* : result of the fold-left operation

fold-right

fold-right($sequence as item()*, $zero as item()*, $function as function(*)) as item()*

Processes the supplied sequence from right to left, applying the supplied function repeatedly to each item in turn, together with an accumulated result value.

Parameters:
$sequence* the sequence to filter
$zero* initial value to start with
$function the function to call
Returns:
item()* : result of the fold-right operation

for-each

for-each($sequence as item()*, $function as function(*)) as item()*

Applies the function item $function to every item from the sequence $sequence in turn, returning the concatenation of the resulting sequences in order.

Parameters:
$sequence* the sequence on which to apply the function
$function the function to call
Returns:
item()* : result of applying the function to each item of the sequence

for-each-pair

for-each-pair($seq1 as item()*, $seq2 as item()*, $function as function(*)) as item()*

Applies the function item $f to successive pairs of items taken one from $seq1 and one from $seq2, returning the concatenation of the resulting sequences in order.

Parameters:
$seq1* first sequence to take items from
$seq2* second sequence to take items from
$function the function to call
Returns:
item()* : concatenation of resulting sequences

format-date

format-date($value as xs:date?, $picture as xs:string) as xs:string?

Returns a string containing an xs:date value formatted for display.

Read more
Parameters:
$value? The date
$picture The picture string
Returns:
xs:string? : The formatted date

format-date

format-date($value as xs:date?, $picture as xs:string, $language as xs:string?, $calendar as xs:string?, $place as xs:string?) as xs:string?

Returns a string containing an xs:date value formatted for display.

Read more
Parameters:
$value? The date
$picture The picture string
$language? The language string
$calendar? The calendar string
$place? The place string
Returns:
xs:string? : The formatted date

format-dateTime

format-dateTime($value as xs:dateTime?, $picture as xs:string) as xs:string?

Returns a string containing an xs:date value formatted for display.

Parameters:
$value? The datetime
$picture The picture string
Returns:
xs:string? : The formatted date

format-dateTime

format-dateTime($value as xs:dateTime?, $picture as xs:string, $language as xs:string?, $calendar as xs:string?, $place as xs:string?) as xs:string?

Returns a string containing an xs:date value formatted for display.

Parameters:
$value? The datetime
$picture The picture string
$language? The language string
$calendar? The calendar string
$place? The place string
Returns:
xs:string? : The formatted date

format-number

format-number($value as xs:numeric?, $picture as xs:string) as xs:string

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

Parameters:
$value? The number to format
$picture The picture string to use for formatting. To understand the picture string syntax, see: https://www.w3.org/TR/xpath-functions-31/#func-format-number
Returns:
xs:string : The formatted string representation of the supplied number

format-number

format-number($value as xs:numeric?, $picture as xs:string, $decimal-format-name as xs:string?) as xs:string

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

Parameters:
$value? The number to format
$picture The picture string to use for formatting. To understand the picture string syntax, see: https://www.w3.org/TR/xpath-functions-31/#func-format-number
$decimal-format-name? The name (as an EQName) of a decimal format to use.
Returns:
xs:string : The formatted string representation of the supplied number

format-time

format-time($value as xs:time?, $picture as xs:string) as xs:string?

Returns a string containing an xs:time value formatted for display.

Parameters:
$value? The time
$picture The picture string
Returns:
xs:string? : The formatted date

format-time

format-time($value as xs:time?, $picture as xs:string, $language as xs:string?, $calendar as xs:string?, $place as xs:string?) as xs:string?

Returns a string containing an xs:time value formatted for display.

Parameters:
$value? The time
$picture The picture string
$language? The language string
$calendar? The calendar string
$place? The place string
Returns:
xs:string? : The formatted date

function-arity

function-arity($function as function(*)) as xs:integer

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

Parameters:
$function The function item
Returns:
xs:integer : The arity of the function.

function-lookup

function-lookup($name as xs:QName, $arity as xs:integer) as function(*)?

Returns a reference to the function having a given name and arity, if there is one, the empty sequence otherwise

Parameters:
$name Qualified name of the function
$arity The arity (number of arguments) of the function
Returns:
function(*)? : The function if found, empty sequence otherwise

function-name

function-name($function as function(*)) as xs:QName?

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

Parameters:
$function The function item
Returns:
xs:QName? : The name of the function or the empty sequence if $function is an anonymous function.

generate-id

generate-id() as xs:string

This function returns a string that uniquely identifies a given node. Without an argument, the node to identify is taken from the current context item.

Returns:
xs:string : Unique identifier for the node

generate-id

generate-id($node as node()?) as xs:string

This function returns a string that uniquely identifies a given node.

Parameters:
$node? The node for which an identifier will be generated. If it is the empty sequence, the result will be the empty string
Returns:
xs:string : Unique identifier for the node

has-children

has-children() as xs:boolean

Returns true if the context item has one or more child nodes

Returns:
xs:boolean : true if the context item has one of more child nodes, false otherwise

has-children

has-children($node as node()?) as xs:boolean

Returns true if the supplied node has one or more child nodes

Parameters:
$node? The node to test
Returns:
xs:boolean : true if $node has one of more child nodes, false otherwise

head

head($arg as item()*) as item()?

The function returns the value of the expression $arg[1], i.e. the first item in the passed in sequence.

Parameters:
$arg* $arg*
Returns:
item()? : the first item or the empty sequence

hours-from-dateTime

hours-from-dateTime($date-time as xs:dateTime?) as xs:integer?

Returns an xs:integer between 0 and 23, both inclusive, representing the value of the hours component in the localized value of $date-time.

Parameters:
$date-time? The date-time as xs:dateTime
Returns:
xs:integer? : the hours component from $date-time

hours-from-duration

hours-from-duration($duration as xs:duration?) as xs:integer?

Returns an xs:integer representing the hours component in the canonical lexical representation of the value of $duration. The result may be negative.

Parameters:
$duration? The duration as xs:duration
Returns:
xs:integer? : the hours component of $duration

hours-from-time

hours-from-time($time as xs:time?) as xs:integer?

Returns an xs:integer between 0 and 23, both inclusive, representing the value of the hours component in the localized value of $time.

Parameters:
$time? The time as xs:time
Returns:
xs:integer? : the hours component from $time

id

id($idrefs as xs:string*) as element()*

Returns the sequence of element nodes that have an ID value matching the value of one or more of the IDREF values supplied in $idrefs. If none is matching or $idrefs is the empty sequence, returns the empty sequence.

Parameters:
$idrefs* The IDREF sequence
Returns:
element()* : the elements with IDs matching IDREFs from $idref-sequence

id

id($idrefs as xs:string*, $node-in-document as node()) as element()*

Returns the sequence of element nodes that have an ID value matching the value of one or more of the IDREF values supplied in $idrefs and is in the same document as $node-in-document. If none is matching or $idrefs is the empty sequence, returns the empty sequence.

Parameters:
$idrefs* The IDREF sequence
$node-in-document The node in document
Returns:
element()* : the elements with IDs matching IDREFs from $idrefs in the same document as $node-in-document

idref

idref($ids as xs:string*) as node()*

Returns the sequence of element or attributes nodes with an IDREF value matching the value of one or more of the ID values supplied in $ids. If none is matching or $ids is the empty sequence, returns the empty sequence.

Parameters:
$ids* The ID sequence
Returns:
node()* : the elements with matching IDREF values from IDs in $ids

idref

idref($ids as xs:string*, $node-in-document as node()) as node()*

Returns the sequence of element or attributes nodes with an IDREF value matching the value of one or more of the ID values supplied in $ids. If none is matching or $ids is the empty sequence, returns the empty sequence.

Parameters:
$ids* The ID sequence
$node-in-document The node in document
Returns:
node()* : the elements with matching IDREF values from IDs in $ids in the same document as $node-in-document

implicit-timezone

implicit-timezone() as xs:dayTimeDuration

Returns the value of the implicit timezone property from the dynamic context.

Returns:
xs:dayTimeDuration : the implicit timezone daytime-duration from the dynamic context

in-scope-prefixes

in-scope-prefixes($element as element()) as xs:string*

Returns the prefixes of the in-scope namespaces for $element. For namespaces that have a prefix, it returns the prefix as an xs:NCName. For the default namespace, which has no prefix, it returns the zero-length string.

Parameters:
$element The element
Returns:
xs:string* : the prefixes

index-of

index-of($source as xs:anyAtomicType*, $search as xs:anyAtomicType) as xs:integer*

Returns a sequence of positive integers giving the positions within the sequence of atomic values $source that are equal to $search.
The collation used by the invocation of this function is determined according to the rules in 7.3.1 Collations. The collation is used when string comparison is required.
The items in the sequence $source are compared with $search under the rules for the 'eq' operator. Values of type xs:untypedAtomic are compared as if they were of type xs:string. Values that cannot be compared, i.e. the 'eq' 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 $source is included in the result.
If the value of $source is the empty sequence, or if no item in $source matches $search, then the empty sequence is returned.
The first item in a sequence is at position 1, not position 0.
The result sequence is in ascending numeric order.

Parameters:
$source* The source sequence
$search The search component
Returns:
xs:integer* : the sequence of positive integers giving the positions within the sequence

index-of

index-of($source as xs:anyAtomicType*, $search as xs:anyAtomicType, $collation-uri as xs:string) as xs:integer*

Returns a sequence of positive integers giving the positions within the sequence of atomic values $source that are equal to $search.
The collation used by the invocation of this function is determined according to the rules in 7.3.1 Collations. The collation is used when string comparison is required.
The items in the sequence $source are compared with $search under the rules for the 'eq' operator. Values of type xs:untypedAtomic are compared as if they were of type xs:string. Values that cannot be compared, i.e. the 'eq' 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 $source is included in the result.
If the value of $source is the empty sequence, or if no item in $source matches $search, then the empty sequence is returned.
The first item in a sequence is at position 1, not position 0.
The result sequence is in ascending numeric order. The third argument $collation-uri is either: 1) the full URI e.g. "http://www.w3.org/2013/collation/UCA?lang=en;strength=secondary", or 2) relative where you only need to specify the last part of a valid full collation-uri, e.g. "?lang=sv-SE", "lang=sv-SE;strength=primary;decomposition=standard" or "swedish".

Parameters:
$source* The source sequence
$search The search component
$collation-uri The collation URI
Returns:
xs:integer* : the sequence of positive integers giving the positions within the sequence

innermost

innermost($nodes as node()*) as node()*

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.

Parameters:
$nodes* The nodes to test
Returns:
node()* : The nodes that are not an ancestor of another node in the input sequence

insert-before

insert-before($target as item()*, $position as xs:integer, $inserts as item()*) as item()*

Returns a new sequence constructed from the value of $target with the value of $inserts inserted at the position specified by the value of $position. (The value of $target is not affected by the sequence construction.)
If $target is the empty sequence, $inserts is returned. If $inserts is the empty sequence, $target is returned.
The value returned by the function consists of all items of $target whose index is less than $position, followed by all items of $inserts, followed by the remaining elements of $target, in that sequence.
If $position is less than one (1), the first position, the effective value of $position is one (1). If $position is greater than the number of items in $target, then the effective value of $position is equal to the number of items in $target plus 1.

Parameters:
$target* The target
$position The position to insert before
$inserts* The data to insert
Returns:
item()* : the new sequence

iri-to-uri

iri-to-uri($iri as xs:string?) as xs:string

This function converts an xs:string containing an IRI into a URI according to the rules spelled out in Section 3.1 of [RFC 3987]. It is idempotent but not invertible. If $iri 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. If $iri is the empty sequence, returns the zero-length string. 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: This function does not check whether $iri is a legal IRI. It treats it as an xs:string and operates on the characters in the xs: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 $iri they will be percent-encoded. In addition, characters outside the range x20-x126 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".

Parameters:
$iri? The IRI
Returns:
xs:string : the URI

json-doc

json-doc($href as xs:string?) as item()?

Reads an external (or database) resource containing JSON, and returns the results of parsing the resource as JSON. An URL parameter without scheme or scheme 'xmldb:' is considered to point to a database resource.

Parameters:
$href? URL pointing to a JSON resource
Returns:
item()? : The parsed data, typically a map, array or atomic value

json-doc

json-doc($href as xs:string?, $options as map(*)) as item()?

Reads an external (or database) resource containing JSON, and returns the results of parsing the resource as JSON. An URL parameter without scheme or scheme 'xmldb:' is considered to point to a database resource.

Parameters:
$href? URL pointing to a JSON resource
$options Parsing options
Returns:
item()? : The parsed data, typically a map, array or atomic value

json-to-xml

json-to-xml($json-text as xs:string?) as item()?

Parses a string supplied in the form of a JSON text, returning the results in the form of an XML document node.

Parameters:
$json-text? JSON text as defined in [RFC 7159]. The function parses this string to return an XDM value
Returns:
item()? : The parsed data as XML

json-to-xml

json-to-xml($json-text as xs:string?, $options as map(*)) as item()?

Parses a string supplied in the form of a JSON text, returning the results in the form of an XML document node.

Parameters:
$json-text? JSON text as defined in [RFC 7159]. The function parses this string to return an XDM value
$options Parsing options
Returns:
item()? : The parsed data as XML

lang

lang($lang as xs:string?) as xs:boolean

Tests whether the language of the context item as specified by xml:lang attributes is the same as, or is a sublanguage of, the language specified by $lang. The behavior of the function if the second argument is omitted is exactly the same as if the context item (.) had been passed as the second argument. The language of the argument node, or the context item if the second argument is omitted, is determined by the value of the xml:lang attribute on the node, or, if the node has no such attribute, by the value of the xml:lang attribute on the nearest ancestor of the node that has an xml:lang attribute. If there is no such ancestor, then the function returns false().
The following errors may be raised: if the context item is undefined [err:XPDY0002]XP; if the context item is not a node [err:XPTY0004]XP.
If $lang is the empty sequence it is interpreted as the zero-length string.

Parameters:
$lang? The language code
Returns:
xs:boolean : true if the language code matches, false otherwise

lang

lang($lang as xs:string?, $node as node()) as xs:boolean

Tests whether the language of $node as specified by xml:lang attributes is the same as, or is a sublanguage of, the language specified by $lang. The behavior of the function if the second argument is omitted is exactly the same as if the context item (.) had been passed as the second argument. The language of the argument node, or the context item if the second argument is omitted, is determined by the value of the xml:lang attribute on the node, or, if the node has no such attribute, by the value of the xml:lang attribute on the nearest ancestor of the node that has an xml:lang attribute. If there is no such ancestor, then the function returns false().
The following errors may be raised: if the context item is undefined [err:XPDY0002]XP; if the context item is not a node [err:XPTY0004]XP.
If $lang is the empty sequence it is interpreted as the zero-length string.

Parameters:
$lang? The language code
$node The node
Returns:
xs:boolean : true if the language code matches, false otherwise

last

last() as xs:integer

Returns the context size from the dynamic context. If the context item is undefined, an error is raised.

Returns:
xs:integer : the context size from the dynamic context

load-xquery-module

load-xquery-module($module-uri as xs:string) as map(*)

Provides access to the public functions and global variables of a dynamically-loaded XQuery library module.

Parameters:
$module-uri The target namespace of the module
Returns:
map(*) : a map with two entries: 1) 'variables': a map with 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 xs:QName value; the associated value is the value of the variable; 2) 'functions': a map which 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 xs:QName 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 xs:integer 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.

load-xquery-module

load-xquery-module($module-uri as xs:string, $options as map(*)) as map(*)

Provides access to the public functions and global variables of a dynamically-loaded XQuery library module.

Parameters:
$module-uri The target namespace of the module
$options Options for loading the module
Returns:
map(*) : a map with two entries: 1) 'variables': a map with 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 xs:QName value; the associated value is the value of the variable; 2) 'functions': a map which 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 xs:QName 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 xs:integer 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.

local-name

local-name() as xs:string

Returns the local part of the name of $arg as an xs:string that will either be the zero-length string or will have the lexical form of an xs:NCName.
If the argument is omitted, it defaults to the context item (.). 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 following errors may be raised: if the context item is undefined [err:XPDY0002]XP; if the context item is not a node [err:XPTY0004]XP.
If the argument is supplied and is the empty sequence, the function returns the zero-length string.
If the target node has no name (that is, if it is a document node, a comment, or a text node), the function returns the zero-length string.
Otherwise, the value returned will be the local part of the expanded-QName of the target node (as determined by the dm:node-name accessor in Section 5.11 node-name AccessorDM. This will be an xs:string whose lexical form is an xs:NCName.

Returns:
xs:string : the local name

local-name

local-name($arg as node()?) as xs:string

Returns the local part of the name of $arg as an xs:string that will either be the zero-length string or will have the lexical form of an xs:NCName.
If the argument is omitted, it defaults to the context item (.). 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 following errors may be raised: if the context item is undefined [err:XPDY0002]XP; if the context item is not a node [err:XPTY0004]XP.
If the argument is supplied and is the empty sequence, the function returns the zero-length string.
If the target node has no name (that is, if it is a document node, a comment, or a text node), the function returns the zero-length string.
Otherwise, the value returned will be the local part of the expanded-QName of the target node (as determined by the dm:node-name accessor in Section 5.11 node-name AccessorDM. This will be an xs:string whose lexical form is an xs:NCName.

Parameters:
$arg? The node to retrieve the local name from
Returns:
xs:string : the local name

local-name-from-QName

local-name-from-QName($arg as xs:QName?) as xs:NCName?

Returns an xs:NCName representing the local part of $arg. If $arg is the empty sequence, returns the empty sequence.

Parameters:
$arg? The QName
Returns:
xs:NCName? : the local name

lower-case

lower-case($arg as xs:string?) as xs:string

Returns the value of $arg after translating every character to its lower-case correspondent as defined in the appropriate case mappings section in 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.

Parameters:
$arg? The text to be converted to all lower-case characters
Returns:
xs:string : the resulting lower-case text

matches

matches($input as xs:string?, $pattern as xs:string) as xs:boolean

The function returns true if $input matches the regular expression supplied as $pattern as influenced by the value of $flags, if present; otherwise, it returns false.
The effect of calling this version of the function with the $flags argument set to azero-length string is the same as using the other two argument version. Flags are defined in 7.6.1.1 Flags.
If $input is the empty sequence, it is interpreted as the zero-length string.
Unless the metacharacters ^ and $ 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 multiline mode).
Note:
This is different from the behavior of patterns in [XML Schema Part 2: Datatypes Second Edition], where regular expressions are implicitly anchored.
Please note that - in contrast - with the specification - this method allows zero or more items for the string argument.
An error is raised [err:FORX0002] if the value of $pattern is invalid according to the rules described in section 7.6.1 Regular Expression Syntax.
An error is raised [err:FORX0001] if the value of $flags is invalid according to the rules described in section 7.6.1 Regular Expression Syntax.

Parameters:
$input? The input string
$pattern The pattern
Returns:
xs:boolean : true if the pattern is a match, false otherwise

matches

matches($input as xs:string?, $pattern as xs:string, $flags as xs:string) as xs:boolean

The function returns true if $input matches the regular expression supplied as $pattern as influenced by the value of $flags, if present; otherwise, it returns false.
The effect of calling this version of the function with the $flags argument set to azero-length string is the same as using the other two argument version. Flags are defined in 7.6.1.1 Flags.
If $input is the empty sequence, it is interpreted as the zero-length string.
Unless the metacharacters ^ and $ 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 multiline mode).
Note:
This is different from the behavior of patterns in [XML Schema Part 2: Datatypes Second Edition], where regular expressions are implicitly anchored.
Please note that - in contrast - with the specification - this method allows zero or more items for the string argument.
An error is raised [err:FORX0002] if the value of $pattern is invalid according to the rules described in section 7.6.1 Regular Expression Syntax.
An error is raised [err:FORX0001] if the value of $flags is invalid according to the rules described in section 7.6.1 Regular Expression Syntax.

Parameters:
$input? The input string
$pattern The pattern
$flags The flags
Returns:
xs:boolean : true if the pattern is a match, false otherwise

max

max($arg as xs:anyAtomicType*) as xs:anyAtomicType?

Selects an item from the input sequence $arg whose value is greater than or equal to the value of every other item in the input sequence. If there are two or more such items, then the specific item whose value is returned is implementation dependent.
The following rules are applied to the input sequence:
- Values of type xs:untypedAtomic in $arg are cast to xs:double. - Numeric and xs:anyURI values are converted to the least common type that supports the 'ge' operator by a combination of type promotion and subtype substitution. See Section B.1 Type PromotionXP and Section B.2 Operator MappingXP.
The items in the resulting sequence may be reordered in an arbitrary order. The resulting sequence is referred to below as the converted sequence. This 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 $arg must be numeric or derived from a single base type for which the 'ge' 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 purposes of comparison. Duration values must either all be xs:yearMonthDuration values or must all be xs:dayTimeDuration values.
If any of these conditions is not met, then a type error is raised [err:FORG0006].
If the converted sequence contains the value NaN, the value NaN is returned.
If the items in the value of $arg are of type xs:string or types derived by restriction from xs:string, then the determination of the item with the largest value is made according to the collation that is used.The collation used by the invocation of this function is determined according to the rules in 7.3.1 Collations.

Parameters:
$arg* The input sequence
Returns:
xs:anyAtomicType? : the max value

max

max($arg as xs:anyAtomicType*, $collation-uri as xs:string) as xs:anyAtomicType?

Selects an item from the input sequence $arg whose value is greater than or equal to the value of every other item in the input sequence. If there are two or more such items, then the specific item whose value is returned is implementation dependent.
The following rules are applied to the input sequence:
- Values of type xs:untypedAtomic in $arg are cast to xs:double. - Numeric and xs:anyURI values are converted to the least common type that supports the 'ge' operator by a combination of type promotion and subtype substitution. See Section B.1 Type PromotionXP and Section B.2 Operator MappingXP.
The items in the resulting sequence may be reordered in an arbitrary order. The resulting sequence is referred to below as the converted sequence. This 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 $arg must be numeric or derived from a single base type for which the 'ge' 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 purposes of comparison. Duration values must either all be xs:yearMonthDuration values or must all be xs:dayTimeDuration values.
If any of these conditions is not met, then a type error is raised [err:FORG0006].
If the converted sequence contains the value NaN, the value NaN is returned.
If the items in the value of $arg are of type xs:string or types derived by restriction from xs:string, then the determination of the item with the largest value is made according to the collation that is used.If the type of the items in $arg is not xs:string and $collation-uri is specified, the collation is ignored.
The collation used by the invocation of this function is determined according to the rules in 7.3.1 Collations.

Parameters:
$arg* The input sequence
$collation-uri The collation URI
Returns:
xs:anyAtomicType? : the max value

min

min($arg as xs:anyAtomicType*) as xs:anyAtomicType?

Selects an item from the input sequence $arg whose value is less than or equal to the value of every other item in the input sequence. If there are two or more such items, then the specific item whose value is returned is implementation dependent.
The following rules are applied to the input sequence:
- Values of type xs:untypedAtomic in $arg are cast to xs:double. - Numeric and xs:anyURI values are converted to the least common type that supports the 'le' operator by a combination of type promotion and subtype substitution. See Section B.1 Type PromotionXP and Section B.2 Operator MappingXP.
The items in the resulting sequence may be reordered in an arbitrary order. The resulting sequence is referred to below as the converted sequence. This 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 $arg must be numeric or derived from a single base type for which the 'le' 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 xs:yearMonthDuration values or must all be xs:dayTimeDuration values.
If any of these conditions is not met, a type error is raised [err:FORG0006].
If the converted sequence contains the value NaN, the value NaN is returned.
If the items in the value of $arg are of type xs:string or types derived by restriction from xs:string, then the determination of the item with the smallest value is made according to the collation that is used. The collation used by the invocation of this function is determined according to the rules in 7.3.1 Collations.

Parameters:
$arg* The input sequence
Returns:
xs:anyAtomicType? : the minimum value

min

min($arg as xs:anyAtomicType*, $collation-uri as xs:string) as xs:anyAtomicType?

Selects an item from the input sequence $arg whose value is less than or equal to the value of every other item in the input sequence. If there are two or more such items, then the specific item whose value is returned is implementation dependent.
The following rules are applied to the input sequence:
- Values of type xs:untypedAtomic in $arg are cast to xs:double. - Numeric and xs:anyURI values are converted to the least common type that supports the 'le' operator by a combination of type promotion and subtype substitution. See Section B.1 Type PromotionXP and Section B.2 Operator MappingXP.
The items in the resulting sequence may be reordered in an arbitrary order. The resulting sequence is referred to below as the converted sequence. This 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 $arg must be numeric or derived from a single base type for which the 'le' 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 xs:yearMonthDuration values or must all be xs:dayTimeDuration values.
If any of these conditions is not met, a type error is raised [err:FORG0006].
If the converted sequence contains the value NaN, the value NaN is returned.
If the items in the value of $arg are of type xs:string or types derived by restriction from xs:string, 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 $arg is not xs:string and $collation is specified, the collation is ignored.
The collation used by the invocation of this function is determined according to the rules in 7.3.1 Collations.

Parameters:
$arg* The input sequence
$collation-uri The collation URI
Returns:
xs:anyAtomicType? : the minimum value

minutes-from-dateTime

minutes-from-dateTime($date-time as xs:dateTime?) as xs:integer?

Returns an xs:integer value between 0 to 59, both inclusive, representing the value of the minutes component in the localized value of $date-time.

Parameters:
$date-time? The date-time as xs:dateTime
Returns:
xs:integer? : the minutes component from $date-time

minutes-from-duration

minutes-from-duration($duration as xs:duration?) as xs:integer?

Returns an xs:integer representing the minutes component in the canonical lexical representation of the value of $duration. The result may be negative.

Parameters:
$duration? The duration as xs:duration
Returns:
xs:integer? : the minutes component of $duration

minutes-from-time

minutes-from-time($time as xs:time?) as xs:integer?

Returns an xs:integer value between 0 to 59, both inclusive, representing the value of the minutes component in the localized value of $time.

Parameters:
$time? The time as xs:time
Returns:
xs:integer? : the minutes component from $time

month-from-date

month-from-date($date as xs:date?) as xs:integer?

Returns an xs:integer between 1 and 12, both inclusive, representing the month component in the localized value of $date.

Parameters:
$date? The date as xs:date
Returns:
xs:integer? : the month component from $date

month-from-dateTime

month-from-dateTime($date-time as xs:dateTime?) as xs:integer?

Returns an xs:integer between 1 and 12, both inclusive, representing the month component in the localized value of $date-time.

Parameters:
$date-time? The date-time as xs:dateTime
Returns:
xs:integer? : the month component from $date-time

months-from-duration

months-from-duration($duration as xs:duration?) as xs:integer?

Returns an xs:integer representing the months component in the canonical lexical representation of the value of $duration. The result may be negative.

Parameters:
$duration? The duration as xs:duration
Returns:
xs:integer? : the months component of $duration

name

name() as xs:string

Returns the name of the context item as an xs:string that is either the zero-length string, or has the lexical form of an xs:QName.
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 following errors may be raised: if the context item is undefined [err:XPDY0002]XP; if the context item is not a node [err:XPTY0004]XP.
If the argument is supplied and is the empty sequence, the function returns the zero-length string.
If the target node has no name (that is, if it is a document node, a comment, a text node, or a namespace binding having no name), the function returns the zero-length string.
Otherwise, the value returned is fn:string(fn:node-name($arg)).

Returns:
xs:string : the name

name

name($arg as node()?) as xs:string

Returns the name of $arg as an xs:string that is either the zero-length string, or has the lexical form of an xs:QName.
If the argument is omitted, it defaults to the context item (.). 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 following errors may be raised: if the context item is undefined [err:XPDY0002]XP; if the context item is not a node [err:XPTY0004]XP.
If the argument is supplied and is the empty sequence, the function returns the zero-length string.
If the target node has no name (that is, if it is a document node, a comment, a text node, or a namespace binding having no name), the function returns the zero-length string.
Otherwise, the value returned is fn:string(fn:node-name($arg)).

Parameters:
$arg? The input node
Returns:
xs:string : the name

namespace-uri

namespace-uri() as xs:anyURI

Returns the namespace URI of the xs:QName of the context item.
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 following errors may be raised: if the context item is undefined [err:XPDY0002]XP; if the context item is not a node [err:XPTY0004]XP.
If $arg is neither an element nor an attribute node, or if it is an element or attribute node whose expanded-QName (as determined by the dm:node-name accessor in the Section 5.11 node-name AccessorDM) is in no namespace, then the function returns the xs:anyURI corresponding to the zero-length string.

Returns:
xs:anyURI : the namespace URI

namespace-uri

namespace-uri($arg as node()?) as xs:anyURI

Returns the namespace URI of the xs:QName of $arg.
If the argument is omitted, it defaults to the context node (.). 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 following errors may be raised: if the context item is undefined [err:XPDY0002]XP; if the context item is not a node [err:XPTY0004]XP.
If $arg is neither an element nor an attribute node, or if it is an element or attribute node whose expanded-QName (as determined by the dm:node-name accessor in the Section 5.11 node-name AccessorDM) is in no namespace, then the function returns the xs:anyURI corresponding to the zero-length string.

Parameters:
$arg? The input node
Returns:
xs:anyURI : the namespace URI

namespace-uri-for-prefix

namespace-uri-for-prefix($prefix as xs:string?, $element as element()) as xs:anyURI?

Returns the namespace URI of one of the in-scope namespaces for $element, identified by its namespace prefix.
If $element has an in-scope namespace whose namespace prefix is equal to $prefix, it returns the namespace URI of that namespace. If $prefix is the zero-length string or the empty sequence, it returns the namespace URI of the default (unnamed) namespace. Otherwise, it returns the empty sequence.
Prefixes are equal only if their Unicode code points match exactly.

Parameters:
$prefix? The namespace prefix
$element The element
Returns:
xs:anyURI? : the namespace URI

namespace-uri-from-QName

namespace-uri-from-QName($arg as xs:QName?) as xs:anyURI?

Returns the namespace URI for $arg. If $arg is the empty sequence, returns the empty sequence.

Parameters:
$arg? The QName
Returns:
xs:anyURI? : the namespace URI

nilled

nilled($arg as node()?) as xs:boolean?

Returns an xs:boolean indicating whether the argument node is "nilled". If the argument is not an element node, returns the empty sequence. If the argument is the empty sequence, returns the empty sequence.

Parameters:
$arg? The input node
Returns:
xs:boolean? : true if the argument node is "nilled"

node-name

node-name() as xs:QName?

Returns an expanded-QName for node kinds that can have names. For other kinds of nodes it returns the empty sequence. If the context item is the empty sequence, the empty sequence is returned.

Returns:
xs:QName? : the expanded QName

node-name

node-name($arg as node()?) as xs:QName?

Returns an expanded-QName for node kinds that can have names. For other kinds of nodes it returns the empty sequence. If $arg is the empty sequence, the empty sequence is returned.

Parameters:
$arg? The input node
Returns:
xs:QName? : the expanded QName

normalize-space

normalize-space() as xs:string

Returns the calculated string value of the context item with whitespace normalized by stripping leading and trailing whitespace and replacing sequences of one or more than one whitespace character with a single space, #x20.
The whitespace characters are defined in the metasymbol S (Production 3) of [Extensible Markup Language (XML) 1.0 Recommendation (Third Edition)].
Note:
The definition of the metasymbol S (Production 3), is unchanged in [Extensible Markup Language (XML) 1.1 Recommendation].
If no argument is supplied, $arg defaults to the string value (calculated using fn:string()) of the context item (.). If no argument is supplied or if the argument is the context item and the context item is undefined an error is raised: [err:XPDY0002].

Returns:
xs:string : the normalized text

normalize-space

normalize-space($arg as xs:string?) as xs:string

Returns the value of $arg with whitespace normalized by stripping leading and trailing whitespace and replacing sequences of one or more than one whitespace character with a single space, #x20.
The whitespace characters are defined in the metasymbol S (Production 3) of [Extensible Markup Language (XML) 1.0 Recommendation (Third Edition)].
Note:
The definition of the metasymbol S (Production 3), is unchanged in [Extensible Markup Language (XML) 1.1 Recommendation].
If the value of $arg is the empty sequence, returns the zero-length string.
If no argument is supplied, $arg defaults to the string value (calculated using fn:string()) of the context item (.). If no argument is supplied or if the argument is the context item and the context item is undefined an error is raised: [err:XPDY0002].

Parameters:
$arg? The string to normalize
Returns:
xs:string : the normalized text

normalize-unicode

normalize-unicode($arg as xs:string?) as xs:string

Returns the value of the context item normalized according to the nomalization form "NFC"

Parameters:
$arg? The unicode string to normalize
Returns:
xs:string : the normalized text

normalize-unicode

normalize-unicode($arg as xs:string?, $normalization-form as xs:string) as xs:string

Returns the value of $arg normalized according to the normalization criteria for a normalization form identified by the value of $normalization-form. The effective value of the $normalization-form is computed by removing leading and trailing blanks, if present, and converting to upper case.
If the value of $arg is the empty sequence, returns the zero-length string.
See [Character Model for the World Wide Web 1.0: Normalization] for a description of the normalization forms.
- If the effective value of $normalization-form is "NFC", then the value returned by the function is the value of $arg in Unicode Normalization Form C (NFC). - If the effective value of $normalization-form is "NFD", then the value returned by the function is the value of $arg in Unicode Normalization Form D (NFD). - If the effective value of $normalization-form is "NFKC", then the value returned by the function is the value of $arg in Unicode Normalization Form KC (NFKC). - If the effective value of $normalization-form is "NFKD", then the value returned by the function is the value of $arg in Unicode Normalization Form KD (NFKD). - If the effective value of $normalization-form is "FULLY-NORMALIZED", then the value returned by the function is the value of $arg in the fully normalized form. - If the effective value of $normalization-form is the zero-length string, no normalization is performed and $arg is returned.
Conforming implementations must support normalization form "NFC" and may support normalization forms "NFD", "NFKC", "NFKD", "FULLY-NORMALIZED". They may also support other normalization forms with implementation-defined semantics. If the effective value of the $normalization-form is other than one of the values supported by the implementation, then an error is raised [err:FOCH0003].

Parameters:
$arg? The unicode string to normalize
$normalization-form The normalization form
Returns:
xs:string : the normalized text

not

not($arg as item()*) as xs:boolean

Returns true if the effective boolean value is false, and false if the effective boolean value is true.
$arg is reduced to an effective boolean value by applying the fn:boolean() function.

Parameters:
$arg* The input items
Returns:
xs:boolean : the negated effective boolean value (ebv) of $arg

number

number() as xs:double

Returns the value of the context item after atomization, converted to an xs:double.
If the context item cannot be converted to an xs:double, the xs:double value NaN is returned. If the context item is undefined an error is raised: [err:XPDY0002]XP.

Returns:
xs:double : the numerical value

number

number($arg as xs:anyAtomicType?) as xs:double

Returns the value indicated by $arg or, if $arg is not specified, the context item after atomization, converted to an xs:double.
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 (.). That is, fn:number() is equivalent to fn:number(.).
If $arg is the empty sequence or if $arg or the context item cannot be converted to an xs:double, the xs:double value NaN is returned. If the context item is undefined an error is raised: [err:XPDY0002]XP.
If $arg is the empty sequence, NaN is returned. Otherwise, $arg, or the context item after atomization, is converted to an xs:double following the rules of 17.1.3.2 Casting to xs:double. If the conversion to xs:double fails, the xs:double value NaN is returned.

Parameters:
$arg? The input item
Returns:
xs:double : the numerical value

one-or-more

one-or-more($arg as item()*) as item()+

Returns $arg if it contains one or more items. Otherwise, raises an error.

Parameters:
$arg* The input sequence
Returns:
item()+ : the sequence passed in by $arg if it contains one or more items.

outermost

outermost($nodes as node()*) as node()*

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.

Parameters:
$nodes* The nodes to test
Returns:
node()* : The nodes that have no ancestor which is itself in the input sequence

parse-ietf-date

parse-ietf-date($value as xs:string?) as xs:dateTime?

Parses a string containing the date and time in IETF format, returning the corresponding xs:dateTime value.

Parameters:
$value? The IETF-dateTime string
Returns:
xs:dateTime? : The parsed date

parse-json

parse-json($json-text as xs:string?) as item()?

Parses a string supplied in the form of a JSON text, returning the results typically in the form of a map or array.

Parameters:
$json-text? JSON string
Returns:
item()? : The parsed data, typically a map, array or atomic value

parse-json

parse-json($json-text as xs:string?, $options as map(*)) as item()?

Parses a string supplied in the form of a JSON text, returning the results typically in the form of a map or array.

Parameters:
$json-text? JSON string
$options Parsing options
Returns:
item()? : The parsed data, typically a map, array or atomic value

parse-xml

parse-xml($arg as xs:string?) as document-node()?

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.

Parameters:
$arg? The string to be parsed
Returns:
document-node()? : the parsed document

parse-xml-fragment

parse-xml-fragment($arg as xs:string?) as document-node()?

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.

Parameters:
$arg? The string to be parsed
Returns:
document-node()? : the parsed document fragment

position

position() as xs:integer

Returns the context position from the dynamic context. If the context item is undefined, raises an error.

Returns:
xs:integer : the context position

prefix-from-QName

prefix-from-QName($arg as xs:QName?) as xs:NCName?

Returns an xs:NCName representing the prefix of $arg. If $arg is the empty sequence, returns the empty sequence.

Parameters:
$arg? The QName
Returns:
xs:NCName? : the prefix

random-number-generator

random-number-generator() as map(*)

Returns a random number generator, which can be used to generate sequences of random numbers.

Returns:
map(*) : 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: `number`, `next`, and `permute`.

random-number-generator

random-number-generator($seed as xs:anyAtomicType?) as map(*)

Returns a random number generator, which can be used to generate sequences of random numbers.

Parameters:
$seed? A seed value for the random generator
Returns:
map(*) : 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: `number`, `next`, and `permute`.

remove

remove($target as item()*, $position as xs:integer) as item()*

Returns a new sequence constructed from the value of $target with the item at $position removed.
If $position is less than 1 or greater than the number of items in $target, $target is returned. Otherwise, the value returned by the function consists of all items of $target whose index is less than $position, followed by all items of $target whose index is greater than $position. If $target is the empty sequence, the empty sequence is returned.

Parameters:
$target* The input sequence
$position The position of the value to be removed
Returns:
item()* : the new sequence with the item at the position specified by the value of $position removed.

replace

replace($input as xs:string?, $pattern as xs:string, $replacement as xs:string) as xs:string

The function returns the xs:string that is obtained by replacing each non-overlapping substring of $input that matches the given $pattern with an occurrence of the $replacement string. If $input is the empty sequence, it is interpreted as the zero-length string. If two overlapping substrings of $input both match the $pattern, then only the first one (that is, the one whose first character comes first in the $input string) is replaced. Within the $replacement string, a variable $N 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 $input that matched the pattern. $0 refers to the substring captured by the regular expression as a whole. More specifically, the rules are as follows, where S is the number of parenthesized sub-expressions in the regular expression, and N is the decimal number formed by taking all the digits that consecutively follow the $ character: 1. If N=0, then the variable is replaced by the substring matched by the regular expression as a whole. 2. If 1<=N<=S, then the variable is replaced by the substring captured by the Nth parenthesized sub-expression. If the Nth parenthesized sub-expression was not matched, then the variable is replaced by the zero-length string. 3. If S<N<=9, then the variable is replaced by the zero-length string. 4. Otherwise (if N>S and N>9), the last digit of N is taken to be a literal character to be included "as is" in the replacement string, and the rules are reapplied using the number N formed by stripping off this last digit.

Parameters:
$input? The input string
$pattern The pattern to match
$replacement The string to replace the pattern with
Returns:
xs:string : the altered string

replace

replace($input as xs:string?, $pattern as xs:string, $replacement as xs:string, $flags as xs:string) as xs:string

The function returns the xs:string that is obtained by replacing each non-overlapping substring of $input that matches the given $pattern with an occurrence of the $replacement string. The $flags argument is interpreted in the same manner as for the fn:matches() function. Calling the four argument version with the $flags argument set to a zero-length string gives the same effect as using the three argument version. If $input is the empty sequence, it is interpreted as the zero-length string. If two overlapping substrings of $input both match the $pattern, then only the first one (that is, the one whose first character comes first in the $input string) is replaced. Within the $replacement string, a variable $N 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 $input that matched the pattern. $0 refers to the substring captured by the regular expression as a whole. More specifically, the rules are as follows, where S is the number of parenthesized sub-expressions in the regular expression, and N is the decimal number formed by taking all the digits that consecutively follow the $ character: 1. If N=0, then the variable is replaced by the substring matched by the regular expression as a whole. 2. If 1<=N<=S, then the variable is replaced by the substring captured by the Nth parenthesized sub-expression. If the Nth parenthesized sub-expression was not matched, then the variable is replaced by the zero-length string. 3. If S<N<=9, then the variable is replaced by the zero-length string. 4. Otherwise (if N>S and N>9), the last digit of N is taken to be a literal character to be included "as is" in the replacement string, and the rules are reapplied using the number N formed by stripping off this last digit.

Parameters:
$input? The input string
$pattern The pattern to match
$replacement The string to replace the pattern with
$flags The flags
Returns:
xs:string : the altered string

resolve-QName

resolve-QName($qname as xs:string?, $element as element()) as xs:QName?

Returns an xs:QName value (that is, an expanded-QName) by taking an xs:string that has the lexical form of an xs:QName (a string in the form "prefix:local-name" or "local-name") and resolving it using the in-scope namespaces for a given element.
If $qname does not have the correct lexical form for xs:QName an error is raised [err:FOCA0002].
If $qname is the empty sequence, returns the empty sequence.
More specifically, the function searches the namespace bindings of $element for a binding whose name matches the prefix of $qname, or the zero-length string if it has no prefix, and constructs an expanded-QName whose local name is taken from the supplied $qname, and whose namespace URI is taken from the string value of the namespace binding.
If the $qname has a prefix and if there is no namespace binding for $element that matches this prefix, then an error is raised [err:FONS0004].
If the $qname has no prefix, and there is no namespace binding for $element 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 $qname argument is retained in the returned expanded-QName.

Parameters:
$qname? The QName name
$element The element
Returns:
xs:QName? : the QName of $element with lexical form $qname

resolve-uri

resolve-uri($relative as xs:string?) as xs:anyURI?

Resolves $relative against the value of the base-uri property from the static context using an algorithm such as the ones described in [RFC 2396] or [RFC 3986], and the resulting absolute URI reference is returned. An error may be raised [err:FORG0009] in the resolution process.
If $relative is an absolute URI reference, it is returned unchanged.
If $relative or $base is not a valid xs:anyURI an error is raised [err:FORG0002].
If $relative is the empty sequence, the empty sequence is returned.

Parameters:
$relative? The relative URI
Returns:
xs:anyURI? : the absolute URI

resolve-uri

resolve-uri($relative as xs:string?, $base as xs:string) as xs:anyURI?

Resolves $relative against $base using an algorithm such as the ones described in [RFC 2396] or [RFC 3986], and the resulting absolute URI reference is returned. An error may be raised [err:FORG0009] in the resolution process.
If $relative is an absolute URI reference, it is returned unchanged.
If $relative or $base is not a valid xs:anyURI an error is raised [err:FORG0002].
If $relative is the empty sequence, the empty sequence is returned.

Parameters:
$relative? The relative URI
$base The base URI
Returns:
xs:anyURI? : the absolute URI

reverse

reverse($arg as item()*) as item()*

Reverses the order of items in a sequence. If the argument is an emptysequence, the empty sequence is returned.

Parameters:
$arg* The sequence to reverse
Returns:
item()* : the reverse order sequence

root

root() as node()

Returns the root of the tree to which the context item belongs.

Returns:
node() : the root node of the tree to which the context node belongs

root

root($arg as node()?) as node()?

Returns the root of the tree to which $arg belongs. This will usually, but not necessarily, be a document node.
If $arg is the empty sequence, the empty sequence is returned.
If $arg is a document node, $arg is returned.
The behavior of the zero argument version of the function is exactly the same as if the context item had been passed in $arg.

Parameters:
$arg? The input node
Returns:
node()? : the root node of the tree to which $arg belongs

round

round($arg as xs:numeric?) as xs:numeric?

Returns the number with no fractional part that is closest to the argument $arg. If there are two such numbers, then the one that is closest to positive infinity is returned. If type of $arg is one of the four numeric types xs:float, xs:double, xs:decimal or xs:integer the type of the result is the same as the type of $arg. If the type of $arg is a type derived from one of the numeric types, the result is an instance of the base numeric type.
For xs:float and xs:double arguments, if the argument is positive infinity, then positive infinity is returned. If the argument is negative infinity, then negative infinity is returned. 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, but greater than or equal to -0.5, then negative zero is returned. In the cases where positive zero or negative zero is returned, negative zero or positive zero may be returned as [XML Schema Part 2: Datatypes Second Edition] does not distinguish between the values positive zero and negative zero.

Parameters:
$arg? The input number
Returns:
xs:numeric? : the rounded value

round-half-to-even

round-half-to-even($arg as xs:numeric?) as xs:numeric?

The value returned is the nearest (that is, numerically closest) value to $arg that is a multiple of ten to the power of minus 0. If two such values are equally near (e.g. if the fractional part in $arg is exactly .500...), the function returns the one whose least significant digit is even.
If the type of $arg is one of the four numeric types xs:float, xs:double, xs:decimal or xs:integer the type of the result is the same as the type of $arg. If the type of $arg is a type derived from one of the numeric types, the result is an instance of the base numeric type.
The three argument version of the function with $precision = 0 produces the same result as the two argument version.
For arguments of type xs:float and xs:double, if the argument is NaN, positive or negative zero, or positive or negative infinity, then the result is the same as the argument. In all other cases, the argument is cast to xs:decimal, the function is applied to this xs:decimal value, and the resulting xs:decimal is cast back to xs:float or xs:double as appropriate to form the function result. If the resulting xs:decimal value is zero, then positive or negative zero is returned according to the sign of the original argument.
Note that the process of casting to xs:decimal may result in an error [err:FOCA0001].
If $arg is of type xs:float or xs:double, rounding occurs on the value of the mantissa computed with exponent = 0.

Parameters:
$arg? The input number
Returns:
xs:numeric? : the rounded value

round-half-to-even

round-half-to-even($arg as xs:numeric?, $precision as xs:integer) as xs:numeric?

The value returned is the nearest (that is, numerically closest) value to $arg that is a multiple of ten to the power of minus $precision. If two such values are equally near (e.g. if the fractional part in $arg is exactly .500...), the function returns the one whose least significant digit is even.
If the type of $arg is one of the four numeric types xs:float, xs:double, xs:decimal or xs:integer the type of the result is the same as the type of $arg. If the type of $arg is a type derived from one of the numeric types, the result is an instance of the base numeric type.
The three argument version of the function with $precision = 0 produces the same result as the two argument version.
For arguments of type xs:float and xs:double, if the argument is NaN, positive or negative zero, or positive or negative infinity, then the result is the same as the argument. In all other cases, the argument is cast to xs:decimal, the function is applied to this xs:decimal value, and the resulting xs:decimal is cast back to xs:float or xs:double as appropriate to form the function result. If the resulting xs:decimal value is zero, then positive or negative zero is returned according to the sign of the original argument.
Note that the process of casting to xs:decimal may result in an error [err:FOCA0001].
If $arg is of type xs:float or xs:double, rounding occurs on the value of the mantissa computed with exponent = 0.

Parameters:
$arg? The input number
$precision The precision factor
Returns:
xs:numeric? : the rounded value

seconds-from-dateTime

seconds-from-dateTime($date-time as xs:dateTime?) as xs:decimal?

Returns an xs:decimal value between 0 and 60.999..., both inclusive, representing the seconds and fractional seconds in the localized value of $date-time. Note that the value can be greater than 60 seconds to accommodate occasional leap seconds used to keep human time synchronized with the rotation of the planet.

Parameters:
$date-time? The date-time as xs:dateTime
Returns:
xs:decimal? : the seconds component from $date-time

seconds-from-duration

seconds-from-duration($duration as xs:duration?) as xs:decimal?

Returns an xs:decimal representing the seconds component in the canonical lexical representation of the value of $duration. The result may be negative

Parameters:
$duration? The duration as xs:duration
Returns:
xs:decimal? : the seconds component of $duration

seconds-from-time

seconds-from-time($time as xs:time?) as xs:decimal?

Returns an xs:decimal value between 0 and 60.999..., both inclusive, representing the seconds and fractional seconds in the localized value of $date. Note that the value can be greater than 60 seconds to accommodate occasional leap seconds used to keep human time synchronized with the rotation of the planet.

Parameters:
$time? The time as xs:time
Returns:
xs:decimal? : the seconds component from $time

serialize

serialize($args as item()*) as xs:string

This function serializes the supplied input sequence $arg as described in XSLT and XQuery Serialization 3.0, returning the serialized representation of the sequence as a string.

Parameters:
$args* The node set to serialize
Returns:
xs:string : the string containing the serialized node set.

serialize

serialize($args as item()*, $parameters as item()?) as xs:string

This function serializes the supplied input sequence $arg as described in XSLT and XQuery Serialization 3.0, returning the serialized representation of the sequence as a string.

Parameters:
$args* The node set to serialize
$parameters? The serialization parameters as either a output:serialization-parameters element or a map
Returns:
xs:string : the string containing the serialized node set.

sort

sort($input as item()*) as item()*

Sorts a supplied sequence.

Parameters:
$input* $input*
Returns:
item()* : the first item or the empty sequence

sort

sort($input as item()*, $collation as xs:string?) as item()*

Sorts a supplied sequence, based on the value of a sort key supplied as a function.

Parameters:
$input* $input*
$collation? $collation?
Returns:
item()* : the resulting sequence

sort

sort($input as item()*, $collation as xs:string?, $key as function(*)) as item()*

Sorts a supplied sequence, based on the value of a sort key supplied as a function.

Parameters:
$input* $input*
$collation? $collation?
$key $key
Returns:
item()* : the resulting sequence

starts-with

starts-with($source as xs:string?, $prefix as xs:string?) as xs:boolean

Returns an xs:boolean indicating whether or not the value of $source starts with a sequence of collation units that provides a minimal match to the collation units of $prefix according to the collation that is used.
Note:
"Minimal match" is defined in [Unicode Collation Algorithm].
If the value of $source or $prefix is the empty sequence, or contains only ignorable collation units, it is interpreted as the zero-length string.
If the value of $prefix is the zero-length string, then the function returns true. If the value of $source is the zero-length string and the value of $prefix is not the zero-length string, then the function returns false.
The collation used by the invocation of this function is determined according to the rules in 7.3.1 Collations. If the specified collation does not support collation units an error may be raised [err:FOCH0004].

Parameters:
$source? The source string
$prefix? The string to determine if is a prefix of $source
Returns:
xs:boolean : true if $prefix is a prefix of the string $source

starts-with

starts-with($source as xs:string?, $prefix as xs:string?, $collation-uri as xs:string) as xs:boolean

Returns an xs:boolean indicating whether or not the value of $source starts with a sequence of collation units that provides a minimal match to the collation units of $prefix according to the collation that is used.
Note:
"Minimal match" is defined in [Unicode Collation Algorithm].
If the value of $source or $prefix is the empty sequence, or contains only ignorable collation units, it is interpreted as the zero-length string.
If the value of $prefix is the zero-length string, then the function returns true. If the value of $source is the zero-length string and the value of $prefix is not the zero-length string, then the function returns false.
The collation used by the invocation of this function is determined according to the rules in 7.3.1 Collations. If the specified collation does not support collation units an error may be raised [err:FOCH0004]. The third argument $collation-uri is either: 1) the full URI e.g. "http://www.w3.org/2013/collation/UCA?lang=en;strength=secondary", or 2) relative where you only need to specify the last part of a valid full collation-uri, e.g. "?lang=sv-SE", "lang=sv-SE;strength=primary;decomposition=standard" or "swedish".

Parameters:
$source? The source string
$prefix? The string to determine if is a prefix of $source
$collation-uri The collation URI
Returns:
xs:boolean : true if $prefix is a prefix of the string $source

static-base-uri

static-base-uri() as xs:anyURI?

Returns the value of the static base URI property from the static context. If the base-uri property is undefined, the empty sequence is returned.

Returns:
xs:anyURI? : The base URI from the static context.

string

string() as xs:string

Returns the value of the context item as xs:string. If the context item is undefined, an error is raised.

Returns:
xs:string : the value of the context item as an xs:string

string

string($arg as item()?) as xs:string

Returns the value of $arg as xs:string. If the value of $arg is the empty sequence, the zero-length string is returned. If the context item of $arg is undefined, an error is raised.

Parameters:
$arg? The sequence to get the value of as an xs:string
Returns:
xs:string : the value of $arg as an xs:string

string-join

string-join($arg as xs:anyAtomicType*) as xs:string

Returns a xs:string created by concatenating the members of the $arg sequence using $separator as a separator. If the value of the separator is the zero-length string, then the members of the sequence are concatenated without a separator. The effect of calling the single-argument version of this function is the same as calling the two-argument version with $separator set to a zero-length string.

Parameters:
$arg* The sequence to be joined to form the string. If it is empty, a zero-length string is returned.
Returns:
xs:string : the joined string

string-join

string-join($arg as xs:anyAtomicType*, $separator as xs:string) as xs:string

Returns a xs:string created by concatenating the members of the $arg sequence using $separator as a separator. If the value of the separator is the zero-length string, then the members of the sequence are concatenated without a separator.

Parameters:
$arg* The sequence to be joined to form the string. If it is empty, a zero-length string is returned.
$separator The separator to be placed in the string between the items of $arg
Returns:
xs:string : the joined string

string-length

string-length() as xs:integer

Returns an xs:integer equal to the length in characters of the value of the context item. If the context item is undefined an error is raised.

Returns:
xs:integer : the length in characters

string-length

string-length($arg as xs:string?) as xs:integer

Returns an xs:integer equal to the length in characters of the value of $arg. If the value of $arg is the empty sequence, the xs:integer 0 is returned. If no argument is supplied, $arg defaults to the string value (calculated using fn:string()) of the context item (.). If no argument is supplied or if the argument is the context item and the context item is undefined an error is raised

Parameters:
$arg? The input string
Returns:
xs:integer : the length in characters

string-to-codepoints

string-to-codepoints($arg as xs:string?) as xs:integer*

Returns the sequence of unicode code points that constitute an xs:string. If $arg is a zero-length string or the empty sequence, the empty sequence is returned.

Parameters:
$arg? The input string
Returns:
xs:integer* : the sequence of code points

subsequence

subsequence($source as item()*, $starting-at as xs:double) as item()*

Returns a subsequence of the items in $source-sequence, items starting at the position, $starting-at, up to the end of the sequence are included.

Parameters:
$source* The source sequence
$starting-at The starting position in the $source
Returns:
item()* : the subsequence

subsequence

subsequence($source as item()*, $starting-at as xs:double, $length as xs:double) as item()*

Returns a subsequence of the items in $source, starting at the position, $starting-at, including the number of items indicated by $length.

Parameters:
$source* The source sequence
$starting-at The starting position in the $source
$length The length of the subsequence
Returns:
item()* : the subsequence

substring

substring($source as xs:string?, $starting-at as xs:double) as xs:string

Returns the portion of the value of $source beginning at the position indicated by the value of $starting-at and continuing to the end of $source. The characters returned do not extend beyond the end of $source. If $starting-at is zero or negative, only those characters in positions greater than zero are returned.If the value of $source is the empty sequence, the zero-length string is returned.

Parameters:
$source? The source string
$starting-at The starting position
Returns:
xs:string : the substring

substring

substring($source as xs:string?, $starting-at as xs:double, $length as xs:double) as xs:string

Returns the portion of the value of $source beginning at the position indicated by the value of $starting-at and continuing for the number of characters indicated by the value of $length. The characters returned do not extend beyond the end of $source. If $starting-at is zero or negative, only those characters in positions greater than zero are returned. If the value of $source is the empty sequence, the zero-length string is returned.

Parameters:
$source? The source string
$starting-at The starting position
$length The number of characters in the substring
Returns:
xs:string : the substring

substring-after

substring-after($source as xs:string?, $search as xs:string?) as xs:string

Returns the substring of the value of $source that follows the first occurrence of a sequence of the value of $search. If the value of $source or $search is the empty sequence it is interpreted as the zero-length string. If the value of $search is the zero-length string, the zero-length string is returned. If the value of $source does not contain a string that is equal to the value of $search, the zero-length string is returned.

Parameters:
$source? The input string
$search? The search string
Returns:
xs:string : the substring after $search

substring-after

substring-after($source as xs:string?, $search as xs:string?, $collation-uri as xs:string) as xs:string

Returns the substring of the value of $source that follows the first occurrence of a sequence of the value of $search in the collation $collation-uri. If the value of $source or $search is the empty sequence it is interpreted as the zero-length string. If the value of $search is the zero-length string, the zero-length string is returned. If the value of $source does not contain a string that is equal to the value of $search, the zero-length string is returned. The third argument $collation-uri is either: 1) the full URI e.g. "http://www.w3.org/2013/collation/UCA?lang=en;strength=secondary", or 2) relative where you only need to specify the last part of a valid full collation-uri, e.g. "?lang=sv-SE", "lang=sv-SE;strength=primary;decomposition=standard" or "swedish".

Parameters:
$source? The input string
$search? The search string
$collation-uri The collation URI
Returns:
xs:string : the substring after $search

substring-before

substring-before($source as xs:string?, $search as xs:string?) as xs:string

Returns the substring of the value of $source that precedes the first occurrence of a sequence of the value of $search. If the value of $source or $search is the empty sequence it is interpreted as the zero-length string. If the value of $search is the zero-length string, the zero-length string is returned. If the value of $source does not contain a string that is equal to the value of $search, the zero-length string is returned.

Parameters:
$source? The input string
$search? The search string
Returns:
xs:string : the substring before $search

substring-before

substring-before($source as xs:string?, $search as xs:string?, $collation-uri as xs:string) as xs:string

Returns the substring of the value of $source that precedes the first occurrence of a sequence of the value of $search in the collation $collation-uri. If the value of $source or $search is the empty sequence it is interpreted as the zero-length string. If the value of $search is the zero-length string, the zero-length string is returned. If the value of $source does not contain a string that is equal to the value of $search, the zero-length string is returned. The third argument $collation-uri is either: 1) the full URI e.g. "http://www.w3.org/2013/collation/UCA?lang=en;strength=secondary", or 2) relative where you only need to specify the last part of a valid full collation-uri, e.g. "?lang=sv-SE", "lang=sv-SE;strength=primary;decomposition=standard" or "swedish".

Parameters:
$source? The input string
$search? The search string
$collation-uri The collation URI
Returns:
xs:string : the substring before $search

sum

sum($arg as xs:anyAtomicType*) as xs:anyAtomicType

Returns a value obtained by adding together the values in $arg. If $arg is the the empty sequence the xs:double value 0.0e0 is returned.

Parameters:
$arg* The sequence of numbers to be summed up
Returns:
xs:anyAtomicType : the sum of all numbers in $arg

sum

sum($arg as xs:anyAtomicType*, $default as xs:anyAtomicType?) as xs:anyAtomicType?

Returns a value obtained by adding together the values in $arg. If $arg is the the empty sequence then $default is returned.

Parameters:
$arg* The sequence of numbers to be summed up
$default? The default value if $arg computes to the empty sequence
Returns:
xs:anyAtomicType? : the sum of all numbers in $arg

tail

tail($sequence as item()*) as item()*

The function returns the value of the expression subsequence($sequence, 2), i.e. a new sequence containing all items of the input sequence except the first.

Parameters:
$sequence* The source sequence
Returns:
item()* : the resulting sequence

timezone-from-date

timezone-from-date($date as xs:date?) as xs:dayTimeDuration?

Returns the timezone component of $date if any. If $date has a timezone component, then the result is an xs:dayTimeDuration that indicates deviation from UTC; its value may range from +14:00 to -14:00 hours, both inclusive. Otherwise, the result is the empty sequence.If $date is the empty sequence, returns the empty sequence.

Parameters:
$date? The date as xs:date
Returns:
xs:dayTimeDuration? : the timezone component from $date

timezone-from-dateTime

timezone-from-dateTime($date-time as xs:dateTime?) as xs:dayTimeDuration?

Returns the timezone component of $date-time if any. If $date-time has a timezone component, then the result is an xdt:dayTimeDuration that indicates deviation from UTC; its value may range from +14:00 to -14:00 hours, both inclusive. Otherwise, the result is the empty sequence.

Parameters:
$date-time? The date-time as xs:dateTime
Returns:
xs:dayTimeDuration? : the timezone component from $date-time

timezone-from-time

timezone-from-time($time as xs:time?) as xs:dayTimeDuration?

Returns the timezone component of $time if any. If $time has a timezone component, then the result is an xdt:dayTimeDuration that indicates deviation from UTC; its value may range from +14:00 to -14:00 hours, both inclusive. Otherwise, the result is the empty sequence.

Parameters:
$time? The time as xs:time
Returns:
xs:dayTimeDuration? : the timezone component from $time

tokenize

tokenize($input as xs:string?) as xs:string*

Breaks the input string $input into a sequence of strings,

Parameters:
$input? The input string
Returns:
xs:string* : the token sequence

tokenize

tokenize($input as xs:string?, $pattern as xs:string) as xs:string*

Breaks the input string $input into a sequence of strings,

Parameters:
$input? The input string
$pattern The tokenization pattern
Returns:
xs:string* : the token sequence

tokenize

tokenize($input as xs:string?, $pattern as xs:string, $flags as xs:string) as xs:string*

Breaks the input string $input into a sequence of strings,

Parameters:
$input? The input string
$pattern The tokenization pattern
$flags The flags
Returns:
xs:string* : the token sequence

trace

trace($value as item()*) as item()*

This function is intended to be used in debugging queries by providing a trace of their execution. The input $value is returned, unchanged, as the result of the function. In addition, the inputs $value is serialized with adaptive settings and is written into the eXist log files.

Parameters:
$value* The values
Returns:
item()* : The unlabelled $value in the log

trace

trace($value as item()*, $label as xs:string) as item()*

This function is intended to be used in debugging queries by providing a trace of their execution. The input $value is returned, unchanged, as the result of the function. In addition, the inputs $value is serialized with adaptive settings and is written together with $label into the eXist log files.

Parameters:
$value* The values
$label The label in the log file
Returns:
item()* : The labelled $value in the log

translate

translate($arg as xs:string?, $map as xs:string, $trans as xs:string) as xs:string

Returns the value of $arg modified so that every character in the value of $arg that occurs at some position N in the value of $map has been replaced by the character that occurs at position N in the value of $trans.
If the value of $arg is the empty sequence, the zero-length string is returned.
Every character in the value of $arg that does not appear in the value of $map is unchanged.
Every character in the value of $arg that appears at some position M in the value of $map, where the value of $trans is less than M characters in length, is omitted from the returned value. If $map is the zero-length string $arg is returned.
If a character occurs more than once in $map, then the first occurrence determines the replacement character. If $trans is longer than $map, the excess characters are ignored.
i.e. fn:translate("bar","abc","ABC") returns "BAr"

Parameters:
$arg? The string to be translated
$map The map string
$trans The translation string
Returns:
xs:string : the translated string

true

true() as xs:boolean

Always returns the boolean value true

Returns:
xs:boolean : true

unordered

unordered($arg as item()*) as item()*

Takes a sequence $arg as input and returns an arbitrary implementation dependent permutation of it. Currently, this has no effect in eXist, but it might be used for future optimizations.

Parameters:
$arg* The input sequence
Returns:
item()* : the input sequence in an arbitrary implementation dependent permutation

unparsed-text

unparsed-text($href as xs:string?) as xs:string?

reads an external resource (for example, a file) and returns a string representation of the resource

Parameters:
$href? the URI to load text from
Returns:
xs:string?

unparsed-text

unparsed-text($href as xs:string?, $encoding as xs:string) as xs:string?

reads an external resource (for example, a file) and returns a string representation of the resource

Parameters:
$href? the URI to load text from
$encoding character encoding of the resource
Returns:
xs:string?

unparsed-text-available

unparsed-text-available($href as xs:string?) as xs:boolean

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

Parameters:
$href? the URI to load text from
Returns:
xs:boolean

unparsed-text-available

unparsed-text-available($href as xs:string?, $encoding as xs:string) as xs:boolean

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

Parameters:
$href? the URI to load text from
$encoding character encoding of the resource
Returns:
xs:boolean

unparsed-text-lines

unparsed-text-lines($href as xs:string?) as xs:string*

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

Parameters:
$href? the URI to load text from
Returns:
xs:string*

unparsed-text-lines

unparsed-text-lines($href as xs:string?, $encoding as xs:string) as xs:string*

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

Parameters:
$href? the URI to load text from
$encoding character encoding of the resource
Returns:
xs:string*

upper-case

upper-case($arg as xs:string?) as xs:string

Returns the value of $arg after translating every character to its upper-case correspondent as defined in the appropriate case mappings section in 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.

Parameters:
$arg? The text to be converted to all upper-case characters
Returns:
xs:string : the resulting upper-case text

xml-to-json

xml-to-json($node as node()?) as xs:string?

Converts an XML tree (in w3c 'XML Representation of JSON' format) into a string conforming to the JSON grammar. Basic string (un)escaping.

Read more
Parameters:
$node? The input node
Returns:
xs:string? : The JSON representation of the input node

xml-to-json

xml-to-json($node as node()?, $options as map(*)?) as xs:string?

Converts an XML tree (in w3c 'XML Representation of JSON' format) into a string conforming to the JSON grammar. Basic string (un)escaping.

Read more
Parameters:
$node? The input node
$options? The options map
Returns:
xs:string? : The JSON representation of the input node

year-from-date

year-from-date($date as xs:date?) as xs:integer?

Returns an xs:integer representing the year in the localized value of $date. The value may be negative.

Parameters:
$date? The date as xs:date
Returns:
xs:integer? : the year component from $date

year-from-dateTime

year-from-dateTime($date-time as xs:dateTime?) as xs:integer?

Returns an xs:integer representing the year in the localized value of $date-time. The value may be negative.

Parameters:
$date-time? The date-time as xs:dateTime
Returns:
xs:integer? : the year component from $date-time

years-from-duration

years-from-duration($duration as xs:duration?) as xs:integer?

Returns an xs:integer representing the years component in the canonical lexical representation of the value of $duration. The result may be negative.

Parameters:
$duration? The duration as xs:duration
Returns:
xs:integer? : the years component of $duration

zero-or-one

zero-or-one($arg as item()*) as item()?

Returns the argument sequence $arg if it contains zero or one items. Otherwise, raises an error.

Parameters:
$arg* The sequence to be tested for cardinality
Returns:
item()? : the input sequence if it contains zero or one items.