Name
SourceLocator
Synopsis
This interface defines methods that return
the system and public identifiers of an XML document, and return a
line number and column number within that document.
SourceLocator
objects are used with
TransformerException
and
TransformerConfigurationException
objects to
specify the location in an XML file at which the exception occurred.
Note, however that system and public identifiers are not always
available for a document, and so getSystemId(
)
and getPublicId(
)
may return null
. Also, a
Tranformer
is not required to track line and
column numbers precisely, or at all, so getLineNumber(
)
and
getColumnNumber( )
may return -1 to indicate that
line and column number information is not available. If they return a
value other than -1, it should be considered an approximation to the
actual value. Note that lines and columns within a document are
numbered starting with 1, not with 0.
If you are familiar with the SAX API for parsing XML,
you’ll recognize this interface as a renamed version
of org.xml.sax.Locator
.
public interface SourceLocator { // Public Instance Methods int getColumnNumber( ); int getLineNumber( ); String getPublicId( ); String getSystemId( ); }
Implementations
javax.xml.transform.dom.DOMLocator
Passed To
TransformerConfigurationException.TransformerConfigurationException(
)
, TransformerException.{setLocator( )
,
TransformerException( )}
Returned By
TransformerException.getLocator( )
Get Java in a Nutshell, 5th Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.