# Extensions

A new extension function `saxon:adjust-to-civil-time()` is available. This adjusts a date/time value to its equivalent in the civil time of a named timezone, taking account of summer time (daylight savings time) changes. For example `adjust-to-civil-time(xs:dateTime('2008-07-10T12:00:00Z', 'America/New_York')` returns `2008-07-10T08:00:00-04:00`

Two new XSLT extension instructions are available (in Saxon-EE only): `<saxon:try>` and `<saxon:catch>`. These complement the existing `saxon:try()` extension function, but are more powerful, and more convenient in many cases because they catch errors at the XSLT level. For details see saxon:try.

A new extension function `saxon:parse-html()` is available. This works in the same way as `saxon:parse()`, but it assumes the input is HTML rather than XML. The TagSoup parser must be available on the classpath for this to work.

The extension functions `saxon:file-last-modified()` and `saxon:last-modified()` have been changed. There is now only one function, `saxon:last-modified()`, and it takes a URI as its argument. It can now be a relative or absolute URI (if relative, it is resolved against the base URI from the static context). To get the last-modified date of the file from which a particular node was loaded, use `saxon:last-modified(document-uri(/))`. The function now throws a dynamic error if given an invalid URI or a URI that cannot be resolved or dereferenced; this can be caught using try/catch if needed. The function returns an empty sequence if the resource can be retrieved but no date/time is available.

In the `saxon:try()` extension function, the ability to supply a function as the second parameter (to be called if evaluation of the first parameter fails) is withdrawn. The second argument is now always evaluated directly.

The support for the EXSLT date-and-time library has been updated. Some new methods are available (add(), difference(), seconds(), duration(), sum()), and implementations of existing functions have been upgraded to conform more closely to the spec, in particular by checking for erroneous input. One change that may be noticed is that the function `date()`, with no arguments, now returns the current date with a timezone.

The extension function `saxon:function()` has changed so the argument can now be a system function as well as a user-defined function. If the function name is unprefixed, it is now assumed to be in the default function namespace.

The extension functions `saxon:highest()`, `saxon:lowest()`, `saxon:sort()`, and `saxon:leading()` have been reworked to take advantage of higher-order functions. The second argument (if present) is now a function item rather than a dynamic expression.

The extension function `saxon:after()`, which has been undocumented for many years, is finally dropped from the code.

The extension functions `saxon:index()` and `saxon:find()` now impose the same comparison rules as value comparisons: for example, if the value indexed is untyped atomic, then supplying an integer as the argument to `saxon:find()`results in a type error. Previously, it resulted in a "no match" (typically, `saxon:find()` returned an empty sequence).

The extension function `saxon:type-annotation()`, when applied to a document node, now returns `xs:anyType` if the document has been schema-validated, or `xs:untyped` otherwise. Previously it return `xs:untypedAtomic`. For comment, processing-instruction, and namespace nodes it now returns `xs:string`.

The XSLT extension instruction `saxon:script` is dropped. It suffered a major design problem: the bindings it declared were global (applying to a Configuration as a whole, and in part to all Configurations in the Java VM, rather than to a particular stylesheet), and the cost of fixing this problem would not be justified by the level of usage of this legacy feature. Equivalent facilities are now available via the configuration file, or using the Configuration API.

Next