CopperSpice API  1.7.2
QXmlDefaultHandler Class Reference

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

Inheritance diagram for QXmlDefaultHandler:
QXmlContentHandler QXmlErrorHandler QXmlDTDHandler QXmlEntityResolver QXmlLexicalHandler QXmlDeclHandler

Public Methods

 QXmlDefaultHandler ()
 
virtual ~QXmlDefaultHandler ()
 
bool attributeDecl (const QString &eName, const QString &aName, const QString &type, const QString &valueDefault, const QString &value) override
 
bool characters (const QString &ch) override
 
bool comment (const QString &ch) override
 
bool endCDATA () override
 
bool endDocument () override
 
bool endDTD () override
 
bool endElement (const QString &namespaceURI, const QString &localName, const QString &qName) override
 
bool endEntity (const QString &name) override
 
bool endPrefixMapping (const QString &prefix) override
 
bool error (const QXmlParseException &exception) override
 
QString errorString () const override
 
bool externalEntityDecl (const QString &name, const QString &publicId, const QString &systemId) override
 
bool fatalError (const QXmlParseException &exception) override
 
bool ignorableWhitespace (const QString &ch) override
 
bool internalEntityDecl (const QString &name, const QString &value) override
 
bool notationDecl (const QString &name, const QString &publicId, const QString &systemId) override
 
bool processingInstruction (const QString &target, const QString &data) override
 
bool resolveEntity (const QString &publicId, const QString &systemId, QXmlInputSource *&inputSource) override
 
void setDocumentLocator (QXmlLocator *locator) override
 
bool skippedEntity (const QString &name) override
 
bool startCDATA () override
 
bool startDocument () override
 
bool startDTD (const QString &name, const QString &publicId, const QString &systemId) override
 
bool startElement (const QString &namespaceURI, const QString &localName, const QString &qName, const QXmlAttributes &atts) override
 
bool startEntity (const QString &name) override
 
bool startPrefixMapping (const QString &prefix, const QString &uri) override
 
bool unparsedEntityDecl (const QString &name, const QString &publicId, const QString &systemId, const QString &notationName) override
 
bool warning (const QXmlParseException &exception) override
 
- Public Methods inherited from QXmlContentHandler
virtual ~QXmlContentHandler ()
 
virtual bool characters (const QString &ch) = 0
 
virtual bool endDocument () = 0
 
virtual bool endElement (const QString &namespaceURI, const QString &localName, const QString &qName) = 0
 
virtual bool endPrefixMapping (const QString &prefix) = 0
 
virtual QString errorString () const = 0
 
virtual bool ignorableWhitespace (const QString &ch) = 0
 
virtual bool processingInstruction (const QString &target, const QString &data) = 0
 
virtual void setDocumentLocator (QXmlLocator *locator) = 0
 
virtual bool skippedEntity (const QString &name) = 0
 
virtual bool startDocument () = 0
 
virtual bool startElement (const QString &namespaceURI, const QString &localName, const QString &qName, const QXmlAttributes &atts) = 0
 
virtual bool startPrefixMapping (const QString &prefix, const QString &uri) = 0
 
- Public Methods inherited from QXmlErrorHandler
virtual ~QXmlErrorHandler ()
 
virtual bool error (const QXmlParseException &exception) = 0
 
virtual QString errorString () const = 0
 
virtual bool fatalError (const QXmlParseException &exception) = 0
 
virtual bool warning (const QXmlParseException &exception) = 0
 
- Public Methods inherited from QXmlDTDHandler
virtual ~QXmlDTDHandler ()
 
virtual QString errorString () const = 0
 
virtual bool notationDecl (const QString &name, const QString &publicId, const QString &systemId) = 0
 
virtual bool unparsedEntityDecl (const QString &name, const QString &publicId, const QString &systemId, const QString &notationName) = 0
 
- Public Methods inherited from QXmlEntityResolver
virtual ~QXmlEntityResolver ()
 
virtual QString errorString () const = 0
 
virtual bool resolveEntity (const QString &publicId, const QString &systemId, QXmlInputSource *&inputSource) = 0
 
- Public Methods inherited from QXmlLexicalHandler
virtual ~QXmlLexicalHandler ()
 
virtual bool comment (const QString &ch) = 0
 
virtual bool endCDATA () = 0
 
virtual bool endDTD () = 0
 
virtual bool endEntity (const QString &name) = 0
 
