<?xml version="1.0" encoding="iso-8859-1"?>
<?xml-stylesheet href="../../make-menu.xsl" type="text/xsl"?><html>
   <head>
      <this-is section="changes" page="intro91" subpage="trace91"/>
      <!--
           Generated at 2011-12-09T20:47:22.916Z--><title>Saxonica: XSLT and XQuery Processing: Diagnostics and Tracing</title>
      <meta name="coverage" content="Worldwide"/>
      <meta name="copyright" content="Copyright Saxonica Ltd"/>
      <meta name="title"
            content="Saxonica: XSLT and XQuery Processing: Diagnostics and Tracing"/>
      <meta name="robots" content="noindex,nofollow"/>
      <link rel="stylesheet" href="../../saxondocs.css" type="text/css"/>
   </head>
   <body class="main">
      <h1>Diagnostics and Tracing</h1>
      <p>If requested using the <code>-l</code> (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
function <code>saxon:column-number()</code>, or at the level of the Java API via a new method on the <code>NodeInfo</code> interface,
<code>getColumnNumber()</code>. (Third-party implementations of <code>NodeInfo</code> 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 "&gt;" character that forms the last character of the element's start tag.</p>
      <p>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.</p>
      <p>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 <code>xsl:apply-templates</code> or <code>xsl:for-each</code>).</p>
      <p>The information in the stack trace is also available programmatically through the method <code>iterateStackFrames()</code>
on the <code>XPathContext</code> object.</p>
      <p>The formatted print of the stack trace can be retrieved as a string from within a query or stylesheet using the new extension
function <code>saxon:print-stack()</code>.</p>
      <p>There are some internal changes as a result of this development, which may be noticeable to applications that do debugging
or tracing. The <code>InstructionInfoProvider</code> interface has disappeared; instead all expressions (including instructions)
now implement <code>InstructionInfo</code> directly, as do container objects such as <code>UserFunction</code> and <code>Template</code>.
Generally the <code>getProperties()</code> method of <code>InstructionInfo</code> is not so well supported; applications requiring
properties of expressions should cast the <code>InstructionInfo</code> to the required class and get the information directly from
the expression tree.</p>
      <p>The <code>InstructionInfo</code> object no longer contains a <code>NamespaceResolver</code> - it is no longer needed because
all names are now represented as expanded names.</p>
      <p>New methods are available to allow the output from the <code>trace()</code> function to be directed
to a specified output stream, or to be discarded.</p>
      <p>A new option <code>FeatureKeys.TRACE_LISTENER_CLASS</code> 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 <code>FeatureKeys.TRACE_LISTENER</code> remains available.</p>
      <table width="100%">
         <tr>
            <td>
               <p align="right"><a class="nav" href="dotnet91.xml">Next</a></p>
            </td>
         </tr>
      </table>
   </body>
</html>