![]() |
Home · All Classes · Main Classes · Grouped Classes · Modules · Functions | ![]() |
The QAbstractXmlNodeModel class provides an abstract interface for representing arbitrary data as XML. More...
#include <QAbstractXmlNodeModel>
Inherits QSharedData.
Inherited by QPatternist::AccelTree, QPatternist::QObjectNodeModel, and QSimpleXmlNodeModel.
Note: All the functions in this class are reentrant.
This class was introduced in Qt 4.4.
The QAbstractXmlNodeModel class provides an abstract interface for representing arbitrary data as XML.
The QAbstractXmlNodeModel defines the interface that custom node models must use when being part of XQuery queries.
For instance, let's consider that we have a chemistry application whose molecules and atoms we want to query with an XQuery. So we write a QAbstractXmlNodeModel sub-class that delegates the structure that represent modules and atoms through the generic QAbstractXmlNodeModel interface, such that the Patternist engine can see them as XML nodes, without having to know that they really are. Once that is done, a QXmlNodeModelIndex instance is created by calling createIndex(), which subsequently is bound to a variable in the query using QXmlQuery::bindVariable().
For that reason QAbstractXmlNodeModel is rather central. It bridges the XML world that XQuery understands, to any custom model. For instance, if Patternist needs to know the name of a particular node, it will call name() and pass the QXmlNodeModelIndex for which it wants to know the name. kind(), stringValue(), baseUri(), documentUri() are called when other simple properties are needed.
For navigating nodes, Patternist calls iterate() and passes in a QXmlNodeModelIndex::Axis and a QXmlNodeModelIndex, and hence asks for an iterator that returns the nodes that resides on that particular axis.
QAbstractXmlNodeModel is a powerful mechnism that allows a whole XQuery engine to be applied to arbitrary data On the other hand, it can require quite some work to subclass it. For that reason QSimpleXmlNodeModel exists, which makes common scenarios easier.
A smart pointer to a QAbstractXmlNodeModel instance.
Default constructor.
Destructor.
Returns the base URI for n.
The caller guarantees that n is not null and that it belongs to this QAbstractXmlNodeModel instance.
The base URI of nodes can be extracted using the fn:base-uri() function, and is typically used for resolving relative URIs appearing directly, or as child of the node. It is conformant to just return the document URI, although that might not properly reflect the underlying data.
This function maps to the dm:base-uri accessor, which the specification completely specifies. Here's a summary:
The implementation guarantees to return a valid QUrl instance, or a default constructed QUrl instance. If a node has no base URI, such as in the case of that a comment has no parent, a default constructed QUrl is returned.
See also XQuery 1.0 and XPath 2.0 Data Model (XDM), 5.2 base-uri Accessor.
Returns the relative document order between ni1 and ni2.
This is used for the is operator, and to sort nodes in document order.
The caller guarantees that ni1 and ni2 are not null and that they belong to this QAbstractXmlNodeModel instance.
If ni1 is identical to ni2, QXmlNodeModelIndex::Is is returned. If ni1 precedes ni2 in document order, QXmlNodeModelIndex::Precedes is returned. If ni1 follows ni2 in document order, QXmlNodeModelIndex::Follows is returned.
Creates a node index with data as its internal data.
What data is, is not constrained.
This is an overloaded member function, provided for convenience.
Creates a node index with pointer and additionalData as its internal data.
What pointer and additionalData is, is not constrained.
This is an overloaded member function, provided for convenience.
Creates a QXmlNodeModelIndex that houses data and additionalData.
Returns the document URI of n.
The document URI identifies the resource which is the document. For instance, if the document would be a regular file, it would perhaps be the file:/ or http:// URL of the location. The document URI is used for resolving URIs and to simply know where the document is.
If the data model maps to a URI in a natural way -- use that. Otherwise return the company or product's URI. It can be any URI as long as its valid and absolute.
The caller guarantees that n is not null and that it belongs to this QAbstractXmlNodeModel instance.
This function maps to the dm:document-uri accessor, which the specification completely specifies. Here's a summary:
- If n is a document node, return an absolute, valid QUrl containing the document URI, or a default constructed QUrl. The latter signals that no document URI is available for the document node. - For all other kinds of nodes, return a default constructed QUrl.
See also XQuery 1.0 and XPath 2.0 Data Model (XDM), 5.4 document-uri Accessor, QUrl::isValid(), and QUrl::isRelative().
Returns the element that has id id. XQuery's id() function ends up calling this.
Returns the element node whose typed value is of type ID and equals id, or the element that has an attribute whose typed value is of type ID and equals id. If there is no such element, a default constructed QXmlNodeModelIndex instance is returned. The implementor guarantees the returned node, if not null, is an element.
In effect it's not sufficient for an attribute or element to merely be called id in order to be of type ID. However, the reserved name xml:id is always recognized as so.
The caller guarantees that id is a valid instance of xs:NCName.
See also XQuery 1.0 and XPath 2.0 Functions and Operators, 15.5.2 fn:id.
Returns the element or atttribute that an IDREF value equal to idref. XQuery's idref() function ends up calling this.
The implementor guarantees the returned node, if not null, is an element or attribute.
In effect it's not sufficient for an attribute or element to merely be called idref in order to be of type IDREF. Elements must be typed as xs:IDREF or xs:IDREFS, or in the case of attributes only, as IDREF or IDREFS in the DTD.
The caller guarantees that idref is a valid instance of xs:NCName.
See also XQuery 1.0 and XPath 2.0 Functions and Operators, 15.5.3 fn:idref.
Determines what node kind ni is. Simply, whether ni is an element or comment for instance.
The caller guarantees that ni is not null and that it belongs to this QAbstractXmlNodeModel instance.
This function maps to the dm:node-kind() accessor.
See also XQuery 1.0 and XPath 2.0 Data Model (XDM), 5.10 node-kind Accessor.
Returns the name of ni.
The caller guarantees that ni is not null and that it belong to this QAbstractXmlNodeModel instance.
If a node does not have a name, such as a comment code, a null QXmlName is returned. QXmlName instances must be created with the same QXmlQuery instance that is used for evaluating queries using this QAbstractXmlNodeModel instance.
This function maps to the dm:node-name() accessor.
As specified, if ni is a processing instruction, a QXmlName is returned where the local name is the target name and the namespace URI and prefix is empty.
See also XQuery 1.0 and XPath 2.0 Data Model (XDM), 5.11 node-name Accessor and QXmlName.
Returns the in-scope namespaces of n.
The caller guarantees that n is not null and that it belong to this QAbstractXmlNodeModel instance.
This corresponds to the dm:namespace-nodes accessor.
Note: This is not only the namespace declarations that appear on this element, but takes also into account namespace bindings of the ancestors.
The caller guarantees that n is an Element.
Returns the root node of the tree that n is part of. This is typically a document node. This function is used among other things for fn:root() and the root expression, such as seen in the expression /html.
The caller guarantees that n is null, or that it is not null and that it belong to this QAbstractXmlNodeModel instance.
If n is a direct child of the QXmlNodeModelIndex returned from this function, parent() would return the same QXmlNodeModelIndex.
Returns the string value for node n.
The caller guarantees that n is not null and that it belong to this QAbstractXmlNodeModel instance.
This function maps to the dm:string-value() accessor, which the specification completely specifies. Here's a summary:
See also XQuery 1.0 and XPath 2.0 Data Model (XDM), 5.13 string-value Accessor.
Returns the typed value for node node.
The typed value is an atomic value, which an element or attribute contains.
The caller guarantees that node is either an element or an attribute. The implementor guarantees that the returned QVariant has a value which is supported in XQuery. It cannot be an arbitrary QVariant value. The implementor also guarantees that stringValue() returns a lexical representation of typedValue()(this is guaranteed by QSimpleXmlNodeModel::stringValue()).
Copyright © 2007 Trolltech | Trademarks | Qt 4.4.0-tp1 |