Internal changes

There has been considerable internal reorganization to support the introduction of XSLT packages. In the expression tree, compile-time methods no longer have access to the Executable, which represents the stylesheet as a whole, but rather get the same information from the StylesheetPackage which represents a package (or unit of compilation).

The mechanisms for registering collations have been greatly simplified. All collations are now known globally at the level of a Configuration. The Configuration maintains a table of collations, where collations can be registered by URI, and also a CollationURIResolver, where collation URIs can be handled programmatically. The ability to define collations locally for a particular query or stylesheet is discontinued; in general, the methods that permitted this have been deprecated, and if they are used, they cause the collation to be registered at the Configuration level. The default collation URI can however still be defined on a per-query or per-stylesheet level (indeed, in XSLT it can be defined for any element within a stylesheet, and for XQuery it can be defined for each module making up a query).

The implementation of regular expressions has changed, to reduce the incidence of stack overflows caused by backtracking. Saxon is now better at detecting expressions where backtracking cannot arise (which eliminates the need to keep data for the purpose of backtracking), and where if does arise, the depth of recursion now depends only on the complexity of the regular expression, and not on the length of the input string.

The implementation of maps has changed. It is now based on a hash trie data structure, specifically a cut-down version of the open source Java hash trie implementation by Michael Froh. The new implementation gives comparable timings for initial building of a map and for map retrieval, and substantially better times for workloads where additions to the map and retrievals are intermixed; the performance of map:remove() is vastly improved.

The SequenceIterator interface has changed so that it no longer supports the methods current() and position(). This means that during normal expression processing, there is no longer a need for every iterator to keep track of the context item and context position. These values are now maintained only when the iterator is used as the current focus, that is, when it is stored in the XPathContext object, and this is achieved by wrapping the SequenceIterator in a FocusTrackingIterator that maintains these values.

In Saxon 9.5, some interfaces such as SequenceIterator were defined as parameterized (generic) types, on the same model as collections and iterators in the standard Java class library. In 9.6, an attempt was made to complete this process, and to apply it also to Sequence and its subclasses. This attempt was eventually abandoned because it led to excessive complexity and excessive numbers of compilation warnings, and was proving to give very little benefit, largely because most uses of these interfaces are in fact generic: they apply to all sequences of items, not to sequences of specific kinds of item. So SequenceIterator has reverted to being a non-parameterized class. Generics are used, however, in the interface for reflexive calling of Java extension functions, where types such as ZeroOrOne<StringValue> can now be used to indicate the expected type precisely, giving much better type checking.