trace
Returns the value of the first argument after outputting a diagnostic message
trace($value as item()*, $label as xs:string) ➔ item()*
Arguments | |||
| $value | item()* | The value to be traced, and to be returned as the function result |
| $label | xs:string | Label to be included in the trace output |
Result | item()* |
Links to W3C specifications
Namespace: http://www.w3.org/2005/xpath-functions
Applies to: XPath 2.0, XSLT 2.0, XQuery 1.0 and later versions
XPath 2.0 Functions and Operators
XPath 3.0 Functions and Operators
Notes on the Saxon implementation
Saxon by default outputs trace messages to System.err
. However, the output may be redirected to a
TraceListener
or to an alternative output destination.
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.
If a TraceListener has been nominated, then instead of writing the output to System.err
, the information
instead results in events being notified to the TraceListener.