virtual QString errorString () const = 0
 
virtual bool startCDATA () = 0
 
virtual bool startDTD (const QString &name, const QString &publicId, const QString &systemId) = 0
 
virtual bool startEntity (const QString &name) = 0
 
- Public Methods inherited from QXmlDeclHandler
virtual ~QXmlDeclHandler ()
 

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, Introduction to SAX2

Constructor & Destructor Documentation

QXmlDefaultHandler::QXmlDefaultHandler ( )
inline

Constructs a handler for use with subclasses of QXmlReader.

QXmlDefaultHandler::~QXmlDefaultHandler ( )
inlinevirtual

Destroys the handler.

Method Documentation

bool QXmlDefaultHandler::attributeDecl ( const QString eName,
const QString aName,
const QString type,
const QString valueDefault,
const QString value 
)
overridevirtual

This reimplementation does nothing.

Implements QXmlDeclHandler.

bool QXmlDefaultHandler::characters ( const QString ch)
override

This reimplementation does nothing.

bool QXmlDefaultHandler::comment ( const QString ch)
override

This reimplementation does nothing.

bool QXmlDefaultHandler::endCDATA ( )
override

This reimplementation does nothing.

bool QXmlDefaultHandler::endDocument ( )
override

This reimplementation does nothing.

bool QXmlDefaultHandler::endDTD ( )
override

This reimplementation does nothing.

bool QXmlDefaultHandler::endElement ( const QString namespaceURI,
const QString localName,
const QString qName 
)
override

This reimplementation does nothing.

bool QXmlDefaultHandler::endEntity ( const QString name)
override

This reimplementation does nothing.

bool QXmlDefaultHandler::endPrefixMapping ( const QString prefix)
override

This reimplementation does nothing.

bool QXmlDefaultHandler::error ( const QXmlParseException exception)
override

This reimplementation does nothing.

QString QXmlDefaultHandler::errorString ( ) const
overridevirtual

Returns the default error string.

Implements QXmlDeclHandler.

bool QXmlDefaultHandler::externalEntityDecl ( const QString name,
const QString publicId,
const QString systemId 
)
overridevirtual

This reimplementation does nothing.

Implements QXmlDeclHandler.

bool QXmlDefaultHandler::fatalError ( const QXmlParseException exception)
override

This reimplementation does nothing.

bool QXmlDefaultHandler::ignorableWhitespace ( const QString ch)
override

This reimplementation does nothing.

bool QXmlDefaultHandler::internalEntityDecl ( const QString name,
const QString value 
)
overridevirtual

This reimplementation does nothing.

Implements QXmlDeclHandler.

bool QXmlDefaultHandler::notationDecl ( const QString name,
const QString publicId,
const QString systemId 
)
override

This reimplementation does nothing.

bool QXmlDefaultHandler::processingInstruction ( const QString target,
const QString data 
)
override

This reimplementation does nothing.

bool QXmlDefaultHandler::resolveEntity ( const QString publicId,
const QString systemId,
QXmlInputSource *&  inputSource 
)
override

Sets inputSource to a nullptr. The reader will use the system identifier provided in the XML document.

void QXmlDefaultHandler::setDocumentLocator ( QXmlLocator locator)
override

This reimplementation does nothing.

bool QXmlDefaultHandler::skippedEntity ( const QString name)
override

This reimplementation does nothing.

bool QXmlDefaultHandler::startCDATA ( )
override

This reimplementation does nothing.

bool QXmlDefaultHandler::startDocument ( )
override

This reimplementation does nothing.

bool QXmlDefaultHandler::startDTD ( const QString name,
const QString publicId,
const QString systemId 
)
override

This reimplementation does nothing.

bool QXmlDefaultHandler::startElement ( const QString namespaceURI,
const QString localName,
const QString qName,
const QXmlAttributes atts 
)
override

This reimplementation does nothing.

bool QXmlDefaultHandler::startEntity ( const QString name)
override

This reimplementation does nothing.

bool QXmlDefaultHandler::startPrefixMapping ( const QString prefix,
const QString uri 
)
override

This reimplementation does nothing.

bool QXmlDefaultHandler::unparsedEntityDecl ( const QString name,
const QString publicId,
const QString systemId,
const QString notationName 
)
override

This reimplementation does nothing.

bool QXmlDefaultHandler::warning ( const QXmlParseException exception)
override

This reimplementation does nothing.