<?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>QAbstractXmlReceiver 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="index.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">QAbstractXmlReceiver Class Reference<br /><sup><sup>[<a href="qtxmlpatterns.html">QtXmlPatterns</a> module]</sup></sup></h1><p>The QAbstractXmlReceiver class provides a callback interface for transforming the output of a <a href="qxmlquery.html">QXmlQuery</a>. <a href="#details">More...</a></p> <p>Inherited by <a href="qxmlserializer.html">QXmlSerializer</a>.</p><h3>Methods</h3><ul><li><div class="fn" /><b><a href="qabstractxmlreceiver.html#QAbstractXmlReceiver">__init__</a></b> (<i>self</i>)</li><li><div class="fn" /><b><a href="qabstractxmlreceiver.html#atomicValue">atomicValue</a></b> (<i>self</i>, QVariant <i>value</i>)</li><li><div class="fn" /><b><a href="qabstractxmlreceiver.html#attribute">attribute</a></b> (<i>self</i>, QXmlName <i>name</i>, QStringRef <i>value</i>)</li><li><div class="fn" /><b><a href="qabstractxmlreceiver.html#characters">characters</a></b> (<i>self</i>, QStringRef <i>value</i>)</li><li><div class="fn" /><b><a href="qabstractxmlreceiver.html#comment">comment</a></b> (<i>self</i>, QString <i>value</i>)</li><li><div class="fn" /><b><a href="qabstractxmlreceiver.html#endDocument">endDocument</a></b> (<i>self</i>)</li><li><div class="fn" /><b><a href="qabstractxmlreceiver.html#endElement">endElement</a></b> (<i>self</i>)</li><li><div class="fn" /><b><a href="qabstractxmlreceiver.html#endOfSequence">endOfSequence</a></b> (<i>self</i>)</li><li><div class="fn" /><b><a href="qabstractxmlreceiver.html#namespaceBinding">namespaceBinding</a></b> (<i>self</i>, QXmlName <i>name</i>)</li><li><div class="fn" /><b><a href="qabstractxmlreceiver.html#processingInstruction">processingInstruction</a></b> (<i>self</i>, QXmlName <i>target</i>, QString <i>value</i>)</li><li><div class="fn" /><b><a href="qabstractxmlreceiver.html#startDocument">startDocument</a></b> (<i>self</i>)</li><li><div class="fn" /><b><a href="qabstractxmlreceiver.html#startElement">startElement</a></b> (<i>self</i>, QXmlName <i>name</i>)</li><li><div class="fn" /><b><a href="qabstractxmlreceiver.html#startOfSequence">startOfSequence</a></b> (<i>self</i>)</li></ul><a name="details" /><hr /><h2>Detailed Description</h2><p>The QAbstractXmlReceiver class provides a callback interface for transforming the output of a <a href="qxmlquery.html">QXmlQuery</a>.</p> <p>QAbstractXmlReceiver is an abstract base class that provides a callback interface for receiving an <a href="#xquery-sequence">XQuery sequence</a>, usually the output of an <a href="qxmlquery.html">QXmlQuery</a>, and transforming that sequence into a structure of your choosing, usually XML. Consider the example:</p> <pre class="cpp"> <span class="type"><a href="qxmlquery.html">QXmlQuery</a></span> query; query<span class="operator">.</span>setQuery(<span class="string">"doc('index.html')/html/body/p[1]"</span>); <span class="type"><a href="qxmlserializer.html">QXmlSerializer</a></span> serializer(query<span class="operator">,</span> myOutputDevice); query<span class="operator">.</span>evaluateTo(<span class="operator">&</span>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 <a href="qxmlserializer.html">XML serializer</a> with the <a href="qxmlquery.html">query</a> and <a href="qiodevice.html">myOutputDevice</a> (Note the <a href="qxmlserializer.html">serializer</a> is an <i>XML receiver</i>, ie a subclass of QAbstractXmlReceiver). Finally, it <a href="qxmlquery.html#evaluateTo">evaluates</a> the <a href="qxmlquery.html">query</a>, producing an ordered sequence of calls to the <a href="qxmlserializer.html">serializer's</a> callback functions. The sequence of callbacks transforms the query output to XML and writes it to <a href="qiodevice.html">myOutputDevice</a>.</p> <p>Although the example uses <a href="qxmlquery.html">QXmlQuery</a> to produce the sequence of callbacks to functions in QAbstractXmlReceiver, you can call the callback functions directly as long as your sequence of calls represents a valid <a href="#xquery-sequence">XQuery sequence</a>.</p> <a id="xquery-sequence" name="xquery-sequence" /><a id="xquery-sequences" name="xquery-sequences" /> <h3>XQuery Sequences</h3> <p>An <a href="xmlprocessing.html">XQuery</a> <i>sequence</i> is an ordered collection of zero, one, or many <i>items</i>. Each <i>item</i> is either an <i>atomic value</i> or a <i>node</i>. An <i>atomic value</i> is a simple data value.</p> <p>There are six kinds of <i>nodes</i>.</p> <ul> <li>An <i>Element Node</i> represents an XML element.</li> <li>An <i>Attribute Node</i> represents an XML attribute.</li> <li>A <i>Document Node</i> represents an entire XML document.</li> <li>A <i>Text Node</i> represents character data (element content).</li> <li>A <i>Processing Instruction Node</i> represents an XML processing instruction, which is used in an XML document to tell the application reading the document to perform some action. A typical example is to use a processing instruction to tell the application to use a particular XSLT stylesheet to display the document.</li> <li>And a <i>Comment node</i> represents an XML comment.</li> </ul> <p>The <i>sequence</i> of <i>nodes</i> and <i>atomic values</i> obeys the following rules. Note that <i>Namespace Node</i> refers to a special <i>Attribute Node</i> with name <i>xmlns</i>.</p> <ul> <li>Each <i>node</i> appears in the <i>sequence</i> before its children and their descendants appear.</li> <li>A <i>node</i>'s descendants appear in the <i>sequence</i> before any of its siblings appear.</li> <li>A <i>Document Node</i> represents an entire document. Zero or more <i>Document Nodes</i> can appear in a <i>sequence</i>, but they can only be top level items (i.e., a <i>Document Node</i> can't be a child of another <i>node</i>.</li> <li><i>Namespace Nodes</i> immediately follow the <i>Element Node</i> with which they are associated.</li> <li><i>Attribute Nodes</i> immediately follow the <i>Namespace Nodes</i> of the element with which they are associated, or...</li> <li>If there are no <i>Namespace Nodes</i> following an element, then the <i>Attribute Nodes</i> immediately follow the element.</li> <li>An <i>atomic value</i> can only appear as a top level <i>item</i>, i.e., it can't appear as a child of a <i>node</i>.</li> <li><i>Processing Instruction Nodes</i> do not have children, and their parent is either a <i>Document Node</i> or an <i>Element Node</i>.</li> <li><i>Comment Nodes</i> do not have children, and their parent is either a <i>Document Node</i> or an <i>Element Node</i>.</li> </ul> <p>The <i>sequence</i> of <i>nodes</i> and <i>atomic values</i> is sent to an QAbstractXmlReceiver (<a href="qxmlserializer.html">QXmlSerializer</a> in the example above) as a sequence of calls to the receiver's callback functions. The mapping of callback functions to sequence items is as follows.</p> <ul> <li><a href="qabstractxmlreceiver.html#startDocument">startDocument</a>() and <a href="qabstractxmlreceiver.html#endDocument">endDocument</a>() are called for each <i>Document Node</i> in the <i>sequence</i>. <a href="qabstractxmlreceiver.html#endDocument">endDocument</a>() is not called until all the <i>Document Node's</i> children have appeared in the <i>sequence</i>.</li> <li><a href="qabstractxmlreceiver.html#startElement">startElement</a>() and <a href="qabstractxmlreceiver.html#endElement">endElement</a>() are called for each <i>Element Node</i>. <a href="qabstractxmlreceiver.html#endElement">endElement</a>() is not called until all the <i>Element Node's</i> children have appeared in the <i>sequence</i>.</li> <li><a href="qabstractxmlreceiver.html#attributex">attribute</a>() is called for each <i>Attribute Node</i>.</li> <li><a href="qabstractxmlreceiver.html#comment">comment</a>() is called for each <i>Comment Node</i>.</li> <li><a href="qabstractxmlreceiver.html#characters">characters</a>() is called for each <i>Text Node</i>.</li> <li><a href="qabstractxmlreceiver.html#processingInstruction">processingInstruction</a>() is called for each <i>Processing Instruction Node</i>.</li> <li><a href="qabstractxmlreceiver.html#namespaceBinding">namespaceBinding</a>() is called for each <i>Namespace Node</i>.</li> <li><a href="qabstractxmlreceiver.html#atomicValue">atomicValue</a>() is called for each <i>atomic value</i>.</li> </ul> <p>For a complete explanation of <a href="xmlprocessing.html">XQuery</a> sequences, visit <a href="http://www.w3.org/TR/xpath-datamodel/">XQuery Data Model</a>.</p> <hr /><h2>Method Documentation</h2><h3 class="fn"><a name="QAbstractXmlReceiver" />QAbstractXmlReceiver.__init__ (<i>self</i>)</h3><p>Constructs an abstract xml receiver.</p> <h3 class="fn"><a name="atomicValue" />QAbstractXmlReceiver.atomicValue (<i>self</i>, QVariant <i>value</i>)</h3><p>This method is abstract and should be reimplemented in any sub-class.</p><p>This callback is called when an atomic value appears in the <a href="qabstractxmlreceiver.html#xquery-sequence">sequence</a>. The <i>value</i> is a simple <a href="qvariant.html">data value</a>. It is guaranteed to be <a href="qvariant.html#isValid">valid</a>.</p> <h3 class="fn"><a name="attribute" />QAbstractXmlReceiver.attribute (<i>self</i>, <a href="qxmlname.html">QXmlName</a> <i>name</i>, QStringRef <i>value</i>)</h3><p>This method is abstract and should be reimplemented in any sub-class.</p><h3 class="fn"><a name="characters" />QAbstractXmlReceiver.characters (<i>self</i>, QStringRef <i>value</i>)</h3><p>This method is abstract and should be reimplemented in any sub-class.</p><p>This callback is called when a text node appears in the <a href="qabstractxmlreceiver.html#xquery-sequence">sequence</a>. The <i>value</i> contains the text. Adjacent text nodes may not occur in the <a href="qabstractxmlreceiver.html#xquery-sequence">sequence</a>, i.e., this callback must not be called twice in a row.</p> <h3 class="fn"><a name="comment" />QAbstractXmlReceiver.comment (<i>self</i>, QString <i>value</i>)</h3><p>This method is abstract and should be reimplemented in any sub-class.</p><p>This callback is called when a comment node appears in the <a href="qabstractxmlreceiver.html#xquery-sequence">sequence</a>. The <i>value</i> is the comment text, which must not contain the string "--".</p> <h3 class="fn"><a name="endDocument" />QAbstractXmlReceiver.endDocument (<i>self</i>)</h3><p>This method is abstract and should be reimplemented in any sub-class.</p><p>This callback is called when the end of a document node appears in the <a href="qabstractxmlreceiver.html#xquery-sequence">sequence</a>.</p> <h3 class="fn"><a name="endElement" />QAbstractXmlReceiver.endElement (<i>self</i>)</h3><p>This method is abstract and should be reimplemented in any sub-class.</p><p>This callback is called when the end of an element node appears in the <a href="qabstractxmlreceiver.html#xquery-sequence">sequence</a>.</p> <h3 class="fn"><a name="endOfSequence" />QAbstractXmlReceiver.endOfSequence (<i>self</i>)</h3><p>This method is abstract and should be reimplemented in any sub-class.</p><p>This callback is called once only, right after the <a href="qabstractxmlreceiver.html#xquery-sequence">sequence</a> ends.</p> <h3 class="fn"><a name="namespaceBinding" />QAbstractXmlReceiver.namespaceBinding (<i>self</i>, <a href="qxmlname.html">QXmlName</a> <i>name</i>)</h3><p>This method is abstract and should be reimplemented in any sub-class.</p><p>This callback is called when a namespace binding is in scope of an element. A namespace is defined by a URI. In the <a href="qxmlname.html">QXmlName</a> <i>name</i>, the value of <a href="qxmlname.html#namespaceUri">QXmlName.namespaceUri</a>() is that URI. The value of <a href="qxmlname.html#prefix">QXmlName.prefix</a>() is the prefix that the URI is bound to. The local name is insignificant and can be an arbitrary value.</p> <h3 class="fn"><a name="processingInstruction" />QAbstractXmlReceiver.processingInstruction (<i>self</i>, <a href="qxmlname.html">QXmlName</a> <i>target</i>, QString <i>value</i>)</h3><p>This method is abstract and should be reimplemented in any sub-class.</p><p>This callback is called when a processing instruction appears in the <a href="qabstractxmlreceiver.html#xquery-sequence">sequence</a>. A processing instruction is used in an XML document to tell the application reading the document to perform some action. A typical example is to use a processing instruction to tell the application to use a particular XSLT stylesheet to process the document.</p> <pre class="cpp"> <?xml-stylesheet type="test/xsl" href="formatter.xsl"?> </pre> <p><i>target</i> is the <a href="qxmlname.html">name</a> of the processing instruction. Its <i>prefix</i> and <i>namespace URI</i> must both be empty. Its <i>local name</i> is the target. In the above example, the name is <i>xml-stylesheet</i>.</p> <p>The <i>value</i> specifies the action to be taken. Note that the <i>value</i> must not contain the string "?>". In the above example, the <i>value</i> is <i>type="test/xsl" href="formatter.xsl</i>.</p> <p>Generally, use of processing instructions should be avoided, because they are not namespace aware and in many contexts are stripped out anyway. Processing instructions can often be replaced with elements from a custom namespace.</p> <h3 class="fn"><a name="startDocument" />QAbstractXmlReceiver.startDocument (<i>self</i>)</h3><p>This method is abstract and should be reimplemented in any sub-class.</p><p>This callback is called when a document node appears in the <a href="qabstractxmlreceiver.html#xquery-sequence">sequence</a>.</p> <h3 class="fn"><a name="startElement" />QAbstractXmlReceiver.startElement (<i>self</i>, <a href="qxmlname.html">QXmlName</a> <i>name</i>)</h3><p>This method is abstract and should be reimplemented in any sub-class.</p><p>This callback is called when a new element node appears in the <a href="qabstractxmlreceiver.html#xquery-sequence">sequence</a>. <i>name</i> is the valid <a href="qxmlname.html">name</a> of the node element.</p> <h3 class="fn"><a name="startOfSequence" />QAbstractXmlReceiver.startOfSequence (<i>self</i>)</h3><p>This method is abstract and should be reimplemented in any sub-class.</p><p>This callback is called once only, right before the <a href="qabstractxmlreceiver.html#xquery-sequence">sequence</a> begins.</p> <address><hr /><div align="center"><table border="0" cellspacing="0" width="100%"><tr class="address"><td align="left" width="25%">PyQt 4.10.3 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> 2012</td><td align="right" width="25%">Qt 4.8.5</td></tr></table></div></address></body></html>