CopperSpice API
1.9.2
|
The QAbstractXmlReceiver class provides a callback interface for transforming the output of a QXmlQuery. More...
Public Methods | |
QAbstractXmlReceiver () | |
virtual | ~QAbstractXmlReceiver () |
virtual void | atomicValue (const QVariant &value) = 0 |
virtual void | attribute (const QXmlName &name, QStringView value) = 0 |
virtual void | characters (QStringView value) = 0 |
virtual void | comment (const QString &value) = 0 |
virtual void | endDocument () = 0 |
virtual void | endElement () = 0 |
virtual void | endOfSequence () = 0 |
virtual void | namespaceBinding (const QXmlName &name) = 0 |
virtual void | processingInstruction (const QXmlName &target, const QString &value) = 0 |
virtual void | startDocument () = 0 |
virtual void | startElement (const QXmlName &name) = 0 |
virtual void | startOfSequence () = 0 |
The QAbstractXmlReceiver class provides a callback interface for transforming the output of a QXmlQuery. QAbstractXmlReceiver is an abstract base class that provides a callback interface for receiving an XQuery sequence, usually the output of an QXmlQuery, and transforming that sequence into a structure of your choosing, usually XML.
First it constructs a query that gets the first paragraph from document index.html
. Then it constructs an XML serializer with the query and myOutputDevice (Note the serializer is an XML receiver, ie a subclass of QAbstractXmlReceiver). 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.
Although the example uses QXmlQuery 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 XQuery sequence.
An XQuery sequence is an ordered collection of zero, one, or many items. Each item is either an atomic value or a node. An atomic value is a simple data value.
There are six kinds of nodes.
The sequence of nodes and atomic values obeys the following rules. Note that Namespace Node refers to a special Attribute Node with name xmlns.
The sequence of nodes and atomic values is sent to an QAbstractXmlReceiver (QXmlSerializer 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.
For a complete explanation of XQuery sequences, visit XQuery Data Model.
QAbstractXmlReceiver::QAbstractXmlReceiver | ( | ) |
Constructs an abstract xml receiver.
|
virtual |
Destroys the xml receiver.
|
pure virtual |
This callback is called when an atomic value appears in the sequence. The value is a simple data value. It is guaranteed to be valid.
Implemented in QXmlSerializer::atomicValue(), QXmlFormatter::atomicValue()
|
pure virtual |
This callback is called when an attribute node appears in the sequence. The name is the attribute name and the value string contains the attribute value.
Implemented in QXmlSerializer::attribute(), QXmlFormatter::attribute()
|
pure virtual |
This callback is called when a text node appears in the sequence. The value contains the text. Adjacent text nodes may not occur in the sequence, i.e., this callback must not be called twice in a row.
Implemented in QXmlSerializer::characters(), QXmlFormatter::characters()
|
pure virtual |
This callback is called when a comment node appears in the sequence. The value is the comment text, which must not contain the string "–".
Implemented in QXmlSerializer::comment(), QXmlFormatter::comment()
|
pure virtual |
This callback is called when the end of a document node appears in the sequence.
Implemented in QXmlSerializer::endDocument(), QXmlFormatter::endDocument()
|
pure virtual |
This callback is called when the end of an element node appears in the sequence.
Implemented in QXmlSerializer::endElement(), QXmlFormatter::endElement()
|
pure virtual |
This callback is called once only, right after the sequence ends.
Implemented in QXmlSerializer::endOfSequence(), QXmlFormatter::endOfSequence()
|
pure virtual |
This callback is called when a namespace binding is in scope of an element. A namespace is defined by a URI. In the QXmlName name, the value of QXmlName::namespaceUri() is that URI. The value of QXmlName::prefix() is the prefix that the URI is bound to. The local name is insignificant and can be an arbitrary value.
Implemented in QXmlSerializer::namespaceBinding()
|
pure virtual |
This callback is called when a processing instruction appears in the sequence. 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.
The target is the name of the processing instruction. Its prefix and namespace URI must both be empty. Its local name is the target. In the above example, the name is xml-stylesheet.
The value specifies the action to be taken. The value must not contain the string "?>". In the above example the value is type="test/xsl" href="formatter.xsl.
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.
Implemented in QXmlSerializer::processingInstruction(), QXmlFormatter::processingInstruction()
|
pure virtual |
This callback is called when a document node appears in the sequence.
Implemented in QXmlSerializer::startDocument(), QXmlFormatter::startDocument()
|
pure virtual |
This callback is called when a new element node appears in the sequence. The name is the valid name of the node element.
Implemented in QXmlSerializer::startElement(), QXmlFormatter::startElement()
|
pure virtual |
This callback is called once only, right before the sequence begins.
Implemented in QXmlSerializer::startOfSequence(), QXmlFormatter::startOfSequence()