Saxon home page

XSLT 2.0 and XPath 2.0 Functions

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

It includes both the core functions defined in XPath 2.0, and the additional functions defined in the XSLT 2.0 specification.

Index

fn:abs
fn:adjust-dateTime-to-timezone
fn:adjust-dateTime-to-timezone
fn:adjust-date-to-timezone
fn:adjust-date-to-timezone
fn:adjust-time-to-timezone
fn:adjust-time-to-timezone
fn:avg
fn:base-uri
fn:base-uri
fn:boolean
fn:ceiling
fn:codepoints-to-string
fn:collection
fn:compare
fn:compare
fn:concat
fn:contains
fn:contains
fn:context-item
fn:count
xslt:current
fn:current-date
fn:current-dateTime
xslt:current-group
xslt:current-grouping-key
fn:current-time
fn:data
fn:day-from-date
fn:day-from-dateTime
fn:days-from-dayTimeDuration
fn:deep-equal
fn:deep-equal
fn:default-collation
fn:distinct-nodes
fn:distinct-values
fn:distinct-values
fn:doc
xslt:document
xslt:document
fn:document-uri
xslt:element-available
fn:empty
fn:ends-with
fn:ends-with
fn:error
fn:error
fn:escape-uri
fn:exactly-one
fn:exists
fn:expanded-QName
fn:false
fn:floor
xslt:format-date
xslt:format-date
xslt:format-dateTime
xslt:format-dateTime
xslt:format-number
xslt:format-number
xslt:format-time
xslt:format-time
xslt:function-available
xslt:function-available
xslt:generate-id
xslt:generate-id
fn:hours-from-dateTime
fn:hours-from-dayTimeDuration
fn:hours-from-time
fn:id
fn:idref
fn:implicit-timezone
fn:index-of
fn:index-of
fn:input
fn:in-scope-prefixes
fn:insert-before
fn:item-at
xslt:key
fn:lang
fn:last
fn:local-name
fn:local-name
fn:local-name-from-QName
fn:lower-case
fn:matches
fn:matches
fn:max
fn:max
fn:min
fn:min
fn:minutes-from-dateTime
fn:minutes-from-dayTimeDuration
fn:minutes-from-time
fn:month-from-date
fn:month-from-dateTime
fn:months-from-yearMonthDuration
fn:name
fn:name
fn:namespace-uri
fn:namespace-uri
fn:namespace-uri-for-prefix
fn:namespace-uri-from-QName
fn:node-kind
fn:node-name
fn:normalize-space
fn:normalize-space
fn:normalize-unicode
fn:normalize-unicode
fn:not
fn:number
fn:number
fn:one-or-more
fn:position
xslt:regex-group
fn:remove
fn:replace
fn:replace
fn:resolve-QName
fn:resolve-uri
fn:resolve-uri
fn:reverse
fn:root
fn:root
fn:round
fn:round-half-to-even
fn:round-half-to-even
fn:seconds-from-dateTime
fn:seconds-from-dayTimeDuration
fn:seconds-from-time
fn:sequence-node-identical
fn:starts-with
fn:starts-with
fn:string
fn:string
fn:string-join
fn:string-length
fn:string-length
fn:string-pad
fn:string-to-codepoints
fn:subsequence
fn:subsequence
fn:substring
fn:substring
fn:substring-after
fn:substring-after
fn:substring-before
fn:substring-before
fn:subtract-dateTimes-yielding-dayTimeDuration
fn:subtract-dateTimes-yielding-yearMonthDuration
fn:sum
xslt:system-property
fn:timezone-from-date
fn:timezone-from-dateTime
fn:timezone-from-time
fn:tokenize
fn:tokenize
fn:trace
fn:translate
fn:true
fn:unordered
xslt:unparsed-entity-public-id
xslt:unparsed-entity-uri
xslt:unparsed-text
xslt:unparsed-text
fn:upper-case
fn:year-from-date
fn:year-from-dateTime
fn:years-from-yearMonthDuration
fn:zero-or-one

Function Definitions

fn:abs

Function signature

$srcval numeric ?
Result numeric ?

Returns the absolute value of a given number. Returns the same type as the supplied argument.

XPath 2.0 Specification

Implemented in Saxon 7.6.1.


fn:adjust-dateTime-to-timezone

Function signature

$srcval xs:dateTime ?
Result xs:dateTime ?

XPath 2.0 Specification

Implemented in Saxon 7.8


fn:adjust-dateTime-to-timezone

Function signature

$srcval xs:dateTime ?
$timezone xdt:dayTimeDuration
Result xs:dateTime ?

XPath 2.0 Specification

Implemented in Saxon 7.8


fn:adjust-date-to-timezone

Function signature

$srcval xs:date ?
Result xs:date ?

XPath 2.0 Specification

Implemented in Saxon 7.8


fn:adjust-date-to-timezone

Function signature

$srcval xs:date ?
$timezone xdt:dayTimeDuration
Result xs:date ?

XPath 2.0 Specification

