QXmlFormatter Class ReferenceThe QXmlFormatter class is an implementation of QXmlSerializer for transforming XQuery output into formatted XML. More... #include <QXmlFormatter> Inherits: QXmlSerializer. Note: All functions in this class are reentrant. This class was introduced in Qt 4.4. Public Functions
Reimplemented Public Functions
Detailed DescriptionThe QXmlFormatter class is an implementation of QXmlSerializer for transforming XQuery output into formatted XML. QXmlFormatter is a subclass of QXmlSerializer that formats the XML output to make it easier for humans to read. QXmlSerializer outputs XML without adding unnecessary whitespace. In particular, it does not add newlines and indentation. To make the XML output easier to read, QXmlFormatter adds newlines and indentation by adding, removing, and modifying sequence nodes that only consist of whitespace. It also modifies whitespace in other places where it is not significant; e.g., between attributes and in the document prologue. For example, where the base class QXmlSerializer would output this: <a><b/><c/><p>Some Text</p></a> QXmlFormatter outputs this: <a> <b/> <c/> <p>Some Text</p> </a> If you just want to serialize your XML in a human-readable format, use QXmlFormatter as it is. The default indentation level is 4 spaces, but you can set your own indentation value setIndentationDepth(). The newlines and indentation added by QXmlFormatter are suitable for common formats, such as XHTML, SVG, or Docbook, where whitespace is not significant. However, if your XML will be used as input where whitespace is significant, then you must write your own subclass of QXmlSerializer or QAbstractXmlReceiver. Note that using QXmlFormatter instead of QXmlSerializer will increase computational overhead and document storage size due to the insertion of whitespace. Note also that the indentation style used by QXmlFormatter remains loosely defined and may change in future versions of Qt. If a specific indentation style is required then either use the base class QXmlSerializer directly, or write your own subclass of QXmlSerializer or QAbstractXmlReceiver. Alternatively, you can subclass QXmlFormatter and reimplement the callbacks there. QXmlQuery query; query.setQuery("doc('index.html')/html/body/p[1]"); QXmlFormatter formatter(query, myOutputDevice); formatter.setIndentationDepth(2); query.evaluateTo(&formatter); Member Function Documentation
|
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.8 | |
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 ! |
Copyright © 2000-2012 - www.developpez.com