<?xml version="1.0" encoding="iso-8859-1"?>
<?xml-stylesheet href="../../make-menu.xsl" type="text/xsl"?><html>
   <head>
      <this-is section="extensions" page="output-extras" subpage="supply-source-locator"/>
      <!--
           Generated at 2010-10-29T18:20:48.427+01:00--><title>Saxonica: XSLT and XQuery Processing: The saxon:supply-source-locator attribute</title>
      <meta name="coverage" content="Worldwide"/>
      <meta name="copyright" content="Copyright Saxonica Ltd"/>
      <meta name="title"
            content="Saxonica: XSLT and XQuery Processing: The saxon:supply-source-locator attribute"/>
      <meta name="robots" content="noindex,nofollow"/>
      <link rel="stylesheet" href="../../saxondocs.css" type="text/css"/>
   </head>
   <body class="main">
      <h1>The saxon:supply-source-locator attribute</h1>
      <p>This attribute is relevant only when output is sent to a user-written <code>ContentHandler</code>,
that is, a <code>SAXResult</code>. It causes extra information to be maintained and made available to
the <code>ContentHandler</code> for diagnostic purposes: specifically, the <code>Locator</code> that is
passed to the <code>ContentHandler</code> via the <code>setDocumentLocator</code> method may be cast to a
<code>ContentHandlerProxyLocator</code>, which exposes the method <code>getContextItemStack()</code>. This
returns a <code>java.util.Stack</code>. The top item on the stack is the current context item, and below this
are previous context items. Each item is represented by the interface <code>net.sf.saxon.om.Item</code>. If
the item is a node, and if the node is one derived by parsing a source document with the line-numbering
option enabled, then it is possible to obtain the URI and line number of this node in the original XML source.</p>
      <p>For this to work, the code must be compiled with tracing enabled. This can be achieved by setting the option
<code>config.setCompileWithTracing(true)</code> on the <code>Configuration</code> object, or equivalently by
setting the property <code>FeatureKeys.COMPILE_WITH_TRACING</code> on the JAXP <code>TransformerFactory</code>.
Note that this compile-time option imposes a substantial run-time overhead, even if tracing is not switched on
at run-time by providing a <code>TraceListener</code>.</p>
      <table width="100%">
         <tr>
            <td>
               <p align="right"><a class="nav" href="suppress-indentation.xml">Next</a></p>
            </td>
         </tr>
      </table>
   </body>
</html>