This document is also available in these non-normative formats: Specification in XML format and XML function catalog.
Copyright © 2000 W3C® (MIT, ERCIM, Keio, Beihang). W3C liability, trademark and document use rules apply.
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.
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.
The publications of this community group are dedicated to our co-chair, Michael Sperberg-McQueen (1954–2024).
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.
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.
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 name | Availability |
|---|---|
| fn:accumulator-after | XSLT 3.0 and later |
| fn:accumulator-before | XSLT 3.0 and later |
| fn:apply-templates | XSLT 4.0 |
| fn:available-system-properties | XSLT 3.0 and later |
| fn:character-map | XSLT 4.0 |
| fn:collation-key | Originally XSLT 3.0, then XPath 3.1 and later |
| fn:copy-of | XSLT 3.0 and later |
| fn:current | XSLT 1.0 and later |
| fn:current-group | XSLT 2.0 and later |
| fn:current-grouping-key | XSLT 2.0 and later |
| fn:current-merge-group | XSLT 3.0 and later |
| fn:current-merge-key | XSLT 3.0 and later |
| fn:current-merge-key-array | XSLT 4.0 |
| fn:current-output-uri | XSLT 3.0 and later |
| fn:document | XSLT 1.0 and later |
| fn:element-available | XSLT 1.0 and later |
| fn:format-date | Originally XSLT 2.0, then XPath 3.0 and later |
| fn:format-dateTime | Originally XSLT 2.0, then XPath 3.0 and later |
| fn:format-number | Originally XSLT 1.0 and 2.0; then XPath 3.0 and later |
| fn:format-time | Originally XSLT 2.0; then XPath 3.0 and later |
| fn:function-available | XSLT 1.0 and later |
| fn:generate-id | Originally XSLT 1.0 and 2.0; then XPath 3.0 and later |
| fn:json-to-xml | Originally XSLT 3.0, then XPath 3.1 and later |
| fn:key | XSLT 1.0 and later |
| fn:map-for-key | XSLT 4.0 |
| fn:regex-group | XSLT 2.0 and later |
| fn:regex-groups | XSLT 4.0 |
| fn:snapshot | XSLT 3.0 and later |
| fn:stream-available | XSLT 3.0 and later |
| fn:system-property | XSLT 1.0 and later |
| fn:type-available | XSLT 2.0 and later |
| fn:unparsed-entity-public-id | XSLT 2.0 and later |
| fn:unparsed-entity-uri | XSLT 1.0 and later |
| fn:unparsed-text | Originally XSLT 2.0; then XPath 3.0 and later |
| fn:unparsed-text-available | Originally XSLT 2.0; then XPath 3.0 and later |
| fn:xml-to-json | Originally XSLT 3.0, then XPath 3.1 and later |
| map:contains | Originally XSLT 3.0, then XPath 3.1 and later |
| map:entry | Originally XSLT 3.0, then XPath 3.1 and later |
| map:find | Originally XSLT 3.0, then XPath 3.1 and later |
| map:for-each | Originally XSLT 3.0, then XPath 3.1 and later |
| map:get | Originally XSLT 3.0, then XPath 3.1 and later |
| map:keys | Originally XSLT 3.0, then XPath 3.1 and later |
| map:merge | Originally XSLT 3.0, then XPath 3.1 and later |
| map:put | Originally XSLT 3.0, then XPath 3.1 and later |
| map:remove | Originally XSLT 3.0, then XPath 3.1 and later |
| map:size | Originally 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.