|  | Home · All Classes · Main Classes · Grouped Classes · Modules · Functions |

# QSimpleXmlNodeModel Class Reference
[QtXmlPatterns module]

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.

- List of all members, including inherited members

### Public Functions

- QSimpleXmlNodeModel ( const QXmlNamePool & namePool )
- virtual ~QSimpleXmlNodeModel ()
- virtual QUrl baseUri ( const QXmlNodeModelIndex & node ) const
- virtual QXmlNodeModelIndex elementById ( const QXmlName & id ) const
- QXmlNamePool & namePool () const
- virtual QVector<QXmlName> namespaceBindings ( const QXmlNodeModelIndex & node ) const
- virtual QVector<QXmlNodeModelIndex> nodesByIdref ( const QXmlName & idref ) const
- virtual QString stringValue ( const QXmlNodeModelIndex & node ) const

- 11 public functions inherited from QAbstractXmlNodeModel

### Additional Inherited Members

- 5 protected functions inherited from QAbstractXmlNodeModel

## Detailed Description

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.

Sub-classes of QSimpleXmlNodeModel must be thread-safe, just like sub-classes other sub-classes of QAbstractXmlNodeModel.

## Member Function Documentation

### QSimpleXmlNodeModel::QSimpleXmlNodeModel ( const QXmlNamePool & namePool )

Constructs a QSimpleXmlNodeModel instance that can be used with the name pool namePool. It can subsequently be accessed with namePool().

### QSimpleXmlNodeModel::~QSimpleXmlNodeModel () `[virtual]`

Destructor.

### QUrl QSimpleXmlNodeModel::baseUri ( const QXmlNodeModelIndex & node ) const `[virtual]`

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().

### QXmlNodeModelIndex QSimpleXmlNodeModel::elementById ( const QXmlName & id ) const `[virtual]`

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.

### QXmlNamePool & QSimpleXmlNodeModel::namePool () const

Returns the name pool that is associated with this model. The implementation of name() would use this to create names.

### QVector<QXmlName> QSimpleXmlNodeModel::namespaceBindings ( const QXmlNodeModelIndex & node ) const `[virtual]`

Returns always an empty QVector. This signals that no namespace bindings are in scope for node.

Reimplemented from QAbstractXmlNodeModel.

### QVector<QXmlNodeModelIndex> QSimpleXmlNodeModel::nodesByIdref ( const QXmlName & idref ) const `[virtual]`

Always returns an empty vector, regardless of idref.

This effectively means the model has no elements or attributes of type `IDREF`.

Reimplemented from QAbstractXmlNodeModel.

### QString QSimpleXmlNodeModel::stringValue ( const QXmlNodeModelIndex & node ) const `[virtual]`

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.