Qt 4.8
Public Functions | Properties | List of all members
QXmlDefaultHandler Class Reference

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

#include <qxml.h>

Inheritance diagram for QXmlDefaultHandler:
QXmlContentHandler QXmlErrorHandler QXmlDTDHandler QXmlEntityResolver QXmlLexicalHandler QXmlDeclHandler QDomHandler

Public Functions

bool attributeDecl (const QString &eName, const QString &aName, const QString &type, const QString &valueDefault, const QString &value)
 This reimplementation does nothing. More...
 
bool characters (const QString &ch)
 This reimplementation does nothing. More...
 
bool comment (const QString &ch)
 This reimplementation does nothing. More...
 
bool endCDATA ()
 This reimplementation does nothing. More...
 
bool endDocument ()
 This reimplementation does nothing. More...
 
bool endDTD ()
 This reimplementation does nothing. More...
 
bool endElement (const QString &namespaceURI, const QString &localName, const QString &qName)
 This reimplementation does nothing. More...
 
bool endEntity (const QString &name)
 This reimplementation does nothing. More...
 
bool endPrefixMapping (const QString &prefix)
 This reimplementation does nothing. More...
 
bool error (const QXmlParseException &exception)
 This reimplementation does nothing. More...
 
QString errorString () const
 Returns the default error string. More...
 
bool externalEntityDecl (const QString &name, const QString &publicId, const QString &systemId)
 This reimplementation does nothing. More...
 
bool fatalError (const QXmlParseException &exception)
 This reimplementation does nothing. More...
 
bool ignorableWhitespace (const QString &ch)
 This reimplementation does nothing. More...
 
bool internalEntityDecl (const QString &name, const QString &value)
 This reimplementation does nothing. More...
 
bool notationDecl (const QString &name, const QString &publicId, const QString &systemId)
 This reimplementation does nothing. More...
 
bool processingInstruction (const QString &target, const QString &data)
 This reimplementation does nothing. More...
 
 QXmlDefaultHandler ()
 Constructs a handler for use with subclasses of QXmlReader. More...
 
bool resolveEntity (const QString &publicId, const QString &systemId, QXmlInputSource *&ret)
 Sets ret to 0, so that the reader uses the system identifier provided in the XML document. More...
 
void setDocumentLocator (QXmlLocator *locator)
 This reimplementation does nothing. More...
 
bool skippedEntity (const QString &name)
 This reimplementation does nothing. More...
 
bool startCDATA ()
 This reimplementation does nothing. More...
 
bool startDocument ()
 This reimplementation does nothing. More...
 
bool startDTD (const QString &name, const QString &publicId, const QString &systemId)
 This reimplementation does nothing. More...
 
bool startElement (const QString &namespaceURI, const QString &localName, const QString &qName, const QXmlAttributes &atts)
 This reimplementation does nothing. More...
 
bool startEntity (const QString &name)
 This reimplementation does nothing. More...
 
bool startPrefixMapping (const QString &prefix, const QString &uri)
 This reimplementation does nothing. More...
 
bool unparsedEntityDecl (const QString &name, const QString &publicId, const QString &systemId, const QString &notationName)
 This reimplementation does nothing. More...
 
bool warning (const QXmlParseException &exception)
 This reimplementation does nothing. More...
 
virtual ~QXmlDefaultHandler ()
 Destroys the handler. More...
 
- Public Functions inherited from QXmlContentHandler
virtual ~QXmlContentHandler ()
 Destroys the content handler. More...
 
- Public Functions inherited from QXmlErrorHandler
virtual ~QXmlErrorHandler ()
 Destroys the error handler. More...
 
- Public Functions inherited from QXmlDTDHandler
virtual ~QXmlDTDHandler ()
 Destroys the DTD handler. More...
 
- Public Functions inherited from QXmlEntityResolver
virtual ~QXmlEntityResolver ()
 Destroys the entity resolver. More...
 
- Public Functions inherited from QXmlLexicalHandler
virtual ~QXmlLexicalHandler ()
 Destroys the lexical handler. More...
 
- Public Functions inherited from QXmlDeclHandler
virtual ~QXmlDeclHandler ()
 Destroys the declaration handler. More...
 

