W3C

XQuery, XPath, and XSLT Functions and Operators Namespace Document

Table of Contents

1 Introduction
2 XQuery and XPath Functions
3 XSL Transformations (XSLT) Functions
4 XML Schema
5 Normative References
6 Non-Normative References


1 Introduction

This document describes the namespace http://www.w3.org/2005/xpath-functions defined by the [XPath and XQuery Functions and Operators 3.1] and [XSLT 3.0] specifications (October 2014 and December 2013 versions, respectively). This namespace is identified by the namespace prefix fn:, which is a predefined prefix. For updated information, please refer to the latest version of the [XPath and XQuery Functions and Operators 3.1] and [XSLT 3.0] specifications.

This document describes the names that are defined in this namespace at the time of publication. The W3C reserves the right to define additional names in this namespace in the future. [XPath and XQuery Functions and Operators 3.1] and [XSLT 3.0] are the only specifications that may amend this namespace.

This document contains a directory of links to related resources, using RDDL (as defined in [Resource Directory Description Language (RDDL)]).

It is GRDDL-enabled (as defined in [Gleaning Resource Descriptions from Dialects of Languages (GRDDL)]); that is to say that a GRDDL-compliant processor can extract useful RDF (as defined in [Resource Description Framework (RDF): Concepts and Abstract Syntax]) representations of the information contained herein.

2 XQuery and XPath Functions

This section lists all of the functions defined in the [XPath and XQuery Functions and Operators 3.1] specification. Each function and operator is uniquely identified with a URI of the form: “http://www.w3.org/2005/xpath-functions#name” where name is the name of a function or operator, such as “max”: http://www.w3.org/2005/xpath-functions#max.

The normative definitions of these functions are in the [XPath and XQuery Functions and Operators 3.1] specification. For convenience, a very brief, non-normative summary of each function is provided. For details, follow the link on the “Summary:” introductory text below each function.

abs

Summary:

Returns the absolute value of $arg.

adjust-dateTime-to-timezone

Summary:

Adjusts an xs:dateTime value to a specific timezone, or to no timezone at all.

adjust-date-to-timezone

Summary:

Adjusts an xs:date value to a specific timezone, or to no timezone at all; the result is the date in the target timezone that contains the starting instant of the supplied date.

adjust-time-to-timezone

Summary:

Adjusts an xs:time value to a specific timezone, or to no timezone at all.

analyze-string

Summary:

Analyzes a string using a regular expression, returning an XML structure that identifies which parts of the input string matched or failed to match the regular expression, and in the case of matched substrings, which substrings matched each capturing group in the regular expression.

append

Summary:

Returns an array containing all the members of a supplied array, plus one additional member at the end.

apply

Summary:

Makes a dynamic call on a function with an argument list supplied in the form of an array.

available-environment-variables

Summary:

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

avg

Summary:

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

base-uri

Summary:

Returns the base URI of a node.

boolean

Summary:

Computes the effective boolean value of the sequence $arg.

ceiling

Summary:

Rounds $arg upwards to a whole number.

codepoint-equal

Summary:

Returns true if two strings are equal, considered codepoint-by-codepoint.

codepoints-to-string

Summary:

Returns an xs:string whose characters have supplied codepoints.

collation-key

Summary:

Given a string value and a collation, generates an internal value called a collation key, with the property that the matching and ordering of collation keys reflects the matching and ordering of strings under the specified collation.

collection

Summary:

Returns a sequence of nodes representing a collection of documents indentified by a collection URI; or a default collection if no URI is supplied.

compare

Summary:

Returns -1, 0, or 1, depending on whether $comparand1 collates before, equal to, or after $comparand2 according to the rules of a selected collation.

contains

Summary:

Returns true if the string $arg1 contains $arg2 as a substring, taking collations into account.

Summary:

Tests whether a supplied map contains an entry for a given key

contains-token

Summary:

Determines whether or not any of the supplied strings, when tokenized at whitespace boundaries, contains the supplied token, under the rules of the supplied collation.

count

Summary:

Returns the number of items in a sequence.

current-date

Summary:

Returns the current date.

current-dateTime

Summary:

Returns the current date and time (with timezone).

current-time

Summary:

Returns the current time.

data

Summary:

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

dateTime

Summary:

Returns an xs:dateTime value created by combining an xs:date and an xs:time.

day-from-date

Summary:

Returns the day component of an xs:date.

day-from-dateTime

Summary:

Returns the day component of an xs:dateTime.

days-from-duration

