|  | Home · All Classes · Modules

# QXmlDefaultHandler Class Reference
[QtXml module]

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

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

### Methods

- __init__ (self)
- bool attributeDecl (self, QString eName, QString aName, QString type, QString valueDefault, QString value)
- bool characters (self, QString ch)
- bool comment (self, QString ch)
- bool endCDATA (self)
- bool endDocument (self)
- bool endDTD (self)
- bool endElement (self, QString namespaceURI, QString localName, QString qName)
- bool endEntity (self, QString name)
- bool endPrefixMapping (self, QString prefix)
- bool error (self, QXmlParseException exception)
- QString errorString (self)
- bool externalEntityDecl (self, QString name, QString publicId, QString systemId)
- bool fatalError (self, QXmlParseException exception)
- bool ignorableWhitespace (self, QString ch)
- bool internalEntityDecl (self, QString name, QString value)
- bool notationDecl (self, QString name, QString publicId, QString systemId)
- bool processingInstruction (self, QString target, QString data)
- (bool, QXmlInputSource ret) resolveEntity (self, QString publicId, QString systemId)
- setDocumentLocator (self, QXmlLocator locator)
- bool skippedEntity (self, QString name)
- bool startCDATA (self)
- bool startDocument (self)
- bool startDTD (self, QString name, QString publicId, QString systemId)
- bool startElement (self, QString namespaceURI, QString localName, QString qName, QXmlAttributes atts)
- bool startEntity (self, QString name)
- bool startPrefixMapping (self, QString prefix, QString uri)
- bool unparsedEntityDecl (self, QString name, QString publicId, QString systemId, QString notationName)
- bool warning (self, 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.

## Method Documentation

### QXmlDefaultHandler.__init__ (self)

Constructs a handler for use with subclasses of QXmlReader.

### bool QXmlDefaultHandler.attributeDecl (self, QString eName, QString aName, QString type, QString valueDefault, QString value)

Reimplemented from QXmlDeclHandler.attributeDecl().

This reimplementation does nothing.

### bool QXmlDefaultHandler.characters (self, QString ch)

Reimplemented from QXmlContentHandler.characters().

This reimplementation does nothing.

### bool QXmlDefaultHandler.comment (self, QString ch)

Reimplemented from QXmlLexicalHandler.comment().

This reimplementation does nothing.

### bool QXmlDefaultHandler.endCDATA (self)

Reimplemented from QXmlLexicalHandler.endCDATA().

This reimplementation does nothing.

### bool QXmlDefaultHandler.endDocument (self)

Reimplemented from QXmlContentHandler.endDocument().

This reimplementation does nothing.

### bool QXmlDefaultHandler.endDTD (self)

Reimplemented from QXmlLexicalHandler.endDTD().

This reimplementation does nothing.

### bool QXmlDefaultHandler.endElement (self, QString namespaceURI, QString localName, QString qName)

Reimplemented from QXmlContentHandler.endElement().

This reimplementation does nothing.

### bool QXmlDefaultHandler.endEntity (self, QString name)

Reimplemented from QXmlLexicalHandler.endEntity().

This reimplementation does nothing.

### bool QXmlDefaultHandler.endPrefixMapping (self, QString prefix)

Reimplemented from QXmlContentHandler.endPrefixMapping().

This reimplementation does nothing.

### bool QXmlDefaultHandler.error (self, QXmlParseException exception)

Reimplemented from QXmlErrorHandler.error().

This reimplementation does nothing.

### QString QXmlDefaultHandler.errorString (self)

Reimplemented from QXmlContentHandler.errorString().

Returns the default error string.

### bool QXmlDefaultHandler.externalEntityDecl (self, QString name, QString publicId, QString systemId)

Reimplemented from QXmlDeclHandler.externalEntityDecl().

This reimplementation does nothing.

### bool QXmlDefaultHandler.fatalError (self, QXmlParseException exception)

Reimplemented from QXmlErrorHandler.fatalError().

This reimplementation does nothing.

### bool QXmlDefaultHandler.ignorableWhitespace (self, QString ch)

Reimplemented from QXmlContentHandler.ignorableWhitespace().

This reimplementation does nothing.

### bool QXmlDefaultHandler.internalEntityDecl (self, QString name, QString value)

Reimplemented from QXmlDeclHandler.internalEntityDecl().

This reimplementation does nothing.

### bool QXmlDefaultHandler.notationDecl (self, QString name, QString publicId, QString systemId)

Reimplemented from QXmlDTDHandler.notationDecl().

This reimplementation does nothing.

### bool QXmlDefaultHandler.processingInstruction (self, QString target, QString data)

Reimplemented from QXmlContentHandler.processingInstruction().

This reimplementation does nothing.

### (bool, QXmlInputSource ret) QXmlDefaultHandler.resolveEntity (self, QString publicId, QString systemId)

Reimplemented from QXmlEntityResolver.resolveEntity().

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

### QXmlDefaultHandler.setDocumentLocator (self, QXmlLocator locator)

Reimplemented from QXmlContentHandler.setDocumentLocator().

This reimplementation does nothing.

### bool QXmlDefaultHandler.skippedEntity (self, QString name)

Reimplemented from QXmlContentHandler.skippedEntity().

This reimplementation does nothing.

### bool QXmlDefaultHandler.startCDATA (self)

Reimplemented from QXmlLexicalHandler.startCDATA().

This reimplementation does nothing.

### bool QXmlDefaultHandler.startDocument (self)

Reimplemented from QXmlContentHandler.startDocument().

This reimplementation does nothing.

### bool QXmlDefaultHandler.startDTD (self, QString name, QString publicId, QString systemId)

Reimplemented from QXmlLexicalHandler.startDTD().

This reimplementation does nothing.

### bool QXmlDefaultHandler.startElement (self, QString namespaceURI, QString localName, QString qName, QXmlAttributes atts)

Reimplemented from QXmlContentHandler.startElement().

This reimplementation does nothing.

### bool QXmlDefaultHandler.startEntity (self, QString name)

Reimplemented from QXmlLexicalHandler.startEntity().

This reimplementation does nothing.

### bool QXmlDefaultHandler.startPrefixMapping (self, QString prefix, QString uri)

Reimplemented from QXmlContentHandler.startPrefixMapping().

This reimplementation does nothing.

### bool QXmlDefaultHandler.unparsedEntityDecl (self, QString name, QString publicId, QString systemId, QString notationName)

Reimplemented from QXmlDTDHandler.unparsedEntityDecl().

This reimplementation does nothing.

### bool QXmlDefaultHandler.warning (self, QXmlParseException exception)

Reimplemented from QXmlErrorHandler.warning().

This reimplementation does nothing.