# Extensions

Some performance improvements have been made to the code for calling Java extension functions. Thanks to Wolfgang Hoschek for providing these.

The ability to define user-written functions as memo functions is now available in XQuery as well as XSLT. In XQuery this is achieved by preceding the function decilaration with `declare option saxon:memo-function 'true'`. The effect is that the function caches its results, so if it is called again with the same arguments it returns the remembered result.

The extension function `saxon:serialize()` has been enhanced. As an alternative to the existing format, the second argument may now be a (dynamically-constructed) `xsl:output` element, allowing full access to all serialization properties, and allowing all the properties to be defined dynamically. This works in both XSLT and XQuery.

The use of external object types in namespace `http://saxon.sf.net/java-type` now reflects the Java type hierarchy. For example, if a variable is declared to accept a type of `jt:java.util.List`, then a value of type `jt:java.util.ArrayList` will be accepted, but a value of type `jt:java.util.HashMap` will not. The same applies to the new namespace `http://saxon.sf.net/.net-type` used for external .NET types.

A new extension function `saxon:generate-id()` is available. The semantics are identical to the XSLT function generate-id(): the function returns an ASCII alphanumeric string that uniquely identifies the node supplied as the argument (there must always be exactly one argument). This extension function is made available to provide the same capability as generate-id() in non-XSLT environments, for example in XQuery.

The extension functions `saxon:max()`, `saxon:min()`, and `saxon:sum()`, which have long been deprecated, are now dropped from the product.

In the `saxon:evaluate()` function under XSLT, the default namespace for elements and types is taken from the value of the `xpath-default-namespace` attribute in the stylesheet, if present. Previously it was taken from the default namespace declared using `xmlns="xyz.uri"`, which was a bug. (In XQuery the net effect is no change, because there is only one default namespace.)

The documentation of other extension functions involving sequences of nodes, such as `saxon:leading`, has been changed to reflect the fact that the sequences of nodes on which they operate may contain duplicates and might not be in document order. The implementation of these functions has not been changed, the documentation has been corrected to describe the current behavior.

A new serialization parameter `saxon:supply-source-locator="yes"|"no"` is provided. This is intended for use when sending output to a user-written `ContentHandler` (that is, to a `SAXResult`). The effect of the option is that information is sent to the `Locator` supplied to the `ContentHandler` identifying the position of the context node in the source document. To access this information, the supplied `Locator` must be cast to its implementation class.

Next