Saxon home page

XPath 2.0 Functions

The list on this page indicates which XPath 2.0 functions are implemented in this Saxon release, and any restrictions in the current implementation.

Functions defined in the XSLT 2.0 specification are not currently listed.

fn:add-timezone-to-date( date $srcval) => date

Sets the timezone information on a date value to the system timezone

XPath 2.0 Specification

** Not yet implemented **


fn:add-timezone-to-date( date $srcval, dayTimeDuration $timezone) => date

Sets the timezone information on a date value to $timezone

XPath 2.0 Specification

** Not yet implemented **


fn:add-timezone-to-dateTime( dateTime $srcval) => dateTime

Sets the timezone information on a dateTime value to the system timezone

XPath 2.0 Specification

** Not yet implemented **


fn:add-timezone-to-dateTime( dateTime $srcval, dayTimeDuration $timezone) => dateTime

Sets the timezone information on a dateTime value to $timezone

XPath 2.0 Specification

** Not yet implemented **


fn:add-timezone-to-time( time $srcval) => time

Sets the timezone information on a time value to the system timezone

XPath 2.0 Specification

** Not yet implemented **


fn:add-timezone-to-time( time $srcval, dayTimeDuration $timezone) => time

Sets the timezone information on a time value to $timezone

XPath 2.0 Specification

** Not yet implemented **


fn:avg(item* $srcval) => double?

Returns the average of a set of numbers

XPath 2.0 Specification


fn:base-uri(node $srcval) => anyURI?,returns String

Returns the base URI of a given node

XPath 2.0 Specification


fn:boolean(item* $srcval) => boolean

Obtains the effective boolean value of any expression

XPath 2.0 Specification


fn:ceiling(double? $srcval) => double?

Rounds a value towards positive infinity

XPath 2.0 Specification


fn:codepoints-to-string(integer* codes) => string

Converts a sequence of integers representing Unicode characters to the corresponding string

XPath 2.0 Specification


fn:collection(string $srcval) => node*

Loads an external collection of nodes identified by the URI of the collection

XPath 2.0 Specification

** Not yet implemented **


fn:compare(string? $comparand1, string? $comparand2) => integer?

Compares two strings using the default collation

XPath 2.0 Specification


fn:compare(string? $comparand1, string? $comparand2, anyURI $collationLiteral) => integer?

Compares two strings using a specified collation

XPath 2.0 Specification

y (collation is a string)

Note: In Saxon, the collation is represented as a string


fn:concat(string $arg1, ...) => string

Concatenates the string-values of the arguments into a single string

XPath 2.0 Specification


fn:contains(string? $operand1, string? $operand2) => boolean?

Returns true if the second string is a substring of the first

XPath 2.0 Specification

Note: Currently implemented by comparing Unicode code-points


fn:contains(string? $operand1, string? $operand2, anyURI $collationLiteral) => boolean?

XPath 2.0 Specification

** Not yet implemented **


fn:context-item() => item?

XPath 2.0 Specification

** Not yet implemented **


fn:copy(node? $srcval) => node?

XPath 2.0 Specification

** Not yet implemented **


fn:count(item* $srcval) => unsignedInt

Counts the number of items in a sequence

XPath 2.0 Specification

Note: Currently returns an integer, not an unsignedInt


fn:current-date() => date

Returns the current date

XPath 2.0 Specification


fn:current-dateTime() => dateTime

Returns the current date and time

XPath 2.0 Specification


fn:current-time() => time

Returns the current time

XPath 2.0 Specification


fn:data(node $srcval) => atomic value*

Returns the typed value of a node

XPath 2.0 Specification


fn:deep-equal(node $parameter1, node $parameter2) => boolean

Compares two nodes for deep equality: the names and contents must be identical

XPath 2.0 Specification


fn:deep-equal(node $parameter1, node $parameter2, anyURI $collation) => boolean

Compares two nodes for deep equality; string values are compared using the named collation

XPath 2.0 Specification

Note: Untested


fn:distinct-nodes( node* $srcval) => node*

Eliminates nodes with duplicate values

XPath 2.0 Specification


fn:distinct-values( item* $srcval) => item*

Returns the set of distinct values present in a given sequence

XPath 2.0 Specification

** Not yet implemented **