Implemented in Saxon 7.8


fn:adjust-time-to-timezone

Function signature

$srcval xs:time ?
Result xs:time ?

XPath 2.0 Specification

Implemented in Saxon 7.8


fn:adjust-time-to-timezone

Function signature

$srcval xs:time ?
$timezone xdt:dayTimeDuration
Result xs:time ?

XPath 2.0 Specification

Implemented in Saxon 7.8


fn:avg

Function signature

$srcval xdt:anyAtomicType *
Result xdt:anyAtomicType ?

Returns the average of a set of numbers

XPath 2.0 Specification

Implemented. Changed in 7.4 to return the same type as the argument, when appropriate. (For a set of integers, the result is a double). Not yet implemented for other addable types, e.g. duration.


fn:base-uri

Function signature

Result xs:string ?

Returns the base URI of the static context

XPath 2.0 Specification


fn:base-uri

Function signature

$srcval node()
Result xs:string ?

Returns the base URI of a given node

XPath 2.0 Specification


fn:boolean

Function signature

$srcval item() *
Result xs:boolean

Obtains the effective boolean value of any expression

XPath 2.0 Specification


fn:ceiling

Function signature

$srcval numeric ?
Result numeric ?

Rounds a value towards positive infinity

XPath 2.0 Specification

Implemented. Changed in 7.4 to return the same type as the supplied argument.


fn:codepoints-to-string

Function signature

$codes xs:integer *
Result xs:string

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

XPath 2.0 Specification

Implemented. The error checking is incomplete (there is no check that the integers in the supplied sequence are legal XML characters).


fn:collection

Function signature

$srcval xs:string
Result node() *

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

XPath 2.0 Specification

Implemented. In the Saxon implementation, the argument is interpreted as the URI of an XML catalogue document containing the URIs of the documents that make up the collection. An example of a catalogue is:

<collection>
  <doc href="doc1.xml"/>
  <doc href="doc2.xml"/>
  <doc href="doc3.xml"/>
</collection>


fn:compare

Function signature

$comparand1 xs:string ?
$comparand2 xs:string ?
Result xs:integer ?

Compares two strings using the default collation

XPath 2.0 Specification


fn:compare

Function signature

$comparand1 xs:string ?
$comparand2 xs:string ?
$collation xs:string
Result xs:integer ?

Compares two strings using a specified collation

XPath 2.0 Specification


fn:concat

Function signature

$arg1 xs:string
Result xs:string

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

XPath 2.0 Specification


fn:contains

Function signature

$operand1 xs:string ?
$operand2 xs:string ?
Result xs:boolean ?

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

XPath 2.0 Specification


fn:contains

Function signature

$operand1 xs:string ?
$operand2 xs:string ?
$collation xs:string
Result xs:boolean ?

XPath 2.0 Specification


fn:context-item

Function signature

Result item() ?

XPath 2.0 Specification

Removed in Saxon 7.8


fn:count

Function signature

$srcval item() *
Result xs:integer

Counts the number of items in a sequence

XPath 2.0 Specification


xslt:current

Function signature

Result item() ?

Returns the item that was the current item supplied on entry to the XPath expression

XSLT 2.0 Specification


fn:current-date

Function signature

Result xs:date

Returns the current date

XPath 2.0 Specification

Implemented. Changed in 7.8 to return a date in the local timezone.


fn:current-dateTime

Function signature

Result xs:dateTime

Returns the current date and time

XPath 2.0 Specification

Implemented. Changed in 7.8 to return a date/time in the local timezone.


xslt:current-group

Function signature

Result item() *

Returns the contents of the current group selected by xsl:for-each-group

XSLT 2.0 Specification


xslt:current-grouping-key

Function signature

Result xdt:anyAtomicType

Returns the value that is the grouping key of the current group selected by xsl:for-each-group

XSLT 2.0 Specification

Implemented in Saxon 7.6.5


fn:current-time

Function signature

Result xs:time

Returns the current time

XPath 2.0 Specification

Implemented. Changed in 7.8 to return a time in the local timezone.


fn:data

Function signature

$srcval item() *
Result xdt:anyAtomicType *

Returns the result of atomizing the supplied sequence

XPath 2.0 Specification


fn:day-from-date

Function signature

$srcval xs:date ?
Result xs:integer ?

Extracts the day component of a date value

XPath 2.0 Specification

Note: The old name get-day-from-date is retained as a synonym


fn:day-from-dateTime

Function signature

$srcval xs:dateTime ?
Result xs:integer ?

Extracts the day component of a dateTime value

XPath 2.0 Specification

Note: The old name get-day-from-dateTime is retained as a synonym


fn:days-from-dayTimeDuration

Function signature

$srcval xdt:dayTimeDuration ?
Result xs:integer ?

Extracts the days component of a dayTimeDuration value

XPath 2.0 Specification

Note: The old name get-days-from-dayTimeDuration is retained as a synonym


fn:deep-equal

Function signature

$operand1 item() *
$operand2 item() *
Result xs:boolean

