# TQXmlReader Class

Home | All Classes | Main Classes | Annotated | Grouped Classes | Functions |

# TQXmlReader Class Reference
[XML module]

The TQXmlReader class provides an interface for XML readers (i.e. parsers). More...

All the functions in this class are reentrant when TQt is built with thread support.

`#include <ntqxml.h>`

Inherited by TQXmlSimpleReader.

List of all member functions.

## Public Members

- virtual bool feature ( const TQString & name, bool * ok = 0 ) const = 0
- virtual void setFeature ( const TQString & name, bool value ) = 0
- virtual bool hasFeature ( const TQString & name ) const = 0
- virtual void * property ( const TQString & name, bool * ok = 0 ) const = 0
- virtual void setProperty ( const TQString & name, void * value ) = 0
- virtual bool hasProperty ( const TQString & name ) const = 0
- virtual void setEntityResolver ( TQXmlEntityResolver * handler ) = 0
- virtual TQXmlEntityResolver * entityResolver () const = 0
- virtual void setDTDHandler ( TQXmlDTDHandler * handler ) = 0
- virtual TQXmlDTDHandler * DTDHandler () const = 0
- virtual void setContentHandler ( TQXmlContentHandler * handler ) = 0
- virtual TQXmlContentHandler * contentHandler () const = 0
- virtual void setErrorHandler ( TQXmlErrorHandler * handler ) = 0
- virtual TQXmlErrorHandler * errorHandler () const = 0
- virtual void setLexicalHandler ( TQXmlLexicalHandler * handler ) = 0
- virtual TQXmlLexicalHandler * lexicalHandler () const = 0
- virtual void setDeclHandler ( TQXmlDeclHandler * handler ) = 0
- virtual TQXmlDeclHandler * declHandler () const = 0
- virtual bool parse ( const TQXmlInputSource & input ) = 0 (obsolete)
- virtual bool parse ( const TQXmlInputSource * input ) = 0

## Detailed Description

The TQXmlReader class provides an interface for XML readers (i.e. parsers).

This abstract class provides an interface for all of TQt's XML readers. Currently there is only one implementation of a reader included in TQt's XML module: TQXmlSimpleReader. In future releases there might be more readers with different properties available (e.g. a validating parser).

The design of the XML classes follows the SAX2 Java interface, with the names adapted to fit TQt naming conventions. It should be very easy for anybody who has worked with SAX2 to get started with the TQt XML classes.

All readers use the class TQXmlInputSource to read the input document. Since you are normally interested in particular content in the XML document, the reader reports the content through special handler classes (TQXmlDTDHandler, TQXmlDeclHandler, TQXmlContentHandler, TQXmlEntityResolver, TQXmlErrorHandler and TQXmlLexicalHandler), which you must subclass, if you want to process the contents.

Since the handler classes only describe interfaces you must implement all the functions. We provide the TQXmlDefaultHandler class to make this easier: it implements a default behaviour (do nothing) for all functions, so you can subclass it and just implement the functions you are interested in.

Features and properties of the reader can be set with setFeature() and setProperty() respectively. You can set the reader to use your own subclasses with setEntityResolver(), setDTDHandler(), setContentHandler(), setErrorHandler(), setLexicalHandler() and setDeclHandler(). The parse itself is started with a call to parse().

See also TQXmlSimpleReader and XML.

## Member Function Documentation

### TQXmlDTDHandler * TQXmlReader::DTDHandler () const`[pure virtual]`

Returns the DTD handler or 0 if none was set.

See also setDTDHandler().

### TQXmlContentHandler * TQXmlReader::contentHandler () const`[pure virtual]`

Returns the content handler or 0 if none was set.

See also setContentHandler().

### TQXmlDeclHandler * TQXmlReader::declHandler () const`[pure virtual]`

Returns the declaration handler or 0 if none was set.

See also setDeclHandler().

### TQXmlEntityResolver * TQXmlReader::entityResolver () const`[pure virtual]`

Returns the entity resolver or 0 if none was set.

See also setEntityResolver().

### TQXmlErrorHandler * TQXmlReader::errorHandler () const`[pure virtual]`

Returns the error handler or 0 if none is set.

See also setErrorHandler().

### bool TQXmlReader::feature ( const TQString & name, bool * ok = 0 ) const`[pure virtual]`

If the reader has the feature called name, the feature's value is returned. If no such feature exists the return value is undefined.

If ok is not 0: *ok is set to TRUE if the reader has the feature called name; otherwise *ok is set to FALSE.

See also setFeature() and hasFeature().

### bool TQXmlReader::hasFeature ( const TQString & name ) const`[pure virtual]`

Returns `TRUE` if the reader has the feature called name; otherwise returns FALSE.

See also feature() and setFeature().

### bool TQXmlReader::hasProperty ( const TQString & name ) const`[pure virtual]`

Returns TRUE if the reader has the property name; otherwise returns FALSE.

See also property() and setProperty().

### TQXmlLexicalHandler * TQXmlReader::lexicalHandler () const`[pure virtual]`

Returns the lexical handler or 0 if none was set.

See also setLexicalHandler().

### bool TQXmlReader::parse ( const TQXmlInputSource * input )`[pure virtual]`

Reads an XML document from input and parses it. Returns TRUE if the parsing was successful; otherwise returns FALSE.

Example: xml/tagreader/tagreader.cpp.

### bool TQXmlReader::parse ( const TQXmlInputSource & input )`[pure virtual]`

This function is obsolete. It is provided to keep old source working. We strongly advise against using it in new code.

### void * TQXmlReader::property ( const TQString & name, bool * ok = 0 ) const`[pure virtual]`

If the reader has the property name, this function returns the value of the property; otherwise the return value is undefined.

If ok is not 0: if the reader has the name property *ok is set to TRUE; otherwise *ok is set to FALSE.

See also setProperty() and hasProperty().

### void TQXmlReader::setContentHandler ( TQXmlContentHandler * handler )`[pure virtual]`

Sets the content handler to handler.

See also contentHandler().

Example: xml/tagreader/tagreader.cpp.

### void TQXmlReader::setDTDHandler ( TQXmlDTDHandler * handler )`[pure virtual]`

Sets the DTD handler to handler.

See also DTDHandler().

### void TQXmlReader::setDeclHandler ( TQXmlDeclHandler * handler )`[pure virtual]`

Sets the declaration handler to handler.

See also declHandler().

### void TQXmlReader::setEntityResolver ( TQXmlEntityResolver * handler )`[pure virtual]`

Sets the entity resolver to handler.

See also entityResolver().

### void TQXmlReader::setErrorHandler ( TQXmlErrorHandler * handler )`[pure virtual]`

Sets the error handler to handler. Clears the error handler if handler is 0.

See also errorHandler().

### void TQXmlReader::setFeature ( const TQString & name, bool value )`[pure virtual]`

Sets the feature called name to the given value. If the reader doesn't have the feature nothing happens.

See also feature() and hasFeature().

Reimplemented in TQXmlSimpleReader.

### void TQXmlReader::setLexicalHandler ( TQXmlLexicalHandler * handler )`[pure virtual]`

Sets the lexical handler to handler.

See also lexicalHandler().

### void TQXmlReader::setProperty ( const TQString & name, void * value )`[pure virtual]`

Sets the property name to value. If the reader doesn't have the property nothing happens.

See also property() and hasProperty().

This file is part of the TQt toolkit. Copyright © 1995-2007 Trolltech. All Rights Reserved.