fn:distinct-values( item* $srcval, anyURI $collationLiteral) => item*

Returns the set of distinct values present in a given sequence, comparing strings using a named collation.

XPath 2.0 Specification

** Not yet implemented **


fn:document(item* $srcval1) => node*

Loads one or more documents identified by their URIs

XPath 2.0 Specification


fn:document(item* $srcval1, node* $srcval2) => node*

Loads one or more documents identified by their URIs, using the base URI of the node given in the second argument to resolve any relative URIs

XPath 2.0 Specification


fn:empty(item* $srcval) => boolean

Returns true if the given sequence is empty

XPath 2.0 Specification


fn:ends-with(string? $operand1, string? $operand2) => boolean?

Returns true if the first string ends with the second string

XPath 2.0 Specification

Note: Currently compares string using Unicode codepoint matching


fn:ends-with(string? $operand1, string? $operand2, anyURI $collationLiteral) => boolean?

Returns true if the first string ends with the second string, when compared using the named collation

XPath 2.0 Specification

** Not yet implemented **


fn:error()

Raises an error

XPath 2.0 Specification

** Not yet implemented **


fn:error(item $srcval)

Raises an error

XPath 2.0 Specification

** Not yet implemented **


fn:escape-uri(string $uri-part, boolean $escape-reserved) => string

Applies the %HH escaping convention to a URI

XPath 2.0 Specification


fn:exists(item* $srcval) => boolean

Returns true if the given sequence is not empty

XPath 2.0 Specification


fn:expanded-QName( string $paramURI, string $paramLocal) => QName

Constructs a QName value from a URI and local name

XPath 2.0 Specification


fn:false() => boolean

Returns the boolean value false

XPath 2.0 Specification


fn:floor(double? $srcval) => double?

Rounds a number towards minus infinity

XPath 2.0 Specification


fn:get-day-from-date( date? $srcval) => integer?

Extracts the day component of a date value

XPath 2.0 Specification


fn:get-day-from-dateTime( dateTime? $srcval) => integer?

Extracts the day component of a dateTime value

XPath 2.0 Specification


fn:get-days-from-dayTimeDuration( dayTimeDuration? $srcval) => integer?

Extracts the days component of a dayTimeDuration value

XPath 2.0 Specification

** Not yet implemented **


fn:get-dayTimeDuration-from-dateTimes( dateTime $srcval1, dateTime $srcval2) => dayTimeDuration

Returns the difference between two dateTimes in the form of a dayTimeDuration

XPath 2.0 Specification

** Not yet implemented **


fn:get-hours-from-dateTime( dateTime? $srcval) => integer?

Extracts the hour component of a dateTime value

XPath 2.0 Specification


fn:get-hours-from-dayTimeDuration( dayTimeDuration? $srcval) => integer?

Extracts the hours component of a dayTimeDuration value

XPath 2.0 Specification

** Not yet implemented **


fn:get-hours-from-time( time? $srcval) => integer?

Extracts the hours component of a time value

XPath 2.0 Specification


fn:get-local-name-from-QName( QName? $srcval) => string?

Extracts the local name component of a QName value

XPath 2.0 Specification


fn:get-minutes-from-dateTime( dateTime? $srcval) => integer?

Extracts the minutes component of a dateTime value

XPath 2.0 Specification


fn:get-minutes-from-dayTimeDuration( dayTimeDuration? $srcval) => integer?

Extracts the minutes component of a dayTimeDuration value

XPath 2.0 Specification

** Not yet implemented **


fn:get-minutes-from-time( time? $srcval) => integer?

Extracts the minutes component of a time value

XPath 2.0 Specification


fn:get-month-from-date( date? $srcval) => integer?

Extracts the month component of a date value

XPath 2.0 Specification


fn:get-month-from-dateTime( dateTime? $srcval) => integer?

Extracts the month component of a dateTime value

XPath 2.0 Specification


fn:get-months-from-yearMonthDuration( yearMonthDuration? $srcval) => integer?

Extracts the months component of a yearMonthDuration value

XPath 2.0 Specification

** Not yet implemented **


fn:get-namespace-from-QName( QName? $srcval) => anyURI?

Extracts the namespace URI component of a QName value

XPath 2.0 Specification


