Home · All Classes · Modules

QXmlSerializer Class Reference
[QtXmlPatterns module]

The QXmlSerializer class is an implementation of QAbstractXmlReceiver for transforming XQuery output into unformatted XML. More...

Inherits QAbstractXmlReceiver.

Inherited by QXmlFormatter.

Methods


Detailed Description

The QXmlSerializer class is an implementation of QAbstractXmlReceiver for transforming XQuery output into unformatted XML.

QXmlSerializer translates an XQuery sequence, usually the output of an QXmlQuery, into XML. Consider the example:

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

 QXmlSerializer serializer(query, myOutputDevice);
 query.evaluateTo(&serializer);

First it constructs a query that gets the first paragraph from document index.html. Then it constructs an instance of this class with the query and myOutputDevice. 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.

QXmlSerializer will:

If an error occurs during serialization, result is undefined unless the serializer is driven through a call to QXmlQuery.evaluateTo().

If the generated XML should be indented and formatted for reading, use QXmlFormatter.


Method Documentation

QXmlSerializer.__init__ (self, QXmlQuery query, QIODevice outputDevice)

Constructs a serializer that uses the name pool and message handler in query, and writes the output to outputDevice.

outputDevice must be a valid, non-null device that is open in write mode, otherwise behavior is undefined.

outputDevice must not be opened with QIODevice.Text because it will cause the output to be incorrect. This class will ensure line endings are serialized as according with the XML specification. QXmlSerializer does not take ownership of outputDevice.

QXmlSerializer.atomicValue (self, QVariant value)

Reimplemented from QAbstractXmlReceiver.atomicValue().

QXmlSerializer.attribute (self, QXmlName name, QStringRef value)

Reimplemented from QAbstractXmlReceiver.attribute().

QXmlSerializer.characters (self, QStringRef value)

Reimplemented from QAbstractXmlReceiver.characters().

QTextCodec QXmlSerializer.codec (self)

Returns the codec being used by the serializer for encoding its XML output.

See also setCodec().

QXmlSerializer.comment (self, QString value)

Reimplemented from QAbstractXmlReceiver.comment().

QXmlSerializer.endDocument (self)

Reimplemented from QAbstractXmlReceiver.endDocument().

QXmlSerializer.endElement (self)

Reimplemented from QAbstractXmlReceiver.endElement().

QXmlSerializer.endOfSequence (self)

Reimplemented from QAbstractXmlReceiver.endOfSequence().

QXmlSerializer.namespaceBinding (self, QXmlName nb)

Reimplemented from QAbstractXmlReceiver.namespaceBinding().

QIODevice QXmlSerializer.outputDevice (self)

Returns a pointer to the output device. There is no corresponding function to set the output device, because the output device must be passed to the constructor. The serializer does not take ownership of its IO device.

QXmlSerializer.processingInstruction (self, QXmlName name, QString value)

Reimplemented from QAbstractXmlReceiver.processingInstruction().

QXmlSerializer.setCodec (self, QTextCodec codec)

Sets the codec the serializer will use for encoding its XML output. The output codec is set to outputCodec. By default, the output codec is set to the one for UTF-8. The serializer does not take ownership of the codec.

See also codec().

QXmlSerializer.startDocument (self)

Reimplemented from QAbstractXmlReceiver.startDocument().

QXmlSerializer.startElement (self, QXmlName name)

Reimplemented from QAbstractXmlReceiver.startElement().

QXmlSerializer.startOfSequence (self)

Reimplemented from QAbstractXmlReceiver.startOfSequence().


PyQt 4.9.4 for WindowsCopyright © Riverbank Computing Ltd and Nokia 2012Qt 4.8.2