XML technologies / XSLT / XSLT and XPath functions / Function categories in XPath 1.0 and XSLT 1.0
(Excerpt from "XSLT 2.0 & XPath 2.0" by Frank Bongers, chapter 5.)
XPath 1.0 and XSLT 1.0 define 36 functions in total, 11 originating in XSLT. XPath 1.0 also has four node tests that look similar but are not functions, although often called node-test “functions”.
XPath 1.0 functions:
XPath 1.0 functions are described in the W3C XPath 1.0 specification dated 16 November 1999.
XSLT 1.0 functions:
XSLT 1.0 functions belong to the W3C XSLT 1.0 specification, also dated 16 November 1999.
Functions can be grouped by purpose as follows:
Type conversion and formatting
Name | Origin | Use |
|---|---|---|
| XPath 1.0 | Convert to Boolean |
| XSLT 1.0 | Format a number as a string |
| XPath 1.0 | Convert to a number |
| XPath 1.0 | Convert to a string |
Table: type conversion and formatting functions.
Rounding functions for numeric types
Name | Origin | Use |
|---|---|---|
| XPath 1.0 | Round input upward |
| XPath 1.0 | Round input downward |
| XPath 1.0 | Round input upward or downward |
Table: rounding functions for numeric types.
Boolean functions
Name | Origin | Use |
|---|---|---|
| XPath 1.0 | Boolean value |
| XPath 1.0 | Boolean value |
| XPath 1.0 | Boolean negation |
Table: Boolean functions.
String functions: analysis and manipulation
Name | Origin | Use |
|---|---|---|
| XPath 1.0 | String concatenation |
| XPath 1.0 | Test for a substring |
| XPath 1.0 | Normalize whitespace |
| XPath 1.0 | Test for a substring at the start |
| XPath 1.0 | String length |
| XPath 1.0 | Extract a substring |
| XPath 1.0 | Substring after a delimiter |
| XPath 1.0 | Substring before a delimiter |
| XPath 1.0 | Character replacement by pattern |
Table: string analysis and manipulation.
Aggregation
Name | Origin | Use |
|---|---|---|
| XPath 1.0 | Number of nodes in a node set |
| XPath 1.0 | Sum of node-set values |
Table: aggregation functions.
Node names and identifiers
Name | Origin | Use |
|---|---|---|
| XSLT 1.0 | Generate an ID at runtime |
| XSLT 1.0 | Determine language |
| XPath 1.0 | Local part of the QName |
| XPath 1.0 | QName of a node |
| XPath 1.0 | namespace URI of a node |
Table: node-name and identifier functions.
Context information within a node set
Name | Origin | Use |
|---|---|---|
| XSLT 1.0 | Current node |
| XPath 1.0 | Index of the last node in the set |
| XPath 1.0 | Index of the current node in the set |
Table: context information within a node set.
Associating and locating nodes and resources at runtime
Name | Origin | Use |
|---|---|---|
| XSLT 1.0 | Load an external document |
| XSLT 1.0 | Find a node by a defined key |
| XSLT 1.0 | Find a node by ID (DTD) |
| XSLT 1.0 | Load an unparsed entity (DTD) |
Table: associating and locating nodes and resources at runtime.
Runtime environment information
Name | Origin | Use |
|---|---|---|
| XPath 1.0 | Instruction available at runtime |
| XSLT 1.0 | Function available at runtime |
| XPath 1.0 | Runtime environment information |
Table: runtime environment information.
Node tests are not functions
The following are not functions despite their similar appearance: node tests. Their names, such as 'comment', 'text', are not reserved words. Parentheses therefore mark their use as node tests unambiguously.
They are listed here but are not included in the following function explanations. The detailed explanation of node tests is in the discussion of XPath expressions and patterns.
Name | Origin | Use |
|---|---|---|
| XPath 1.0 | Test for comment nodes |
| XPath 1.0 | Test for text nodes |
| XPath 1.0 | Test for processing instructions |
| XPath 1.0 | Test for any node kind |
Table: XPath node-test expressions.
Copyright © Galileo Press, Bonn 2008
You may print the online version for private use.
Otherwise, this chapter from "XSLT 2.0 & XPath 2.0 ― Das umfassende Handbuch" is subject to the same terms as the bound edition: the work and all its parts are protected by copyright. All rights reserved, including reproduction, translation, microfilming, storage and processing in electronic systems.
Galileo Press, Rheinwerkallee 4, 53227 Bonn