Properties

QXmlDefaultHandlerPrivated
 

Detailed Description

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

Note
This class or function is reentrant.
Attention
Module: QtXml

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}

Definition at line 372 of file qxml.h.

Constructors and Destructors

◆ QXmlDefaultHandler()

QXmlDefaultHandler::QXmlDefaultHandler ( )
inline

Constructs a handler for use with subclasses of QXmlReader.

Definition at line 375 of file qxml.h.

375 { }

◆ ~QXmlDefaultHandler()

QXmlDefaultHandler::~QXmlDefaultHandler ( )
inlinevirtual

Destroys the handler.

Definition at line 376 of file qxml.h.

376 { }

Functions

◆ attributeDecl()

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

This reimplementation does nothing.

Reimplemented Function

Implements QXmlDeclHandler.

Definition at line 2972 of file qxml.cpp.

2973 {
2974  return true;
2975 }

◆ characters()

bool QXmlDefaultHandler::characters ( const QString ch)
virtual

This reimplementation does nothing.

Reimplemented Function

Implements QXmlContentHandler.

Definition at line 2732 of file qxml.cpp.

2733 {
2734  return true;
2735 }

◆ comment()

bool QXmlDefaultHandler::comment ( const QString ch)
virtual

This reimplementation does nothing.

Reimplemented Function

Implements QXmlLexicalHandler.

Definition at line 2959 of file qxml.cpp.

2960 {
2961  return true;
2962 }

◆ endCDATA()

bool QXmlDefaultHandler::endCDATA ( )
virtual

This reimplementation does nothing.

Reimplemented Function

Implements QXmlLexicalHandler.

Definition at line 2946 of file qxml.cpp.

2947 {
2948  return true;
2949 }

◆ endDocument()

bool QXmlDefaultHandler::endDocument ( )
virtual

This reimplementation does nothing.

Reimplemented Function

Implements QXmlContentHandler.

Definition at line 2665 of file qxml.cpp.

2666 {
2667  return true;
2668 }

◆ endDTD()

bool QXmlDefaultHandler::endDTD ( )
virtual

This reimplementation does nothing.

Reimplemented Function

Implements QXmlLexicalHandler.

Definition at line 2894 of file qxml.cpp.

2895 {
2896  return true;
2897 }

◆ endElement()

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

This reimplementation does nothing.

Reimplemented Function

Implements QXmlContentHandler.

Definition at line 2718 of file qxml.cpp.

2720 {
2721  return true;
2722 }

◆ endEntity()

bool QXmlDefaultHandler::endEntity ( const QString name)
virtual

This reimplementation does nothing.

Reimplemented Function

Implements QXmlLexicalHandler.

Definition at line 2920 of file qxml.cpp.

2921 {
2922  return true;
2923 }

◆ endPrefixMapping()

bool QXmlDefaultHandler::endPrefixMapping ( const QString prefix)
virtual

This reimplementation does nothing.

Reimplemented Function

Implements QXmlContentHandler.

Definition at line 2691 of file qxml.cpp.

2692 {
2693  return true;
2694 }

◆ error()

bool QXmlDefaultHandler::error ( const QXmlParseException exception)
virtual

This reimplementation does nothing.

Reimplemented Function

Implements QXmlErrorHandler.

Definition at line 2798 of file qxml.cpp.

2799 {
2800  return true;
2801 }

◆ errorString()

QString QXmlDefaultHandler::errorString ( ) const
virtual

Returns the default error string.

Reimplemented Function

Implements QXmlContentHandler.

Definition at line 2868 of file qxml.cpp.

2869 {
2871 }
static QString fromLatin1(const char *, int size=-1)
Returns a QString initialized with the first size characters of the Latin-1 string str...
Definition: qstring.cpp:4188
#define XMLERR_ERRORBYCONSUMER
Definition: qxml.cpp:60

◆ externalEntityDecl()

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

This reimplementation does nothing.

Reimplemented Function

Implements QXmlDeclHandler.

Definition at line 2998 of file qxml.cpp.

2999 {
3000  return true;
3001 }

◆ fatalError()

bool QXmlDefaultHandler::fatalError ( const QXmlParseException exception)
virtual

