Diagnostics and tracing
If requested using the
-l (letter ell) option on the command line (or the equivalent in the API), Saxon now maintains
column numbers as well as line numbers for source documents. The information is available to applications using a new extension
saxon:column-number(), or at the level of the Java API via a new method on the
getColumnNumber(). (Third-party implementations of
NodeInfo will need to implement this method; by default
it can return -1). Note that the information is only as good as that supplied by the XML parser: SAX parsers report for an element the
line and column of the ">" character that forms the last character of the element's start tag.
Errors that occur during schema validation of an input document now display both line number and column, as do static errors detected in a stylesheet or schema. Dynamic errors occurring during expression evaluation still contain a line number only.
After a dynamic error, Saxon now outputs a stack trace - that is, a representation of the XSLT or XQuery call stack.
This feature is now available in Saxon-B, it was previously only in Saxon-SA. The stack trace has been improved at the same
time (it now shows changes to the context item made by
The information in the stack trace is also available programmatically through the method
The formatted print of the stack trace can be retrieved as a string from within a query or stylesheet using the new extension
There are some internal changes as a result of this development, which may be noticeable to applications that do debugging
or tracing. The
InstructionInfoProvider interface has disappeared; instead all expressions (including instructions)
InstructionInfo directly, as do container objects such as
getProperties() method of
InstructionInfo is not so well supported; applications requiring
properties of expressions should cast the
InstructionInfo to the required class and get the information directly from
the expression tree.
InstructionInfo object no longer contains a
NamespaceResolver - it is no longer needed because
all names are now represented as expanded names.
New methods are available to allow the output from the
trace() function to be directed
to a specified output stream, or to be discarded.
A new option TRACE_LISTENER_CLASS allows the TraceListener to be nominated as a class name, rather than as an instance of the class. This is useful in environments such as Ant where the values of configuration properties must be supplied as strings. A new instance of the class is created for each query or transformation executed under the Configuration. The existing option TRACE_LISTENER remains available.