Home · All Classes · All Functions · Overviews

QXmlDefaultHandler Class Reference
[
QtXml module]

The QXmlDefaultHandler class provides a default implementation of all the XML handler classes. More...

 #include <QXmlDefaultHandler>

This class is not part of the Qt GUI Framework Edition.

Inherits QXmlContentHandler, QXmlErrorHandler, QXmlDTDHandler, QXmlEntityResolver, QXmlLexicalHandler, and QXmlDeclHandler.

Note: All functions in this class are reentrant.


Public Functions

QXmlDefaultHandler ()
virtual ~QXmlDefaultHandler ()

Reimplemented Public Functions

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 )

Detailed Description

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 QXmlReader, particularly QXmlSimpleReader. 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, 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 QXmlContentHandler and QXmlErrorHandler, 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 reimplement QXmlErrorHandler::fatalError() if, for example, we want to stop parsing when such an error occurs:

 bool Handler::fatalError (const QXmlParseException & exception)
 {
     qWarning() << "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 QXmlContentHandler::startDocument() to prepare the handler for new content. Document elements and the text within them can be processed by reimplementing QXmlContentHandler::startElement(), QXmlContentHandler::endElement(), and QXmlContentHandler::characters(). You may want to reimplement QXmlContentHandler::endDocument() to perform some finalization or validation on the content once the document has been read completely.

See also QXmlDTDHandler, QXmlDeclHandler, QXmlContentHandler, QXmlEntityResolver, QXmlErrorHandler, QXmlLexicalHandler, and Introduction to SAX2.


Member Function Documentation

QXmlDefaultHandler::QXmlDefaultHandler ()

Constructs a handler for use with subclasses of QXmlReader.

QXmlDefaultHandler::~QXmlDefaultHandler ()   [virtual]

Destroys the handler.

bool QXmlDefaultHandler::attributeDecl ( const QString & eName, const QString & aName, const QString & type, const QString & valueDefault, const QString & value )   [virtual]

Reimplemented from QXmlDeclHandler::attributeDecl().

This reimplementation does nothing.

bool QXmlDefaultHandler::characters ( const QString & ch )   [virtual]

Reimplemented from QXmlContentHandler::characters().

This reimplementation does nothing.

bool QXmlDefaultHandler::comment ( const QString & ch )   [virtual]

Reimplemented from QXmlLexicalHandler::comment().

This reimplementation does nothing.

bool QXmlDefaultHandler::endCDATA ()   [virtual]

Reimplemented from QXmlLexicalHandler::endCDATA().

This reimplementation does nothing.

bool QXmlDefaultHandler::endDTD ()   [virtual]

Reimplemented from QXmlLexicalHandler::endDTD().

This reimplementation does nothing.

bool QXmlDefaultHandler::endDocument ()   [virtual]

Reimplemented from QXmlContentHandler::endDocument().

This reimplementation does nothing.

bool QXmlDefaultHandler::endElement ( const QString & namespaceURI, const QString & localName, const QString & qName )   [virtual]

Reimplemented from QXmlContentHandler::endElement().

This reimplementation does nothing.

bool QXmlDefaultHandler::endEntity ( const QString & name )   [virtual]

Reimplemented from QXmlLexicalHandler::endEntity().

This reimplementation does nothing.

bool QXmlDefaultHandler::endPrefixMapping ( const QString & prefix )   [virtual]

Reimplemented from QXmlContentHandler::endPrefixMapping().

This reimplementation does nothing.

bool QXmlDefaultHandler::error ( const QXmlParseException & exception )   [virtual]

Reimplemented from QXmlErrorHandler::error().

This reimplementation does nothing.

QString QXmlDefaultHandler::errorString () const   [virtual]

Reimplemented from QXmlContentHandler::errorString().

Returns the default error string.

bool QXmlDefaultHandler::externalEntityDecl ( const QString & name, const QString & publicId, const QString & systemId )   [virtual]

Reimplemented from QXmlDeclHandler::externalEntityDecl().

This reimplementation does nothing.

bool QXmlDefaultHandler::fatalError ( const QXmlParseException & exception )   [virtual]

Reimplemented from QXmlErrorHandler::fatalError().

This reimplementation does nothing.

bool QXmlDefaultHandler::ignorableWhitespace ( const QString & ch )   [virtual]

Reimplemented from QXmlContentHandler::ignorableWhitespace().

This reimplementation does nothing.

bool QXmlDefaultHandler::internalEntityDecl ( const QString & name, const QString & value )   [virtual]

Reimplemented from QXmlDeclHandler::internalEntityDecl().

This reimplementation does nothing.

bool QXmlDefaultHandler::notationDecl ( const QString & name, const QString & publicId, const QString & systemId )   [virtual]

Reimplemented from QXmlDTDHandler::notationDecl().

This reimplementation does nothing.

bool QXmlDefaultHandler::processingInstruction ( const QString & target, const QString & data )   [virtual]

Reimplemented from QXmlContentHandler::processingInstruction().

This reimplementation does nothing.

bool QXmlDefaultHandler::resolveEntity ( const QString & publicId, const QString & systemId, QXmlInputSource *& ret )   [virtual]

Reimplemented from QXmlEntityResolver::resolveEntity().

Sets ret to 0, so that the reader uses the system identifier provided in the XML document.

void QXmlDefaultHandler::setDocumentLocator ( QXmlLocator * locator )   [virtual]

Reimplemented from QXmlContentHandler::setDocumentLocator().

This reimplementation does nothing.

bool QXmlDefaultHandler::skippedEntity ( const QString & name )   [virtual]

Reimplemented from QXmlContentHandler::skippedEntity().

This reimplementation does nothing.

bool QXmlDefaultHandler::startCDATA ()   [virtual]

Reimplemented from QXmlLexicalHandler::startCDATA().

This reimplementation does nothing.

bool QXmlDefaultHandler::startDTD ( const QString & name, const QString & publicId, const QString & systemId )   [virtual]

Reimplemented from QXmlLexicalHandler::startDTD().

This reimplementation does nothing.

bool QXmlDefaultHandler::startDocument ()   [virtual]

Reimplemented from QXmlContentHandler::startDocument().

This reimplementation does nothing.

bool QXmlDefaultHandler::startElement ( const QString & namespaceURI, const QString & localName, const QString & qName, const QXmlAttributes & atts )   [virtual]

Reimplemented from QXmlContentHandler::startElement().

This reimplementation does nothing.

bool QXmlDefaultHandler::startEntity ( const QString & name )   [virtual]

Reimplemented from QXmlLexicalHandler::startEntity().

This reimplementation does nothing.

bool QXmlDefaultHandler::startPrefixMapping ( const QString & prefix, const QString & uri )   [virtual]

Reimplemented from QXmlContentHandler::startPrefixMapping().

This reimplementation does nothing.

bool QXmlDefaultHandler::unparsedEntityDecl ( const QString & name, const QString & publicId, const QString & systemId, const QString & notationName )   [virtual]

Reimplemented from QXmlDTDHandler::unparsedEntityDecl().

This reimplementation does nothing.

bool QXmlDefaultHandler::warning ( const QXmlParseException & exception )   [virtual]

Reimplemented from QXmlErrorHandler::warning().

This reimplementation does nothing.


Copyright © 2009 Nokia Corporation and/or its subsidiary(-ies) Trademarks
Qt 4.6.0