Functions, operators, and data types for XPath 2.0

The standard functions have been enhanced, where the spec requires it, to return an empty sequence if one of their arguments is an empty sequence.

The max() and min() functions now handle any comparable type, returning the correct data type (for example, if given a set of integers, they return an integer). The default (for untyped nodes) is string comparison. A collation can be specified as the second argument; if not specified, the default collation is used. {expr56, expr57, sort20, sort21, date065, error220}

The implementation of deep-equal(), sequence-deep-equal(), and sequence-node-equal() has been revised to conform to the current specifications.

The distinct-values() function is now implemented, with an optional collation argument. {group017-019}

The functions floor(), round(), ceiling() now return a value of the same type as the supplied argument. {math87-90}

The index-of() function now takes an optional collation argument. {expr87}

For functions that take a collation argument, such as compare(), the default if no collation is specified in the call, and no default <saxon:collation> is supplied, is to use code-point collation. This differs from previous releases, where the default was to use a locale-dependent collation. For xsl:sort, the default is still locale-dependent. This decision is likely to be reviewed in future.

The arguments of sort() are now reversed: the first argument is the sequence to be sorted, the second is the name of the sort key specification.

Changed sum() and avg() to return the same type as supplied. The average of an empty sequence is now (), not NaN. These functions are still confined to handling numeric values, they do not yet work over other summable types such as durations. {math91, math92, expr55, error227}

Corrected a bug: conversion of a double to a float was returning a double!

The functions starts-with(), contains(), and ends-with() now accept a collation name as an optional second argument. {str126-128}

The functions substring-before() and substring-after() now accept a collation name as an optional second argument. {str129-130}

The saxon:distinct() function, with a single argument, is dropped: the functionality is available using either the XPath 2.0 distinct-values() function, or the EXSLT set:distinct() function. The two-argument form (which takes an expression as the second argument) remains.

The dynamic expression supplied to saxon:expression and saxon:evaluate can now contain references to the variables $p1, $p2, ... $p9. The values of these variables can be supplied when the expression is evaluated using saxon:eval or saxon:evaluate respectively. The expression can also contain calls to Java extension functions bound using the implicit mapping of Java classes to namespaces, and to Saxon and EXSLT extension functions. For more details see Saxon Extensions.

The function saxon:get-user-data() has changed to return an empty sequence rather than a zero-length string if no data exists. This is to prevent type-checking problems when the expected value is not a string. {saxon06}

The error() function (with optional argument) is implemented. If the argument is specified, its string-value is used as the error message. {error223-224}

The node-name() function is implemented. It returns a value of type xs:QName.

The functions get-in-scope-namespaces() and get-namespace-uri-for-prefix() are implemented. {nspc45-46}

The unparsed-entity-public-id() function (defined in XSLT 2.0) is implemented. This required a minor change to the DocumentInfo interface implemented by the tree model. {expr88}

The unordered() function is implemented. This returns the results of a sequence in implementation-defined order. In practice the only important case where it 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. {axes60}

A simple implementation of the input() function is available. If the parameter {http://saxon.sf.net/}input has been supplied to the transformation, it 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). {Limited testing only: mdocs09}

The default-collation() function is implemented: it returns the URI of the default collation if specified, or the URI of the code-point collation otherwise.

The component extraction functions for durations are now available only on the two subtypes yearMonthDuration and dayTimeDuration, and are named accordingly: for example get-years-from-yearMonthDuration and get-hours-from-dayTimeDuration. (But other operations remain available on durations even though not specified in the current working draft, for example equality comparison on durations). {date055-058}

Casts and constructor functions, when converting from a string to another type, now apply the appropriate whitespace normalization to the supplied value, as defined in the whitespace facet for the target data type. This means, for example, that an ID value can have leading and trailing spaces, which are ignored. {type035}