
We bake cookies in your browser for a better experience. Using this site means that you consent.Read More
TheQAbstractXmlReceiver class provides a callback interface for transforming the output of aQXmlQuery.More...
| Header: | #include <QAbstractXmlReceiver> |
| Since: | Qt 4.4 |
| Inherited By: |
Note: All functions in this class arereentrant.
| QAbstractXmlReceiver() | |
| virtual | ~QAbstractXmlReceiver() |
| virtual void | atomicValue(const QVariant & value) = 0 |
| virtual void | attribute(const QXmlName & name, const QStringRef & value) = 0 |
| virtual void | characters(const QStringRef & 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 |
TheQAbstractXmlReceiver class provides a callback interface for transforming the output of aQXmlQuery.
QAbstractXmlReceiver is an abstract base class that provides a callback interface for receiving anXQuery sequence, usually the output of anQXmlQuery, and transforming that sequence into a structure of your choosing, usually 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 aquery that gets the first paragraph from documentindex.html. Then it constructs anXML serializer with thequery andmyOutputDevice (Note theserializer is anXML receiver, ie a subclass ofQAbstractXmlReceiver). Finally, itevaluates thequery, producing an ordered sequence of calls to theserializer's callback functions. The sequence of callbacks transforms the query output to XML and writes it tomyOutputDevice.
Although the example usesQXmlQuery to produce the sequence of callbacks to functions inQAbstractXmlReceiver, you can call the callback functions directly as long as your sequence of calls represents a validXQuery sequence.
AnXQuerysequence is an ordered collection of zero, one, or manyitems. Eachitem is either anatomic value or anode. Anatomic value is a simple data value.
There are six kinds ofnodes.
Thesequence ofnodes andatomic values obeys the following rules. Note thatNamespace Node refers to a specialAttribute Node with namexmlns.
Thesequence ofnodes andatomic values is sent to anQAbstractXmlReceiver (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 ofXQuery sequences, visitXQuery Data Model.
See alsoW3C XQuery 1.0 and XPath 2.0 Data Model (XDM),QXmlSerializer, andQXmlResultItems.
Constructs an abstract xml receiver.
[virtual]QAbstractXmlReceiver::~QAbstractXmlReceiver()Destroys the xml receiver.
[pure virtual]void QAbstractXmlReceiver::atomicValue(constQVariant & value)This callback is called when an atomic value appears in thesequence. Thevalue is a simpledata value. It is guaranteed to bevalid.
[pure virtual]void QAbstractXmlReceiver::attribute(constQXmlName & name, constQStringRef & value)This callback is called when an attribute node appears in thesequence.name is theattribute name and thevalue string contains the attribute value.
[pure virtual]void QAbstractXmlReceiver::characters(constQStringRef & value)This callback is called when a text node appears in thesequence. Thevalue contains the text. Adjacent text nodes may not occur in thesequence, i.e., this callback must not be called twice in a row.
[pure virtual]void QAbstractXmlReceiver::comment(constQString & value)This callback is called when a comment node appears in thesequence. Thevalue is the comment text, which must not contain the string "--".
[pure virtual]void QAbstractXmlReceiver::endDocument()This callback is called when the end of a document node appears in thesequence.
[pure virtual]void QAbstractXmlReceiver::endElement()This callback is called when the end of an element node appears in thesequence.
[pure virtual]void QAbstractXmlReceiver::endOfSequence()This callback is called once only, right after thesequence ends.
[pure virtual]void QAbstractXmlReceiver::namespaceBinding(constQXmlName & name)This callback is called when a namespace binding is in scope of an element. A namespace is defined by a URI. In theQXmlNamename, the value ofQXmlName::namespaceUri() is that URI. The value ofQXmlName::prefix() is the prefix that the URI is bound to. The local name is insignificant and can be an arbitrary value.
[pure virtual]void QAbstractXmlReceiver::processingInstruction(constQXmlName & target, constQString & value)This callback is called when a processing instruction appears in thesequence. 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.
<?xml-stylesheet type="test/xsl" href="formatter.xsl"?>
target is thename of the processing instruction. Itsprefix andnamespace URI must both be empty. Itslocal name is the target. In the above example, the name isxml-stylesheet.
Thevalue specifies the action to be taken. Note that thevalue must not contain the string "?>". In the above example, thevalue istype="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.
[pure virtual]void QAbstractXmlReceiver::startDocument()This callback is called when a document node appears in thesequence.
[pure virtual]void QAbstractXmlReceiver::startElement(constQXmlName & name)This callback is called when a new element node appears in thesequence.name is the validname of the node element.
[pure virtual]void QAbstractXmlReceiver::startOfSequence()This callback is called once only, right before thesequence begins.
© 2016 The Qt Company Ltd. Documentation contributions included herein are the copyrights of their respective owners. The documentation provided herein is licensed under the terms of theGNU Free Documentation License version 1.3 as published by the Free Software Foundation. Qt and respective logos are trademarks of The Qt Company Ltd. in Finland and/or other countries worldwide. All other trademarks are property of their respective owners.