|
||||||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||||||
SUMMARY: java.lang.Object
The QXmlDefaultHandler class provides a default implementation of all the XML handler classes. This class gathers together the features of the specialized handler classes, making it a convenient starting point when implementing custom handlers for subclasses of The XML reader must be told which handler to use for different kinds of events during parsing. This means that, although QXmlDefaultHandler provides default implementations of functions inherited from all its base classes, we can still use specialized handlers for particular kinds of events. For example, QXmlDefaultHandler subclasses both xmlReader.setContentHandler(handler); xmlReader.setErrorHandler(handler);Since the reader will inform the handler of parsing errors, it is necessary to reimplement QXmlErrorHandler::fatalError() if, for example, we want to stop parsing when such an error occurs: boolean fatalError (QXmlParseException exception) { System.err.println("Fatal error on line" + exception.lineNumber() + ", column" + exception.columnNumber() + ":" + exception.message()); return false; }The above function returns false, which tells the reader to stop parsing. To continue to use the same reader, it is necessary to create a new handler instance, and set up the reader to use it in the manner described above. It is useful to examine some of the functions inherited by QXmlDefaultHandler, and consider why they might be reimplemented in a custom handler. Custom handlers will typically reimplement QXmlDTDHandler , QXmlDeclHandler , QXmlContentHandler , QXmlEntityResolver , QXmlErrorHandler , QXmlLexicalHandler , and Introduction to SAX2.
QXmlDefaultHandlerpublic QXmlDefaultHandler()
|