<?xml version="1.0" encoding="iso-8859-1"?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "DTD/xhtml1-strict.dtd"> <html><head><title>QXmlSerializer Class Reference</title><style>h3.fn,span.fn { margin-left: 1cm; text-indent: -1cm } a:link { color: #004faf; text-decoration: none } a:visited { color: #672967; text-decoration: none } td.postheader { font-family: sans-serif } tr.address { font-family: sans-serif } body { background: #ffffff; color: black; } </style></head><body><table border="0" cellpadding="0" cellspacing="0" width="100%"><tr /><td align="left" valign="top" width="32"><img align="left" border="0" height="32" src="images/rb-logo.png" width="32" /></td><td width="1">  </td><td class="postheader" valign="center"><a href="../pyqt4ref.html"><font color="#004faf">Home</font></a> · <a href="classes.html"><font color="#004faf">All Classes</font></a> · <a href="modules.html"><font color="#004faf">Modules</font></a></td></table><h1 align="center">QXmlSerializer Class Reference<br /><sup><sup>[<a href="qtxmlpatterns.html">QtXmlPatterns</a> module]</sup></sup></h1><p>The QXmlSerializer class is an implementation of <a href="qabstractxmlreceiver.html">QAbstractXmlReceiver</a> for transforming XQuery output into unformatted XML. <a href="#details">More...</a></p> <p>Inherits <a href="qabstractxmlreceiver.html">QAbstractXmlReceiver</a>.</p><p>Inherited by <a href="qxmlformatter.html">QXmlFormatter</a>.</p><h3>Methods</h3><ul><li><div class="fn" /><b><a href="qxmlserializer.html#QXmlSerializer">__init__</a></b> (<i>self</i>, QXmlQuery, QIODevice)</li><li><div class="fn" /><b><a href="qxmlserializer.html#atomicValue">atomicValue</a></b> (<i>self</i>, QVariant)</li><li><div class="fn" /><b><a href="qxmlserializer.html#attribute">attribute</a></b> (<i>self</i>, QXmlName, QStringRef)</li><li><div class="fn" /><b><a href="qxmlserializer.html#characters">characters</a></b> (<i>self</i>, QStringRef)</li><li><div class="fn" />QTextCodec <b><a href="qxmlserializer.html#codec">codec</a></b> (<i>self</i>)</li><li><div class="fn" /><b><a href="qxmlserializer.html#comment">comment</a></b> (<i>self</i>, QString)</li><li><div class="fn" /><b><a href="qxmlserializer.html#endDocument">endDocument</a></b> (<i>self</i>)</li><li><div class="fn" /><b><a href="qxmlserializer.html#endElement">endElement</a></b> (<i>self</i>)</li><li><div class="fn" /><b><a href="qxmlserializer.html#endOfSequence">endOfSequence</a></b> (<i>self</i>)</li><li><div class="fn" /><b><a href="qxmlserializer.html#namespaceBinding">namespaceBinding</a></b> (<i>self</i>, QXmlName)</li><li><div class="fn" />QIODevice <b><a href="qxmlserializer.html#outputDevice">outputDevice</a></b> (<i>self</i>)</li><li><div class="fn" /><b><a href="qxmlserializer.html#processingInstruction">processingInstruction</a></b> (<i>self</i>, QXmlName, QString)</li><li><div class="fn" /><b><a href="qxmlserializer.html#setCodec">setCodec</a></b> (<i>self</i>, QTextCodec)</li><li><div class="fn" /><b><a href="qxmlserializer.html#startDocument">startDocument</a></b> (<i>self</i>)</li><li><div class="fn" /><b><a href="qxmlserializer.html#startElement">startElement</a></b> (<i>self</i>, QXmlName)</li><li><div class="fn" /><b><a href="qxmlserializer.html#startOfSequence">startOfSequence</a></b> (<i>self</i>)</li></ul><a name="details" /><hr /><h2>Detailed Description</h2><p>The QXmlSerializer class is an implementation of <a href="qabstractxmlreceiver.html">QAbstractXmlReceiver</a> for transforming XQuery output into unformatted XML.</p> <p>QXmlSerializer translates an <a href="qabstractxmlreceiver.html#xquery-sequence">XQuery sequence</a>, usually the output of an <a href="qxmlquery.html">QXmlQuery</a>, into XML. Consider the example:</p> <pre> QXmlQuery query; query.setQuery("doc('index.html')/html/body/p[1]"); QXmlSerializer serializer(query, myOutputDevice); query.evaluateTo(&serializer);</pre> <p>First it constructs a <a href="qxmlquery.html">query</a> that gets the first paragraph from document <tt>index.html</tt>. Then it constructs an instance of this class with the <a href="qxmlquery.html">query</a> and <a href="qiodevice.html">myOutputDevice</a>. Finally, it <a href="qxmlquery.html#evaluateTo">evaluates</a> the <a href="qxmlquery.html">query</a>, 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 <a href="qiodevice.html">myOutputDevice</a>.</p> <p>QXmlSerializer will:</p> <ul> <li>Declare namespaces when needed,</li> <li>Use appropriate escaping, when characters can't be represented in the XML,</li> <li>Handle line endings appropriately,</li> <li>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.</li> </ul> <p>If an error occurs during serialization, result is undefined unless the serializer is driven through a call to <a href="qxmlquery.html#evaluateTo">QXmlQuery.evaluateTo</a>().</p> <p>If the generated XML should be indented and formatted for reading, use <a href="qxmlformatter.html">QXmlFormatter</a>.</p> <p>See also <a href="http://www.w3.org/TR/xslt-xquery-serialization/">XSLT 2.0 and XQuery 1.0 Serialization</a> and <a href="qxmlformatter.html">QXmlFormatter</a>.</p> <hr /><h2>Method Documentation</h2><h3 class="fn"><a name="QXmlSerializer" />QXmlSerializer.__init__ (<i>self</i>, <a href="qxmlquery.html">QXmlQuery</a>, <a href="qiodevice.html">QIODevice</a>)</h3><p>Constructs a serializer that uses the name pool and message handler in <i>query</i>, and writes the output to <i>outputDevice</i>.</p> <p><i>outputDevice</i> must be a valid, non-null device that is open in write mode, otherwise behavior is undefined.</p> <p><i>outputDevice</i> must not be opened with <a href="qiodevice.html#OpenModeFlag-enum">QIODevice.Text</a> because it will cause the output to be incorrect. This class will ensure line endings are serialized as according with the XML specification. <a href="qxmlserializer.html">QXmlSerializer</a> does not take ownership of <i>outputDevice</i>.</p> <a name="//apple_ref/cpp/instm/QXmlSerializer/atomicValue" /> <h3 class="fn"><a name="atomicValue" />QXmlSerializer.atomicValue (<i>self</i>, QVariant)</h3><p>Reimplemented from <a href="qabstractxmlreceiver.html#atomicValue">QAbstractXmlReceiver.atomicValue</a>().</p> <a name="//apple_ref/cpp/instm/QXmlSerializer/attribute" /> <h3 class="fn"><a name="attribute" />QXmlSerializer.attribute (<i>self</i>, <a href="qxmlname.html">QXmlName</a>, QStringRef)</h3><p>Reimplemented from <a href="qabstractxmlreceiver.html#attribute">QAbstractXmlReceiver.attribute</a>().</p> <a name="//apple_ref/cpp/instm/QXmlSerializer/characters" /> <h3 class="fn"><a name="characters" />QXmlSerializer.characters (<i>self</i>, QStringRef)</h3><p>Reimplemented from <a href="qabstractxmlreceiver.html#characters">QAbstractXmlReceiver.characters</a>().</p> <a name="//apple_ref/cpp/instm/QXmlSerializer/codec" /> <h3 class="fn"><a name="codec" /><a href="qtextcodec.html">QTextCodec</a> QXmlSerializer.codec (<i>self</i>)</h3><p>Returns the codec being used by the serializer for encoding its XML output.</p> <p>See also <a href="qxmlserializer.html#setCodec">setCodec</a>().</p> <a name="//apple_ref/cpp/instm/QXmlSerializer/comment" /> <h3 class="fn"><a name="comment" />QXmlSerializer.comment (<i>self</i>, QString)</h3><p>Reimplemented from <a href="qabstractxmlreceiver.html#comment">QAbstractXmlReceiver.comment</a>().</p> <a name="//apple_ref/cpp/instm/QXmlSerializer/endDocument" /> <h3 class="fn"><a name="endDocument" />QXmlSerializer.endDocument (<i>self</i>)</h3><p>Reimplemented from <a href="qabstractxmlreceiver.html#endDocument">QAbstractXmlReceiver.endDocument</a>().</p> <a name="//apple_ref/cpp/instm/QXmlSerializer/endElement" /> <h3 class="fn"><a name="endElement" />QXmlSerializer.endElement (<i>self</i>)</h3><p>Reimplemented from <a href="qabstractxmlreceiver.html#endElement">QAbstractXmlReceiver.endElement</a>().</p> <a name="//apple_ref/cpp/instm/QXmlSerializer/endOfSequence" /> <h3 class="fn"><a name="endOfSequence" />QXmlSerializer.endOfSequence (<i>self</i>)</h3><p>Reimplemented from <a href="qabstractxmlreceiver.html#endOfSequence">QAbstractXmlReceiver.endOfSequence</a>().</p> <a name="//apple_ref/cpp/instm/QXmlSerializer/namespaceBinding" /> <h3 class="fn"><a name="namespaceBinding" />QXmlSerializer.namespaceBinding (<i>self</i>, <a href="qxmlname.html">QXmlName</a>)</h3><p>Reimplemented from <a href="qabstractxmlreceiver.html#namespaceBinding">QAbstractXmlReceiver.namespaceBinding</a>().</p> <a name="//apple_ref/cpp/instm/QXmlSerializer/outputDevice" /> <h3 class="fn"><a name="outputDevice" /><a href="qiodevice.html">QIODevice</a> QXmlSerializer.outputDevice (<i>self</i>)</h3><p>Returns a pointer to the output device. There is no corresponding function to <i>set</i> the output device, because the output device must be passed to the constructor. The serializer does not take ownership of its IO device.</p> <a name="//apple_ref/cpp/instm/QXmlSerializer/processingInstruction" /> <h3 class="fn"><a name="processingInstruction" />QXmlSerializer.processingInstruction (<i>self</i>, <a href="qxmlname.html">QXmlName</a>, QString)</h3><p>Reimplemented from <a href="qabstractxmlreceiver.html#processingInstruction">QAbstractXmlReceiver.processingInstruction</a>().</p> <a name="//apple_ref/cpp/instm/QXmlSerializer/setCodec" /> <h3 class="fn"><a name="setCodec" />QXmlSerializer.setCodec (<i>self</i>, <a href="qtextcodec.html">QTextCodec</a>)</h3><p>Sets the codec the serializer will use for encoding its XML output. The output codec is set to <i>outputCodec</i>. By default, the output codec is set to the one for <tt>UTF-8</tt>. The serializer does not take ownership of the codec.</p> <p>See also <a href="qxmlserializer.html#codec">codec</a>().</p> <a name="//apple_ref/cpp/instm/QXmlSerializer/startDocument" /> <h3 class="fn"><a name="startDocument" />QXmlSerializer.startDocument (<i>self</i>)</h3><p>Reimplemented from <a href="qabstractxmlreceiver.html#startDocument">QAbstractXmlReceiver.startDocument</a>().</p> <a name="//apple_ref/cpp/instm/QXmlSerializer/startElement" /> <h3 class="fn"><a name="startElement" />QXmlSerializer.startElement (<i>self</i>, <a href="qxmlname.html">QXmlName</a>)</h3><p>Reimplemented from <a href="qabstractxmlreceiver.html#startElement">QAbstractXmlReceiver.startElement</a>().</p> <a name="//apple_ref/cpp/instm/QXmlSerializer/startOfSequence" /> <h3 class="fn"><a name="startOfSequence" />QXmlSerializer.startOfSequence (<i>self</i>)</h3><p>Reimplemented from <a href="qabstractxmlreceiver.html#startOfSequence">QAbstractXmlReceiver.startOfSequence</a>().</p> <p /><address><hr /><div align="center"><table border="0" cellspacing="0" width="100%"><tr class="address"><td align="left" width="25%">PyQt 4.7.4 for X11</td><td align="center" width="50%">Copyright © <a href="http://www.riverbankcomputing.com">Riverbank Computing Ltd</a> and <a href="http://www.qtsoftware.com">Nokia</a> 2010</td><td align="right" width="25%">Qt 4.6.3</td></tr></table></div></address></body></html>