Qyoto
4.0.5
Qyoto is a C# language binding for Qt
|
The QXmlFormatter class is an implementation of QXmlSerializer for transforming XQuery output into formatted XML. More...
Public Member Functions | |
QXmlFormatter (QXmlQuery query, QIODevice outputDevice) | |
| |
override void | CreateProxy () |
override void | AtomicValue (object value) |
| |
override void | Attribute (QXmlName name, QStringRef value) |
| |
override void | Characters (QStringRef value) |
| |
override void | Comment (string value) |
| |
override void | EndDocument () |
| |
override void | EndElement () |
| |
override void | EndOfSequence () |
| |
override void | ProcessingInstruction (QXmlName name, string value) |
| |
override void | StartDocument () |
| |
override void | StartElement (QXmlName name) |
| |
override void | StartOfSequence () |
| |
new void | Dispose () |
Public Member Functions inherited from QXmlSerializer | |
QXmlSerializer (QXmlQuery query, QIODevice outputDevice) | |
| |
override void | CreateProxy () |
override void | AtomicValue (object value) |
| |
override void | Attribute (QXmlName name, QStringRef value) |
| |
override void | Characters (QStringRef value) |
| |
override void | Comment (string value) |
| |
override void | EndDocument () |
| |
override void | EndElement () |
| |
override void | EndOfSequence () |
| |
override void | NamespaceBinding (QXmlName nb) |
| |
new QIODevice | OutputDevice () |
| |
override void | ProcessingInstruction (QXmlName name, string value) |
| |
override void | StartDocument () |
| |
override void | StartElement (QXmlName name) |
| |
override void | StartOfSequence () |
| |
new void | Dispose () |
Protected Member Functions | |
QXmlFormatter (System.Type dummy) | |
Protected Member Functions inherited from QXmlSerializer | |
QXmlSerializer (System.Type dummy) | |
Properties | |
new int | IndentationDepth [get, set] |
| |
Properties inherited from QXmlSerializer | |
new QTextCodec | Codec [get, set] |
| |
Additional Inherited Members | |
Public Types inherited from QXmlSerializer | |
enum | State |
The 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);
|
protected |
Constructs a formatter that uses the name pool and message handler in query, and writes the result to outputDevice as formatted XML.
outputDevice is passed directly to QXmlSerializer's constructor.
See also QXmlSerializer.
override void QtXmlPatterns.QXmlFormatter.AtomicValue | ( | object | value | ) |
Reimplemented from QAbstractXmlReceiver::atomicValue().
override void QtXmlPatterns.QXmlFormatter.Attribute | ( | QXmlName | name, |
QStringRef | value | ||
) |
Reimplemented from QAbstractXmlReceiver::attribute().
override void QtXmlPatterns.QXmlFormatter.Characters | ( | QStringRef | value | ) |
Reimplemented from QAbstractXmlReceiver::characters().
override void QtXmlPatterns.QXmlFormatter.Comment | ( | string | value | ) |
Reimplemented from QAbstractXmlReceiver::comment().
override void QtXmlPatterns.QXmlFormatter.CreateProxy | ( | ) |
new void QtXmlPatterns.QXmlFormatter.Dispose | ( | ) |
override void QtXmlPatterns.QXmlFormatter.EndDocument | ( | ) |
Reimplemented from QAbstractXmlReceiver::endDocument().
override void QtXmlPatterns.QXmlFormatter.EndElement | ( | ) |
Reimplemented from QAbstractXmlReceiver::endElement().
override void QtXmlPatterns.QXmlFormatter.EndOfSequence | ( | ) |
Reimplemented from QAbstractXmlReceiver::endOfSequence().
override void QtXmlPatterns.QXmlFormatter.ProcessingInstruction | ( | QXmlName | name, |
string | value | ||
) |
Reimplemented from QAbstractXmlReceiver::processingInstruction().
override void QtXmlPatterns.QXmlFormatter.StartDocument | ( | ) |
Reimplemented from QAbstractXmlReceiver::startDocument().
override void QtXmlPatterns.QXmlFormatter.StartElement | ( | QXmlName | name | ) |
Reimplemented from QAbstractXmlReceiver::startElement().
override void QtXmlPatterns.QXmlFormatter.StartOfSequence | ( | ) |
Reimplemented from QAbstractXmlReceiver::startOfSequence().
|
getset |
Returns the number of spaces QXmlFormatter will output for each indentation level. The default is four.
Sets depth to be the number of spaces QXmlFormatter will output for level of indentation. The default is four.