Tracing Execution
Saxon-CE provides a Trace
mode to help with understanding the dynamic behaviour of
an XSLT stylesheet. In this mode the execution of each instruction in the stylesheet is traced
and selected details are output to the developer console in XML form.
To initiate Trace mode you should use the debug version of Saxon-CE, then set the
logLevel
attribute to FINEST
(see the Logging section) and refresh the host HTML page.
Trace output can be voluminous. It will be rendered differently according to the capabilities of the development console of the browser you use. Chrome and Safari provide a better environment for large trace outputs as they render the trace XML using 'lazy-loading'.
Note that the order of execution of traced instructions may be different from what you might expect due to optimisations made by the XSLT compiler. Details are added within the trace to help associate traced instructions with the corresponding source XSLT, and for top-level instructions the URI for the XSLT module is also provided.
The fn:trace()
function can be used to insert user-selected information into a trace. It has the signature:
trace($value as item()*, $label as xs:string)
. The $value
argument of
this function is an XPath expression and its evaluation result is shown as an attribute of the
user-trace
element, with $label
as the other attribute. Each value in
the result sequence is output in the trace. The output of fn:trace()
can also be reviewed
independently of the Trace mode when the logLevel
is set to FINE
.
Each transform results in a separate trace output; for example, new trace output is generated
for ixsl:schedule-action
or DOM event initiated transforms. If a fatal dynamic error
occurs during XSLT execution, the trace is output up to the error point, the error message is
then sent and the trace terminated.