Name
Locator
Synopsis
Objects called locators are used to provide
access to information about where events occur in the document. The
application receives a locator by implementing the setDocumentLocator
method on the content handler. Locator objects provide methods
that allow the application to determine which entity was being parsed
when the event occurred, and where in the entity the parse had
reached. The SAXParseException
exception class also conforms to the Locator
interface.
The information provided by these methods can be extremely valuable in reporting problems with your documents in an application. For example, if a purchase order document has a price that is out of range, or a part number that does not exist in your database, you could aid in debugging by providing specific details about the location in the XML document where the problem occurred. This could be used to direct an editor widget to position the cursor where the problem is found so that the user can correct the document.
getColumnNumber( )
Returns the character offset within the line on which the parse event occurred. The column is not adjusted for tab characters.
getLineNumber( )
Returns the number of the line on which the parse event occurred. The first line is numbered
1
rather than0
.getPublicId( )
Returns the public identifier of the entity being parsed, if one is known. If there isn’t one,
None
is returned.getSystemId( )
Returns the system identifier of the entity being parsed when the event occurred, ...
Get Python & XML 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.