Compares two sequences for deep equality: the names and contents must be the same, but nodes need not have the same identity.

XPath 2.0 Specification


fn:deep-equal

Function signature

$operand1 item() *
$operand2 item() *
$collation string
Result xs:boolean

Compares two sequences for deep equality; string values are compared using the named collation; nodes are compared for deep equality of names and content.

XPath 2.0 Specification


fn:default-collation

Function signature

Result xs:string

Returns the name of the default collation

XPath 2.0 Specification

Implemented. In Saxon this always returns a value: if no default collation has been specified explicitly, it returns the URI of the code-point collation. Note, the May 2003 draft still returns an anyURI, though elsewhere collations are now represented by a string.


fn:distinct-nodes

Function signature

$srcval node() *
Result node() *

Eliminates nodes with duplicate values

XPath 2.0 Specification

Removed in Saxon 7.8


fn:distinct-values

Function signature

$srcval xdt:anyAtomicType *
Result xdt:anyAtomicType *

Returns the set of distinct values present in a given sequence

XPath 2.0 Specification


fn:distinct-values

Function signature

$srcval xdt:anyAtomicType *
$collation string
Result xdt:anyAtomicType *

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

XPath 2.0 Specification


fn:doc

Function signature

$uri string ?
Result document-node() ?

Loads a document identified by its URI

XPath 2.0 Specification

Implemented in Saxon 7.6


xslt:document

Function signature

$uri item *
Result node() *

Loads one or more documents identified by their URIs

XSLT 2.0 Specification


xslt:document

Function signature

$uri item *
$base node() *
Result 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

XSLT 2.0 Specification

Note: Check the type of the second argument against the latest spec.


fn:document-uri

Function signature

$srcval node()
Result string ?

Returns the URI of a document

XPath 2.0 Specification

Note: The function is supported, though not strictly according to the spec. It is defined only for document nodes (as specified in the data model), and the URI returned is not guaranteed to be absolute, and is not guaranteed to be capable of retrieving the document using the document function (for example, a value is returned for a temporary tree).


xslt:element-available

Function signature

$element xs:string
Result xs:boolean

Determines whether a particular instruction (typically, an extension element) is available in the context

XSLT 2.0 Specification

Implemented. There is a restriction, namely that if the argument value is not a compile-time constant, then the function has no information about the names of user-defined extension elements, so it will return false if the name of such an element is supplied.


fn:empty

Function signature

$srcval item() *
Result xs:boolean

Returns true if the given sequence is empty

XPath 2.0 Specification


fn:ends-with

Function signature

$operand1 xs:string ?
$operand2 xs:string ?
Result xs:boolean ?

Returns true if the first string ends with the second string

XPath 2.0 Specification


fn:ends-with

Function signature

$operand1 xs:string ?
$operand2 xs:string ?
$collation xs:string
Result xs:boolean ?

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

XPath 2.0 Specification


fn:error

Function signature

Result

Raises an error.

XPath 2.0 Specification


fn:error

Function signature

$srcval item() ?
Result

Raises an error. The string value of the supplied item is used as the error message.

XPath 2.0 Specification


fn:escape-uri

Function signature

$uri-part xs:string
$escape-reserved xs:boolean
Result string

Applies the %HH escaping convention to a URI

XPath 2.0 Specification


fn:exactly-one

Function signature

$srcval item() *
Result item() ?

XPath 2.0 Specification


fn:exists

Function signature

$srcval item() *
Result xs:boolean

Returns true if the given sequence is not empty

XPath 2.0 Specification


fn:expanded-QName

Function signature

$paramURI xs:string
$paramLocal xs:string
Result xs:QName

Constructs a QName value from a URI and local name

XPath 2.0 Specification


fn:false

Function signature

Result xs:boolean

Returns the boolean value false

XPath 2.0 Specification


fn:floor

Function signature

$srcval numeric ?
Result numeric ?

Rounds a number towards minus infinity

XPath 2.0 Specification

Implemented. Changed in 7.4 to return the same type as the supplied argument.


xslt:format-date

Function signature

$value xs:date ?
$picture xs:string
$date-format-name xs:string
Result xs:string

Formats a date

XSLT 2.0 Specification

Supported with limitations. The third argument is ignored, the function always formats the date for the current locale. Alphabetic forms of numbers (including ordinals) are not at present localized.


xslt:format-date

Function signature

$value xs:date ?
$picture xs:string
Result xs:string

Formats a date

XSLT 2.0 Specification

Supported with limitations. The function always formats the date for the current locale. Alphabetic forms of numbers (including ordinals) are not at present localized.


xslt:format-dateTime

Function signature

$value xs:dateTime ?
$picture xs:string
$date-format-name xs:string
Result xs:string

Formats a dateTime

XSLT 2.0 Specification

Supported with limitations. The third argument is ignored, the function always formats the date for the current locale. Alphabetic forms of numbers (including ordinals) are not at present localized.


xslt:format-dateTime

Function signature

$value xs:dateTime ?
$picture xs:string
Result xs:string