This reimplementation does nothing.

Reimplemented Function

Implements QXmlErrorHandler.

Definition at line 2811 of file qxml.cpp.

Referenced by QDomHandler::fatalError().

2812 {
2813  return true;
2814 }

◆ ignorableWhitespace()

bool QXmlDefaultHandler::ignorableWhitespace ( const QString ch)
virtual

This reimplementation does nothing.

Reimplemented Function

Implements QXmlContentHandler.

Definition at line 2745 of file qxml.cpp.

2746 {
2747  return true;
2748 }

◆ internalEntityDecl()

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

This reimplementation does nothing.

Reimplemented Function

Implements QXmlDeclHandler.

Definition at line 2985 of file qxml.cpp.

2986 {
2987  return true;
2988 }

◆ notationDecl()

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

This reimplementation does nothing.

Reimplemented Function

Implements QXmlDTDHandler.

Definition at line 2824 of file qxml.cpp.

2826 {
2827  return true;
2828 }

◆ processingInstruction()

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

This reimplementation does nothing.

Reimplemented Function

Implements QXmlContentHandler.

Definition at line 2758 of file qxml.cpp.

2760 {
2761  return true;
2762 }

◆ resolveEntity()

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

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

Reimplemented Function

Implements QXmlEntityResolver.

Definition at line 2853 of file qxml.cpp.

2855 {
2856  ret = 0;
2857  return true;
2858 }

◆ setDocumentLocator()

void QXmlDefaultHandler::setDocumentLocator ( QXmlLocator locator)
virtual

This reimplementation does nothing.

Reimplemented Function

Implements QXmlContentHandler.

Definition at line 2640 of file qxml.cpp.

2641 {
2642 }

◆ skippedEntity()

bool QXmlDefaultHandler::skippedEntity ( const QString name)
virtual

This reimplementation does nothing.

Reimplemented Function

Implements QXmlContentHandler.

Definition at line 2772 of file qxml.cpp.

2773 {
2774  return true;
2775 }

◆ startCDATA()

bool QXmlDefaultHandler::startCDATA ( )
virtual

This reimplementation does nothing.

Reimplemented Function

Implements QXmlLexicalHandler.

Definition at line 2933 of file qxml.cpp.

2934 {
2935  return true;
2936 }

◆ startDocument()

bool QXmlDefaultHandler::startDocument ( )
virtual

This reimplementation does nothing.

Reimplemented Function

Implements QXmlContentHandler.

Definition at line 2652 of file qxml.cpp.

2653 {
2654  return true;
2655 }

◆ startDTD()

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

This reimplementation does nothing.

Reimplemented Function

Implements QXmlLexicalHandler.

Definition at line 2881 of file qxml.cpp.

2882 {
2883  return true;
2884 }

◆ startElement()

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

This reimplementation does nothing.

Reimplemented Function

Implements QXmlContentHandler.

Definition at line 2704 of file qxml.cpp.

2706 {
2707  return true;
2708 }

◆ startEntity()

bool QXmlDefaultHandler::startEntity ( const QString name)
virtual

This reimplementation does nothing.

Reimplemented Function

Implements QXmlLexicalHandler.

Definition at line 2907 of file qxml.cpp.

2908 {
2909  return true;
2910 }

◆ startPrefixMapping()

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

This reimplementation does nothing.

Reimplemented Function

Implements QXmlContentHandler.

Definition at line 2678 of file qxml.cpp.

2679 {
2680  return true;
2681 }

◆ unparsedEntityDecl()

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

This reimplementation does nothing.

Reimplemented Function

Implements QXmlDTDHandler.

Definition at line 2838 of file qxml.cpp.

2840 {
2841  return true;
2842 }

◆ warning()

bool QXmlDefaultHandler::warning ( const QXmlParseException exception)
virtual

This reimplementation does nothing.

Reimplemented Function

Implements QXmlErrorHandler.

Definition at line 2785 of file qxml.cpp.

2786 {
2787  return true;
2788 }

Properties

◆ d

QXmlDefaultHandlerPrivate* QXmlDefaultHandler::d
private

Definition at line 414 of file qxml.h.


The documentation for this class was generated from the following files: