Viadeo Twitter Google Bookmarks ! Facebook Digg del.icio.us MySpace Yahoo MyWeb Blinklist Netvouz Reddit Simpy StumbleUpon Bookmarks Windows Live Favorites 
Logo Documentation Qt ·  Page d'accueil  ·  Toutes les classes  ·  Toutes les fonctions  ·  Vues d'ensemble  · 

QXmlSerializer Class Reference

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

 #include <QXmlSerializer>

Inherits: QAbstractXmlReceiver.

Inherited by: QXmlFormatter.

Note: All functions in this class are reentrant.

This class was introduced in Qt 4.4.

Public Functions

QXmlSerializer ( const QXmlQuery & query, QIODevice * outputDevice )
const QTextCodec * codec () const
QIODevice * outputDevice () const
void setCodec ( const QTextCodec * outputCodec )

Reimplemented Public Functions

virtual void atomicValue ( const QVariant & value )
virtual void attribute ( const QXmlName & name, const QStringRef & value )
virtual void characters ( const QStringRef & value )
virtual void comment ( const QString & value )
virtual void endDocument ()
virtual void endElement ()
virtual void endOfSequence ()
virtual void namespaceBinding ( const QXmlName & nb )
virtual void processingInstruction ( const QXmlName & name, const QString & value )
virtual void startDocument ()
virtual void startElement ( const QXmlName & name )
virtual void startOfSequence ()

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:

  • Declare namespaces when needed,
  • Use appropriate escaping, when characters can't be represented in the XML,
  • Handle line endings appropriately,
  • Report errors, when it can't serialize the content, e.g., when asked to serialize an attribute that is a top-level node, or when more than one top-level element is encountered.

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.

See also XSLT 2.0 and XQuery 1.0 Serialization and QXmlFormatter.

Member Function Documentation

QXmlSerializer::QXmlSerializer ( const 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.

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

Reimplemented from QAbstractXmlReceiver::atomicValue().

void QXmlSerializer::attribute ( const QXmlName & name, const QStringRef & value ) [virtual]

Reimplemented from QAbstractXmlReceiver::attribute().

void QXmlSerializer::characters ( const QStringRef & value ) [virtual]

Reimplemented from QAbstractXmlReceiver::characters().

const QTextCodec * QXmlSerializer::codec () const

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

See also setCodec().

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

Reimplemented from QAbstractXmlReceiver::comment().

void QXmlSerializer::endDocument () [virtual]

Reimplemented from QAbstractXmlReceiver::endDocument().

void QXmlSerializer::endElement () [virtual]

Reimplemented from QAbstractXmlReceiver::endElement().

void QXmlSerializer::endOfSequence () [virtual]

Reimplemented from QAbstractXmlReceiver::endOfSequence().

void QXmlSerializer::namespaceBinding ( const QXmlName & nb ) [virtual]

Reimplemented from QAbstractXmlReceiver::namespaceBinding().

QIODevice * QXmlSerializer::outputDevice () const

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.

void QXmlSerializer::processingInstruction ( const QXmlName & name, const QString & value ) [virtual]

Reimplemented from QAbstractXmlReceiver::processingInstruction().

void QXmlSerializer::setCodec ( const QTextCodec * outputCodec )

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().

void QXmlSerializer::startDocument () [virtual]

Reimplemented from QAbstractXmlReceiver::startDocument().

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

Reimplemented from QAbstractXmlReceiver::startElement().

void QXmlSerializer::startOfSequence () [virtual]

Reimplemented from QAbstractXmlReceiver::startOfSequence().

Publicit�

Best Of

Actualit�s les plus lues

Semaine
Mois
Ann�e
  1. Microsoft ouvre aux autres compilateurs C++ AMP, la sp�cification pour la conception d'applications parall�les C++ utilisant le GPU 22
  2. Les d�veloppeurs ignorent-ils trop les failles d�couvertes dans leur code ? Prenez-vous en compte les remarques des autres ? 17
  3. RIM : � 13 % des d�veloppeurs ont gagn� plus de 100 000 $ sur l'AppWord �, Qt et open-source au menu du BlackBerry DevCon Europe 0
  4. � Quelque chose ne va vraiment pas avec les d�veloppeurs "modernes" �, un d�veloppeur � "l'ancienne" critique la multiplication des biblioth�ques 12
  5. BlackBerry 10 : premi�res images du prochain OS de RIM qui devrait int�grer des widgets et des tuiles inspir�es de Windows Phone 0
  6. Adieu qmake, bienvenue qbs : Qt Building Suite, un outil d�claratif et extensible pour la compilation de projets Qt 17
  7. Quelles nouveaut�s de C++11 Visual C++ doit-il rapidement int�grer ? Donnez-nous votre avis 10
Page suivante

Le Qt Developer Network au hasard

Logo

Compiler l'add-in Qt de Visual Studio

Le Qt Developer Network est un r�seau de d�veloppeurs Qt anglophone, o� ils peuvent partager leur exp�rience sur le framework. Lire l'article.

Communaut�

Ressources

Liens utiles

Contact

  • Vous souhaitez rejoindre la r�daction ou proposer un tutoriel, une traduction, une question... ? Postez dans le forum Contribuez ou contactez-nous par MP ou par email (voir en bas de page).

Qt dans le magazine

Cette page est une traduction d'une page de la documentation de Qt, �crite par Nokia Corporation and/or its subsidiary(-ies). Les �ventuels probl�mes r�sultant d'une mauvaise traduction ne sont pas imputables � Nokia. Qt 4.7
Copyright © 2012 Developpez LLC. Tous droits r�serv�s Developpez LLC. Aucune reproduction, m�me partielle, ne peut �tre faite de ce site et de l'ensemble de son contenu : textes, documents et images sans l'autorisation expresse de Developpez LLC. Sinon, vous encourez selon la loi jusqu'� 3 ans de prison et jusqu'� 300 000 E de dommages et int�r�ts. Cette page est d�pos�e � la SACD.
Vous avez d�nich� une erreur ? Un bug ? Une redirection cass�e ? Ou tout autre probl�me, quel qu'il soit ? Ou bien vous d�sirez participer � ce projet de traduction ? N'h�sitez pas � nous contacter ou par MP !
 
 
 
 
Partenaires

H�bergement Web