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

boolean()

XPath 1.0

Convert to Boolean

format-number()

XSLT 1.0

Format a number as a string

number()

XPath 1.0

Convert to a number

string()

XPath 1.0

Convert to a string

Table: type conversion and formatting functions.

Rounding functions for numeric types

Name

Origin

Use

ceiling()

XPath 1.0

Round input upward

floor()

XPath 1.0

Round input downward

round()

XPath 1.0

Round input upward or downward

Table: rounding functions for numeric types.

Boolean functions

Name

Origin

Use

false()

XPath 1.0

Boolean value false

true()

XPath 1.0

Boolean value true

not()

XPath 1.0

Boolean negation

Table: Boolean functions.

String functions: analysis and manipulation

Name

Origin

Use

concat()

XPath 1.0

String concatenation

contains()

XPath 1.0

Test for a substring

normalize-space()

XPath 1.0

Normalize whitespace

starts-with()

XPath 1.0

Test for a substring at the start

string-length()

XPath 1.0

String length

substring()

XPath 1.0

Extract a substring

substring-after()

XPath 1.0

Substring after a delimiter

substring-before()

XPath 1.0

Substring before a delimiter

translate()

XPath 1.0

Character replacement by pattern

Table: string analysis and manipulation.

Aggregation

Name

Origin

Use

count()

XPath 1.0

Number of nodes in a node set

sum()

XPath 1.0

Sum of node-set values

Table: aggregation functions.

Node names and identifiers

Name

Origin

Use

generate-id()

XSLT 1.0

Generate an ID at runtime

lang()

XSLT 1.0

Determine language

local-name()

XPath 1.0

Local part of the QName

name()

XPath 1.0

QName of a node

namespace-uri()

XPath 1.0

namespace URI of a node

Table: node-name and identifier functions.

Context information within a node set

Name

Origin

Use

current()

XSLT 1.0

Current node

last()

XPath 1.0

Index of the last node in the set

position()

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

document()

XSLT 1.0

Load an external document

key()

XSLT 1.0

Find a node by a defined key

id()

XSLT 1.0

Find a node by ID (DTD)

unparsed-entity-uri()

XSLT 1.0

Load an unparsed entity (DTD)

Table: associating and locating nodes and resources at runtime.

Runtime environment information

Name

Origin

Use

element-available()

XPath 1.0

Instruction available at runtime

function-available()

XSLT 1.0

Function available at runtime

system-property()

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

comment()

XPath 1.0

Test for comment nodes

text()

XPath 1.0

Test for text nodes

processing-instruction()

XPath 1.0

Test for processing instructions

node()

XPath 1.0

Test for any node kind

Table: XPath node-test expressions.

   

back to top