# Diagnostics

The format of the "explain" output which displays a compiled and optimized expression tree has changed. The format is now XML, making the raw output amenable to further processing, for example filtering or graphical display. The `-e` flag on the Query command line is extended to allow `-explain:filename`, so that the output can more easily be captured in a file.

The options `-explain` and `-explain:filename` have been added to the `Transform` command line allowing an expression tree to be generated for an entire stylesheet. The extension attribute `saxon:explain` remains available for more selective reporting.

Because the explain output is now XML, it is amenable to analysis using XQuery or XSLT. The Saxon XQuery test driver now allows the test catalog to contain assertions (in the form of XPath expressions) about the content of the expression tree. This allows tests to be written that check not only that the query produces correct results, but that the expected optimizations are applied.

From the Java level, explain output is available via a new method on the `Expression` class. The old `display()` method is retained (for the time being) for compatibility, but produces output in the new format.

Next