
We bake cookies in your browser for a better experience. Using this site means that you consent.Read More
TheQXmlDefaultHandler class provides a default implementation of all the XML handler classes.More...
| Header: | #include <QXmlDefaultHandler> |
| Inherits: | QXmlContentHandler,QXmlErrorHandler,QXmlDTDHandler,QXmlEntityResolver,QXmlLexicalHandler, andQXmlDeclHandler |
Note: All functions in this class arereentrant.
| QXmlDefaultHandler() | |
| virtual | ~QXmlDefaultHandler() |
| virtual bool | attributeDecl(const QString & eName, const QString & aName, const QString & type, const QString & valueDefault, const QString & value) |
| virtual bool | characters(const QString & ch) |
| virtual bool | comment(const QString & ch) |
| virtual bool | endCDATA() |
| virtual bool | endDTD() |
| virtual bool | endDocument() |
| virtual bool | endElement(const QString & namespaceURI, const QString & localName, const QString & qName) |
| virtual bool | endEntity(const QString & name) |
| virtual bool | endPrefixMapping(const QString & prefix) |
| virtual bool | error(const QXmlParseException & exception) |
| virtual QString | errorString() const |
| virtual bool | externalEntityDecl(const QString & name, const QString & publicId, const QString & systemId) |
| virtual bool | fatalError(const QXmlParseException & exception) |
| virtual bool | ignorableWhitespace(const QString & ch) |
| virtual bool | internalEntityDecl(const QString & name, const QString & value) |
| virtual bool | notationDecl(const QString & name, const QString & publicId, const QString & systemId) |
| virtual bool | processingInstruction(const QString & target, const QString & data) |
| virtual bool | resolveEntity(const QString & publicId, const QString & systemId, QXmlInputSource *& ret) |
| virtual void | setDocumentLocator(QXmlLocator * locator) |
| virtual bool | skippedEntity(const QString & name) |
| virtual bool | startCDATA() |
| virtual bool | startDTD(const QString & name, const QString & publicId, const QString & systemId) |
| virtual bool | startDocument() |
| virtual bool | startElement(const QString & namespaceURI, const QString & localName, const QString & qName, const QXmlAttributes & atts) |
| virtual bool | startEntity(const QString & name) |
| virtual bool | startPrefixMapping(const QString & prefix, const QString & uri) |
| virtual bool | unparsedEntityDecl(const QString & name, const QString & publicId, const QString & systemId, const QString & notationName) |
| virtual bool | warning(const QXmlParseException & exception) |
TheQXmlDefaultHandler 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 ofQXmlReader, particularlyQXmlSimpleReader. The virtual functions from each of the base classes are reimplemented in this class, providing sensible default behavior for many common cases. By subclassing this class, and overriding these functions, you can concentrate on implementing the parts of the handler relevant to your application.
The XML reader must be told which handler to use for different kinds of events during parsing. This means that, althoughQXmlDefaultHandler 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 bothQXmlContentHandler andQXmlErrorHandler, so by subclassing it we can use the same handler for both of the following reader functions:
xmlReader.setContentHandler(handler); xmlReader.setErrorHandler(handler);
Since the reader will inform the handler of parsing errors, it is necessary to reimplementQXmlErrorHandler::fatalError() if, for example, we want to stop parsing when such an error occurs:
bool Handler::fatalError (constQXmlParseException& exception){qWarning()<<"Fatal error on line"<< exception.lineNumber()<<", column"<< exception.columnNumber()<<":"<< exception.message();returnfalse;}
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 byQXmlDefaultHandler, and consider why they might be reimplemented in a custom handler. Custom handlers will typically reimplementQXmlContentHandler::startDocument() to prepare the handler for new content. Document elements and the text within them can be processed by reimplementingQXmlContentHandler::startElement(),QXmlContentHandler::endElement(), andQXmlContentHandler::characters(). You may want to reimplementQXmlContentHandler::endDocument() to perform some finalization or validation on the content once the document has been read completely.
See alsoQXmlDTDHandler,QXmlDeclHandler,QXmlContentHandler,QXmlEntityResolver,QXmlErrorHandler,QXmlLexicalHandler, andIntroduction to SAX2.
Constructs a handler for use with subclasses ofQXmlReader.
[virtual]QXmlDefaultHandler::~QXmlDefaultHandler()Destroys the handler.
[virtual]bool QXmlDefaultHandler::attributeDecl(constQString & eName, constQString & aName, constQString & type, constQString & valueDefault, constQString & value)Reimplemented fromQXmlDeclHandler::attributeDecl().
This reimplementation does nothing.
[virtual]bool QXmlDefaultHandler::characters(constQString & ch)Reimplemented fromQXmlContentHandler::characters().
This reimplementation does nothing.
[virtual]bool QXmlDefaultHandler::comment(constQString & ch)Reimplemented fromQXmlLexicalHandler::comment().
This reimplementation does nothing.
[virtual]bool QXmlDefaultHandler::endCDATA()Reimplemented fromQXmlLexicalHandler::endCDATA().
This reimplementation does nothing.
[virtual]bool QXmlDefaultHandler::endDTD()Reimplemented fromQXmlLexicalHandler::endDTD().
This reimplementation does nothing.
[virtual]bool QXmlDefaultHandler::endDocument()Reimplemented fromQXmlContentHandler::endDocument().
This reimplementation does nothing.
[virtual]bool QXmlDefaultHandler::endElement(constQString & namespaceURI, constQString & localName, constQString & qName)Reimplemented fromQXmlContentHandler::endElement().
This reimplementation does nothing.
[virtual]bool QXmlDefaultHandler::endEntity(constQString & name)Reimplemented fromQXmlLexicalHandler::endEntity().
This reimplementation does nothing.
[virtual]bool QXmlDefaultHandler::endPrefixMapping(constQString & prefix)Reimplemented fromQXmlContentHandler::endPrefixMapping().
This reimplementation does nothing.
[virtual]bool QXmlDefaultHandler::error(constQXmlParseException & exception)Reimplemented fromQXmlErrorHandler::error().
This reimplementation does nothing.
[virtual]QString QXmlDefaultHandler::errorString() constReimplemented fromQXmlContentHandler::errorString().
Returns the default error string.
[virtual]bool QXmlDefaultHandler::externalEntityDecl(constQString & name, constQString & publicId, constQString & systemId)Reimplemented fromQXmlDeclHandler::externalEntityDecl().
This reimplementation does nothing.
[virtual]bool QXmlDefaultHandler::fatalError(constQXmlParseException & exception)Reimplemented fromQXmlErrorHandler::fatalError().
This reimplementation does nothing.
[virtual]bool QXmlDefaultHandler::ignorableWhitespace(constQString & ch)Reimplemented fromQXmlContentHandler::ignorableWhitespace().
This reimplementation does nothing.
[virtual]bool QXmlDefaultHandler::internalEntityDecl(constQString & name, constQString & value)Reimplemented fromQXmlDeclHandler::internalEntityDecl().
This reimplementation does nothing.
[virtual]bool QXmlDefaultHandler::notationDecl(constQString & name, constQString & publicId, constQString & systemId)Reimplemented fromQXmlDTDHandler::notationDecl().
This reimplementation does nothing.
[virtual]bool QXmlDefaultHandler::processingInstruction(constQString & target, constQString & data)Reimplemented fromQXmlContentHandler::processingInstruction().
This reimplementation does nothing.
[virtual]bool QXmlDefaultHandler::resolveEntity(constQString & publicId, constQString & systemId,QXmlInputSource *& ret)Reimplemented fromQXmlEntityResolver::resolveEntity().
Setsret to 0, so that the reader uses the system identifier provided in the XML document.
[virtual]void QXmlDefaultHandler::setDocumentLocator(QXmlLocator * locator)Reimplemented fromQXmlContentHandler::setDocumentLocator().
This reimplementation does nothing.
[virtual]bool QXmlDefaultHandler::skippedEntity(constQString & name)Reimplemented fromQXmlContentHandler::skippedEntity().
This reimplementation does nothing.
[virtual]bool QXmlDefaultHandler::startCDATA()Reimplemented fromQXmlLexicalHandler::startCDATA().
This reimplementation does nothing.
[virtual]bool QXmlDefaultHandler::startDTD(constQString & name, constQString & publicId, constQString & systemId)Reimplemented fromQXmlLexicalHandler::startDTD().
This reimplementation does nothing.
[virtual]bool QXmlDefaultHandler::startDocument()Reimplemented fromQXmlContentHandler::startDocument().
This reimplementation does nothing.
[virtual]bool QXmlDefaultHandler::startElement(constQString & namespaceURI, constQString & localName, constQString & qName, constQXmlAttributes & atts)Reimplemented fromQXmlContentHandler::startElement().
This reimplementation does nothing.
[virtual]bool QXmlDefaultHandler::startEntity(constQString & name)Reimplemented fromQXmlLexicalHandler::startEntity().
This reimplementation does nothing.
[virtual]bool QXmlDefaultHandler::startPrefixMapping(constQString & prefix, constQString & uri)Reimplemented fromQXmlContentHandler::startPrefixMapping().
This reimplementation does nothing.
[virtual]bool QXmlDefaultHandler::unparsedEntityDecl(constQString & name, constQString & publicId, constQString & systemId, constQString & notationName)Reimplemented fromQXmlDTDHandler::unparsedEntityDecl().
This reimplementation does nothing.
[virtual]bool QXmlDefaultHandler::warning(constQXmlParseException & exception)Reimplemented fromQXmlErrorHandler::warning().
This reimplementation does nothing.
© 2016 The Qt Company Ltd. Documentation contributions included herein are the copyrights of their respective owners. The documentation provided herein is licensed under the terms of theGNU Free Documentation License version 1.3 as published by the Free Software Foundation. Qt and respective logos are trademarks of The Qt Company Ltd. in Finland and/or other countries worldwide. All other trademarks are property of their respective owners.