fn:get-seconds-from-dateTime( dateTime? $srcval) => decimal?

Extracts the seconds component of a dateTime value

XPath 2.0 Specification


fn:get-seconds-from-dayTimeDuration( dayTimeDuration? $srcval) => integer?

Extracts the seconds component of a dayTime value

XPath 2.0 Specification

** Not yet implemented **


fn:get-seconds-from-time( time? $srcval) => decimal?

Extracts the seconds component of a time value

XPath 2.0 Specification


fn:get-timezone-from-date( date? $srcval) => string?

Extracts the timezone component of a date value

XPath 2.0 Specification


fn:get-timezone-from-dateTime( dateTime? $srcval) => string?

Extracts the timezone component of a dateTime value

XPath 2.0 Specification


fn:get-timezone-from-time( time? $srcval) => string?

Extracts the timezone component of a time value

XPath 2.0 Specification


fn:get-year-from-date( date? $srcval) => integer?

Extracts the year component of a date value

XPath 2.0 Specification


fn:get-year-from-dateTime( dateTime? $srcval) => integer?

Extracts the year component of a dateTime value

XPath 2.0 Specification


fn:get-yearMonthDuration-from-dateTimes( dateTime $srcval1, dateTime $srcval2) => yearMonthDuration

Returns the difference between two dateTime values in the form of a yearMonthDuration

XPath 2.0 Specification

** Not yet implemented **


fn:get-years-from-yearMonthDuration( yearMonthDuration? $srcval) => integer?

Extracts the years component of a yearMonthDuration value

XPath 2.0 Specification

** Not yet implemented **


fn:id(IDREF* $srcval) => element*

Finds the elements with given ID attribute values

XPath 2.0 Specification

Note: Implemented according to the XPath 1.0 specification


fn:idref(string* $srcval) => element*

Finds the elements that link to the element with a given ID value

XPath 2.0 Specification

** Not yet implemented **


fn:if-absent(node? $node, anySimpleType $value) => anySimpleType*

Evaluates the second argument if the first is an empty sequence

XPath 2.0 Specification

** Not yet implemented **


fn:if-empty(node? $node, anySimpleType $value) => anySimpleType*

Evaluates the second argument if the first is an element with empty content

XPath 2.0 Specification

** Not yet implemented **


fn:index-of(item* $seqParam, item $srchParam) => unsignedInt*

Finds the positions of items in a sequence that match the second argument

XPath 2.0 Specification

** Not yet implemented **


fn:index-of(item* $seqParam, item $srchParam, anyURI $collationLiteral) => unsignedInt*

Finds the positions of items in a sequence that match the second argument, using a named collation for the comparison

XPath 2.0 Specification

** Not yet implemented **


fn:input() => node*

Return the sequence of nodes established by the calling environment as the current input collection

XPath 2.0 Specification

** Not yet implemented **


fn:insert(item* $target, decimal $position, item* $inserts) => item*

Insert an item into a sequence

XPath 2.0 Specification


fn:item-at(item* $seqParam, decimal $posParam) => item?

Return the item at a given position in a sequence

XPath 2.0 Specification

Note: Currently returns an empty sequence rather than raising an error if the index is out of range


fn:lang(string $testlang) => boolean

Returns true if the xml:lang value for the context node matches the given language

XPath 2.0 Specification


fn:last() => unsignedInt?

Returns the context size (the size of the sequence of items currently being processed)

XPath 2.0 Specification


fn:local-name() => string

Returns the local part of the name of the context node

XPath 2.0 Specification


fn:local-name(node? $srcval) => string

Returns the local part of the name of a given node

XPath 2.0 Specification


fn:lower-case(string? $srcval) => string?

Translates characters in a string to lower case

XPath 2.0 Specification


fn:matches(string? $input, string? $pattern) => boolean?

Returns true if the given string matches the given regular expression

XPath 2.0 Specification


fn:matches(string? $input, string? $pattern, string? $flags) => boolean?

Returns true if the given string matches the given regular expression, specifying flags to control the way pattern matching is performed

XPath 2.0 Specification


fn:max(item* $srcval) => anySimpleType?

Returns the highest value in a sequence of comparable items

XPath 2.0 Specification


fn:max(item* $srcval, anyURI $collationLiteral) => anySimpleType?