Formats a dateTime

XSLT 2.0 Specification

Supported with limitations. The function always formats the date for the current locale. Alphabetic forms of numbers (including ordinals) are not at present localized.


xslt:format-number

Function signature

$value xs:double
$picture xs:string
Result xs:string

Formats a number as specified by a picture string, using the default decimal format

XSLT 2.0 Specification

Implemented. Changed in 7.4.1 to use the new XSLT 2.0 specification. This creates slight incompatibilities from the previous version, which remains available under the name format-number-1.0(). There is one known restriction: characters such as the decimal-separator are restricted to be in the Unicode BMP, i.e. below Unicode 0xFFFF. The current implementation does not attempt to cache or precompile the picture string. Also it does not detect the error that occurs when the same character is used in more than one role. Error checking has not been thoroughly tested.


xslt:format-number

Function signature

$value xs:double
$picture xs:string
$decimal-format xs:string
Result xs:string

Formats a number as specified by a picture string, using a named decimal format

XSLT 2.0 Specification

See two-argument version of format-number().


xslt:format-time

Function signature

$value xs:time ?
$picture xs:string
$date-format-name xs:string
Result xs:string

Formats a time

XSLT 2.0 Specification

Supported with limitations. The third argument is ignored, the function always formats the time for the current locale. Alphabetic forms of numbers (including ordinals) are not at present localized.


xslt:format-time

Function signature

$value xs:time ?
$picture xs:string
Result xs:string

Formats a time

XSLT 2.0 Specification

Supported with limitations. The function always formats the date for the current locale. Alphabetic forms of numbers (including ordinals) are not at present localized.


xslt:function-available

Function signature

$function xs:string
Result xs:boolean

Determines whether a particular function is available in the context

XSLT 2.0 Specification

Implemented. There is a restriction, namely that if the argument value is not a compile-time constant, then the function has no information about the names of stylesheet functions, so it will return false if the name of a stylesheet function is supplied.


xslt:function-available

Function signature

$function xs:string
$arity xs:integer
Result xs:boolean

Determines whether a particular function is available in the context. The two-argument version of the function was added during the Last Call period.

XSLT 2.0 Specification

Implemented in Saxon 7.9. There is a restriction, namely that if the argument value is not a compile-time constant, then the function has no information about the names of stylesheet functions, so it will return false if the name of a stylesheet function is supplied.


xslt:generate-id

Function signature

Result xs:string

Returns a generated unique identifier of the context node

XSLT 2.0 Specification


xslt:generate-id

Function signature

$srcval node() ?
Result xs:string

Returns a generated unique identifier of a given node

XSLT 2.0 Specification


fn:hours-from-dateTime

Function signature

$srcval xs:dateTime ?
Result xs:integer ?

Extracts the hour component of a dateTime value

XPath 2.0 Specification

Implemented

Note: The old name get-hours-from-dateTime is retained as a synonym


fn:hours-from-dayTimeDuration

Function signature

$srcval xdt:dayTimeDuration ?
Result xs:integer ?

Extracts the hours component of a dayTimeDuration value

XPath 2.0 Specification

Note: The old name get-hours-from-dayTimeDuration is retained as a synonym


fn:hours-from-time

Function signature

$srcval xs:time ?
Result xs:integer ?

Extracts the hours component of a time value

XPath 2.0 Specification

Implemented; but currently returns the local time value, not the normalized time value.

Note: The old name get-hours-from-time is retained as a synonym


fn:id

Function signature

$srcval xs:string *
Result element() *

Finds the elements with given ID attribute values

XPath 2.0 Specification

Note: Implemented according to the XPath 1.0 specification. The new second argument (introduced after the 12 Nov 2004 draft) is not yet implemented.


fn:idref

Function signature

$srcval xs:string *
Result node() *

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

XPath 2.0 Specification

Implemented in Saxon 7.9

Note: The new second argument (introduced after the 12 Nov 2004 draft) is not yet implemented.


fn:implicit-timezone

Function signature

Result xdt:dayTimeDuration

Returns the implicit timezone

XPath 2.0 Specification

Implemented in Saxon 7.8


fn:index-of

Function signature

$seqParam xdt:anyAtomicType *
$srchParam xdt:anyAtomicType
Result xs:integer *

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

XPath 2.0 Specification

Implemented.


fn:index-of

Function signature

$seqParam xdt:anyAtomicType *
$srchParam xdt:anyAtomicType
$collation xs:string
Result xs:integer *

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

XPath 2.0 Specification

Implemented.


fn:input

Function signature

Result node() *

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

XPath 2.0 Specification

Removed in Saxon 7.8

Note: This implementation of the input() function is very simple. If the parameter {http://saxon.sf.net/}input has been supplied to the transformation, the function returns the value of this parameter. This must be a node sequence - which means it cannot be supplied from the command line. If no such parameter has been supplied, it returns the root of the principal source document (the document containing the node that was matched on entry to the transformation).


fn:in-scope-prefixes

Function signature

$element element()
Result xs:string *

Returns the names of the namespaces that are in scope for an element

XPath 2.0 Specification

Implemented. Name changed in 7.8 from get-in-scope-namespaces().

Note: The old name get-in-scope-prefixes is retained as a synonym


fn:insert-before

Function signature

$target item() *
$position xs:integer
$inserts item() *
Result item() *

Insert an item into a sequence

XPath 2.0 Specification

Implemented. Changed in 7.4 to reflect the latest WD which changes the name from insert to insert-before, and inserts the new items before the selected position, not after it as previously. Changed in 7.8 to allow the insert position to be beyond the end of the original sequence (which causes the new sequence to be appended).


fn:item-at

Function signature

$seqParam item() *
$posParam xs:integer
Result item() ?

Return the item at a given position in a sequence

XPath 2.0 Specification

Removed in Saxon 7.8


xslt:key

Function signature

$key-name xs:string
$key-value xdt:anyAtomicType *
Result node() *

Returns the nodes identified by a named key declaration in the stylesheet.

XSLT 2.0 Specification


fn:lang

Function signature

$testlang xs:string *
Result xs:boolean

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

XPath 2.0 Specification

The optional second argument (added since the 12 Nov 2003 draft) is not yet implemented.


fn:last

Function signature

Result xs:integer

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

XPath 2.0 Specification


fn:local-name

Function signature

Result xs:string

Returns the local part of the name of the context node

XPath 2.0 Specification


fn:local-name

Function signature

$srcval node() ?
Result xs:string

Returns the local part of the name of a given node

XPath 2.0 Specification


fn:local-name-from-QName

Function signature

$srcval xs:QName ?
Result string ?

Extracts the local name component of a QName value

XPath 2.0 Specification

Note: The old name get-local-name-from-QName is retained as a synonym


fn:lower-case

Function signature

$srcval xs:string ?
Result xs:string ?

Translates characters in a string to lower case

XPath 2.0 Specification


fn:matches

Function signature

$input xs:string ?
$pattern xs:string
Result xs:boolean ?

Returns true if the given string matches the given regular expression

XPath 2.0 Specification

Note: Upgraded in Saxon 7.9 to match the precise regex syntax and to support all four flags s, m, i, x.


fn:matches

Function signature

$input xs:string ?
$pattern xs:string
$flags xs:string
Result xs: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

Note: Upgraded in Saxon 7.9 to match the precise regex syntax and to support all four flags s, m, i, x.


fn:max

Function signature

$srcval xdt:anyAtomicType *
Result xdt:anyAtomicType ?

Returns the highest value in a sequence of comparable items

XPath 2.0 Specification

Implemented. Changed in 7.4 to support any comparable type. Changed in 7.8 to convert untyped Atomic values to xs:double, and to return NaN if the input sequence contains a NaN.


fn:max

Function signature

$srcval xdt:anyAtomicType *
$collation xs:string
Result xdt:anyAtomicType ?

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

XPath 2.0 Specification

Implemented in 7.4. Changed in 7.8 to convert untyped Atomic values to xs:double, and to return NaN if the input sequence contains a NaN.


fn:min

Function signature

$srcval xdt:anyAtomicType *
Result xdt:anyAtomicType ?

Returns the lowest value in a sequence of comparable items

XPath 2.0 Specification

Implemented. Changed in 7.4 to support any comparable type. Changed in 7.8 to convert untyped Atomic values to xs:double, and to return NaN if the input sequence contains a NaN.


fn:min

Function signature

$srcval xdt:anyAtomicType *
$collation xs:string
Result xdt:anyAtomicType ?

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

XPath 2.0 Specification

Implemented in 7.4. Changed in 7.8 to convert untyped Atomic values to xs:double, and to return NaN if the input sequence contains a NaN.


fn:minutes-from-dateTime

Function signature

$srcval xs:dateTime ?
Result xs:integer ?

Extracts the minutes component of a dateTime value

XPath 2.0 Specification

Note: The old name get-minutes-from-dateTime is retained as a synonym


fn:minutes-from-dayTimeDuration

Function signature

$srcval xdt:dayTimeDuration ?
Result xs:integer ?

Extracts the minutes component of a dayTimeDuration value

XPath 2.0 Specification

Note: The old name get-minutes-from-dayTimeDuration is retained as a synonym


fn:minutes-from-time

Function signature

$srcval xs:time ?
Result xs:integer ?

Extracts the minutes component of a time value

XPath 2.0 Specification

Note: The old name get-minutes-from-time is retained as a synonym


fn:month-from-date

Function signature

$srcval xs:date ?
Result xs:integer ?

Extracts the month component of a date value

XPath 2.0 Specification

Note: The old name get-month-from-date is retained as a synonym


fn:month-from-dateTime

Function signature

$srcval xs:dateTime ?
Result xs:integer ?

Extracts the month component of a dateTime value

XPath 2.0 Specification

Note: The old name get-month-from-dateTime is retained as a synonym


fn:months-from-yearMonthDuration

Function signature

$srcval xdt:yearMonthDuration ?
Result xs:integer ?

Extracts the months component of a yearMonthDuration value

XPath 2.0 Specification

Note: The old name get-months-from-yearMonthDuration is retained as a synonym


fn:name

Function signature

Result xs:string

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

XPath 2.0 Specification


fn:name

Function signature

$srcval node() ?
Result xs: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

Function signature

Result xs:string

Returns the namespace URI of the name of the context node

XPath 2.0 Specification


fn:namespace-uri

Function signature

$srcval node() ?
Result xs:string

Returns the namespace URI of the name of a given node

XPath 2.0 Specification


fn:namespace-uri-for-prefix

Function signature

$prefix xs:string
$element element()
Result string ?

Returns the namespace URI corresponding to a given prefix, using the namespaces that are in scope for a given element

XPath 2.0 Specification

Implemented. Changed in 7.9 so the prefix is now the first argument, the element node the second.

Note: The old name get-namespace-uri-for-prefix is retained as a synonym


fn:namespace-uri-from-QName

Function signature

$srcval xs:QName ?
Result string ?

Extracts the namespace URI component of a QName value

XPath 2.0 Specification

Note: The old name get-namespace-from-QName [sic] is retained as a synonym


fn:node-kind

Function signature

$srcval node()
Result xs:string

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

XPath 2.0 Specification

Removed in Saxon 7.8


fn:node-name

Function signature

$srcval node()
Result xs:QName ?

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

XPath 2.0 Specification


fn:normalize-space

Function signature

Result xs:string ?

Eliminates redundant spaces from the string value of the context node

XPath 2.0 Specification


fn:normalize-space

Function signature

$srcval xs:string ?
Result xs:string ?

Eliminates redundant spaces from a string

XPath 2.0 Specification


fn:normalize-unicode

Function signature

$srcval xs:string ?
Result xs: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

Function signature

$srcval xs:string ?
$normalizationForm xs:string
Result xs: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

Function signature

$srcval item() *
Result xs:boolean

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

XPath 2.0 Specification


fn:number

Function signature

Result xs:double

Converts the string value of the context node to a number

XPath 2.0 Specification

Note: Saxon 7.4 implements some incompatible changes to this function defined in XPath 2.0. When given an empty sequence as the argument, the number function now returns an empty sequence, rather than NaN. When given a value that is not a valid number, it raises an error rather than returning NaN. The strings "INF" and "-INF" are recognized as representations of positive and negative infinity.


fn:number

Function signature

$srcval item() ?
Result xs:double

Converts the string value of the given node to a number

XPath 2.0 Specification

Note: Implementation follows the XPath 1.0 specification. Changed in 7.4 so that if the argument is the empty sequence, the result is the empty sequence - this causes some backwards compatibility problems.


fn:one-or-more

Function signature

$srcval item() *
Result item() ?

XPath 2.0 Specification


fn:position

Function signature

Result xs:integer

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

XPath 2.0 Specification


xslt:regex-group

Function signature

$groupNumber xs:integer
Result xs:string

Returns the contents of the substring that matched the n'th subexpression in a regular expression processed using xsl:analyze-string

XSLT 2.0 Specification


fn:remove

Function signature

$target item() *
$position xs:integer
Result item() *

Removes the item at a given position in a sequence

XPath 2.0 Specification


fn:replace

Function signature

$input xs:string ?
$pattern xs:string
$replacement xs:string
Result xs:string ?

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

XPath 2.0 Specification

Note: Upgraded in Saxon 7.9 to match the precise regex syntax and to support all four flags s, m, i, x. Also changed to disallow a pattern that matches a zero-length string.


fn:replace

Function signature

$input xs:string ?
$pattern xs:string
$replacement xs:string
$flags xs:string
Result xs: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

Note: Upgraded in Saxon 7.9 to match the precise regex syntax and to support all four flags s, m, i, x. Also changed to disallow a pattern that matches a zero-length string.


fn:resolve-QName

Function signature

$qname xs:string
$element element()
Result xs:QName

Expands a lexical QName using the in-scope namespaces from the given element

XPath 2.0 Specification


fn:resolve-uri

Function signature

$relative xs:string
Result xs:string

Resolves a relative URI against the base URI from the static context

XPath 2.0 Specification


fn:resolve-uri

Function signature

$relative xs:string
$base xs:string
Result xs:string

Resolves a relative URI against a given base URI

XPath 2.0 Specification

Note: Current WD still describes the second argument as having type xs:anyURI


fn:reverse

Function signature

$srcval item() *
Result item() *

Reverses the order of the items in the input sequence.

XPath 2.0 Specification

Implemented in Saxon 7.8


fn:root

Function signature

Result node()

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

XPath 2.0 Specification


fn:root

Function signature

$srcval node()
Result node()

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

XPath 2.0 Specification


fn:round

Function signature

$srcval numeric ?
Result numeric ?

Rounds a numeric value to the nearest whole number, rounding x.5 towards positive infinity.

XPath 2.0 Specification

Implemented. Changed in 7.4 to return the same type as the supplied argument.


fn:round-half-to-even

Function signature

$srcval numeric ?
Result numeric ?

Rounds a numeric value to the nearest whole number, rounding x.5 towards the nearest even number.

XPath 2.0 Specification


fn:round-half-to-even

Function signature

$srcval numeric ?
$precision xs:integer
Result numeric ?

Rounds a numeric value to the nearest integer multiple of 10 the power of minus precision, rounding x.5 towards the nearest number whose last digit is even.

XPath 2.0 Specification

Note: In the case of doubles and floats, rounding errors may occur giving unexpected effects.


fn:seconds-from-dateTime

Function signature

$srcval xs:dateTime ?
Result xs:integer ?

Extracts the seconds component of a dateTime value

XPath 2.0 Specification

Note: The old name get-seconds-from-dateTime is retained as a synonym


fn:seconds-from-dayTimeDuration

Function signature

$srcval xdt:dayTimeDuration ?
Result xs:integer ?

Extracts the seconds component of a dayTimeDuration value

XPath 2.0 Specification

Implemented. Return type should be decimal, not integer.

Note: The old name get-seconds-from-dayTimeDuration is retained as a synonym


fn:seconds-from-time

Function signature

$srcval xs:time ?
Result xs:integer ?

Extracts the seconds component of a time value

XPath 2.0 Specification

Note: The old name get-seconds-from-time is retained as a synonym


fn:sequence-node-identical

Function signature

$parameter1 node() *
$parameter2 node() *
Result xs:boolean ?

Tests whether two sequences contain identical nodes in identical positions

XPath 2.0 Specification

Removed in Saxon 7.8


fn:starts-with

Function signature

$operand1 xs:string ?
$operand2 xs:string ?
Result xs:boolean ?

Tests whether one string starts with another string

XPath 2.0 Specification


fn:starts-with

Function signature

$operand1 xs:string ?
$operand2 xs:string ?
$collation xs:string
Result xs:boolean ?

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

XPath 2.0 Specification


fn:string

Function signature

Result xs:string

Returns the string value of the context node

XPath 2.0 Specification


fn:string

Function signature

$srcval item() ?
Result xs:string

Returns the string value of the argument. Saxon implements the argument as type item()* rather than item()?

XPath 2.0 Specification


fn:string-join

Function signature

$sequence xs:string *
$separator xs:string
Result xs:string

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

XPath 2.0 Specification


fn:string-length

Function signature

Result xs:integer ?

Returns the number of characters in the string value of the context node

XPath 2.0 Specification


fn:string-length

Function signature

$srcval xs:string ?
Result xs:integer ?

Returns the number of characters in the given string

XPath 2.0 Specification


fn:string-pad

Function signature

$padString xs:string ?
$padCount xs:integer
Result xs:string ?

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

XPath 2.0 Specification

Removed in Saxon 7.8


fn:string-to-codepoints

Function signature

$srcval xs:string
Result xs:integer *

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

XPath 2.0 Specification


fn:subsequence

Function signature

$sourceSeq item() *
$startingLoc xs:double
Result item() *

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

XPath 2.0 Specification

Implemented, currently requires integer argument

Note: Non-integer values, negative values etc for the second argument may not work as defined in the XPath specification.


fn:subsequence

Function signature

$sourceSeq item() *
$startingLoc xs:double
$length xs:double
Result 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

Implemented, currently requires integer arguments

Note: Non-integer values, negative values etc for the second or third argument may not work as defined in the XPath specification.


fn:substring

Function signature

$sourceString xs:string ?
$startingLoc xs:double
Result xs: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

Function signature

$sourceString xs:string ?
$startingLoc xs:double
$length xs:double
Result xs: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

Function signature

$operand1 xs:string ?
$operand2 xs:string ?
Result xs: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

Function signature

$operand1 xs:string ?
$operand2 xs:string ?
$collation xs:string
Result xs: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


fn:substring-before

Function signature

$operand1 xs:string ?
$operand2 xs:string ?
Result xs: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

Function signature

$operand1 xs:string ?
$operand2 xs:string ?
$collation xs:string
Result xs: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


fn:subtract-dateTimes-yielding-dayTimeDuration

Function signature

$operand1 xs:dateTime ?
$operand2 xs:dateTime ?
Result xdt:dayTimeDuration ?

Returns the difference between two dateTimes as a dayTimeDuration

XPath 2.0 Specification

** Not yet implemented **


fn:subtract-dateTimes-yielding-yearMonthDuration

Function signature

$operand1 xs:dateTime ?
$operand2 xs:dateTime ?
Result xdt:yearMonthDuration ?

Returns the difference between two dateTimes as a yearMonthDuration

XPath 2.0 Specification

** Not yet implemented **


fn:sum

Function signature

$srcval xdt:anyAtomicType *
Result xdt:anyAtomicType ?

Returns the total of a sequence of numbers

XPath 2.0 Specification

Implemented. In 7.4, works on all numeric types and returns the same type as the arguments. Not implemented for other addable types, e.g. duration. The new optional second parameter is not implemented. Changed in 7.8 to return integer 0 for an empty sequence, rather than double 0.0.


xslt:system-property

Function signature

$propertyName xs:string
Result xs:string

Returns the value of a system property

XSLT 2.0 Specification


fn:timezone-from-date

Function signature

$srcval xs:date ?
Result xdt:dayTimeDuration ?

Extracts the timezone component of a date value

XPath 2.0 Specification

Implemented. Changed in 7.8 to return dayTimeDuration rather than string.

Note: The old name get-timezone-from-date is retained as a synonym


fn:timezone-from-dateTime

Function signature

$srcval xs:dateTime ?
Result xdt:dayTimeDuration ?

Extracts the timezone component of a dateTime value

XPath 2.0 Specification

Implemented. Changed in 7.8 to return dayTimeDuration rather than string.

Note: The old name timezone-from-dateTime is retained as a synonym


fn:timezone-from-time

Function signature

$srcval xs:time ?
Result xdt:dayTimeDuration ?

Extracts the timezone component of a time value

XPath 2.0 Specification

Implemented. Changed in 7.8 to return dayTimeDuration rather than string.

Note: The old name get-timezone-from-time is retained as a synonym


fn:tokenize

Function signature

$input xs:string ?
$pattern xs:string
Result xs: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

Implemented. The facility to split a string into its individual characters by supplying a regex that matches a zero-length string is newly implemented in Saxon 7.7.

Note: Upgraded in Saxon 7.9 to match the precise regex syntax and to support all four flags s, m, i, x. Also changed to disallow a pattern that matches a zero-length string.


fn:tokenize

Function signature

$input xs:string ?
$pattern xs:string
$flags xs:string
Result xs: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

Note: Upgraded in Saxon 7.9 to match the precise regex syntax and to support all four flags s, m, i, x. Also changed to disallow a pattern that matches a zero-length string.


fn:trace

Function signature

$value item() *
$label xs:string
Result item() *

Returns the value of the first argument after outputting a diagnostic message

XPath 2.0 Specification

Note: The Saxon implementation outputs the value of each item in a sequence as it is evaluated (except when the sequence is empty, in which case it outputs "empty sequence" at the start). Atomic values are output by converting them to a string, nodes by calling getPath() to generate a path expression to the node. With complex expressions the order of evaluation may be rather different from the expected order. The trace output is directed to System.err, this may be redirected by using "2>log.txt" on the command line.


fn:translate

Function signature

$srcval xs:string ?
$mapString xs:string ?
$transString xs:string ?
Result xs: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

Function signature

Result xs:boolean

Return the boolean value true

XPath 2.0 Specification


fn:unordered

Function signature

$sequence item() *
Result item() *

Returns a random permutation of its argument

XPath 2.0 Specification

Note: In practice the only important case where this function has any effect in the Saxon implementation is where the sequence supplied as argument is a Step using a reverse axis: for example, unordered(ancestor::*) returns the ancestors in reverse document order. But applications should not rely on the actual order; the function is intended to be used by applications that do not care about the order of the results.


xslt:unparsed-entity-public-id

Function signature

$srcval xs:string
Result xs:string

Return the public ID of an unparsed entity, given its name

XSLT 2.0 Specification


xslt:unparsed-entity-uri

Function signature

$srcval xs:string
Result xs:string

Return the system ID of an unparsed entity, given its name

XSLT 2.0 Specification


xslt:unparsed-text

Function signature

$uri xs:string
Result xs:string

Returns the contents of an external text file, given its URI and encoding

XSLT 2.0 Specification

Not implemented. The encoding parameter is currently mandatory.


xslt:unparsed-text

Function signature

$uri xs:string
$encoding xs:string
Result xs:string

Returns the contents of an external text file, given its URI and encoding

XSLT 2.0 Specification

Implemented. Changed at 7.5 so it no longer processes multiple URIs ina single call.


fn:upper-case

Function signature

$srcval xs:string ?
Result xs:string ?

Converts a string to upper case

XPath 2.0 Specification


fn:year-from-date

Function signature

$srcval xs:date ?
Result xs:integer ?

Extracts the year component of a date value

XPath 2.0 Specification

Note: The old name get-year-from-date is retained as a synonym


fn:year-from-dateTime

Function signature

$srcval xs:dateTime ?
Result xs:integer ?

Extracts the year component of a dateTime value

XPath 2.0 Specification

Note: The old name get-year-from-dateTime is retained as a synonym


fn:years-from-yearMonthDuration

Function signature

$srcval xdt:yearMonthDuration ?
Result xs:integer ?

Extracts the years component of a yearMonthDuration value

XPath 2.0 Specification

Note: The old name get-years-from-yearMonthDuration is retained as a synonym


fn:zero-or-one

Function signature

$srcval item() *
Result item() ?

XPath 2.0 Specification


Michael H. Kay
March 2004