Qyoto
4.0.5
Qyoto is a C# language binding for Qt
|
The QXmlSerializer class is an implementation of QAbstractXmlReceiver for transforming XQuery output into unformatted XML. More...
Public Types | |
enum | State |
Public Member Functions | |
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 | |
QXmlSerializer (System.Type dummy) | |
Properties | |
new QTextCodec | Codec [get, set] |
| |
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.
enum QXmlSerializer.State |
|
protected |
QXmlSerializer.QXmlSerializer | ( | 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.
override void QXmlSerializer.AtomicValue | ( | object | value | ) |
Reimplemented from QAbstractXmlReceiver::atomicValue().
override void QXmlSerializer.Attribute | ( | QXmlName | name, |
QStringRef | value | ||
) |
Reimplemented from QAbstractXmlReceiver::attribute().
override void QXmlSerializer.Characters | ( | QStringRef | value | ) |
Reimplemented from QAbstractXmlReceiver::characters().
override void QXmlSerializer.Comment | ( | string | value | ) |
Reimplemented from QAbstractXmlReceiver::comment().
override void QXmlSerializer.CreateProxy | ( | ) |
new void QXmlSerializer.Dispose | ( | ) |
override void QXmlSerializer.EndDocument | ( | ) |
Reimplemented from QAbstractXmlReceiver::endDocument().
override void QXmlSerializer.EndElement | ( | ) |
Reimplemented from QAbstractXmlReceiver::endElement().
override void QXmlSerializer.EndOfSequence | ( | ) |
Reimplemented from QAbstractXmlReceiver::endOfSequence().
override void QXmlSerializer.NamespaceBinding | ( | QXmlName | nb | ) |
Reimplemented from QAbstractXmlReceiver::namespaceBinding().
new QIODevice QXmlSerializer.OutputDevice | ( | ) |
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.
override void QXmlSerializer.ProcessingInstruction | ( | QXmlName | name, |
string | value | ||
) |
Reimplemented from QAbstractXmlReceiver::processingInstruction().
override void QXmlSerializer.StartDocument | ( | ) |
Reimplemented from QAbstractXmlReceiver::startDocument().
override void QXmlSerializer.StartElement | ( | QXmlName | name | ) |
Reimplemented from QAbstractXmlReceiver::startElement().
override void QXmlSerializer.StartOfSequence | ( | ) |
Reimplemented from QAbstractXmlReceiver::startOfSequence().
|
getset |
Returns the codec being used by the serializer for encoding its XML output.
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.