Returns the highest value in a sequence of strings, using a specified collation to perform the comparisons

XPath 2.0 Specification

** Not yet implemented **


fn:min(item* $srcval) => anySimpleType?

Returns the lowest value in a sequence of comparable items

XPath 2.0 Specification


fn:min(item* $srcval, anyURI $collationLiteral) => anySimpleType?

Returns the lowest value in a sequence of strings, using a specified collation to perform the comparisons

XPath 2.0 Specification

** Not yet implemented **


fn:name() => string

Returns the name of the context node, as a string in the lexical form of a QName

XPath 2.0 Specification


fn:name(node? $srcval) => string

Returns the name of a given node, as a string in the lexical form of a QName

XPath 2.0 Specification


fn:namespace-uri() => string

Returns the namespace URI of the name of the context node

XPath 2.0 Specification


fn:namespace-uri(node? $srcval) => string

Returns the namespace URI of the name of a given node

XPath 2.0 Specification


fn:node-kind(node $srcval) => string

Identifies what kind of node the argument is, as a string, for example "element" or "attribute"

XPath 2.0 Specification


fn:node-name(node $srcval) => QName?

Returns the name of the given node, as a QName value (that is, a namespace URI plus local name)

XPath 2.0 Specification

** Not yet implemented **


fn:normalize-space( string? $srcval) => string?

Eliminates redundant spaces from a string

XPath 2.0 Specification


fn:normalize-unicode( string? $srcval) => string?

Converts a string to Unicode normalized form NFC by modifying the way in which combining characters are represented

XPath 2.0 Specification

** Not yet implemented **


fn:normalize-unicode( string? $srcval, string $normalizationForm) => string?

Converts a string to a given Unicode normalized form by modifying the way in which combining characters are represented

XPath 2.0 Specification

** Not yet implemented **


fn:not(item* $srcval) => boolean

Returns true if the effective boolean value of the argument is false, and vice versa

XPath 2.0 Specification


fn:number() => double

Converts the string value of the context node to a number

XPath 2.0 Specification


fn:number(node $srcval) => double

Converts the string value of the given node to a number

XPath 2.0 Specification

Note: Implementation follows the XPath 1.0 specification


fn:position() => unsignedInt?

Returns the context position (that is, the position of the context item in the sequence currenly being processed)

XPath 2.0 Specification


fn:remove(item* $target, decimal $position) => item*

Removes the item at a given position in a sequence

XPath 2.0 Specification


fn:remove-timezone-from-dateTime( dateTime $srcval) => dateTime

Removes the timezone information from a dateTime value

XPath 2.0 Specification

** Not yet implemented **


fn:remove-timezone-from-dateTime( dateTime $srcval, dayTimeDuration $timezone) => dateTime

Removes the timezone information from a dateTime value, substituting the given timezone

XPath 2.0 Specification

** Not yet implemented **


fn:remove-timezone-from-time( time $srcval) => time

Removes the timezone information from a time value

XPath 2.0 Specification

** Not yet implemented **


fn:remove-timezone-from-time( time $srcval, dayTimeDuration $timezone) => time

Removes the timezone information from a time value, substituting the given timezone

XPath 2.0 Specification

** Not yet implemented **


fn:replace(string? $input, string? $pattern, string? $replacement) => string?

Replaces sequences of characters within a string that match a given regular expression

XPath 2.0 Specification


fn:replace(string? $input, string? $pattern, string? $replacement, string? $flags) => string?

Replaces sequences of characters within a string that match a given regular expression, specifying flags to control the way the regular expression is matched

XPath 2.0 Specification


fn:resolve-uri(anyURI $base, anyURI $relative) => anyURI

Resolves a relative URI against a given base URI

XPath 2.0 Specification

** Not yet implemented **


fn:root(node $srcval) => node

Returns the root node (document node) of the tree containing the given node

XPath 2.0 Specification


fn:round(double? $srcval) => double?

Rounds a numeric value to the nearest whole number

XPath 2.0 Specification


fn:sequence-deep-equal( item* $parameter1, item* $parameter2) => boolean?

Tests whether two sequences contain items that are pairwise deep-equal

XPath 2.0 Specification


