This file describes changes for versions 7.0 and later. For changes prior to version 7.0, see http://saxon.sf.net/saxon6.5.3/changes.html.
912721 tokenize() crashes with a NullPointerException if the regular expression is not known statically.
913392 Superfluous spaces are inserted between the text nodes used to construct the content of a comment or processing instruction
913504 In format-time(), when the value of the minutes or seconds field is zero, it is output as "0" rather than "00"
914497 Calling saxon:evaluate() can corrupt the values of local variables on the current stack frame
915656 Invalid namespace prefixes in the exclude-result-prefixes attribute of an xsl:stylesheet element in an imported module go unreported.
915661 An attempt to exclude a system namespace (e.g. xs, xsi, xslt) using exclude-result-prefixes succeeds even if the namespace is used in the result tree, causing non-well-formed output.
918146 In XQuery, FLWOR expressions are sometimes optimized incorrectly.
919394 A crash occurs when doing a Query with JDOM input and a SAXResult output destination.
919437 Using the "as" attribute on xsl:template or xsl:sequence may cause the result tree to be prematurely condensed, causing the possibility of a failure when subsequent attributes are added.
When an xsl:variable element is traced (using the -T option) the value of the variable
is no longer output. This was causing the variable to be evaluated twice, which potentially causes additional
instructions to be executed, which were themselves traced, thus making the resulting output very difficult
to interpret. You can trace the values of variables using the trace() function.
Casting from any atomic type to xdt:untypedAtomic is now permitted.
Negative (BC) dates are allowed.
Overflow of durations is detected (each component of a duration must fit in an integer, and the total number of seconds must fit in a long.
The xsl:number instruction, given format="01", now outputs the value zero as
"00" rather than "0". This is contrary to the spec, but the change is made so that time values
containing a zero value of hours or minutes are properly formatted by format-time(). A request
has been raised to change the spec.
The use of «chevron» characters in error messages has been discontinued, because Microsoft's MSDOS command-line is unable to display non-ASCII characters correctly.
841466
The default for a parameter with an as attribute and no select attribute should be (), not "".
843948 The XQuery does not allow spaces after the "=" sign in attributes within a direct element constructor.
843954 Pattern separators in the format-number() picture argument are rejected.
844436
Tail call optimization in XSLT templates fails when type checking of the template's result is required (by virtue
of an as attribute).
851636 Conversion of a string consisting of one or more whitespace characters to a number causes a StringIndexOutOfBoundsException.
852344 format-number() output is wrong for numbers greater than 10e19
852622 Local variables don't work in the standalone XPath API.
854939 Two problems with character maps. Namespaces in the name of the character map are handled wrongly, and character maps don't work with method="text".
855943
In XQuery order by, the second and subsequent sort keys cannot be written as function calls.
856136 The QueryStaticContext is not serially reusable.
859629
The parameters passed to saxon:evaluate() must be singleton items, not sequences.
859632
The XQuery parser does not allow the where expression to start with a left parenthesis.
874935
When running against a DOM or JDOM source, calling generate-id() causes infinite recursion and a stack overflow.
884847 A NullPointerException can occur when using a DOMSource with a default namespace declaration.
891839 When XQuery is run from the command line, without the -wrap option, the output encoding is labelled as UTF-8 but is in whatever encoding the Java VM chooses.
895201 Infinite recursion can occur when a DOMSource is used, especially a DOMSource starting at a non-root node.
896533
In an XQuery typeswitch expression, Saxon reports a spurious compile-time error if it can establish
at compile time that one of the branches will never be executed.
896547
In an XQuery FLWOR expression, if there is an order by clause then the return expression
can only deliver a single value for each item in the input sequence.
896947 Comparisons of two values where one is NaN can give true: they should always be false.
897989 Type checking: when a singleton is required Saxon is sometimes not checking for multiple items, but simply returning the first.
901695
Local variables used within an expression evaluated using saxon:evaluate() don't work correctly.
904221 XQuery parsing errors can occur as a result of incorrect handling of lexical states. The exact circumstances are rare but highly variable.
It is now possible to specify an initial template to be invoked when the transformation starts.
From the command line this is done using the -it option, followed by the template name. When
this option is used, no source file should be provided. In the API, the initial template is set using
setInitialTemplate on the Controller class. The transformation is then started
using the transform method in the normal way, except that the source argument
may be null. (It does not have to be null: if a source is supplied, it will still cause the context node
to be initialized, but will no longer cause execution to start by applying templates to this node).
An XPath expression within an attribute value may now contain a comment {avt15}
A newline is now written before a DOCTYPE declaration only if the DOCTYPE declaration is preceded by an XML declaration. This means that the newline is always omitted when serializing as HTML. There have been unconfirmed reports of browsers that require the DOCTYPE declaration to be right at the start of the file. An unintended but hopefully harmless side-effect of this change is that where the result tree is empty, previous releases serialized the result as a file containing only an XML declaration; the current release serializes it as an empty file containing no XML declaration.
The href attribute of xsl:result-document can now be omitted. Generally this is done
when writing the principal result tree, if you want to set the validation or type
attributes. Don't do this if the stylesheet also writes output nodes before callling xsl:result-document
(it's an error to write two result trees to the same URI).
To achieve this, opening of the output file is delayed until the first attempt to write to it. A side-effect of this change is that when the result tree is empty, or when a failure occurs before writing any output, the output file is no longer written.
In xsl:key, the as attribute is no longer available. The data type of the key
is now implicit. To implement this, one index is built for each primitive type encountered in the supplied
argument of the key() function: for example, if a key is used both as a string and as an integer, in different
calls, then both a string and an integer index will be built. NaN is no longer considered to match NaN for
indexing purposes.
The select attribute of xsl:message is implemented. {ver18}
The xsl:value-of instruction can now contain a sequence constructor as an alternative
to the select attribute. {atrs52}
The xsl:attribute instruction can now take a separator attribute. {atrs51, 52}
When a sequence constructor is used to construct a simple-valued node such as an attribute or comment, any non-text nodes in the sequence are now atomized. Previously (as in XSLT 1.0) they were ignored with a warning message.
The new xsl:document instruction is implemented. This instruction has been added since
the 12 Nov 2003 working draft; it creates a document node, and optionally validates it using validation
and type attributes. Unlike xsl:result-document, the new document is not serialized.
See further details.
This version of Saxon aims to conform to the rules for a basic XSLT processor (that is, a non-schema-aware processor).
A future release will provide a schema-aware processor. To align with the two conformance levels, this release does
not support the validation or type attributes on instructions that create element, attribute,
or document nodes.
Within a direct element constructor, a namespace prefix may now be used in an attribute name, or within an attribute value constructor, that precedes the declaration of that namespace prefix on the same element.
There have been some minor changes to the XQuery API. When constructing a StaticQueryContext, you must
now supply a Configuration object; and when constructing a QueryProcessor,
you must supply a StaticQueryContext
(which will already contain a Configuration). These changes simplify the interface and help to ensure that
the various objects are consistent with each other.
A processing instruction constructor now uses the keyword processing-instruction
rather than pi.
In the construct processing-instruction('xxx'), I have removed the check that xxx
is a valid NCName. The specification does not require this in the case where the name is included in quotes.
Internal changes have been made to prepare the way for Saxon to become a schema-aware processor. The changes
are by way of calls to classes and methods that in this (non-schema-aware) version of Saxon have a dummy implementation.
These dummy implementations are generally included in the Configuration object, which will be subclassed
in the schema-aware product.
Casting to xs:double or xs:float now fails if the value is non-numeric
(other than the special values INF, -INF, and NaN);
previously it returned NaN. This does not affect the number() function,
which still returns NaN. A consequence of this change is that "ABC" castable as xs:float
now returns false.
The types xs:hexBinary and xs:base64Binary are implemented. (I have not
attempted to reduce the set of supported types to the basic set required in XSLT, partly because XSLT 2.0
and XQuery 1.0 differ in this regard.)
Functions contains(), starts-with(), ends-with(), substring-before(), substring-after(), string-value(), substring(), replace(), now treat an empty sequence (supplied in either argument) as if it were a zero-length string. The result can no longer be an empty sequence.
The translate() function is changed so that an empty sequence is treated as a zero-length string in the first argument, and is not allowed in the second and third arguments; the result can no longer be empty.
Reversed the order of the arguments to get-namespace-uri-for-prefix. The prefix
is now the first argument, the element is the second.
Changed get-timezone-from-date() to return the correct timezone, and to return it as a dayTimeDuration; changed get-timezone-from-time() to return the timezone as a dayTimeDuration.
Addition or subtraction of a date|time|dateTime to a duration is supported,
as defined in the specification. {date080-082}
Subtraction of two date|time|dateTime values to return an
xdt:dayTimeDuration is supported. {date083}
The idref() function is implemented. {idky201, idky202, qxmp120}
All the functions whose names begin with get- support the new name
(without the get- prefix)
as a synonym. The old name will be dropped in a later release. (This change to the specification
was made after the 12 November 2003 working drafts).
The regular expression syntax in the functions matches, replace, and
tokenize, and also in xsl:analyze-string, is now implemented strictly
as defined in the language specifications. The has been achieved by integrating James Clark's code
for translating XML Schema regular expressions to Java JDK 1.4 regular expressions, with modifications
to handle the additional capabilities allowed in XPath and XSLT (such as reluctant quantifiers and
back-references).
The four flags m, s, i, x in regular expression
functions are now implemented as described in the specification.
The XSLT function function-available now accepts a second argument, the required
arity. (This new feature has been added during the Last Call).
The types of external objects returned by extension functions or extension instructions can now be
represented using the actual Java class name. For example, a variable holding the value returned by
the instruction sql:connect can be described with the attribute as="java:java.sql.Connection".
The system will check that the actual value conforms to this type. The java prefix here must be bound
to the namespace URI http://saxon.sf.net/java-type.
In mapping a Java class name to a QName with this namespace URI, any '$' signs in the class name are now mapped to '-' characters, to ensure that the resulting name is a legal QName.
A singleton atomic value can now be passed to an extension function that expects a List, a SequenceIterator, or a SequenceValue. (Saxon previously allowed sequences to be passed to such functions, but this failed in the special case where the sequence was a singleton).
I have added an extension function saxon:typeAnnotation for diagnostic use. It takes a
node as argument, and returns a string representation of its type. In the case of an anonymous type, this
will be a path identifying the type within the schema.
Saxon 7.9 is tested with JDOM beta 10. The only change needed to move forward from beta 9 was to ensure that DOCTYPE nodes are skipped when processing the children of a Document node.
There have been some changes to key internal interfaces which affect a great many classes throughout the product, and which also occasionally surface in APIs.
The SequenceIterator interface, which is widely used throughout the Saxon code, has been
changed so that it no longer has a hasNext() method. Instead, the caller should invoke next()
repeatedly, and the end of the sequence is indicated by returning null. The purpose of this change is to reduce
the number of method calls, but more importantly, to reduce the amount of state information that iterators
have to hold, and to reduce the effect whereby each iterator in a pipeline looks ahead by one item, causing
an unnecessary amount of wasted effort if the pipeline is aborted, which happens for example when finding
the effective boolean value of a sequence.
The internal representation of type information has changed, because of the need to accommodate
user-defined types. A new class (actually an Interface) ItemType has been introduced; this
and the occurrence indicator form the two parts of a SequenceType. The method getItemType
on an expression now returns an object that implements this interface. For atomic values, this is an
AtomicType object, which is also used in the heirarchy of schema types. In the case of user-defined
atomic types, this object contains a reference to the SimpleType object held in the schema data model
(which will be available only in the schema-aware version of the product).
For nodes, the ItemType interface is implemented by a NodeTest,
which is also used to represent conditions in an AxisStep of a path expression, and which is a subclass
of Pattern. In the case of node types that specify the required content type, for example
attribute(*,xs:date), a ContentTypeTest is used.
A number of the implementations of the tree model create transient wrapper nodes whenever a path
expression is used to select a set of nodes. A new optimization has been introduced so that in the case
where the nodes are immediately atomized, the tree model is allowed to return the typed value of a node
instead of returning the node. This firstly avoids the cost of creating the wrapper node, and secondly avoids the cost of
creating another iterator to process the typed value, in the case where the typed value is
a singleton. This is currently done only in the common case where the typed value is actually untypedAtomic.
Any user-defined implementations of the tree model that implements the interface AxisIterator will need
to support the additional method setIsAtomizing(); however, an implementation that does nothing is
acceptable.
The method getAttributeValue(uri, localName) has been removed from the NodeInfo interface,
so there is one less thing that suppliers of this interface have to provide. It is replaced by a helper
method in the Navigator object.
The typeCode passed down the Receiver pipeline is now the name pool
fingerprint of the actual type name. This is also the value that is stored as a type annotation in the
data model. Currently this is supported only in the TinyTree. In the non-schema-aware product, the
typeCode will always be -1, indicating that the node is untyped.
The way that standard names are handled in known namespaces such as XSLT, Saxon, and XML Schema has changed. The fingerprints for these names are now compile-time constants. The NamePool code has been adapted so that these namespaces are specially recognized, and the standard constants are returned. This saves time and space when building the NamePool. It also makes it possible to have a standard schema defined as a static Java object for the built-in types.
In response to suggestions from Karsten Rucker, I have made some changes designed to conserve memory in both the standard tree and tiny tree implementations of the data model. In the standard tree, the document node no longer contains a reference to the factory used to build it: this was preventing the XML parser and its buffers being garbage-collected. In the tiny tree, the condense() operation is now called after building trees from source documents (it was previously called only for temporary trees). It also now condenses the buffer used for character data.
818677
There is no type-checking performed on parameters passed by xsl:call-template or
xsl:apply-templates
822257 No error is reported if the stylesheet contains two named templates with the same name and the same import precedence.
826540 Null pointer exception caused by incorrect optimization (moving a variable reference out of a branch of a conditional expression)
827369 An exception (IndexOutOfBounds) occurs if the body of an XSLT stylesheet function is empty.
830841 If there are character maps defined in the stylesheet, then no escaping of special characters in attribute values takes place.
832548
Incorrect optimization occurs for the variable declared as at $x in an XQuery FLWOR expression.
The variable typically retains a value of zero.
Implemented the new xsl:perform-sort instruction. The select
attribute is currently mandatory, it is not possible to use it with a contained sequence
constructor {sortNNN}
Internally, the code for handling sorting has been unified between xsl:for-each,
xsl:apply-templates, and xsl:perform-sort.
The xsl:sort-key declaration and the sort() function are withdrawn.
The instructions xsl:attribute, xsl:comment,
xsl:processing-instruction, and xsl:namespace
now allow a select
attribute; if this attribute is present the content of the instruction must be empty.
The value of the select expression may be a sequence; all of the items in the
sequence are included in the result, by converting them to strings and separating them
with a single space. {arts50, posn80, node51-54}
An xsl:analyze-string element is now required to have at least one
xsl:matching-substring or xsl:non-matching-substring child.
Tunnel parameters have been implemented. {var20-22, 905err, 906err}
The xsl:with-param element now accepts an as attribute.
Patterns of the form *:local-name are now accepted {match51}
No code was being generated to perform run-time type checking or conversion of template parameters (bug 818677). This has been corrected. {var16, var904err}
It is now a compile-time error if a parameter is supplied in xsl:call-template that doesn't
match any parameter declared in the template being called, or if it has the wrong type when compared with
the declared type of the parameter, or if the called template has a required
parameter that isn't supplied in the call.
On the command line, it is now possible to specify a parameter in the form +param=filename.
The filename will be parsed as an XML document, and the document node will be passed to the stylesheet
as the value of the stylesheet parameter param. If the filename is a directory, then all the
files contained immediately within the directory will be parsed and the result will be passed as a sequence
of document nodes.
Parameters supplied on the command line are now treated as untyped atomic values rather than strings, which means they can be supplied where the expected type is (say) integer or date; the string supplied as the value of the parameter will automatically be converted to the required type.
Tracing (with the -T option) has been improved. Some instructions such as
xsl:analyze-string were not being traced. The trace output now includes the
names and values of variables (the value is truncated to the first four items in a sequence,
and the first 20 characters of each item; nodes are shown by their generate-id() value). More
information is available to user-written trace listeners, in particular, the Controller is
now available (as a property of the InstructionInfo object). The InstructionInfo interface now
has a general-purpose getProperty() method, allowing additional information to be made available
without changing the interface for existing TraceListeners.
The rule is now enforced that the namespace URI of a function name, variable name, mode name (etc.) cannot be a reserved namespace URI (such as the XML namespace, the XSLT namespace, or the XML Schema namespace).
In xsl:number, the format tokens one, first, and 1st
are no longer available; they have been replaced by the format tokens W, w, and
Ww (for upper case, lower case, and title case words), together with the optional attribute
ordinal="yes". These sequences are currently implemented for English and
partially (see below) for German. {numb14, 24, 25}
The functions format-date(), format-time(), and format-dateTime()
have been updated to match the latest specs. Specifically, they now take either two or five arguments (though
Saxon currently ignores the last two); names of months or days of the week are requested using
presentation modifiers N (upper-case), n (lower-case) and Nn (title case), and all other modifiers are
interpreted in the same way as xsl:number. {date067, date068, date073}
I have extended the support for localizing xsl:number and format-date
in German. It's mainly a proof of concept, to show
that it's possible. The code is in module net.sf.saxon.number.Numberer_de, and similar
modules can be written for other languages: just change the last two letters of the class name
to the language code used. If you do write implementations for other languages, I will be happy to include
them in future Saxon distributions. {numb28, numb29}
The attribute disable-output-escaping is no longer supported on xsl:attribute.
In theory, you should be able to use character maps instead.
Casting a string to an xs:QName is now supported: but only in XSLT (not in XPath or XQuery), and only when an explicit cast or constructor function is invoked (not, for example, when passing an untyped atomic value to a function that expects an xs:QName).
Literal result elements now compile internally into xsl:element and xsl:attribute instructions. This results in changes to trace output: each attribute is now traced as a separate instruction.
Importing library modules is now supported, using the import module syntax.
At present, all the modules in a query are compiled at the same time. The location of each
module (the at clause in import module) must be included the first
time a particular module is imported, but it may be omitted on subsequent occasions (modules are processed
recursively, depth first). If a module for a particular namespace is already loaded, then the
at clause is ignored. Optionally, applications can precompile library modules and register
them in the Configuration object, and they will then be found when another module attempts to import
them by namespace alone.
The query parser now attempts recovery after a syntax error, resuming parsing at the next semicolon.
The predeclared namespace prefix local is available for use when defining local
user-defined functions.
Creating two attributes with the same name for the same element is now reported as an error. Previously (as in XSLT) the second simply overwrote the first.
Namespace declarations in direct element constructors are now correctly scoped; namespace prefixes in element and attribute names in a direct element constructor are correctly validated. (This is a bug fix). The rules concerning the distinction between active and passive namespaces are properly applied (active namespaces are copied to the result, passive namespaces are not).
The order by options empty least and empty greatest have
been implemented. At the same time, code has been added to check that the sort key is not a sequence
of length greater than one.
It is now possible to specify a parameter on the command line in the form +param=filename.
The filename will be parsed as an XML document, and the document node will be passed to the stylesheet
as the value of the external variable param. If the filename is a directory, then all the
files contained immediately within the directory will be parsed and the result will be passed as a sequence
of document nodes.
A query can now be included directly in the command line rather than reading it from a file. It is
written enclosed in curly braces. For example java net.sf.saxon.Query {doc('a.xml')//p[1]} selects elements
within the file a.xml in the current directory.
Any filename passed using the -s option is no longer accessible via the input()
function, but is still accessible as the context node.
The namespaces for the fn: and xdt: prefixes, and the URI for the
Unicode codepoint collation, have been updated to
match the latest specs (replace 2003/05 with 2003/11).
The new rules for double-to-string conversion are implemented. Values outside the range 1e-6 to 1e+6 are expressed in exponential notation, values within this range are formatted as decimals or integers. {expr111, 112}
In the XPath free-standing API, it is now possible to use the fn: namespace when
calling functions in the core library. (It is also still possible to use these functions without
any namespace).
A rewrite optimization has been added for expressions of the form E = M to N when
E, M, and N are known statically to be integers. The test reduces to E ge M and E le N,
which avoids comparing E with every integer in the range. When the test is of the form
SEQ[position() = M to N] and M and N are constant integers,
an even more powerful optimization is used that stops the iteration over SEQ as soon
as item N is reached. {opt015, opt016}
The "minimax" optimization has been reinstated for comparing numeric sequences. This translates
an expression of the form N1 < N2 into the form min(N1) < max(N2).
It was used prior to version 7.4, at which point it was found to be unsafe if both sequences contain
untyped atomic values. It is now used only if at least one of the sequences is statically known to
contain numeric values only.
The data types gYear, gYearMonth, gMonth,
gMonthDay, and gDay are implemented. {date076-079}
The functions get-current-date/time/dateTime() now return a date/time in the implicit
timezone (as determined from the current Java Locale). {date001}
The function implicit-timezone() has been implemented. {date069}
The functions get-timezone-from-date/time/dateTime() now return the timezone as a
value of type xdt:dayTimeDuration, not as a string. This means the result is displayed
as (for example) PT3H rather than +03:00. {date048-052}
Casting from xs:dateTime to xs:date now retains the timezone, if there is
one.
The functions adjust-date-to-timezone(), adjust-dateTime-to-timezone(),
and adjust-time-to-timezone() are implemented.
Note that the function get-hours-from-date/dateTime() returns the localized
component value. It has always done this in the Saxon implementation, and the latest working
draft now makes this the correct behavior.
The function sum() now returns an integer 0 rather than a double 0.0 when the input
sequence is empty. (An integer can be used anywhere a double can be used, but the converse is not true).
Note: this change was agreed by the Working Groups, but was inadvertently left out of the published drafts.
The function root() now accepts an empty sequence as its argument (and returns an empty
sequence).
The function distinct-values() now returns only one NaN if there are multiple
NaN values in the sequence. {group026}
The function escape-uri() no longer escapes square brackets when the escape-reserved
argument is false.
The function function-available() now recognizes function names that use the fn:
namespace. {func32}
The functions contains, ends-with, starts-with,
substring-after, and substring-before now use the Unicode codepoint
collation if no explicit collation is supplied; they do not use the default collation.
The functions min and max now convert untyped atomic values
to double rather than string, and return NaN if the sequence contains a NaN value. {expr57}
The function get-in-scope-namespaces is renamed get-in-scope-prefixes.
{nspc45}
The function insert-before now allows the insert position to be beyond the end
of the sequence (which causes the new sequence to be appended to the original). {expr71}
The function reverse has been implemented. {expr91}
In a range expression, $x to $y, it is no longer possible to produce a descending
sequence of integers. Instead, if the start point is less than the end point, an empty sequence is
returned. This change is to allow the construct for $i in 1 to count($seq) ... to work
as expected. To get a reverse sequence of integers, use reverse(1 to 5).
The function call remove($seq, 1) is now treated specially, it is optimized in the
same way as $seq[position()!=1] due to the common use of this expression in head-tail
recursion. {expr92}
The functions context-item, distinct-nodes,
input, item-at, node-kind,
sequence-node-identical, and string-pad have been dropped.
The function concat must now have at least two arguments. (This reverts to the
XPath 1.0 specification.)
In regular expression matching (e.g. in replace() and in the XSLT regex-group() function, group 0 now refers to the entire substring that matched the regex. {regex08}
The isnot operator has been dropped.
A new top-level declaration is introduced: saxon:import-xquery allows the functions
defined in an XQuery library module to be called from XPath expressions in the stylesheet. See
extensions.html for details.
The extension functions saxon:before, saxon:get-user-data, and
saxon:set-user-data, which have not been documented for some
while, have finally been removed.
The rules in the spec on extension attributes have been clarified, in a way that makes it clear
that the saxon:allow-avt attribute on xsl:call-template is not conformant.
This attribute has therefore been removed, and dynamic calls on templates are enabled instead using
a new extension element, saxon:call-template. In changing your stylesheet to use the
new instruction, remember to set extension-element-prefixes="saxon". {saxon21}
The sequence type as="java:java.lang.Object" can now be used to refer to the type of a wrapped Java
object returned by an extension function. The namespace prefix "java" binds to the namespace URI
http://saxon.sf.net/java-type. (My thinking is that eventually it will be possible to
use any Java class name to define the actual Java class of the external object. At present, however,
only java.lang.Object is recognized.) {saxon51}
I have changed the design of the SQL extension so that the database connection is now stored
explicitly in a variable, and the value of this variable is supplied on instructions such as
sql:insert and sql:query. See the books-sql.xsl sample
application to see how this works. {saxon51}
When calling Java methods, any XPath value can now be passed to a method that expects a DOM NodeList; a run-time ClassCastException occurs if the value contains an item that is not a node, or a node that is not represented by a DOM org.w3c.xml.Node (e.g. if it is a JDOM node). Not tested.
In general these changes affect both XSLT and XQuery.
It is no longer always true that namespaces present on a parent element are automatically inherited
by the children. XML Namespaces 1.1 allows namespaces to be undeclared using a construct such as
xmlns:x="", and this capability is reflected in the model. Namespace undeclarations will
be output by the serializer if the serialization property undeclare-namespaces="yes" is set.
In XSLT, this can be defined on xsl:output. In XQuery, it can be controlled from the API (using
the constant SaxonOutputKeys.UNDECLARE_NAMESPACES or the command line option
!{http://saxon.sf.net}undeclare-namespaces=yes). If you don't set this option, you probably
won't notice any difference. However, the change does mean that you sometimes get an unexpected
xmlns="" undeclaration.
The rules for both XSLT and XQuery say that namespace nodes are never inherited when you add an element
to a new parent element. Saxon isn't quite implementing this yet. Given the way Saxon represents namespaces
internally, namespaces get inherited unless the code goes out of its way to prevent it, and at the moment
this is only happening when an element is explicitly copied using xsl:copy or the equivalent
in XQuery.
Support for the namespace axis has been reinstated in JDOM. This underpins functions such
as get-in-scope-prefixes, and ensures that namespaces are properly copied by
xsl:copy-of. {axes-jdom049, 055, 129 etc}
For ease of testing, a new command line interface net.sf.saxon.jdom.JDOMTransform has
been added. The arguments are exactly the same as the normal net.sf.saxon.Transform
command.
The constructor for class NodeWrapper has been made protected. A new wrap() method
has been supplied on the DocumentWrapper class, allowing any node in the document to be wrapped,
provided that the document node has been wrapped.
Whitespace stripping should now work for JDOM input in the same way as for other tree models (see below).
A set of DOM wrapper classes have been written, analogous to the JDOM wrapper classes. {axes-dom[001-nnn]}
The DOM wrapper has been tested with the Crimson DOM provided in JDK 1.4 and with Xerces 2.5.0. Different DOM implementations are known to vary widely. Saxon's DOM interface does not attempt to deal with entity reference nodes, which appears to be OK with the default configuration of these two parsers. CDATA sections are treated as text nodes, no attempt is made to merge them with adjacent text nodes.
The DOM interface is very inefficient, for example it has to resolve namespace prefixes by searching the namespace declarations every time a node is referenced. Don't use it if performance matters to you.
I have changed the code for writing output to a DOMResult so that it now uses DOM level 2 interfaces
Document#createElementNS() and Element#setAttributeNS(). As a result, it should
now be possible to use methods such as getPrefix and getNamespaceURI on these
nodes.
If you supply any kind of pre-built tree as input to the transformation (that is, if the Source object is a DOMSource or a NodeInfo), then Saxon no longer strips down the tree and rebuilds it to implement whitespace stripping. Instead, if whitespace stripping has been requested, it wraps the supplied tree in a whitespace-stripping envelope, which hides whitespace text nodes that the stylesheet has asked to be stripped, on the fly. Because this is done in a separate layer above the data model, it works for all data model implementations (JDOM, DOM, and native Saxon), and it imposes no overhead when it is not needed - that is, when the stylesheet doesn't request whitespace stripping, and when nodes are stripped during tree construction, which is still done if you supply a SAXSource or StreamSource as the input). {axes-dom154, 155}
Note that this whitespace stripping layer strips whitespace as requested by the stylesheet,
regardless of whether any xml:space attribute is present in the tree to override this.
In the XQuery interface, whitespace stripping can be requested from the command line or from the API, but not from the query itself.
Whitespace stripping applies equally to documents loaded using the document()
or doc() function as to
the initial source document; but it is not applied to documents supplied as stylesheet (or query)
parameters.
This model now allows the XQuery and XPath APIs to operate directly on a DOM or JDOM structure, with the results of the expression being references to the actual DOM or JDOM nodes, not to copies.
The getLocalName method of the NodeInfo has been renamed
getLocalPart to avoid conflict with the DOM method of the same name. The
getLocalPart method returns "" rather than null for a node with no name, and
it returns a value whether or not the node is in a namespace.
761894: distinct-nodes() crashes when used in an XQuery user-defined function.
770785: Tail-call optimization bug in xsl:apply-templates when the select expression has context dependencies.
783382: Saxon infers the type document-node() rather than string for an empty variable.
788731: Infinite recursion in compiler while optimizing current()
788748: Incorrect static type inference for (integer div integer).
799095: Null Pointer Exception while compiling an XQuery using a variable reference with a direct attribute constructor.
805148: An attribute or namespace node may be deemed identical to an element node if they have the same offset in their respective arrays.
805149: The result of generate-id() for an attribute or namespace node may contain non-alphanumeric characters.
810626: The xsl:number instruction crashes when given a format picture containing a single punctuation token, for example format="*".
810644: The operands of the "is" operator are incorrectly compiled.
811914: The unordered() function fails if the argument is a sequence whose items are all compile-time constants.
The xsl:character-map and xsl:output-character elements have been
implemented. See further details. {charmapNNN}
The rules attribute on saxon:collation is now implemented, allowing
a fully-customized collation to be created using the syntax for the java
RuleBasedCollator. {sort25}
I have added a compile-time warning message if a variable declaration has no following sibling instructions. This is permitted, but has no useful effect and probably means the user has made a mistake.
The xsl:number element now takes a select attribute to select the node
to be numbered. (This anticipates a change in the next working draft). {numb23}
The xsl:sequence instruction can now have either a select attribute or
child instructions, but not both. (This anticipates a change in the next working draft).
Stylesheet attributes whose value is a name, or a number, or an enumeration such as yes|no,
now allow leading and trailing spaces in the value. This feature has not been tested very
thoroughly.
When running with version="2.0", the xsl:value-of instruction now defaults the separator
attribute to a single space. (With version="1.0", in the absence of a separator attribute,
it continues to discard all but the first item in a sequence.) {seq019, seq020}
The constructs element(), element(*, T), attribute(), and
attribute(*, T) are now allowed as NodeTests within a pattern. If a type is specified, the
default priority is 0. If no type is specified, it is -0.5.
{schema019}
The construct [xsl:]exclude-result-prefixes="#all" is now implemented. {nspc48}
Where a namespace is on the list of excluded namespaces for a literal result element, but is used in the name of the element or one of its attributes, Saxon was ignoring the request to exclude the namespace. The effect was that if more than one prefix was assigned to the namespace, unnecessary namespace declarations were output. I have changed the code so it no longer ignores the request to exclude the namespace; instead, the namespace declaration that is actually needed will be reinstated by the namespace fixup process. {nspc49}
Enhancements have been made to the number formatting in format-date(),
format-dateTime(), and format-time(). The format modifier "o" can be
used to request ordinal numbers (1st, 2nd, 3rd). The format modifier "a" (or "A" for uppercase)
gives numbering in words (one, two, three).
They can also be combined ("ao" or "Ao") to give ordinal words (first, second, third).
These formats currently always produce output in English. {date068}
Ordinal numbering is also available in xsl:number. (This was implemented to underpin date
formatting, but is available generally.) Use the format token 1st for the sequence
1st, 2nd, 3rd, 4th..., the format token first or FIRST for the
sequence first, second, third, fourth... (in either upper or lower case). The format tokens
one and ONE have always been available, though not well documented. The full
list of supported formats is documented in xsl-elements.html.
Note that these are available only for English; sequences for other languages can be implemented by
writing a user-defined Numberer, as described in
Implementing a numbering sequence.
{numb24, numb25}
Sorting a set of numeric values, without specifying data-type="number", now handles NaNs correctly.
The result of dividing two integers using the div operator is now a decimal, rather than a double. A consequence
if this is that dividing by zero gives a run-time error, rather than Infinity. It may also affect the
precision of results, but the effect is likely to be minor in most practical cases. (Actually, the
computation is currently carried out with double precision, and then converted to a decimal, so the
results are not as accurate as they could be.) This change exposed a
bug in the handling of the mod operator for decimal arguments, which has been fixed.
A consequence of this change is that the avg() function when applied to a sequence of integers
now returns an xs:decimal.
Numeric promotion is implemented in the type-checking rules: that is, an integer or decimal value can be supplied where a float or double is expected, and a float can be supplied where a double is expected. (The fact that this was not implemented before was something I had overlooked.)
The expression / (or a path expression starting with /) now returns
an error if the context item is in a tree whose root is not a document node. The root() function,
however, succeeds in this case. {seq018, seq908err, seq909err}
The constructs element(), element(*, T), attribute(), and
attribute(*, T) are now allowed as NodeTests within a path expression.
{type042, schema016-018}
In the processing-instruction() NodeTest, the quotes around the processing instruction name
are now optional. The name must now be a valid NCName, whether or not it is enclosed in quotes. {copy63, node03}
The changes affecting XPath also affect XQuery.
Improved documentation for the XQuery API is available on the Using XQuery page, and also in the JavaDoc for the relevant classes.
I have implemented the changes to the Query Prolog syntax introduced in the August Working Draft. These include the addition of semicolons as separators between declarations in the prolog; replacement of the keyword "define" by "declare" throughout; removal of the "=" symbol except in "declare namespace"; and relaxing the rules on ordering of declarations.
The declare base-uri declaration in the prolog is now supported.
The default element namespace now works as specified. This is somewhat different from
the XSLT specification: in XQuery, the default element namespace affects unprefixed element names whether
they appear in element constructors or in path expressions. It isn't possible (as in XSLT 2.0) to specify
different defaults for names in the input document and names in the output document. {ns/addq2}
The typeswitch expression is now implemented. {xmp/addq10}
The collation option of the order by clause in a FLWOR expression
is now implemented. See Collation URIs for details of
the URIs that can be specified. {r/addq1}
Sorting a set of numeric values now handles NaNs correctly (NaNs are considered equal to each other and less than any other value).
Computed comment constructors and processing-instruction constructors are supported. {xmp/addq4}
Entity references and character references are supported in string literals (previously they were supported only in element and attribute content).
It should now be possible to use any output encoding that is supported by the Java VM, without defining
a custom CharacterSet class. In JDK 1.4, Java allows the application to determine whether
particular characters are encodable using a given character set, and this information is now used to
decide whether to replace the character with a numeric character reference. Because I don't know how
efficient this mechanism is, I still use the old mechanism for character sets that were previously
supported in Saxon, and the mechanism for defining user-defined character sets is still available
for the time being. It has been restricted, however, so that Saxon will only attempt to load a
PluggableCharacterSet for encoding XXX if the output property encoding.XXX="class-name"
is present.
The code now allows for the possibility that character encodings other than UTF-8 and UTF-16 may be capable of encoding supplemental characters (characters whose Unicode codepoints are above 65535). Previously such characters were always output as numeric character references, except when using UTF-8 and UTF-16. A consequence of this is that user-written PluggableCharacterSet implementations must be prepared to categorize such characters.
There are some differences between the character encodings supported by the old java.io package
and the new java.nio package. If the requested encoding is not supported by the java.nio package, then
all non-ASCII characters will be represented using numeric character references. If the encoding is
not supported by the java.io package, then Saxon will revert to using UTF-8 as the actual output
encoding. A list of the character encodings
supported in the java.nio package can be obtained by using the command java net.sf.saxon.charcode.CharacterSetFactory,
with no parameters.
The HTML serialization method should now handle INS and DEL elements correctly.
User-written emitters were not working; the code has been fixed but not tested.
Collations can now be specified directly using a URI, without requiring a saxon:collation
declaration. This makes them available in XQuery and XPath applications as well as XSLT. The URI takes
a form such as http://saxon.sf.net/collation?lang=de;strength=primary and is specified
fully in Collation URIs. {r/addq1, sort26}
The collection function is implemented. The Saxon implementation interprets
the URI of the collection as a reference to an XML document that acts as a catalogue listing the
documents in the collection. An example of a catalogue document is:
<collection> <doc href="doc1.xml"/> <doc href="doc2.xml"/> <doc href="doc3.xml"/> </collection>
In effect, collection("a.xml") is merely a shorthand for
document(document("a.xml")/collection/doc/@href). My thinking is to extend the
catalogue structure in future to allow options to be specified for how errors are handled, how
the documents are parsed (e.g. validation, space stripping), and whether the documents should be
locked in memory. {mdocs19}
The tokenize() function now supports the facility to split a string into its invididual
characters if the regex matches a zero-length string. For example, tokenize('alphabet', '')
returns the sequence ('a', 'l', 'p', 'h', 'a', 'b', 'e', 't'). Note: there has
been some discussion on this topic in the public-qt-comments list, and the specification could
change as a result. {regex19}
In XPath expressions in XSLT stylesheets, core functions can now appear in the fn:
namespace (currently http://www.w3.org/2003/05/xpath-functions). Of course, they
can also be unprefixed. {coreFunction101}
The result of dividing two integers is now a decimal. {math-two17}
Values of type xs:language are now properly validated. {type008}
An identity transformation is now able to extract a subtree of a DOMSource starting at any element.
This clears a long-standing bug 548228.
A new test exampleDOMsubtree has been added to TraxExamples to demonstrate
the capability.
The various bit-valued static properties of an XPath expression (dependencies, cardinality, and other special properties) have now been brought together into a single word, whose value is computed once and stored on each node in the expression tree rather than being calculated on demand. (There were some cases where this calculation was still being done at run-time).
Some changes have been made to the design of tail-call optimization. This is mainly to fix a bug arising when apply-templates uses a select expression with context dependencies. The decision that a call is a tail call is now made statically rather than dynamically, to avoid the costs of creating a closure for the select expression when this is not needed.
In some cases XSLT stylesheet functions are now compiled to the UserFunction object originally introduced to support XQuery. This is done where the body of the function is sufficiently simple: this basically means that it must consist of a sequence of xsl:param elements, then xsl:variable elements, and finally an xsl:sequence element with a select attribute to define the result of the function. The effect is that recursive calls in such functions now benefit from tail call optimization, allowing deeply-nested recursive functions to execute without blowing the stack.
A small but useful speed-up has been achieved for the common operation of navigating the child axis, by optimizing for the case where all nodes on the axis are retrieved.
The XMLChar module from Xerces has been incorporated into Saxon, and is now used in
most places where XML names and XML characters are tested for validity. This performs a considerably
more accurate check than Saxon was previously performing, especially for characters that are valid
within names.
The sql:insert extension instruction now tidies up properly by closing the
prepared statement, which prevents Oracle running out of cursors.
Extension functions may now return an array; this is treated in the same way as if they return a list. Thanks to Aleksei Valikov for this enhancement.
A number of defects in XQuery parsing have been fixed silently, without being registered as bugs. For example, constructors for comments and processing instructions were not working at all.
761891
Saxon crashes with a NullPointerException if xsl:include or xsl:import is handled
by a user-written URIResolver which returns a Source with no system ID set.
761894
When called from XQuery, the distinct-nodes() function crashes with an internal error.
763792
The extension function saxon:tokenize fails with a NullPointerException when the supplied
argument is an empty sequence.
764172 The XQuery parser reports a spurious syntax error if a function declaration includes no return type.
768422
The XPath (and XQuery) parser fails on a construct such as element and X where the first
token is element or attribute used as a QName, and the second token is an
operator.
768423
The XQuery parser reports a spurious syntax error if, in the construct let $x := EXP, no
space appears between the variable name and the := operator.
The command line interface by default no longer wraps the result sequence into an XML document with a
result:sequence as its outermost element. This wrapping can still be achieved using the
-wrap option on the command line. The default output format is now to output each item
in the result sequence independently. If the item is a document node or an element node then it is
serialized as XML. It it is anything else, then its string value is output on a new line.
This format is much more useful when the query is designed to produce a single XML or HTML document.
Note that you can specify !method=html on the command line to invoke HTML rather than
XML serialization.
A number of other changes and extensions have been made to the command line options for the
net.sf.saxon.Query command. See Using XQuery for details.
Query execution can now be traced using the -T option. (Though the actual output is
still rather XSLT-oriented). Note that line numbers for some expressions currently indicate where the
expression ends (though for the more complex expressions such as element constructors and FLWOR
expressions, it shows where it starts).
I have added support for the document{} constructor. (This is implemented using an internal
instruction representing a conceptual xsl:document instruction, which is also now used for
producing temporary trees in XSLT.)
Computed element and attribute constructors now accept the name as a value of type xs:QName
as an alternative to xs:string.
Added extra validation of numeric character references, and support for characters above Unicode 65535 (surrogate pairs).
Improvements have been made in error messages, particularly for run-time errors. Many of these changes should also benefit XSLT users.
XHTML output is now selected automatically if the first element in the result tree has local name "html" and namespace URI "http://www.w3.org/1999/xhtml".
Grouping facilities (xsl:for-each-group) have been rewritten.
Grouping keys may now be of any data type that supports equality comparison. Previous Saxon
releases converted the values to strings before comparing; they are now compared according to
the rules for their native data type. (There are actually very few cases where this gives a different
answer: one such case is when comparing dates in different timezones). The function
current-grouping-key() is supported. When using the group-by attribute,
an item in the population may now be assigned to zero or more groups. The collation
attribute is now available to define how string-valued keys should be compared; the default
is Unicode codepoint collation. The new implementation
offers better pipelining in cases where no sorting is needed (though it is not completely serial:
for example with group-adjacent, the contents of one group of adjacent elements will be
held in memory at any one time). {group020-025}
The specification says that it is an error when the set of grouping keys is heterogeneous (for example, a mixture of strings and numbers). Saxon currently detects this error in the case of group-adjacent, but does not detect it for group-by — non-comparable values are simply treated as being not equal.
Added support in the system-property function for the new properties
xsl:is-schema-aware, xsl:supports-serialization, and
xsl:supports-backwards-compatibility. The xsl:version property
now returns 2.0, reflecting the fact that Saxon is now close to achieving
full conformance with the draft 2.0 specification.
Added support for the abs function. (This anticipates a future draft of the
specification.) {math-two15}
Conversion of decimal, float, and double to integer now works as specified, by truncating towards zero. {math-two16}
Conversion of a non-numeric string to a number, when invoked using a cast, or the xs:double()
constructor function, or implicit conversion of an untyped node, now raises a dynamic error rather than
returning NaN. The number() function, however, continues to return NaN.
The doc() function, when it fails to find a document (or to parse it as XML) now raises
a fatal run-time error. This doesn't affect the behaviour of the document() function.
A value of type xs:anyURI can now be passed to an external Java method
whose expected type is java.net.URI.
Comparison of two integer values was converting both to doubles; this has been fixed.
Handling of "head-tail recursion" has been made more efficient. Constructs that select
all items in a sequence after the first (for example $x[position()!=1]) are now
recognized specially when doing deferred evaluation; in effect they return a view of the
underlying sequence. (Previous Saxon versions handled this in some cases, in a different way).
In XQuery, tail calls within user-defined functions are now optimized. This enables deeply recursive algorithms to execute without running out of stack space.
All the decisions about sorting a path expression into document order are now made at compile time.
Union, intersect, and except expressions of the form E[c1] | E[c2] are now rewritten
as E[c1 or c2]. This avoids the need to evaluate E twice, and may avoid a sort.
The coding of the cast, instance of, and castable operators has been cleaned up.
The implementation of substring now optimizes for the case where the second
and third arguments are integers - it no longer does everything using double arithmetic.
The StringValue class can now encapsulate any CharSequence, not
necessarily always a String. This avoids some unnnecessary conversions, though
for full effect the Item#getStringValue() method will also have to be changed to
return a CharSequence.
The implementation of xsl:sequence has been improved. When a required type is
given in the as attribute, the type of the value is now checked "on the fly"
as items are written to the current output destination. The SequenceChecker is
also capable of atomizing any nodes that are written (in fact, the nodes are atomized before they
are even created). It also converts untyped atomic values to the required type.
This is an inverse of the way checking is
done by SequenceIterators during XPath evaluation; we now have a "pull" pipeline (the SequenceIterator)
for iterating over the results of XPath expressions, and a "push" pipeline (the Receiver) for generating
events on a result tree. Both are capable of on-the-fly type checking. The capability of
xsl:sequence to do this is reused in xsl:template and xsl:function:
an implicit xsl:sequence
instruction is generated to wrap the contents of the template or function, and this inner instruction
is responsible for any type checking and atomization.
Eventually I am hoping to move more and more to a "pull" model, where instructions are evaluated using iterators in the same way as expressions are evaluated today. The current model can be seen as transitional. Some instructions, in particular those used by XQuery such as Element and Attribute, are currently dual-mode - they work both as instructions and as expressions.
The expression generate-id(A) = generate-id(B), which is often used in XSLT 1.0
to compare node identities, is now rewritten internally as A is B. This requires some
minor tweaks to ensure that the result is correct when either A or B or both is an empty sequence.
759502 The getOutputProperty() and getOutputProperties() methods of the Transformer object always return null
Added the as attribute to xsl:template. (This is not a very efficient
implementation, as it breaks the pipeline) {seq017, seq906err, seq907err}
The [xsl:]default-xpath-namespace attribute is renamed
[xsl:]xpath-default-namespace.
Two local variables in the same template or function can now have the same name. But parameters must still have unique names. (A side-effect of this change is a useful improvement in compilation speed for stylesheets with many global variables. The checking done in previous releases was implemented very inefficiently.) {var13, var901err}
I have added type-checking for global (stylesheet) parameters. It's not entirely clear here what the
rules ought to be. Somewhat pragmatically, I have adopted the rule that if you supply a string (which will
always be the case if parameters are provided on the command line), then the system attempts to convert it
to the type specified in the xsl:param declaration; if you supply anything else, then it must
(after Java to XPath conversion) be of exactly the required type, without any conversion.
Saxon now supports XQuery. Details of how to use XQuery are provided at using-xquery.html, and information about the conformance to current working drafts is in conformance.html.
The doc function is implemented.
The trace function has been changed so that it is never evaluated at compile time,
even if both arguments are constants.
The optimization of count($x)=0 as empty($x) was working only when the
stylesheet specifies version="2.0". It now works with version="1.0" also.
Text-only temporary trees are used in a wider range of circumstances than before. This data structure
is used when it is known statically that a temporary tree will consist of a single text node; it is a
lot more efficient than a general-purpose temporary tree. It is now used in cases where the content
of the variable invokes xsl:text and xsl:value-of including calls that are
within xsl:for-each, xsl:choose, xsl:if,
xsl:sequence and xsl:analyze-string, and also where it
uses xsl:call-template, provided that
all the subordinate instructions generate text nodes. This has been done
in a generalized way which will eventually lead to static type inferencing working at the XSLT level
in the same way as it currently works at the XPath level. For xsl:template, the type
of the results is inferred from the as attribute if present, or from the contents of
the template otherwise. {not v. thoroughly tested!}
Range variables (that is, variables declared in an XPath expression (for, some, every) are now stored on the local stack frame in the Bindery rather than directly in the XPathContext object. This simplifies the machinery for handling variables and allows instructions and expressions to be treated more interchangeably.
The Expression class has been refactored. The original class net.sf.saxon.expr.Expression
is now an interface. The various expressions are now structured under ComputedExpression for
"true" XPath expressions, net.sf.saxon.value.Value for constant values, and InstructionExpr
for instructions (such as xsl:element) that act as expressions when used from XQuery.
The utility methods, including the make factory method, are now in
net.sf.saxon.expr.ExpressionTool.
When the dependencies of a ComputedExpression are determined, the information is now saved
with the expression rather than being recalculated whenever it is needed. For complex expressions this
calculation can be quite complex, and there are still some cases where it is being done at run-time.
Path expressions now use the standard type-checking machinery to check that both arguments of "/" are node-sets. This means that in some cases an error in this area will now be detected statically; and it means that if the expression is found statically to be safe, no run-time checking is done.
I have changed the way delayed evaluation is done: when an expression is evaluated lazily, a Closure object is created as a surrogate for the value. This now contains the expression itself together with all the context information that the expression needs. The separate SavedContext object is no longer used. The Closure is evaluated using the ordinary XPathContext object, which now holds a reference to the local stack frame. With delayed evaluation, this "stack frame" is not actually on the stack at all, it is in the heap, so it survives if the Closure is returned from a function call.
I have reverted to the principle used prior to Saxon 7.x, that lazy evaluation is used only for expressions that are expected to return a (non-singleton) sequence. However, the classification of such expressions is now much more accurate. The reason for this policy is that delaying evaluation of singleton expressions is usually not beneficial - it saves no memory, and incurs a cost for saving and restoring the context. Also, lazy evaluation is not used for expressions that have unusual context dependencies, for example those that depend on current(), position(), last(), or current-group(). This eliminates the problem of saving these values and ensuring that they are referenced correctly during the delayed evaluation.
The delayed evaluation code now evaluates the underlying expression at most once, thus ensuring that
it never takes longer than direct evaluation. At the same time, if only the first item in the sequence is
used then only the first item will be read. In a construct such as
if (exists($x)) then $x else "nothing", the first reference to $x primes the iterator, and saves
anything it reads in a buffer (called the "reservoir") within the Closure object. The second reference to $x
starts by reading what it can from the reservoir, and if it needs more, it picks up iterating the underlying
expression where the first evaluation left off. Once some user of the variable has accessed all the items
in the underlying expression, the reservoir contains all the values needed and subsequent evaluations read
the value from there.
Certain instructions, specifically those that are used in for XQuery as well as XSLT processing, now act as expressions as well as instructions. There are two modes of evaluating these instructions: the process() method causes the instruction to write its output to the current Receiver, while the evaluateItem() and iterate() methods return the results in the same way as for any other expression.
To support this mechanism, the process() method now takes an XPathContext as its argument, instead of the Controller. This is because in XQuery, the XPath context needs to be passed unchanged by an element constructor to its child expressions.
Thanks to Gunther Schadow for these changes.
If an extension function returns null, this is now mapped to a zero-length sequence rather than to an external object that wraps null. This prevents some run-time type failures.
Exceptions thrown by an extension function are now wrapped in the XPathException thrown by the calling XPath expression, and hence in the TransformerException thrown by the transformation as a whole.
Public fields in Java classes are now accessible as zero-argument functions, for example the field
Double.MIN_VALUE is accessible as Double:MIN_VALUE() with the namespace prefix
bound as xmlns:Double="java:java.lang.Double". Non-static fields can be accessed by including
the object instance as the first argument. It is not possible (and rarely necessary or desirable!) to
modify public fields without use of a setter method. {saxon74}
The extension function saxon:is-null (which was incorrectly documented as
saxon:if-null) is now redundant, and is dropped.
The undocumented saxon:trace function is dropped: use fn:trace instead.
A couple of bugs in tail recursion have been fixed:
736802Tail recursive calls are sometimes not executed
A couple of cases have been reported where stylesheet errors cause a crash, these have been fixed.
I have recently installed JDK 1.4.1: this has revealed a couple of problems/inconstencies. The new JDK release appears to fix some problems with regular expression handling and with use of collations. This means that some of my tests produce subtly different results. In one or two cases the new results are clearly wrong, which means that my code was relying on the incorrect JDK 1.4.0 behavior. I have made adjustments where it seems appropriate, but particularly with collations, it is not always obvious what the right answer is.
It is now possible to have two or more stylesheet functions with the same name, provided they have the same arity (number of parameters). An error is reported if two functions have the same name, arity, and import precedence. {func27, func901err}
Added support for xsl:template mode="#all". {modes30-34, inimode002}
Basic support for the functions format-date, format-time,
and format-dateTime is provided. The xsl:date-format declaration
is not implemented, and the third argument of the function is ignored. Not all formatting
options are supported, and timezones are not handled properly yet. {date67}
I have done a lot of work on the JavaDoc documentation of key interfaces and classes, and some general code cleaning up (for example, removal of redundant methods).
The classes representing character encodings (in package net.sf.saxon.charcode)
are now singleton classes; they only ever have one instance.
The following bugs are fixed in this release:
687946
An internal error may occur when the key function is used on the right-hand-side of the
/ operator in a path expression.
689934 A ClassCastException occurs when comparing two values that are not comparable according to XPath 2.0 rules, for example string and integer.
690736 An IllegalStateException may occur when a sequence-valued variable is promoted by the optimizer to move it outside a predicate. The specific message is: java.lang.IllegalStateException: evaluateItem called on non-singleton variable reference at net.sf.saxon.expr.VariableReference.evaluateItem(VariableReference.java:202)
700837
An expression that uses a range variable (for example, a for or some expression)
cannot be used within a predicate in an XSLT pattern.
706935
A NullPointerException occurs when processing an expression of the form //x[$var] or
.//x[$var].
708789 When two or more items have sort keys that evaluate to the empty sequence, the resulting sort order is incorrect.
708998
Incorrect recovery action when xsl:copy-of generates a non-text node in the value of an
attribute, comment, or processing instruction.
709347 An empty sequence is not being converted to an empty string when calling a function in backwards compatibility mode.
710093
The value of position() is calculated wrongly when navigating an axis on a JDOM tree.
721687
Crash in XPathEvaluator (Java XPath API) due to incorrect generation of type-checking code.
722537 Saxon crashes if an attribute is marked as an ID but is not a valid ID, which can happen when using a non-validating parser.
I have finally dropped support for the old Java-only event-driven API. This was starting to interfere with the ability to optimize XSLT processing. The XPath interfaces remain available. Indeed, all the internal APIs remain available, but I am no longer trying to keep them as simple or as stable as is necessary for a supported external API. There were serious bugs in the ShowBooks.java sample application in Saxon 7.4 that somehow didn't show up in testing; this sample application has now been dropped.
I have also finally been forced to drop preview mode. It no longer works because the optimizer is becoming too clever. The optimizer uses lazy evaluation of expressions, which relies on the fact that the source document is immutable; preview mode violates this assumption. The correct way to handle this requirement is to write a document splitter as a SAX filter, breaking the source document into small pieces and invoking one transformation for each piece.
The deprecated extension functions get-user-data() and set-user-data()
are no longer documented, though they have not yet been deleted from the product.
The required="yes|no" attribute on xsl:param is implemented. Currently,
failure to supply a required parameter is a dynamic error, it is never detected statically.
{ntmp01, ntmp901err}
The xsl:next-match instruction is implemented. {cnfr24-27}
The error that occurs when the name attribute of xsl:element or
xsl:attribute contains an undeclared prefix (in the absence of the namespace
attribute) is now recoverable. This brings it into line with the handling of other errors in this
value. Note however that if the name is known statically then the error is reported at compile time
and is fatal.
The error that occurs when a namespace or attribute node is written using xsl:copy-of,
when there is no open element start tag, is now recoverable. This brings it into line with other
instructions such as xsl:attribute and xsl:copy. {copy62}
Implemented the new facility to allow construction of sequences in XSLT, when a variable
binding element has content and an as attribute.
Added the as attribute to xsl:function. {func20}
Implemented the xsl:sequence instruction, including the as attribute
which checks the type of the returned sequence and performs any necessary (and permitted) conversions. {seqNNN}
The xsl:result element is withdrawn. It can always be replaced by xsl:sequence.
The as attribute, which denotes the return type of the function, should preferably be moved to the
xsl:function element.
Parentless attribute, text, comment, processing-instruction, and namespace nodes are implemented.
They are probably a little fragile - some operations on such nodes (e.g. xsl:number,
xsl:apply-templates)
have not been tested. The new rules for match patterns with parentless nodes have not been implemented:
it's probably best to avoid using apply-templates on such nodes for the moment. {seqNNN}
Some instructions, e.g. xsl:value-of, incorrectly generate multiple text nodes,
some other instructions may pre-merge the text nodes.
Handling of document nodes within the constructed sequence is probably not yet correct.
The separator attribute of xsl:copy-of is withdrawn.
The 2 May 2003 WD changes the syntax for attaching type annotations to nodes in a result tree. These facilities are only partially implemented in Saxon, and no new functionality is provided in this release, but the existing functionality has been converted to use the new syntax. Specifically:
The attribute copy-type-annotations="yes|no" on xsl:copy-of is replaced by
validation="preserve|strip". The default is "preserve".
(The other options, strict and lax, are not implemented.)
The [xsl:]type-annotation attribute of xsl:element, xsl:attribute,
and literal result elements is renamed [xsl:]type; it is still restricted to be a built-in
simple type such as xs:integer or xs:date.
The type-information attribute of xsl:variable and xsl:param
is withdrawn.
In backwards compatibility mode, the November 2002 XPath 2.0 draft specification currently says (if you read it carefully) that for a function expecting an integer, the supplied value should be cast to a double. Saxon 7.4 does this and it fails. This is a bug in the spec, which is fixed in the May 2003 draft; it has been fixed in Saxon 7.5. {type036, type037}
The changes that started in 7.3 to replace the Emitter class with the Receiver
interface have now been completed. The only remaining classes that are Emitters are those that actually
write to a Writer or OutputStream - that is, the XMLEmitter,
HTMLEmitter, etc. All other classes in the
pipeline are now Receivers, many of them being defined as subclasses of ProxyReceiver which
is essentially a filter in the pipeline. The output properties are now notified to each serialization
filter as it is created, rather than being passed down the pipeline.
Identity transformations now copy the source to the result via the Receiver interface, not via SAX2
events as before. Two new classes DocumentSender and DOMSender
have been introduced to generate Receiver
events from a Saxon DocumentInfo or a DOM Document respectively.
The saxon:doctype extension has been completely rewritten. It no longer uses a custom
serializer, but instead generates the DTD within the code of the instruction itself, outputting the
result using the standard serializer with disable-output-escaping. There may be changes in edge cases,
for example the handling of namespaces within the expansion text of entities.
The standard URIResolver has been changed to use the JDK 1.4 class java.net.URI
in place of the old java.net.URL. This gives stricter adherence to the rules for URI handling
and appears to handle a wider range of URI formats. One effect is that (for reasons that I do not fully
understand) it is now possible to use Microsoft UNC filenames of the form \\server\share\dir\file.xml
from the Saxon command line. Another effect of the change is that URIs are checked more rigorously: for
example, a URI that uses backslashes instead of forward slashes is now rejected.
The OutputURIResolver is now used for resolving the principal output document (including the filename
given on the command line) as well as secondary result documents. This eliminates a lot of duplicated code.
The standard OutputURIResolver has
been enhanced to be capable of supporting URI schemes other than the file scheme; however, I haven't
identified any schemes that support output using the standard JDK 1.4 libraries. The file URI scheme
now maps URIs to filenames using standard methods provided in JDK 1.4, rather than through ad-hoc
parsing of the URI: this means that invalid URIs such as file:/c:\temp.xml will be rejected
at this release even though they were accepted by earlier releases.
These changes can cause difficulties dealing with filenames that contain spaces. For example, the JAXP
classes StreamSource and StreamResult, when given a File as input, do not apply URI escaping to the
filename. This means that the "System Id" they contain is not guaranteed to be a valid URI, for example
it may contain spaces. Saxon may therefore report an Illegal URI when using the system identifier as
the base for resolving other URIs. To prevent this problem, given a file java.io.File fname,
use the constructor new StreamResult(fname.toURI().toString()) rather than
new StreamResult(fname).
Comments of the form (: ... :) are now allowed in XPath expressions. Comments may
be nested, and may appear anywhere that whitespace separators are allowed.
An expression of the form 1,2,3 can now be used as a top-level XPath expression, it does
not need to be enclosed in parentheses.
The "keyword" expressions (those starting with for, some, every,
or if) now have the lowest precedence; they cannot be nested within other expressions
except by using parentheses. The only exception is the "," operator, which has lower precedence than
these keywords.
The syntax for cast as and treat as has changed. These are now infix operators,
for example ($x treat as xs:integer) or ('2003-02-20' cast as xs:date). Note also
that there are changes in precedence for these operators and for instance of and
castable as.
The union operator ('|') once again has higher precedence than unary minus, as it had at XPath 1.0.
So (- $a | $b) parses as ( - ($a|$b) ).
The new SequenceType syntax element(*, T) replaces element of type T. Since
only built-in atomic types are recognized, the first component must be "*" at present. This syntax
is not yet available in path expressions or patterns. The syntax document-node(element(X,Y))
is not yet recognized.
The types node and item must now be written as node() and
item().
The built-in types dayTimeDuration, yearMonthDuration,
untypedAtomic and anyAtomicType are now
in the namespace http://www.w3.org/2003/05/xpath-datatypes whose conventional prefix
is xdt. They were previously placed in the xs namespace.
Casting string to untypedAtomic is now permitted {type038}.
The URI for the codepoint collation is changed to
http://www.w3.org/2003/05/xpath-functions/collation/codepoint.
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}
Extension functions that declare an argument type of java.lang.CharSequence can now
be called in the same way as extension functions that declare the argument type as java.lang.String.
Thanks to Gunther Schadow [gunther@aurora.regenstrief.org] for identifying this requirement and the changes
needed.
The net.sf.saxon.Transform command line now allows "-" as either the source file name
or the stylesheet file name, with the meaning that the source file or stylesheet is read from standard
input. Note that this means it will have no system ID, and therefore no base URI, so relative URLs
contained within the document cannot be resolved. Thanks to Gunther Schadow [gunther@aurora.regenstrief.org]
for this enhancement.
It is now possible to specify output parameters on the command line. These are entered in the same
way as stylesheet parameters, but with a "!" as the first character of the name. For example,
!indent=yes switches indentation on, and !{http://saxon.sf.net/}indent-spaces=1
sets the indentation level to one. A value specified on the command line overrides any value specified
in an xsl:output declaration in the stylesheet.
A new TraceListener is available, called TimedTraceListener. This can
be activated using the -TP flag on the command line. A stylesheet is available for analysing
the resulting execution trace. For details, see Performance Analysis.
The command line option -im modename can be used to specify the initial mode in which
the transformation starts. The modename may use the "{uri}local-name" syntax if it is namespace-qualified.
An initial mode can also be selected using the setInitialMode() method on the Controller.
I have tested the JDOM interface more thoroughly at this release than previously, and this has revealed some problems. I have fixed the most serious of these. Most of the failed tests relate to the use of the namespace axis, and since the namespace axis is not mandatory in XPath 2.0, I have withdrawn support for this axis with the JDOM interface.
Shortly before Saxon 7.5 was finished, JDOM beta 9 became available (the first new release for a year). I tested Saxon 7.5 with the new release without problems.
I have changed the mapping for the Java types char and Character. If these
types are returned from an extension function, or supplied as a stylesheet parameter, they are now
mapped to an XPath string. Previously they were returned as an integer.
Revised the code for type checking and conversion in GeneralComparisons, in particular, the rule that in backwards compatibility mode, an argument is converted to a double if the other argument is numeric. {bool73, bool74}
There are four functions whose result depends implicitly on the current document: key,
id, unparsed-entity-uri, and unparsed-entity-public-id. These
functions are now statically rewritten to call an equivalent internally-defined function that takes "/" as
an additional explicit argument: for example id($x) is rewritten as id+($x,/).
This has allowed the removal of the special code needed to handle the
fact that these functions have an implicit dependency on the context. (This is designed as a step
on the way to elimination of expression rewriting during reduction).
The changes made in 7.4 to extract constant sub-expressions out of a loop had an adverse side-effect in forcing path expressions to be sorted into document order unnecessarily. This has been fixed.
The decision whether a sort is necessary to deliver the results of a path expression in document
order is now made at compile time, and is reported by saxon:explain. The phrase "naturally sorted"
means that the path expression delivers its results in document order; the phrase "requiring sort" means
that unless the containing expression asks for the results in arbitrary order, a sort will be performed
to get them in document order.
Some additional cases have been identified where a sort into document order can be avoided.
The main such case is path expressions starting with a variable reference, for example $x/a/b/c.
These are increasingly common within for expressions, and within stylesheet functions.
The system now maintains enough static information about the expression to which the variable is bound to
eliminate the sort in many cases. Note that with expressions used inside a stylesheet function, where
$x is a parameter, this works only when the parameter is given a type that disallows multiple
nodes. Sorting is also avoided in a path expression that starts with the
document() function. A performance bug that caused the results of the key()
function to be sorted unnecessarily has been fixed.
The expression rewriting in 7.4 sometimes introduced an unnecessary redundant range variable (in the
saxon:explain output this appears as let $zz:r1 := $zz:r0). In most cases this has been eliminated.
Apart from a small intrinsic cost saving, this also enables some further expression optimization which
was previously inhibited by the extra complexity of the expression.
The mechanism previously used for lazy evaluation has been changed. In previous releases, the
reduce() method was called to create a copy of the expression, in which context-dependent
subexpressions (such as variable references, or the current() function) were replaced by their values.
This copying was expensive, in both time and memory. The strategy at this release is that a lazily-evaluated
value is represented by a Closure, which consists of the original expression (unchanged), together with
a SavedContext, which holds all the values of context variables.
The changes to lazy evaluation revealed some problems with saxon:preview. The problems
are not actually new, they were exposed by the changes. I eventually decided there was no alternative
to withdrawing this facility. I think the time is coming near when saxon:assign
may also have to go: these "features" are starting to interfere too much with optimization.
The changes can also cause problems with extension functions that have side-effects, by changing
the order of execution of different instructions. These problems can generally be fixed by writing
saxon:assignable="yes" on each xsl:variable element where the order of
execution is significant. However, it is best to avoid using extension functions with side effects
if at all possible.
The ContentEmitter class now declares its methods with throws SAXException, making life
easier for users who want to define a subclass.
Tail calls of named templates are now optimized not only for a directly recursive call, but for any
other call. So mutually-recursive templates now also benefit from this optimization, which means that
deep recursion is possible without running out of stack space. Tail calls using xsl:apply-templates
are also now optimized. The benefit applies only to the last call when a node-set is being processed,
but this is a typical use case with a call such as
<xsl:apply-templates select="following-sibling::*[1]"/>.
However, tail calls of recursive stylesheet functions are not being optimized at the moment. The change in processing model (functions are now made up of instructions rather than expressions) made this too difficult. Reinstating this feature (introduced in 7.4) will require some kind of integration between the XSLT and XPath parts of the compiler.
The change in the way tail recursion is handled requires a change to the implementation of extension elements. A class that extends the Instruction class must now provide the methods processLeavingTail() instead of process(). No change is required other than declaring the return type as TailCall, and actually returning null.
Calls to xsl:function are now notified to the TraceListener.
The theme for this release is strong typing. Saxon does not yet support user-defined types, and
has very limited facilities for supporting type annotations on nodes in the data model, but it does
support most of the built-in atomic types in XML Schema, such as string, integer, decimal, double,
date, dateTime, duration, QName, and anyURI. This release introduces the stronger rules for type
checking of operations applied to values of these types. If you want strong type checking, set
version="2.0" on the stylesheet; if you are more concerned with backwards compatibility,
set version="1.0".
655725 -
Java ClassCastException occurs when executing a positional filter expression of the form
$x[position() > 1].
655948 -
Orphaned namespace declarations can appear when serializing a result tree using method="text".
655950 -
The -a option on the command line does not work.
656857 -
The xsl:analyze-string instruction does not work correctly when no match is found.
659064 -
A ClassCastException can occur when an extension function returns a value of class java.util.List.
(The clearance for this introduces a new facility: an extension function can now return a Java List,
which will be converted to an XPath sequence, each item in the list being converted from a Java object
to an XPath value independently).
680755 -
With the XML output method, indentation should be suppressed when the result tree contains xml:space="preserve".
682979 -
An UnsupportedOperationException occurs when a stylesheet function is called from the return
clause of a for expression.
684487 - Double values less than 0.001 are incorrectly converted to strings: a trailing zero is added (for example, "0.00030").
The following defect has not been fixed, and is carried over until a future release:
655730 - HTML elements in a non-null namespace are serialized as if they were in the null namespace; they should be serialized as XML.
The context item, position, and size are now unset on entry to a stylesheet function. This means that
if the function depends on the context item (or the document containing the context item),
then an explicit parameter must be defined. For example, if the function defines <xsl:result select="count(//*)"/>,
this must be changed to <xsl:result select="count($x//*)"/>, with $x being
supplied as a parameter in the function call. If the function attempts to reference the context item,
position, or size, a dynamic error is reported.
This change gives optimization benefits in all cases where functions are NOT dependent on the context.
The value attribute of <xsl:number> is now handled as described in the
XSLT 2.0 specification: the value may be a sequence, and the items in the sequence are converted to integers
using the casting rules. A recoverable error occurs if casting to an integer is not possible, or
if the value is not positive. {numb07, numb20}
A side-effect of this change is that a user-written Numberer must be changed to handle a long
argument rather than an int as previously.
The code for assignment of variables and parameters has been changed to use the argument conversion
rules defined in XPath (without backwards compatibility mode). This is a weaker conversion than previously:
essentially, the select expression must deliver a value of the correct type, it will not be converted
to the required type except in the case where the supplied value is an untyped node. This means, for example,
that if the required type is xs:integer, you can supply an attribute node, but you cannot supply
a string or a double.
If a cast to the required type is wanted, it must now be written explicitly in the select expression. The error
will be reported statically if the expression could never yield a value of the right type, and will be reported
dynamically otherwise.
In a pattern starting key('k', $x)/..., the variable $x can now be multi-valued;
the pattern matches if it matches any of the values. {idky30}
The XSLT 1.0 rule that xsl:text elements may not contain child elements has been
reinstated. This change anticipates changes to the XSLT 2.0 specification.
In limited circumstances, stylesheet functions (xsl:function) now optimise tail-recursion.
The circumstances are that the select expression of the xsl:result instruction
must contain a call on the same function in the then or else part of a
conditional expression (which may be nested in further conditional expressions). It may require a little
care to write functions to exploit this.
The attribute override=yes|no on xsl:function is implemented.
This determines whether a user-written
stylesheet function should override a vendor-supplied or user-written Java function. The default is "yes".
{func19, func21}
This involved taking the function binding logic out of the ExpressionParser and putting it all in the static context. A simpler version of the routine is provided for StandaloneContext. The code has been structured so it can also test for arity (or even static type of arguments) as part of the binding algorithm, but this is not yet exploited.
A side-effect of this change is that it is now possible to call Saxon and EXSLT extension functions
when using free-standing XPath expressions, that is, expressions executed using the XPath API from Java,
or using saxon:evaluate(). It is also possible to call user-supplied Java extension functions
provided the URI maps implicitly to a Java class name (i.e., not relying on saxon:script).
{saxon36, 37}
Sorting using xsl:sort: I have changed the way data types are specified (in anticipation
of changes to the W3C specification). The data-type attribute may now take
values text or number only.
The values text and number convert the actual sort
key to xs:string or xs:double respectively before doing the comparison.
If the data-type attribute is omitted there
is no conversion. Values are then compared as supplied; if they are not comparable, a run-time error occurs.
If you want to force conversion to a type such as xs:dateTime, use a casting function within
the select expression, for example <xsl:sort select="xs:date(@birth-date)"/>.
There is a small risk of backwards incompatibility if your stylesheet computes a numeric sort key and doesn't specify
a data-type: previously it would have been sorted as a string, it will now be sorted as a number.
I added a check (really a bug fix for 7.3) that when an element is annotated with a simple type
such as xs:integer, the element is not allowed to have attributes. The type annotation for an element
with attributes must always be a complex type.
The type conversion rules as defined in the XPath 2.0 working draft are now implemented. This means that the rules for passing arguments to functions and operators are now stricter: you can't simply assume that the supplied value will be cast to the required type.
The rules are stricter if the stylesheet specifies version="2.0" than if it specifies
version="1.0". The version attribute (or xsl:version on a literal
result element) determines whether XPath 1.0 backwards compatibility mode is used for XPath expressions within
its scope. With backwards compatibility mode on, certain conversions that were permitted in XPath 1.0 (for example,
conversion of anything to a string or number, or extraction of the first item of a sequence) are still permitted
under XPath 2.0. With this mode off, these conversions must be done explicitly in the function call. The only
conversions that happen automatically under 2.0 are extraction of the value from a node: if the node is untyped
(which with Saxon 7.4 will almost invariably be the case), the untyped value is then cast to the type required
by the function signature. This means you can supply an untyped attribute as an operand to the "+" oeprator or
the round() function, for example, but you cannot supply a string.
Division of two decimals (and also the mod operator) now produces a decimal. Previously it produced
a double. The scale of the resulting decimal (the number of digits after the decimal point) is equal to
the sum of the scales of the two decimals, plus 6. So, for example, 10.0 div 3 is 3.333333. There have
been some other refinements to the xs:decimal implementation. Insignificant trailing zeros are always
discarded. Conversion of a decimal to a string uses an integer representation if there is no fractional
part, for example the result of 10.0 div 5.0 is diplayed as 2 (which doesn't
match the current XPath specification).
Conversion of an empty sequence to a double now produces an empty sequence (not NaN as in XPath 1.0); conversion of any other non-numeric string to a double raises an error (rather than producing NaN). This follows the current XPath 2.0 specification.
I attempted to change the double-to-string conversion to fit the XPath 2.0 rules, but it hit numerous
compatibility problems so I have held back on this. But positive and negative infinity are now represented
as INF and -INF (previously they were Infinity and -Infinity).
The strings INF and -INF are also recognized when casting a string to a double or
float; XPath 1.0 had no way of constructing these values except by using a construct such as
(1 div 0). {math95, math96}
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
extensions.html.
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 &emdash; 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}
A new attribute saxon:explain is available on any instruction in the stylesheet. The permitted
values are "yes" and "no". If the value is yes, then at compile-time, Saxon outputs an analysis of all
XPath expressions a