Stephen Collyer wrote:
David Bertoni wrote:
Stephen Collyer wrote:
Is it possible to retrieve the required id
and line/col info from within, say, start_element()
in order to construct a SAXParseException ?
You need to override ContentHandler::setLocator() and store the pointer
in your object. During parsing event handlers, you can use the object
to get this information.
I guess you mean setDocumentLocator() ?
So to use this, I create a Locator object, pass it to
setDocumentLocator(). Then the Xerces parser code will
set the appropriate error info, which I can retrieve
in, say, the warning(), error() methods of an error
handler class ?
Yes, that's the right call, but you've reversed what you need to do. Your
ContentHandler implementation should override setDocumentLocator() and
store that pointer. Then, during parsing callbacks (and only during them),
you can call the accessor functions to get the information you need. The
parser has to provide you with an instance of a Locator, since it's parsing
the document.
Dave