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  · 

QAbstractXmlReceiver Class Reference
[QtXmlPatterns module]

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

 #include <QAbstractXmlReceiver>

This class is not part of the Qt GUI Framework Edition.

Inherited by QXmlSerializer.

Note: All functions in this class are reentrant.

This class was introduced in Qt 4.4.


Public Functions

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

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]");

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

  • An Element Node represents an XML element.
  • An Attribute Node represents an XML attribute.
  • A Document Node represents an entire XML document.
  • A Text Node represents character data (element content).
  • A Processing Instruction Node represents an XML processing instruction, which is used in an XML document to tell the application reading the document to perform some action. A typical example is to use a processing instruction to tell the application to use a particular XSLT stylesheet to display the document.
  • And a Comment node represents an XML comment.

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

  • Each node appears in the sequence before its children and their descendants appear.
  • A node's descendants appear in the sequence before any of its siblings appear.
  • A Document Node represents an entire document. Zero or more Document Nodes can appear in a sequence, but they can only be top level items (i.e., a Document Node can't be a child of another node.
  • Namespace Nodes immediately follow the Element Node with which they are associated.
  • Attribute Nodes immediately follow the Namespace Nodes of the element with which they are associated, or...
  • If there are no Namespace Nodes following an element, then the Attribute Nodes immediately follow the element.
  • An atomic value can only appear as a top level item, i.e., it can't appear as a child of a node.
  • Processing Instruction Nodes do not have children, and their parent is either a Document Node or an Element Node.
  • Comment Nodes do not have children, and their parent is either a Document Node or an Element Node.

The sequence of nodes and atomic values is sent to an QAbstractXmlReceiver (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 an abstract xml receiver.

QAbstractXmlReceiver::~QAbstractXmlReceiver ()   [virtual]

Destroys the xml receiver.

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

This callback is called when an atomic value appears in the sequence. The value is a simple data value. It is guaranteed to be valid.

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

This callback is called when an attribute node appears in the sequence. name is the attribute name and the value string contains the attribute value.

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

This callback is called when a text node appears in the sequence. The value contains the text. Adjacent text nodes may not occur in the sequence, i.e., this callback must not be called twice in a row.

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

This callback is called when a comment node appears in the sequence. The value is the comment text, which must not contain the string "--".

void QAbstractXmlReceiver::endDocument ()   [pure virtual]

This callback is called when the end of a document node appears in the sequence.

void QAbstractXmlReceiver::endElement ()   [pure virtual]

This callback is called when the end of an element node appears in the sequence.

void QAbstractXmlReceiver::endOfSequence ()   [pure virtual]

This callback is called once only, right after the sequence ends.

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

This callback is called when a namespace binding is in scope of an element. A namespace is defined by a URI. In the QXmlName name, the value of QXmlName::namespaceUri() is that URI. The value of QXmlName::prefix() is the prefix that the URI is bound to. The local name is insignificant and can be an arbitrary value.

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

This callback is called when a processing instruction appears in the sequence. A processing instruction is used in an XML document to tell the application reading the document to perform some action. A typical example is to use a processing instruction to tell the application to use a particular XSLT stylesheet to process the document.

 <?xml-stylesheet type="test/xsl" href="formatter.xsl"?>

target is the name of the processing instruction. Its prefix and namespace URI must both be empty. Its local name is the target. In the above example, the name is xml-stylesheet.

The value specifies the action to be taken. Note that the value must not contain the string "?>". In the above example, the value is type="test/xsl" href="formatter.xsl.

Generally, use of processing instructions should be avoided, because they are not namespace aware and in many contexts are stripped out anyway. Processing instructions can often be replaced with elements from a custom namespace.

void QAbstractXmlReceiver::startDocument ()   [pure virtual]

This callback is called when a document node appears in the sequence.

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

This callback is called when a new element node appears in the sequence. name is the valid name of the node element.

void QAbstractXmlReceiver::startOfSequence ()   [pure virtual]

This callback is called once only, right before the sequence begins.

Publicité

Best Of

Actualités les plus lues

Semaine
Mois
Année
  1. « Quelque chose ne va vraiment pas avec les développeurs "modernes" », un développeur à "l'ancienne" critique la multiplication des bibliothèques 70
  2. Apercevoir la troisième dimension ou l'utilisation multithreadée d'OpenGL dans Qt, un article des Qt Quarterly traduit par Guillaume Belz 0
  3. Les développeurs ignorent-ils trop les failles découvertes dans leur code ? Prenez-vous en compte les remarques des autres ? 17
  4. 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
  5. Quelles nouveautés de C++11 Visual C++ doit-il rapidement intégrer ? Donnez-nous votre avis 10
  6. Adieu qmake, bienvenue qbs : Qt Building Suite, un outil déclaratif et extensible pour la compilation de projets Qt 17
  7. La rubrique PyQt/PySide a besoin de vous ! 0
Page suivante

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.6-snapshot
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