Identifying Document and Event Locations

The SAX package contains an interface called Locator. This interface provides methods with which you can associate an event with its location in the document.

Specifically, by using the methods of the Locator interface, you can find out the following information:

  • The public identifier (URN) of the document being parsed

  • The system identifier (URL) of the document being parsed

  • The line number in the XML document where a particular event occurred

  • The column number in the XML document where a particular event occurred

URN VERSUS URL

A URN is an Internet resource that is persistent and location-independent. A URL is a type of URN. For example, an URN could look like the following:

urn:def://turbo_engines

Get Java™ APIs for XML Kick Start 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.