Summary:

Returns the number of days in a duration.

deep-equal

Summary:

This function assesses whether two sequences are deep-equal to each other. To be deep-equal, they must contain items that are pairwise deep-equal; and for two items to be deep-equal, they must either be atomic values that compare equal, or nodes of the same kind, with the same name, whose children are deep-equal, or maps with matching entries, or arrays with matching members.

default-collation

Summary:

Returns the value of the default collation property from the static context.

distinct-values

Summary:

Returns the values that appear in a sequence, with duplicates eliminated.

doc

Summary:

Retrieves a document using a URI supplied as an xs:string, and returns the corresponding document node.

doc-available

Summary:

The function returns true if and only if the function call fn:doc($uri) would return a document node.

document-uri

Summary:

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

element-with-id

Summary:

Returns the sequence of element nodes that have an ID value matching the value of one or more of the IDREF values supplied in $arg.

empty

Summary:

Returns true if the argument is the empty sequence.

encode-for-uri

Summary:

Encodes reserved characters in a string that is intended to be used in the path segment of a URI.

ends-with

Summary:

Returns true if the string $arg1 contains $arg2 as a trailing substring, taking collations into account.

entry

Summary:

Returns a map that contains a single entry (a key-value pair).

environment-variable

Summary:

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

error

Summary:

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

escape-html-uri

Summary:

Escapes a URI in the same way that HTML user agents handle attribute values expected to contain URIs.

exactly-one

Summary:

Returns $arg if it contains exactly one item. Otherwise, raises an error.

exists

Summary:

Returns true if the argument is a non-empty sequence.

false

Summary:

Returns the xs:boolean value false.

filter

Summary:

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

Summary:

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

flatten

Summary:

Replaces any array appearing in a supplied sequence with the members of the array, recursively.

floor

Summary:

Rounds $arg downwards to a whole number.

fold-left

Summary:

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

Summary:

Evaluates the supplied function cumulatively on successive values of the supplied array.

fold-right

Summary:

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

Summary:

Evaluates the supplied function cumulatively on successive values of the supplied array.

for-each

Summary:

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

Summary:

Applies a supplied function to every entry in a map, returning the concatenation of the results.

Summary:

Returns an array whose size is the same as array:size($array), in which each member is computed by applying $function to the corresponding member of $array.

for-each-pair

Summary:

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.

Summary:

Returns an array obtained by evaluating the supplied function once for each pair of members at the same position in the two supplied arrays.

format-date

Summary:

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

format-dateTime

Summary:

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

format-integer

Summary:

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

format-number

Summary:

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

format-time

Summary:

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

function-arity

Summary:

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

function-lookup

Summary:

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

function-name

Summary:

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

generate-id

Summary:

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

get

Summary:

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

Summary:

Returns the value at the specified position in the supplied array (counting from 1).

has-children

Summary:

Returns true if the supplied node has one or more child nodes (of any kind).

head

Summary:

Returns the first item in a sequence.

Summary:

Returns the first member of an array, that is $array(1).

hours-from-dateTime

Summary:

Returns the hours component of an xs:dateTime.

hours-from-duration

Summary:

Returns the number of hours in a duration.

hours-from-time

Summary:

Returns the hours component of an xs:time.

id

Summary:

Returns the sequence of element nodes that have an ID value matching the value of one or more of the IDREF values supplied in $arg.

idref

Summary:

Returns the sequence of element or attribute nodes with an IDREF value matching the value of one or more of the ID values supplied in $arg.

implicit-timezone

Summary:

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

index-of

Summary:

Returns a sequence of positive integers giving the positions within the sequence $seq of items that are equal to $search.

innermost

Summary:

Returns every node within the input sequence that is not an ancestor of another member of the input sequence; the nodes are returned in document order with duplicates eliminated.

in-scope-prefixes

Summary:

Returns the prefixes of the in-scope namespaces for an element node.

insert-before

Summary:

Returns a sequence constructed by inserting an item or a sequence of items at a given position within an existing sequence.

Summary:

Returns an array containing all the members of the supplied array, with one additional member at a specified position.

iri-to-uri

Summary:

Converts a string containing an IRI into a URI according to the rules of [RFC 3987].

join

Summary:

Concatenates the contents of several arrays into a single array.

json-doc

Summary:

Reads an external resource containing JSON, and returns the result of parsing the resource as JSON.

keys

Summary:

Returns a sequence containing all the keys present in a map

lang

Summary:

