![]() |
Home · All Classes · Main Classes · Grouped Classes · Modules · Functions | ![]() |
The QSimpleXmlNodeModel class provides a simple yet powerful way of implementing QAbstractXmlNodeModel. More...
#include <QSimpleXmlNodeModel>
Inherits QAbstractXmlNodeModel.
Note: All the functions in this class are reentrant.
This class was introduced in Qt 4.4.
The QSimpleXmlNodeModel class provides a simple yet powerful way of implementing QAbstractXmlNodeModel.
Since QAbstractXmlNodeModel::iterate() requires a sub-class of QAbstractXmlForwardIterator to be returned for each axis, it can be a bit time consuming to implement. For that reason QSimpleXmlNodeModel exists which has nextFromSimpleAxis(), that that is a quick but often sufficient way of providing the node navigation. Behind the scenes QSimpleXmlNodeModel::iterate() "emulates" the full XPath axes using nextFromSimpleAxis().
Apart from nextFromSimpleAxis(), QSimpleXmlNodeModel provides default implementations for many of the members in QAbstractXmlNodeModel that are suitable for a wide range of scenarios.
Four axes that only contain one node each.
Constant | Value | Description |
---|---|---|
QSimpleXmlNodeModel::Parent | 0 | The parent of the context node |
QSimpleXmlNodeModel::FirstChild | 1 | The first child of the context node |
QSimpleXmlNodeModel::PreviousSibling | 2 | The previous sibling of the context node |
QSimpleXmlNodeModel::NextSibling | 3 | The next sibling of the context node |
Constructs a QSimpleXmlNodeModel instance that can be used with the name pool namePool. It can subsequently be accessed with namePool().
Destructor.
Returns the attributes that element element has.
The caller guarantees that element is always an element.
Returns the base URI for node. This is always the document URI. This is safe, works and is often ok.
Reimplemented from QAbstractXmlNodeModel.
See also documentUri().
Always returns a default constructed QXmlNodeModelIndex instance, regardless of id.
This effectively means the model has no elements that has an id.
Reimplemented from QAbstractXmlNodeModel.
Always returns a default constructed QXmlNodeModelIndex instance, regardless of idref.
This effectively means the model has no elements or attributes are of type IDREF.
Reimplemented from QAbstractXmlNodeModel.
Returns the name pool that is associated with this model. The implementation of name() would use this to create names.
Returns always an empty QVector. This signals that no namespace bindings are in scope for node.
Reimplemented from QAbstractXmlNodeModel.
When Patternist calls iterate(), QSimpleXmlNodeModel create iterators that calls nextFromSimpleAxis() and "emulates" real XPath axes using QSimpleXmlNodeModel::SimpleAxis. Therefore, the implementation of this function should return the node, if any, that appear on axis axis, from origin.
If no such node is available, a default constructed QXmlNodeModelIndex is returned.
QSimpleXmlNodeModel removes the need to handle redundant corner cases by guaranteeing that it will never ask for:
A typical implementation does a switch over axis:
QXmlItemIteratorPointer MyTreeModel::nextFromSimpleAxis(SimpleAxis axis, const QXmlNodeModelIndex &origin) const { // Convert the QXmlNodeModelIndex to a value that is specific to what we represent. const MyValue value = toMyValue(ni); switch(axis) { case Parent: return toNodeIndex(value.parent()); case FirstChild: case PreviousSibling: case NextSibling: // and so on } }
If node is an element or attribute, typedValue() is called, and the return value converted to a string, as per XQuery's rules.
If node is another type of node, the empty string is returned.
If this function is overriden for for instance comments or processing instructions, it is important to remember to call this function for elements and attribute, if they have atomic values that are not of type xs:string, such that they get formatted according to XQuery.
Reimplemented from QAbstractXmlNodeModel.
Copyright © 2007 Trolltech | Trademarks | Qt 4.4.0-tp1 |