# The saxon:supply-source-locator attribute

This attribute is relevant only when output is sent to a user-written `ContentHandler`, that is, a `SAXResult`. It causes extra information to be maintained and made available to the `ContentHandler` for diagnostic purposes: specifically, the `Locator` that is passed to the `ContentHandler` via the `setDocumentLocator` method may be cast to a `ContentHandlerProxyLocator`, which exposes the method `getContextItemStack()`. This returns a `java.util.Stack`. 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 `net.sf.saxon.om.Item`. 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.

For this to work, the code must be compiled with tracing enabled. This can be achieved by setting the option `config.setCompileWithTracing(true)` on the `Configuration` object, or equivalently by setting the property `FeatureKeys.COMPILE_WITH_TRACING` on the JAXP `TransformerFactory`. 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 `TraceListener`.

Next