This function tests whether the language of $node, or the context item if the second argument is omitted, as specified by xml:lang attributes is the same as, or is a sublanguage of, the language specified by $testlang.

last

Summary:

Returns the context size from the dynamic context.

load-xquery-module

Summary:

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

local-name

Summary:

Returns the local part of the name of $arg as an xs:string that is either the zero-length string, or has the lexical form of an xs:NCName.

local-name-from-QName

Summary:

Returns the local part of the supplied QName.

lower-case

Summary:

Converts a string to lower case.

matches

Summary:

Returns true if the supplied string matches a given regular expression.

max

Summary:

Returns a value that is equal to the highest value appearing in the input sequence.

merge

Summary:

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

min

Summary:

Returns a value that is equal to the lowest value appearing in the input sequence.

minutes-from-dateTime

Summary:

Returns the minute component of an xs:dateTime.

minutes-from-duration

Summary:

Returns the number of minutes in a duration.

minutes-from-time

Summary:

Returns the minutes component of an xs:time.

month-from-date

Summary:

Returns the month component of an xs:date.

month-from-dateTime

Summary:

Returns the month component of an xs:dateTime.

months-from-duration

Summary:

Returns the number of months in a duration.

name

Summary:

Returns the name of a node, as an xs:string that is either the zero-length string, or has the lexical form of an xs:QName.

namespace-uri

Summary:

Returns the namespace URI part of the name of $arg, as an xs:anyURI value.

namespace-uri-for-prefix

Summary:

Returns the namespace URI of one of the in-scope namespaces for $element, identified by its namespace prefix.

namespace-uri-from-QName

Summary:

Returns the namespace URI part of the supplied QName.

nilled

Summary:

Returns true for an element that is nilled.

node-name

Summary:

Returns the name of a node, as an xs:QName.

normalize-space

Summary:

Returns the value of $arg with leading and trailing whitespace removed, and sequences of internal whitespace reduced to a single space character.

normalize-unicode

Summary:

Returns the value of $arg after applying Unicode normalization.

not

Summary:

Returns true if the effective boolean value of $arg is false, or false if it is true.

number

Summary:

Returns the value indicated by $arg or, if $arg is not specified, the context item after atomization, converted to an xs:double.

one-or-more

Summary:

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

outermost

Summary:

Returns every node within the input sequence that has no ancestor that is itself a member of the input sequence; the nodes are returned in document order with duplicates eliminated.

parse-ietf-date

Summary:

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

parse-json

Summary:

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

parse-xml

Summary:

This function takes as input an XML document represented as a string, and returns the document node at the root of an XDM tree representing the parsed document.

parse-xml-fragment

Summary:

This function takes as input an XML external entity represented as a string, and returns the document node at the root of an XDM tree representing the parsed document fragment.

path

Summary:

Returns a path expression that can be used to select the supplied node relative to the root of its containing document.

position

Summary:

Returns the context position from the dynamic context.

prefix-from-QName

Summary:

Returns the prefix component of the supplied QName.

put

Summary:

Returns a map containing all the contents of the supplied map, but with an additional entry, which replaces any existing entry for the same key.

QName

Summary:

Returns an xs:QName value formed using a supplied namespace URI and lexical QName.

random-number-generator

Summary:

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

remove

Summary:

Returns a new sequence containing all the items of $target except the item at position $position.

Summary:

Returns a map containing all the entries from a supplied map, except for one.

Summary:

Returns an array containing all the members of the supplied array, except for the member at a specified position.

replace

Summary:

Returns a string produced from the input string by replacing any substrings that match a given regular expression with a supplied replacement string.

resolve-QName

Summary:

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.

resolve-uri

Summary:

Resolves a relative IRI reference against an absolute IRI.

reverse

Summary:

Reverses the order of items in a sequence.

Summary:

Returns an array containing all the members of a supplied array, but in reverse order.

root

Summary:

Returns the root of the tree to which $arg belongs. This will usually, but not necessarily, be a document node.

round

Summary:

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

round-half-to-even

Summary:

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

seconds-from-dateTime

Summary:

Returns the seconds component of an xs:dateTime.

seconds-from-duration

Summary:

Returns the number of seconds in a duration.

seconds-from-time

Summary:

Returns the seconds component of an xs:time.

serialize

Summary:

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.

size

Summary:

Returns the number of entries in the supplied map.

Summary:

Returns the number of members in the supplied array.

sort

Summary:

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

Summary:

Returns an array containing all the members of the supplied array, sorted according to the value of a sort key supplied as a function.

starts-with

Summary:

Returns true if the string $arg1 contains $arg2 as a leading substring, taking collations into account.

static-base-uri

Summary:

This function returns the value of the Static Base URI property from the static context.

string

Summary:

Returns the value of $arg represented as an xs:string.

string-join

Summary:

Returns a string created by concatenating the items in a sequence, with a defined separator between adjacent items.

string-length

Summary:

Returns the number of characters in a string.

string-to-codepoints

Summary:

Returns the sequence of codepoints that constitute an xs:string value.

subarray

Summary:

Returns an array containing all members from a supplied array starting at a supplied position, up to a specified length.

subsequence

Summary:

Returns the contiguous sequence of items in the value of $sourceSeq beginning at the position indicated by the value of $startingLoc and continuing for the number of items indicated by the value of $length.

substring

Summary:

Returns the portion of the value of $sourceString beginning at the position indicated by the value of $start and continuing for the number of characters indicated by the value of $length.

substring-after

Summary:

Returns the part of $arg1 that follows the first occurrence of $arg2, taking collations into account.

substring-before

Summary:

Returns the part of $arg1 that precedes the first occurrence of $arg2, taking collations into account.

sum

Summary:

Returns a value obtained by adding together the values in $arg.

tail

Summary:

Returns all but the first item in a sequence.

Summary:

Returns an array containing all members except the first from a supplied array.

timezone-from-date

Summary:

Returns the timezone component of an xs:date.

timezone-from-dateTime

Summary:

Returns the timezone component of an xs:dateTime.

timezone-from-time

Summary:

Returns the timezone component of an xs:time.

tokenize

Summary:

Returns a sequence of strings constructed by splitting the input wherever a separator is found; the separator is any substring that matches a given regular expression.

trace

Summary:

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

transform

Summary:

Invokes a transformation using a dynamically-loaded XSLT stylesheet.

translate

Summary:

Returns the value of $arg modified by replacing or removing individual characters.

true

Summary:

Returns the xs:boolean value true.

unordered

Summary:

Returns the items of $sourceSeq in an implementation-dependent order.

unparsed-text

Summary:

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

unparsed-text-available

Summary:

Because errors in evaluating the fn:unparsed-text function are non-recoverable, these two functions are provided to allow an application to determine whether a call with particular arguments would succeed.

unparsed-text-lines

Summary:

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

upper-case

Summary:

Converts a string to upper case.

uri-collection

Summary:

Returns a sequence of xs:anyURI values representing the URIs in a resource collection.

year-from-date

Summary:

Returns the year component of an xs:date.

year-from-dateTime

Summary:

Returns the year component of an xs:dateTime.

years-from-duration

Summary:

Returns the number of years in a duration.

zero-or-one

Summary:

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

3 XSL Transformations (XSLT) Functions

This section lists all of the functions defined in the [XSLT 3.0] specification. Each function and operator is uniquely identified with a URI of the form: “http://www.w3.org/2005/xpath-functions#name” where name is the name of a function or operator, such as “system-property”: http://www.w3.org/2005/xpath-functions#system-property.

The normative definitions of these functions are in the [XSLT 3.0] specification. For convenience, a very brief, non-normative summary of each function is provided. For details, follow the link on the “Summary:” introductory text below each function.

4 XML Schema

The function fn:analyze-string(), identified in section 3 XSL Transformations (XSLT) Functions above, returns results that are always valid according to an XML Schema specified in [XPath and XQuery Functions and Operators 3.1]. That XML Schema defined four XML elements and three XML Schema complex types. The XML elements are named:

<analyze-string-result>
<match>
<non-match>
<group>

The XML Schema complex types are named:

analyze-string-result-type
match-type
group-type

The target namespace of this XML Schema is http://www.w3.org/2005/xpath-functions.

This schema specifies the XML syntax of the result returned by fn:analyze-string as defined in [XPath and XQuery Functions and Operators 3.1]. It is located at http://www.w3.org/2014/10/xpath-functions-31/analyze-string.xsd.

5 Normative References

These documents describe the names that are defined in this namespace at the time of publication. The W3C reserves the right to define additional names in this namespace in the future.

XPath and XQuery Functions and Operators 3.1
XSLT 3.0

XSL Transformations (XSLT) 3.0 (12 December 2013 version)

6 Non-Normative References

Resource Directory Description Language (RDDL)
Gleaning Resource Descriptions from Dialects of Languages (GRDDL)
Resource Description Framework (RDF): Concepts and Abstract Syntax