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 2 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/>

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) 4.0]. It also defines functions and operators on nodes and node sequences as defined in the [XQuery and XPath Data Model (XDM) 4.0]. 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 H Changes since 3.1.

Status of this Document

This section describes the status of this document at the time of its publication. Other documents may supersede this document.

This document is a working draft developed and maintained by a W3C Community Group, the XQuery and XSLT Extensions Community Group unofficially known as QT4CG (where "QT" denotes Query and Transformation). This draft is work in progress and should not be considered either stable or complete. Standard W3C copyright and patent conditions apply.

The community group welcomes comments on the specification. Comments are best submitted as issues on the group's GitHub repository.

As the Community Group moves towards publishing dated, stable drafts, some features that the group thinks may likely be removed or substantially changed are marked “at risk” in their changes section. In this draft:

The community group maintains two extensive test suites, one oriented to XQuery and XPath, the other to XSLT. These can be found at qt4tests and xslt40-test respectively. New tests, or suggestions for correcting existing tests, are welcome. The test suites include extensive metadata describing the conditions for applicability of each test case as well as the expected results. They do not include any test drivers for executing the tests: each implementation is expected to provide its own test driver.

Dedication

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


F Functions defined elsewhere (Non-Normative)

This Appendix describes some sources of functions that fall outside the scope of the function library defined in this specification. It includes both function specifications and function implementations. Inclusion of a function in this appendix does not constitute any kind of recommendation or endorsement; neither is omission from this appendix to be construed negatively. This Appendix does not attempt to give any information about licensing arrangements for these function specifications or implementations.

F.1 XPath Functions Defined in Other W3C Recommendations

A number of W3C Recommendations make use of XPath, and in some cases such Recommmendations define additional functions to be made available when XPath is used in a specific host language.

F.1.1 Functions Defined in XSLT

The various versions of XSLT have all included additional functions intended to be available only when XPath is used within XSLT, and not in other host language environments. Some of these functions were originally defined in XSLT, and subsequently migrated into the core function library defined in this specification.

Generally, the reason that functions have been defined in XSLT rather than in the core library has been that they required additional static or dynamic context information.

XSLT-defined functions share the core namespace http://www.w3.org/2005/xpath-functions (but in XPath 1.0 and XSLT 1.0, no namespace was defined for these functions).

The following table lists all functions that have been defined in XSLT, and summarizes their current status.

Function nameAvailability
fn:accumulator-afterXSLT 3.0 and later
fn:accumulator-beforeXSLT 3.0 and later
fn:apply-templatesXSLT 4.0
fn:available-system-propertiesXSLT 3.0 and later
fn:character-mapXSLT 4.0
fn:collation-keyOriginally XSLT 3.0, then XPath 3.1 and later
fn:copy-ofXSLT 3.0 and later
fn:currentXSLT 1.0 and later
fn:current-groupXSLT 2.0 and later
fn:current-grouping-keyXSLT 2.0 and later
fn:current-merge-groupXSLT 3.0 and later
fn:current-merge-keyXSLT 3.0 and later
fn:current-merge-key-arrayXSLT 4.0
fn:current-output-uriXSLT 3.0 and later
fn:documentXSLT 1.0 and later
fn:element-availableXSLT 1.0 and later
fn:format-dateOriginally XSLT 2.0, then XPath 3.0 and later
fn:format-dateTimeOriginally XSLT 2.0, then XPath 3.0 and later
fn:format-numberOriginally XSLT 1.0 and 2.0; then XPath 3.0 and later
fn:format-timeOriginally XSLT 2.0; then XPath 3.0 and later
fn:function-availableXSLT 1.0 and later
fn:generate-idOriginally XSLT 1.0 and 2.0; then XPath 3.0 and later
fn:json-to-xmlOriginally XSLT 3.0, then XPath 3.1 and later
fn:keyXSLT 1.0 and later
fn:map-for-keyXSLT 4.0
fn:regex-groupXSLT 2.0 and later
fn:regex-groupsXSLT 4.0
fn:snapshotXSLT 3.0 and later
fn:stream-availableXSLT 3.0 and later
fn:system-propertyXSLT 1.0 and later
fn:type-availableXSLT 2.0 and later
fn:unparsed-entity-public-idXSLT 2.0 and later
fn:unparsed-entity-uriXSLT 1.0 and later
fn:unparsed-textOriginally XSLT 2.0; then XPath 3.0 and later
fn:unparsed-text-availableOriginally XSLT 2.0; then XPath 3.0 and later
fn:xml-to-jsonOriginally XSLT 3.0, then XPath 3.1 and later
map:containsOriginally XSLT 3.0, then XPath 3.1 and later
map:entryOriginally XSLT 3.0, then XPath 3.1 and later
map:findOriginally XSLT 3.0, then XPath 3.1 and later
map:for-eachOriginally XSLT 3.0, then XPath 3.1 and later
map:getOriginally XSLT 3.0, then XPath 3.1 and later
map:keysOriginally XSLT 3.0, then XPath 3.1 and later
map:mergeOriginally XSLT 3.0, then XPath 3.1 and later
map:putOriginally XSLT 3.0, then XPath 3.1 and later
map:removeOriginally XSLT 3.0, then XPath 3.1 and later
map:sizeOriginally XSLT 3.0, then XPath 3.1 and later

Note:

XSLT 3.0 was well advanced when work started on XPath 3.1, but XPath 3.1 appeared as a Recommendation before XSLT 3.0 reached that status.