View Old View New View Both View Only Previous Next

This draft contains only sections that have differences from the version that it modified.

W3C

XPath and XQuery Functions and Operators 4.0

W3C Editor's Draft 23 February 2026

This version:
https://qt4cg.org/specifications/xpath-functions-40/
Latest version of XPath and XQuery Functions and Operators 4.0:
https://qt4cg.org/specifications/xpath-functions-40/
Most recent Recommendation of XPath and XQuery Functions and Operators:
https://www.w3.org/TR/2017/REC-xpath-functions-31-20170321/
Editor:
Michael Kay, Saxonica <http://www.saxonica.com/>

Please check the errata for any errors or issues reported since publication.

See also translations.

This document is also available in these non-normative formats: Specification in XML format and XML function catalog.


Abstract

This document defines constructor functions, operators, and functions on the datatypes defined in [XML Schema Part 2: Datatypes Second Edition] and the datatypes defined in [XQuery and XPath Data Model (XDM) 3.1]. It also defines functions and operators on nodes and node sequences as defined in the [XQuery and XPath Data Model (XDM) 3.1]. These functions and operators are defined for use in [XML Path Language (XPath) 4.0] and [XQuery 4.0: An XML Query Language] and [XSL Transformations (XSLT) Version 4.0] and other related XML standards. The signatures and summaries of functions defined in this document are available at: http://www.w3.org/2005/xpath-functions/.

A summary of changes since version 3.1 is provided at G Changes since 3.1.

Status of this Document

This version of the specification is work in progress. It is produced by the QT4 Working Group, officially the W3C XSLT 4.0 Extensions Community Group. Individual functions specified in the document may be at different stages of review, reflected in their History notes. Comments are invited, in the form of GitHub issues at https://github.com/qt4cg/qtspecs.

Dedication

The publications of this community group are dedicated to our co-chair, Michael Sperberg-McQueen (1954–2024).


16 Higher-order functions

16.1 Processing function items

The functions included in this section operate on function items, that is, values referring to a function.

[Definition] Functions that accept functions among their arguments, or that return functions in their result, are described in this specification as higher-order functions.

Note:

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

FunctionMeaning
fn:function-lookupReturns a function item having a given name and arity, if there is one.
fn:function-nameReturns the name of the function identified by a function item.
fn:function-arityReturns the arity of the function identified by a function item.
fn:function-identityReturns a string representing the identity of thea function item.
fn:function-annotationsReturns the annotations of the function item.

16.1.4 fn:function-identity

Summary

Returns a string representing the identity of thea function item.

Signature
fn:function-identity(
$functionas fn(*)
) as xs:string
Properties

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

Rules

The fn:function-identity function returns a string that represents the identity of the function identified by $function.

The returned string has the property that fn:function-identity($f1) and fn:function-identity($f2) are codepoint-equal if and only if $f1 and $f2 have the same function identity. Apart from this property, the result is implementation-dependent.

Notes

This function can be useful in any scenario, where the evaluation of a function call requires repeated evaluation of this same, or other functions. Often in such cases, the algorithm needs access to a general structure, containing the cached results of executing possibly many different functions applied on specific arguments-tuples. A unique key is needed under which to group all invocations of a specific function and then the mapping between their function-call arguments and the result of the call. The identity of a function fits exactly the requirements (uniqueness / one per function) for such a key.

This function enables applications to test whether two expressions or variables reference the same function. This may be useful, for example, to allow caching of function results to avoid repeated evaluation. The results of previous function invocations might be held in a map whose key is the function identity.

The function identity, by definition, is generated upon the creation of a function, is implementation-defined, and has meaning throughout the life of that function. It is not meaningful to store this valueor compare the result across different executionsexecution scopes, because the identity given to a function instring used to represent the function identity execution1 will generally be different from the identity, given to it in vary from one execution scope to anotherexecution2.

The function identity, being a string, can be used as a key in a map, thus making it possible to map a particular function to a sequence of items.

The result of an expression such as function-identity(abs#1) eq function-identity(abs(?)) may be either true or false, because it is implementation-dependent whether abs#1 and abs(?) return the same function.

Examples
ExpressionResult
function-identity(abs#1) eq function-identity(abs#1)
true()
function-identity(abs#1) eq function-identity(round#1)
false()