Home · All Classes · Main Classes · Grouped Classes · Modules · Functions

QAbstractXmlReceiver Class Reference
[
QtXmlPatterns module]

The QAbstractXmlReceiver class provides a callback interface for transforming the output of a QXmlQuery. More...

 #include <QAbstractXmlReceiver>

Inherits QSharedData.

Inherited by QPatternist::DocumentContentValidator, QPatternist::DocumentProjector, QPatternist::NodeBuilder, QPatternist::OutputValidator, and QXmlSerializer.

Note: All the functions in this class are reentrant.

This class was introduced in Qt 4.4.

Public Functions


Detailed Description

The QAbstractXmlReceiver class provides a callback interface for transforming the output of a QXmlQuery.

QAbstractXmlReceiver is an abstract base class that provides a callback interface for receiving an XQuery sequence, usually the output of an QXmlQuery, and transforming that sequence into a structure of your choosing, usually XML. Consider the example:

 QXmlQuery query;
 query.setQuery("doc('index.html')/html/body/p[1]");

 QXmlSerializerPointer serializer(new QXmlSerializer(query, myOutputDevice));
 query.evaluateToReceiver(serializer);

First it constructs a query that gets the first paragraph from document index.html. Then it constructs an XML serializer with the query and myOutputDevice (Note the serializer is an XML receiver, ie a subclass of QAbstractXmlReceiver). Finally, it evaluates the query, producing an ordered sequence of calls to the serializer's callback functions. The sequence of callbacks transforms the query output to XML and writes it to myOutputDevice.

Although the example uses QXmlQuery to produce the sequence of callbacks to functions in QAbstractXmlReceiver, you can call the callback functions directly as long as your sequence of calls represents a valid XQuery sequence.

XQuery Sequences

An XQuery sequence is an ordered collection of zero, one, or many items. Each item is either an atomic value or a node. An atomic value is a simple data value.

There are six kinds of nodes.

The order of nodes and atomic values in a sequence obeys the following rules. Note that Namespace Node refers to a special Attribute Node with name xmlns.

The sequence of nodes and atomic values is sent to an XML receiver (QXmlSerializer in the example above) as a sequence of calls to the receiver's callback functions. The mapping of callback functions to sequence items is as follows.

For a complete explanation of XQuery sequences, visit XQuery Data Model.

See also W3C XQuery 1.0 and XPath 2.0 Data Model (XDM), QXmlSerializer, and QXmlResultItems.


Member Function Documentation

QAbstractXmlReceiver::QAbstractXmlReceiver ()

Constructs a QAbstractXmlReceiver instance.

QAbstractXmlReceiver::~QAbstractXmlReceiver ()   [virtual]

Destructs this QAbstractXmlReceiver.

void QAbstractXmlReceiver::atomicValue ( const QVariant & value )   [pure virtual]

Signals an atomic value.

The caller guarantees that value is valid.

See also QVariant::isValid().

void QAbstractXmlReceiver::attribute ( const QXmlName & name, const QString & value )   [pure virtual]

Signals an attribute by name name, and value value.

The caller guarantees name is a valid name.

void QAbstractXmlReceiver::characters ( const QString & value )   [pure virtual]

Signals a text node with content value. Adjacent text nodes may not occur.

void QAbstractXmlReceiver::comment ( const QString & value )   [pure virtual]

Signals a comment whose value is value.

The caller guarantees that value does not contain the string "--".

void QAbstractXmlReceiver::endDocument ()   [pure virtual]

Signals the end of a document node.

void QAbstractXmlReceiver::endElement ()   [pure virtual]

Signals the end of the most recently received element.

void QAbstractXmlReceiver::namespaceBinding ( const QXmlName & name )   [pure virtual]

Signals a namespace binding. In name, the namespace URI is the namespace URI, and the local name is the prefix the binding binds to.

void QAbstractXmlReceiver::processingInstruction ( const QXmlName & target, const QString & value )   [pure virtual]

Signals a processing instruction with target (the name) and content value.

The caller guarantees that value does not contain the string "?>".

The caller guarantees target is a valid name, that the prefix and namespace URI is empty, and that the local name is the target.

void QAbstractXmlReceiver::startDocument ()   [pure virtual]

Signals the start of a document node.

void QAbstractXmlReceiver::startElement ( const QXmlName & name )   [pure virtual]

Signals the start of an element by name name.

The caller guarantees name is a valid name.


Copyright © 2007 Trolltech Trademarks
Qt 4.4.0-tp1