I'm an XML/DOM newbie, and am trying to make sense of the few parsing examples I've been able to find. One example is in the Xerces-C DOMPrint sample application, and the other example is in the book C++ XML. The latter example is a simpler case, whose only error handling is by means of catching [XML and DOM] exceptions thrown by the parser. The use of the DOMParser in the Xerces DOMPrint sample application is considerably more complex, and employs the following measures in addition to the exception catching done in the first example:
 
1) It makes use of the parser's getErrorCount method
2) It uses the parser's setErrorHandler method to attach an ErrorHandler to do some additional black magic
 
I'm confused about why so many seemingly overlapping methods of error handling are being used in the DOMPrint example. I would have thought that simply catching the proper exceptions should be sufficient. My Other sources of confusion are:
 
1) The Xerces-C++ API documentation for the ErrorHandler class (Detailed Description) states that the class is for use by a SAX application. Yet the class is being used by DOMPrint, which I don't believe is a SAX application.
2) The same documentation says that if the setErrorHandler method is used, the parser will use that interface instead of throwing an exception. Yet the DOMPrint example is both calling setErrorHandler AND catching exceptions.
 
My quest to find the information that will help me become a self-sufficient DOM programmer has so far been pretty frustrating. I have obtained a few books on XML and DOM, and have also been searching the web for information. Still, I'm having difficulty getting adequate information to make me feel well prepared to properly use of some of the DOM API. I would be very grateful if someone could help clarify some of the questions I've mentioned here, and/or refer me to a source of more detailed information, books, or examples pertaining to the DOM API in general, and the DOMParser in particular.
 
Thank you very much for any assistance,
Bruce Reid

Reply via email to