fn:sequence-deep-equal( item* $parameter1, item* $parameter2, anyURI $collationLiteral) => boolean?

Tests whether two sequences contain items that are pairwise deep-equal, using the given collation to compare string values

XPath 2.0 Specification


fn:sequence-node-equal( node* $parameter1, node* $parameter2) => boolean?

Tests whether two sequences contain identical nodes in identical positions

XPath 2.0 Specification


fn:starts-with(string? $operand1, string? $operand2) => boolean?

Tests whether one string starts with another string

XPath 2.0 Specification

Note: Currently compares the strings using Unicode code-point matching


fn:starts-with(string? $operand1, string? $operand2, anyURI $collationLiteral) => boolean?

Tests whether one string starts with another string, using the given collation for comparison

XPath 2.0 Specification

** Not yet implemented **


fn:string() => string

Returns the string value of the context node

XPath 2.0 Specification


fn:string(item $srcval) => string

Returns the string value of the argument

XPath 2.0 Specification


fn:string-join(string* $sequence, string $separator) => string

Concatenates all the strings in the given sequence, separated by the given separator

XPath 2.0 Specification


fn:string-length(string? $srcval) => integer?

Returns the number of characters in the given string

XPath 2.0 Specification


fn:string-pad(string? $padString, decimal? $padCount) => string?

Returns a string obtained by concatenating $padCount occurrences of $padString

XPath 2.0 Specification


fn:string-to-codepoints(string $srcval) => integer*

Returns a sequence of integers representing the Unicode codepoints of the characters in the supplied string

XPath 2.0 Specification


fn:subsequence(item* $sourceSeq, decimal $startingLoc) => item*

Returns those items in the given sequence from the given starting position to the end of the sequence

XPath 2.0 Specification


fn:subsequence(item* $sourceSeq, decimal $startingLoc, decimal $length) => item*

Returns those items in the given sequence from the given starting position up to the position implied by the given length

XPath 2.0 Specification


fn:substring(string? $sourceString, decimal? $startingLoc) => string?

Returns a substring of a given string starting at the given starting position and continuing to the end of the string

XPath 2.0 Specification


fn:substring(string? $sourceString, decimal? $startingLoc, decimal? $length) => string?

Returns a subtring of a given string, starting at a given position and continuing up to a given length

XPath 2.0 Specification


fn:substring-after( string? $operand1, string? $operand2) => string?

Returns that part of the given input string that occurs after the first occurrence of the string given in $operand2

XPath 2.0 Specification


fn:substring-after( string? $operand1, string? $operand2, anyURI $collationLiteral) => string?

Returns that part of the given input string that occurs after the first occurrence of the string given in $operand2, using the given collation to compare strings

XPath 2.0 Specification

** Not yet implemented **


fn:substring-before( string? $operand1, string? $operand2) => string?

Returns that part of the given input string that occurs before the first occurrence of the string given in $operand2

XPath 2.0 Specification


fn:substring-before( string? $operand1, string? $operand2, anyURI $collationLiteral) => string?

Returns that part of the given input string that occurs before the first occurrence of the string given in $operand2, using the given collation to compare strings

XPath 2.0 Specification

** Not yet implemented **


fn:sum(item* $srcval) => double

Returns the total of a sequence of numbers

XPath 2.0 Specification


fn:tokenize(string? $input, string? $pattern) => string*

Returns a sequence of strings formed by breaking the input string at any substring that matches the given regular expression

XPath 2.0 Specification


fn:tokenize(string? $input, string? $pattern, string? $flags) => string*

Returns a sequence of strings formed by breaking the input string at any substring that matches the given regular expression, using flags to control the way regular expression matching is performed

XPath 2.0 Specification


fn:translate(string? $srcval, string? $mapString, string? $transString) => string?

Returns a string formed by replacing individual characters that appear in the second argument with the characters that appear at the corresponding position in the third argument

XPath 2.0 Specification


fn:true() => boolean

Return the boolean value true

XPath 2.0 Specification


fn:unique-ID(node $srcval) => ID?

Return the value of the ID attribute of an element, if it has one

XPath 2.0 Specification

** Not yet implemented **


fn:upper-case(string? $srcval) => string?

Converts a string to upper case

XPath 2.0 Specification


Michael H. Kay
15 November 2002