PageRenderTime 52ms CodeModel.GetById 19ms RepoModel.GetById 1ms app.codeStats 0ms

/PyQt-x11-gpl-4.9.4/doc/html/qxmlformatter.html

#
HTML | 108 lines | 80 code | 28 blank | 0 comment | 0 complexity | 03e3bee9b309ff1269b4f99c8d5fa230 MD5 | raw file
Possible License(s): GPL-2.0, GPL-3.0
  1. <?xml version="1.0" encoding="iso-8859-1"?>
  2. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "DTD/xhtml1-strict.dtd">
  3. <html><head><title>QXmlFormatter Class Reference</title><style>h3.fn,span.fn { margin-left: 1cm; text-indent: -1cm }
  4. a:link { color: #004faf; text-decoration: none }
  5. a:visited { color: #672967; text-decoration: none }
  6. td.postheader { font-family: sans-serif }
  7. tr.address { font-family: sans-serif }
  8. body { background: #ffffff; color: black; }
  9. </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">&#160;&#160;</td><td class="postheader" valign="center"><a href="index.html"><font color="#004faf">Home</font></a>&#160;&#183; <a href="classes.html"><font color="#004faf">All Classes</font></a>&#160;&#183; <a href="modules.html"><font color="#004faf">Modules</font></a></td></table><h1 align="center">QXmlFormatter Class Reference<br /><sup><sup>[<a href="qtxmlpatterns.html">QtXmlPatterns</a> module]</sup></sup></h1><p>The QXmlFormatter class is an implementation of <a href="qxmlserializer.html">QXmlSerializer</a> for transforming <a href="xmlprocessing.html">XQuery</a> output into formatted XML. <a href="#details">More...</a></p>
  10. <p>Inherits <a href="qxmlserializer.html">QXmlSerializer</a>.</p><h3>Methods</h3><ul><li><div class="fn" /><b><a href="qxmlformatter.html#QXmlFormatter">__init__</a></b> (<i>self</i>, QXmlQuery&#160;<i>query</i>, QIODevice&#160;<i>outputDevice</i>)</li><li><div class="fn" /><b><a href="qxmlformatter.html#atomicValue">atomicValue</a></b> (<i>self</i>, QVariant&#160;<i>value</i>)</li><li><div class="fn" /><b><a href="qxmlformatter.html#attribute">attribute</a></b> (<i>self</i>, QXmlName&#160;<i>name</i>, QStringRef&#160;<i>value</i>)</li><li><div class="fn" /><b><a href="qxmlformatter.html#characters">characters</a></b> (<i>self</i>, QStringRef&#160;<i>value</i>)</li><li><div class="fn" /><b><a href="qxmlformatter.html#comment">comment</a></b> (<i>self</i>, QString&#160;<i>value</i>)</li><li><div class="fn" /><b><a href="qxmlformatter.html#endDocument">endDocument</a></b> (<i>self</i>)</li><li><div class="fn" /><b><a href="qxmlformatter.html#endElement">endElement</a></b> (<i>self</i>)</li><li><div class="fn" /><b><a href="qxmlformatter.html#endOfSequence">endOfSequence</a></b> (<i>self</i>)</li><li><div class="fn" />int <b><a href="qxmlformatter.html#indentationDepth">indentationDepth</a></b> (<i>self</i>)</li><li><div class="fn" /><b><a href="qxmlformatter.html#processingInstruction">processingInstruction</a></b> (<i>self</i>, QXmlName&#160;<i>name</i>, QString&#160;<i>value</i>)</li><li><div class="fn" /><b><a href="qxmlformatter.html#setIndentationDepth">setIndentationDepth</a></b> (<i>self</i>, int&#160;<i>depth</i>)</li><li><div class="fn" /><b><a href="qxmlformatter.html#startDocument">startDocument</a></b> (<i>self</i>)</li><li><div class="fn" /><b><a href="qxmlformatter.html#startElement">startElement</a></b> (<i>self</i>, QXmlName&#160;<i>name</i>)</li><li><div class="fn" /><b><a href="qxmlformatter.html#startOfSequence">startOfSequence</a></b> (<i>self</i>)</li></ul><a name="details" /><hr /><h2>Detailed Description</h2><p>The QXmlFormatter class is an implementation of <a href="qxmlserializer.html">QXmlSerializer</a> for transforming <a href="xmlprocessing.html">XQuery</a> output into formatted XML.</p>
  11. <p>QXmlFormatter is a subclass of <a href="qxmlserializer.html">QXmlSerializer</a> that formats the XML
  12. output to make it easier for humans to read.</p>
  13. <p><a href="qxmlserializer.html">QXmlSerializer</a> outputs XML
  14. without adding unnecessary whitespace. In particular, it does not
  15. add <i>newlines</i> and indentation. To make the XML output easier
  16. to read, QXmlFormatter adds <i>newlines</i> and indentation by
  17. adding, removing, and modifying <a href="qabstractxmlreceiver.html#xquery-sequence">sequence nodes</a> that
  18. only consist of whitespace. It also modifies whitespace in other
  19. places where it is not significant; e.g., between attributes and in
  20. the document prologue.</p>
  21. <p>For example, where the base class <a href="qxmlserializer.html">QXmlSerializer</a> would output this:</p>
  22. <pre class="cpp">
  23. &lt;a&gt;&lt;b/&gt;&lt;c/&gt;&lt;p&gt;Some Text&lt;/p&gt;&lt;/a&gt;
  24. </pre>
  25. <p>QXmlFormatter outputs this:</p>
  26. <pre class="cpp">
  27. &lt;a&gt;
  28. &lt;b/&gt;
  29. &lt;c/&gt;
  30. &lt;p&gt;Some Text&lt;/p&gt;
  31. &lt;/a&gt;
  32. </pre>
  33. <p>If you just want to serialize your XML in a human-readable
  34. format, use QXmlFormatter as it is. The default indentation level
  35. is 4 spaces, but you can set your own indentation value <a href="qxmlformatter.html#setIndentationDepth">setIndentationDepth</a>().</p>
  36. <p>The <i>newlines</i> and indentation added by QXmlFormatter are
  37. suitable for common formats, such as XHTML, SVG, or Docbook, where
  38. whitespace is not significant. However, if your XML will be used as
  39. input where whitespace is significant, then you must write your own
  40. subclass of <a href="qxmlserializer.html">QXmlSerializer</a> or
  41. <a href="qabstractxmlreceiver.html">QAbstractXmlReceiver</a>.</p>
  42. <p>Note that using QXmlFormatter instead of <a href="qxmlserializer.html">QXmlSerializer</a> will increase
  43. computational overhead and document storage size due to the
  44. insertion of whitespace.</p>
  45. <p>Note also that the indentation style used by QXmlFormatter
  46. remains loosely defined and may change in future versions of Qt. If
  47. a specific indentation style is required then either use the base
  48. class <a href="qxmlserializer.html">QXmlSerializer</a> directly, or
  49. write your own subclass of <a href="qxmlserializer.html">QXmlSerializer</a> or <a href="qabstractxmlreceiver.html">QAbstractXmlReceiver</a>.
  50. Alternatively, you can subclass QXmlFormatter and reimplement the
  51. callbacks there.</p>
  52. <pre class="cpp">
  53. <span class="type"><a href="qxmlquery.html">QXmlQuery</a></span> query;
  54. query<span class="operator">.</span>setQuery(<span class="string">"doc('index.html')/html/body/p[1]"</span>);
  55. <span class="type">QXmlFormatter</span> formatter(query<span class="operator">,</span> myOutputDevice);
  56. formatter<span class="operator">.</span><a href="qxmlformatter.html#setIndentationDepth">setIndentationDepth</a>(<span class="number">2</span>);
  57. query<span class="operator">.</span>evaluateTo(<span class="operator">&amp;</span>formatter);
  58. </pre><hr /><h2>Method Documentation</h2><h3 class="fn"><a name="QXmlFormatter" />QXmlFormatter.__init__ (<i>self</i>, <a href="qxmlquery.html">QXmlQuery</a>&#160;<i>query</i>, <a href="qiodevice.html">QIODevice</a>&#160;<i>outputDevice</i>)</h3><p>Constructs a formatter that uses the name pool and message
  59. handler in <i>query</i>, and writes the result to
  60. <i>outputDevice</i> as formatted XML.</p>
  61. <p><i>outputDevice</i> is passed directly to <a href="qxmlserializer.html">QXmlSerializer</a>'s constructor.</p>
  62. <p><b>See also</b> <a href="qxmlserializer.html">QXmlSerializer</a>.</p>
  63. <h3 class="fn"><a name="atomicValue" />QXmlFormatter.atomicValue (<i>self</i>, QVariant&#160;<i>value</i>)</h3><p>Reimplemented from <a href="qabstractxmlreceiver.html#atomicValue">QAbstractXmlReceiver.atomicValue</a>().</p>
  64. <h3 class="fn"><a name="attribute" />QXmlFormatter.attribute (<i>self</i>, <a href="qxmlname.html">QXmlName</a>&#160;<i>name</i>, QStringRef&#160;<i>value</i>)</h3><p>Reimplemented from <a href="qabstractxmlreceiver.html#attribute">QAbstractXmlReceiver.attribute</a>().</p>
  65. <h3 class="fn"><a name="characters" />QXmlFormatter.characters (<i>self</i>, QStringRef&#160;<i>value</i>)</h3><p>Reimplemented from <a href="qabstractxmlreceiver.html#characters">QAbstractXmlReceiver.characters</a>().</p>
  66. <h3 class="fn"><a name="comment" />QXmlFormatter.comment (<i>self</i>, QString&#160;<i>value</i>)</h3><p>Reimplemented from <a href="qabstractxmlreceiver.html#comment">QAbstractXmlReceiver.comment</a>().</p>
  67. <h3 class="fn"><a name="endDocument" />QXmlFormatter.endDocument (<i>self</i>)</h3><p>Reimplemented from <a href="qabstractxmlreceiver.html#endDocument">QAbstractXmlReceiver.endDocument</a>().</p>
  68. <h3 class="fn"><a name="endElement" />QXmlFormatter.endElement (<i>self</i>)</h3><p>Reimplemented from <a href="qabstractxmlreceiver.html#endElement">QAbstractXmlReceiver.endElement</a>().</p>
  69. <h3 class="fn"><a name="endOfSequence" />QXmlFormatter.endOfSequence (<i>self</i>)</h3><p>Reimplemented from <a href="qabstractxmlreceiver.html#endOfSequence">QAbstractXmlReceiver.endOfSequence</a>().</p>
  70. <h3 class="fn"><a name="indentationDepth" />int QXmlFormatter.indentationDepth (<i>self</i>)</h3><p>Returns the number of spaces <a href="qxmlformatter.html">QXmlFormatter</a> will output for each
  71. indentation level. The default is four.</p>
  72. <p><b>See also</b> <a href="qxmlformatter.html#setIndentationDepth">setIndentationDepth</a>().</p>
  73. <h3 class="fn"><a name="processingInstruction" />QXmlFormatter.processingInstruction (<i>self</i>, <a href="qxmlname.html">QXmlName</a>&#160;<i>name</i>, QString&#160;<i>value</i>)</h3><p>Reimplemented from <a href="qabstractxmlreceiver.html#processingInstruction">QAbstractXmlReceiver.processingInstruction</a>().</p>
  74. <h3 class="fn"><a name="setIndentationDepth" />QXmlFormatter.setIndentationDepth (<i>self</i>, int&#160;<i>depth</i>)</h3><p>Sets <i>depth</i> to be the number of spaces <a href="qxmlformatter.html">QXmlFormatter</a> will output for level of
  75. indentation. The default is four.</p>
  76. <p><b>See also</b> <a href="qxmlformatter.html#indentationDepth">indentationDepth</a>().</p>
  77. <h3 class="fn"><a name="startDocument" />QXmlFormatter.startDocument (<i>self</i>)</h3><p>Reimplemented from <a href="qabstractxmlreceiver.html#startDocument">QAbstractXmlReceiver.startDocument</a>().</p>
  78. <h3 class="fn"><a name="startElement" />QXmlFormatter.startElement (<i>self</i>, <a href="qxmlname.html">QXmlName</a>&#160;<i>name</i>)</h3><p>Reimplemented from <a href="qabstractxmlreceiver.html#startElement">QAbstractXmlReceiver.startElement</a>().</p>
  79. <h3 class="fn"><a name="startOfSequence" />QXmlFormatter.startOfSequence (<i>self</i>)</h3><p>Reimplemented from <a href="qabstractxmlreceiver.html#startOfSequence">QAbstractXmlReceiver.startOfSequence</a>().</p>
  80. <address><hr /><div align="center"><table border="0" cellspacing="0" width="100%"><tr class="address"><td align="left" width="25%">PyQt&#160;4.9.4 for X11</td><td align="center" width="50%">Copyright &#169; <a href="http://www.riverbankcomputing.com">Riverbank&#160;Computing&#160;Ltd</a> and <a href="http://www.qtsoftware.com">Nokia</a> 2012</td><td align="right" width="25%">Qt&#160;4.8.2</td></tr></table></div></address></body></html>