Functions, operators, and data types for XPath 2.0

The URI for the codepoint collation is changed to

All functions that take an optional collation argument now take it as an instance of xs:string, not xs:anyURI as previously. The default-collation() functions also returns an xs:string, although it is still specified as returning an xs:anyURI.

The namespace name supplied to the expanded-QName function is now an xs:string rather than an xs:anyURI, as is the namespace name returned from get-namespace-from-QName.

The base-uri function with no arguments is now supported: it returns the base URI from the static context (effectively, the base URI of the stylesheet). Both forms of the base-uri function now return xs:string rather than xs:anyURI{reluri12-13}

The resolve-uri function is supported, with one or two arguments. Both arguments and the results are URIs provided in the form of strings. {reluri14-15, reluri901err}

The document-uri 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).

The functions exactly-one, one-or-more, zero-or-one are implemented. Because Saxon doesn't do pessimistic static type checking, these functions are never actually needed, but they enable interoperability with systems that do such type checking. {type040, type901-904err}

The first argument of the root function may now be omitted, it defaults to the context node. {axes056}

The trace function is implemented. 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. {ver16, ver17}

The sequence-node-equal function is renamed sequence-node-identical {expr80}

The functionality of sequence-deep-equal and deep-equal has been combined into a single function called deep-equal. {expr81, expr82}

The round-half-to-even function is implemented. Note that for doubles and floats, numbers ending in .5 do not always round as expected, because the true value may be slighly above or below the decimal equivalent. {math-two 10-14}

The substring function no longer accepts an empty sequence for its second or third arguments. (This is technically incompatible with XPath 1.0, though the effect of supplying an empty node-set in XPath 1.0 was very obscure.)

The signature of the subsequence function now accepts a double for the second and third argument (which means that it also accepts an untypedAtomic value). However, if the value is not a whole number, the rounding does not necessarily follow the rules in the XPath specification. {expr72}

The function resolve-QName is implemented. {type041, type[905-908]err}

Added support for the "i" flag in functions using regular expressions. This flag requests case-insensitive matching. {regex16}

Added stricter checking of the contents of the replacement string in the replace function. {regex901err - regex904err}

The signatures of matches, replace, and tokenize are updated to match the latest specification. (Only the first argument is now allowed to be an empty sequence.)

The functions dayTimeDuration-from-seconds and yearMonthDuration-from-months are no longer defined in the core specification; they have been moved to the Saxon namespace and remain available as extension functions.

The unparsed-text function has changed, it now takes a single URI and returns a single string, rather than processing multiple URIs in a single call. This anticipates a change to the XSLT specification.

The format-number function has been rewritten according to the XSLT 2.0 specification. Since the old specification was based on JDK 1.1, which was underspecified, this causes some minor incompatibilities. If needed, the old version of the function is still available under the name format-number-1.0(). {numberformat001-nnn}

The insert function has been replaced by insert-before, which inserts the new sequence before the given position, not after it. {expr71}