Qt 4.8
|
Stores an XML document using the XPath Accelerator scheme, also known as pre/post numbering. More...
#include <qacceltree_p.h>
Classes | |
class | BasicNodeData |
Houses data for a node, and that all node kinds have. More... | |
Public Types | |
enum | Constants { IsCompressed = 1 } |
typedef qint8 | Depth |
typedef PreNumber | PostNumber |
typedef qint32 | PreNumber |
typedef QExplicitlySharedDataPointer< AccelTree > | Ptr |
Public Types inherited from QAbstractXmlNodeModel | |
typedef QList< Ptr > | List |
A list of smart pointers to instances of QAbstractXmlNodeModel. More... | |
enum | NodeCopySetting { InheritNamespaces = 0x1, PreserveNamespaces = 0x2 } |
typedef QFlags< NodeCopySetting > | NodeCopySettings |
typedef QExplicitlySharedDataPointer< QAbstractXmlNodeModel > | Ptr |
A QExplicitlySharedDataPointer {smart pointer} to an instance of QAbstractXmlNodeModel. More... | |
enum | SimpleAxis { Parent, FirstChild, PreviousSibling, NextSibling } |
Four axes that each contain one node only. More... | |
Public Functions | |
AccelTree (const QUrl &docURI, const QUrl &bURI) | |
virtual QUrl | baseUri (const QXmlNodeModelIndex &ni) const |
Returns the base URI for the node whose index is n. More... | |
QUrl | baseUri () const |
virtual QXmlNodeModelIndex::DocumentOrder | compareOrder (const QXmlNodeModelIndex &ni1, const QXmlNodeModelIndex &ni2) const |
This function returns the relative document order for the nodes indexed by ni1 and ni2. More... | |
virtual void | copyNodeTo (const QXmlNodeModelIndex &node, QAbstractXmlReceiver *const receiver, const NodeCopySettings &settings) const |
Depth | depth (const PreNumber pre) const |
virtual QUrl | documentUri (const QXmlNodeModelIndex &ni) const |
Returns the document URI of n. More... | |
QUrl | documentUri () const |
virtual QXmlNodeModelIndex | elementById (const QXmlName &id) const |
Returns the index of the element identified as id. More... | |
bool | hasChildren (const PreNumber pre) const |
Returns true if the node identified by pre has child nodes(in the sense of the XDM), but also if it has namespace nodes, or attribute nodes. More... | |
bool | hasFollowingSibling (const PreNumber pre) const |
bool | hasParent (const PreNumber pre) const |
bool | isCompressed (const PreNumber pre) const |
virtual QXmlNodeModelIndex::Iterator::Ptr | iterate (const QXmlNodeModelIndex &ni, QXmlNodeModelIndex::Axis axis) const |
Performs navigation, starting from ni, by returning an QAbstractXmlForwardIterator that returns nodes the axis emanating from ni. More... | |
virtual QXmlNodeModelIndex::NodeKind | kind (const QXmlNodeModelIndex &ni) const |
Returns a value indicating the kind of node identified by ni. More... | |
QXmlNodeModelIndex::NodeKind | kind (const PreNumber pre) const |
PreNumber | maximumPreNumber () const |
virtual QXmlName | name (const QXmlNodeModelIndex &ni) const |
Returns the name of ni. More... | |
QXmlName | name (const PreNumber pre) const |
virtual QVector< QXmlName > | namespaceBindings (const QXmlNodeModelIndex &n) const |
Returns the in-scope namespaces of n. More... | |
virtual QVector< QXmlNodeModelIndex > | nodesByIdref (const QXmlName &idref) const |
Returns the elements and/or attributes that have an IDREF value equal to idref. More... | |
virtual QXmlNodeModelIndex | parent (const QXmlNodeModelIndex &ni) const |
PreNumber | parent (const PreNumber pre) const |
Returns the parent node of pre . More... | |
PostNumber | postNumber (const PreNumber pre) const |
void | printStats (const NamePool::Ptr &np) const |
virtual QXmlNodeModelIndex | root (const QXmlNodeModelIndex &n) const |
Returns the root node. More... | |
virtual void | sendNamespaces (const QXmlNodeModelIndex &n, QAbstractXmlReceiver *const receiver) const |
virtual Item::Iterator::Ptr | sequencedTypedValue (const QXmlNodeModelIndex &n) const |
PreNumber | size (const PreNumber pre) const |
virtual QString | stringValue (const QXmlNodeModelIndex &n) const |
Returns the string value for node n. More... | |
PreNumber | toPreNumber (const QXmlNodeModelIndex n) const |
virtual ItemType::Ptr | type (const QXmlNodeModelIndex &ni) const |
virtual QVariant | typedValue (const QXmlNodeModelIndex &n) const |
Returns the typed value for node node. More... | |
Public Functions inherited from QAbstractXmlNodeModel | |
virtual void | copyNodeTo (const QXmlNodeModelIndex &node, QAbstractXmlReceiver *const receiver, const NodeCopySettings &) const |
virtual bool | isDeepEqual (const QXmlNodeModelIndex &ni1, const QXmlNodeModelIndex &ni2) const |
Determines whether ni1 is deep equal to ni2. More... | |
virtual QXmlName::NamespaceCode | namespaceForPrefix (const QXmlNodeModelIndex &ni, const QXmlName::PrefixCode prefix) const |
Returns the namespace URI on ni that corresponds to prefix. More... | |
QAbstractXmlNodeModel () | |
Default constructor. More... | |
virtual void | sendNamespaces (const QXmlNodeModelIndex &n, QAbstractXmlReceiver *const receiver) const |
Sends the namespaces declared on n to receiver. More... | |
QSourceLocation | sourceLocation (const QXmlNodeModelIndex &index) const |
Returns the source location for the object with the given index or a default constructed QSourceLocation in case no location information is available. More... | |
virtual | ~QAbstractXmlNodeModel () |
Destructor. More... | |
Public Functions inherited from QSharedData | |
QSharedData () | |
Constructs a QSharedData object with a reference count of 0. More... | |
QSharedData (const QSharedData &) | |
Constructs a QSharedData object with reference count 0. More... | |
Static Public Functions | |
static bool | hasPrefix (const QVector< QXmlName > &nbs, const QXmlName::PrefixCode prefix) |
Public Variables | |
QVector< BasicNodeData > | basicData |
QHash< PreNumber, QString > | data |
QUrl | m_baseURI |
QUrl | m_documentURI |
QHash< PreNumber, QVector< QXmlName > > | namespaces |
QHash< PreNumber, QPair< qint64, qint64 > > | sourcePositions |
Public Variables inherited from QSharedData | |
QAtomicInt | ref |
Protected Functions | |
virtual QVector< QXmlNodeModelIndex > | attributes (const QXmlNodeModelIndex &element) const |
Returns the attributes of element. More... | |
virtual QXmlNodeModelIndex | nextFromSimpleAxis (QAbstractXmlNodeModel::SimpleAxis, const QXmlNodeModelIndex &) const |
When QtXmlPatterns evaluate path expressions, it emulate them through a combination of calls with QSimpleXmlNodeModel::SimpleAxis values. More... | |
Protected Functions inherited from QAbstractXmlNodeModel | |
QXmlNodeModelIndex | createIndex (qint64 data) const |
Creates a node index with data as its internal data. More... | |
QXmlNodeModelIndex | createIndex (void *pointer, qint64 additionalData=0) const |
Creates a node index with pointer and additionalData as its internal data. More... | |
QXmlNodeModelIndex | createIndex (qint64 data, qint64 additionalData) const |
Creates a QXmlNodeModelIndex containing data and additionalData. More... | |
QAbstractXmlNodeModel (QAbstractXmlNodeModelPrivate *d) | |
Private Functions | |
void | copyChildren (const QXmlNodeModelIndex &node, QAbstractXmlReceiver *const receiver, const NodeCopySettings &settings) const |
QSourceLocation | sourceLocation (const QXmlNodeModelIndex &index) const |
Properties | |
QHash< QXmlName::LocalNameCode, PreNumber > | m_IDs |
Friends | |
class | AccelTreeBuilder< false > |
class | AccelTreeBuilder< true > |
class | AccelTreePrivate |
Additional Inherited Members | |
Protected Variables inherited from QAbstractXmlNodeModel | |
QScopedPointer< QAbstractXmlNodeModelPrivate > | d_ptr |
Stores an XML document using the XPath Accelerator scheme, also known as pre/post numbering.
Working on this code will be destructive without a proper understanding of the Accelerator scheme, so do check out the links. We don't implement any form of staircase join, although that is only due to time constraints.
Definition at line 92 of file qacceltree_p.h.
typedef qint8 QPatternist::AccelTree::Depth |
Definition at line 101 of file qacceltree_p.h.
Definition at line 100 of file qacceltree_p.h.
Definition at line 99 of file qacceltree_p.h.
Definition at line 98 of file qacceltree_p.h.
Enumerator | |
---|---|
IsCompressed |
Definition at line 256 of file qacceltree_p.h.
Definition at line 79 of file qacceltree.cpp.
|
protectedvirtual |
Returns the attributes of element.
The caller guarantees that element is an element in this node model.
Implements QAbstractXmlNodeModel.
Definition at line 372 of file qacceltree.cpp.
Referenced by copyNodeTo().
|
virtual |
Returns the base URI for the node whose index is n.
The caller guarantees that n is not null
and that it belongs to a node in this node model.
The base URI of a node can be extracted using the fn:base-uri
() function. The base URI is typically used for resolving relative URIs that appear in the node or its children. 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 returns a base URI according to the following:
For document nodes, the base URI and the document URI are the same.
For elements, the base URI is the URI appearing in the element's xml:base
attribute, if present, or it is resolved to the parent element's base URI.
Namespace nodes have no base URI.
The base URI for a processing instruction, comment, attribute, or text node is the base URI of the node's parent element.
The implementation guarantees to return a valid QUrl, or a default constructed QUrl. If a node has no base URI, as in the case where a comment has no parent, a default constructed QUrl is returned.
Implements QAbstractXmlNodeModel.
Definition at line 140 of file qacceltree.cpp.
|
inline |
|
virtual |
This function returns the relative document order for the nodes indexed by ni1 and ni2.
It is used for the Is
operator and for sorting nodes in document order.
The caller guarantees that ni1 and ni2 are not null
and that both identify nodes in this node model.
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.
Implements QAbstractXmlNodeModel.
Definition at line 219 of file qacceltree.cpp.
|
inlineprivate |
Copies the children of node
to receiver
.
Definition at line 720 of file qacceltree.cpp.
Referenced by copyNodeTo().
|
virtual |
Definition at line 622 of file qacceltree.cpp.
Referenced by copyChildren().
Definition at line 350 of file qacceltree_p.h.
Referenced by QPatternist::ChildIterator::ChildIterator(), QPatternist::ChildIterator::next(), and QPatternist::SiblingIterator< IsFollowing >::next().
|
virtual |
Returns the document URI of n.
The document URI identifies the resource which is the document. For example, the document could be a regular file, e.g., file:/
, or it could be the http://
URL of the location of a file. The document URI is used for resolving URIs and to simply know where the document is.
If the node model maps to a URI in a natural way, return that URI. Otherwise, return the company or product URI. The document URI 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.
This function maps to the dm:document-uri
accessor, which returns a document URI according to the following:
If n is a document node, return an absolute 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 nodes, return a default constructed QUrl.
Implements QAbstractXmlNodeModel.
Definition at line 206 of file qacceltree.cpp.
|
inline |
|
virtual |
Returns the index of the element identified as id.
XQuery's id()
function calls this function.
The node index returned will be the element node whose value is of type ID
and equals id, or it will be the element node 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 that if the returned node index is not null, it identifies an element.
It is not sufficient for an attribute or element to merely be called id
. Its value type must also be ID
. However, the reserved name xml:id
is sufficient.
In id, the namespace URI
and the prefix
are undefined, and the local name
is the ID that should be looked up.
Implements QAbstractXmlNodeModel.
Definition at line 734 of file qacceltree.cpp.
|
inline |
Returns true
if the node identified by pre
has child nodes(in the sense of the XDM), but also if it has namespace nodes, or attribute nodes.
Definition at line 294 of file qacceltree_p.h.
Referenced by QPatternist::AttributeIterator::AttributeIterator(), QPatternist::ChildIterator::ChildIterator(), QPatternist::DescendantIterator< IncludeSelf >::DescendantIterator(), iterate(), and stringValue().
|
inline |
Definition at line 317 of file qacceltree_p.h.
|
inline |
Definition at line 312 of file qacceltree_p.h.
Referenced by QPatternist::AncestorIterator< IncludeSelf >::AncestorIterator(), and iterate().
|
inlinestatic |
Definition at line 574 of file qacceltree.cpp.
Referenced by namespaceBindings().
|
inline |
|
virtual |
Performs navigation, starting from ni, by returning an QAbstractXmlForwardIterator that returns nodes the axis emanating from ni.
The implementation returns the nodes on the axis, without duplicates and in axis order. This means that if axis is a reverse axis, which is the case for the parent
, ancestor
, ancestor-or-self
, preceding
, and preceding-sibling
, the nodes are delivered in reverse document order. Otherwise the nodes are delivered in document order.
The implementor guarantees that the nodes delivered for the axes are consistent with the XPath Data Model. This just implies common sense, e.g., The child axis for a comment node can't contain any children; a document node can't be a child of an element, etc. Attributes aren't considered children of an element, but are only available on AxisAttribute.
The value past in axis is not guaranteed based on what is used in a query. QtXmlPatterns may call this function arbitrarily with any value for axis. This is because QtXmlPatterns may rewrite queries to be more efficient, using axes in different ways from the original query.
QAbstractXmlNodeModel::Axis has a good overview of the axes and what they select.
The caller guarantees that ni is not null
and that it belongs to this QAbstractXmlNodeModel instance.
Implementing iterate() can involve significant work, since it requires different iterators for all the axes used. In the worst case, it could require writing as many QAbstractXmlForwardIterator subclasses as there are axes, but the number can often be reduced with clever use of lists and template classes. It is better to use or subclass QSimpleXmlNodeModel, which makes it easier to write the node navigation code without loss of efficiency or flexibility.
Reimplemented from QAbstractXmlNodeModel.
Definition at line 251 of file qacceltree.cpp.
Referenced by baseUri(), copyNodeTo(), and sendNamespaces().
|
virtual |
Returns a value indicating the kind of node identified by ni.
The caller guarantees that ni is not null and that it identifies a node in this node model. This function maps to the dm:node-kind
() accessor.
Implements QAbstractXmlNodeModel.
Definition at line 214 of file qacceltree.cpp.
Referenced by QPatternist::AttributeIterator::AttributeIterator(), baseUri(), QPatternist::ChildIterator::ChildIterator(), QPatternist::DescendantIterator< IncludeSelf >::DescendantIterator(), documentUri(), iterate(), QPatternist::SiblingIterator< IsFollowing >::next(), QPatternist::DescendantIterator< IncludeSelf >::next(), QPatternist::FollowingIterator::next(), QPatternist::PrecedingIterator::next(), QPatternist::AttributeIterator::next(), sequencedTypedValue(), and stringValue().
|
inline |
Definition at line 328 of file qacceltree_p.h.
|
inline |
Definition at line 333 of file qacceltree_p.h.
Referenced by QPatternist::ChildIterator::ChildIterator(), QPatternist::DescendantIterator< IncludeSelf >::DescendantIterator(), iterate(), QPatternist::ChildIterator::next(), QPatternist::SiblingIterator< IsFollowing >::next(), QPatternist::DescendantIterator< IncludeSelf >::next(), QPatternist::FollowingIterator::next(), QPatternist::AttributeIterator::next(), printStats(), QPatternist::SiblingIterator< IsFollowing >::SiblingIterator(), and stringValue().
|
virtual |
Returns the name of ni.
The caller guarantees that ni is not null
and that it belongs to this QAbstractXmlNodeModel.
If a node does not have a name, e.g., comment nodes, a null QXmlName is returned. QXmlNames must be created with the instance of QXmlQuery that is being used for evaluating queries using this QAbstractXmlNodeModel.
This function maps to the dm:node-name
() accessor.
If ni is a processing instruction, a QXmlName is returned with the local name as the target name and the namespace URI and prefix both empty.
Implements QAbstractXmlNodeModel.
Definition at line 379 of file qacceltree.cpp.
Referenced by sendNamespaces().
Definition at line 357 of file qacceltree_p.h.
|
virtual |
Returns the in-scope namespaces of n.
The caller guarantees that n is not null
and that it belongs to this QAbstractXmlNodeModel.
This function corresponds to the dm:namespace-nodes
accessor.
The returned vector of namespace declarations includes namespaces of the ancestors of n.
The caller guarantees that n is an Element that belongs to this QAbstractXmlNodeModel.
Implements QAbstractXmlNodeModel.
Definition at line 387 of file qacceltree.cpp.
|
protectedvirtual |
When QtXmlPatterns evaluate path expressions, it emulate them through a combination of calls with QSimpleXmlNodeModel::SimpleAxis values.
Therefore, the implementation of this function must return the node, if any, that appears on the axis emanating from the origin.
If no such node is available, a default constructed QXmlNodeModelIndex is returned.
QSimpleXmlNodeModel eliminates the need to handle redundant corner cases by guaranteeing that it will never ask for:
A typical implementation performs a switch
on the value of axis:
Implements QAbstractXmlNodeModel.
Definition at line 365 of file qacceltree.cpp.
|
virtual |
Returns the elements and/or attributes that have an IDREF
value equal to idref.
XQuery's idref()
function calls this function.
The implementor guarantees that the nodes identified by the returned indexes are elements or attributes.
It is not sufficient for an attribute or element to merely be called idref
. It must also be of type IDREF
. Elements must be typed as xs:IDREF
or xs:IDREFS
, or, in the case of attributes, as IDREF
or IDREFS
in the schema.
In idref, the namespace URI
and the prefix
are undefined, and the local name
is the ID that should be looked up.
Implements QAbstractXmlNodeModel.
Definition at line 743 of file qacceltree.cpp.
|
virtual |
Definition at line 241 of file qacceltree.cpp.
Referenced by baseUri(), and iterate().
Returns the parent node of pre
.
If pre
parent doesn't have a parent node, the return value is undefined.
Definition at line 307 of file qacceltree_p.h.
|
inline |
Definition at line 322 of file qacceltree_p.h.
Referenced by QPatternist::DescendantIterator< IncludeSelf >::DescendantIterator(), QPatternist::DescendantIterator< IncludeSelf >::next(), QPatternist::PrecedingIterator::next(), and printStats().
void AccelTree::printStats | ( | const NamePool::Ptr & | np | ) | const |
Definition at line 90 of file qacceltree.cpp.
|
virtual |
Returns the root node.
This function does not use n
, so a default constructed QXmlNodeModelIndex may be passed.
Implements QAbstractXmlNodeModel.
Definition at line 236 of file qacceltree.cpp.
Referenced by QPatternist::AccelTreeResourceLoader::openDocument().
|
virtual |
Definition at line 449 of file qacceltree.cpp.
|
virtual |
Reimplemented from QAbstractXmlNodeModel.
Definition at line 593 of file qacceltree.cpp.
Definition at line 343 of file qacceltree_p.h.
Referenced by hasPrefix(), QPatternist::ChildIterator::next(), QPatternist::SiblingIterator< IsFollowing >::next(), QPatternist::FollowingIterator::next(), and stringValue().
|
private |
Returns the source location for the object with the given index
.
Definition at line 709 of file qacceltree.cpp.
Referenced by QPatternist::AccelTreePrivate::sourceLocation().
|
virtual |
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:
For processing instructions, the string value is the data section(excluding any whitespace appearing between the name and the data).
For text nodes, the string value equals the text node.
For comments, the content of the comment
For elements, the concatenation of all text nodes that are descendants. Note, this is not only the children, but the childrens' childrens' text nodes, and so forth.
For document nodes, the concatenation of all text nodes in the document.
Implements QAbstractXmlNodeModel.
Definition at line 498 of file qacceltree.cpp.
Referenced by sequencedTypedValue(), and typedValue().
|
inline |
Definition at line 338 of file qacceltree_p.h.
Referenced by baseUri(), documentUri(), iterate(), kind(), name(), namespaceBindings(), parent(), sendNamespaces(), sequencedTypedValue(), sourceLocation(), stringValue(), and type().
|
virtual |
Reimplemented from QAbstractXmlNodeModel.
Definition at line 587 of file qacceltree.cpp.
|
virtual |
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()).
If the return QVariant is a default constructed variant, it signals that node has no typed value.
Implements QAbstractXmlNodeModel.
Definition at line 569 of file qacceltree.cpp.
|
friend |
Definition at line 253 of file qacceltree_p.h.
|
friend |
Definition at line 254 of file qacceltree_p.h.
|
friend |
Definition at line 94 of file qacceltree_p.h.
QVector<BasicNodeData> QPatternist::AccelTree::basicData |
Definition at line 276 of file qacceltree_p.h.
Referenced by AccelTree(), QPatternist::AncestorIterator< IncludeSelf >::next(), parent(), printStats(), and type().
Stores data for nodes. The QHash's value is the data of the processing instruction, and the content of a text node or comment.
Definition at line 274 of file qacceltree_p.h.
Referenced by AccelTree(), printStats(), and stringValue().
QUrl QPatternist::AccelTree::m_baseURI |
Definition at line 370 of file qacceltree_p.h.
QUrl QPatternist::AccelTree::m_documentURI |
Definition at line 369 of file qacceltree_p.h.
Referenced by printStats(), and sourceLocation().
|
private |
The key is the xml:id value, and the value is the element with that value.
Definition at line 394 of file qacceltree_p.h.
Referenced by elementById().
The key is the pre number of an element, and the value is a vector containing the namespace declarations being declared on that element. Therefore, it does not reflect the namespaces being in scope for that element. For that, a walk along axis ancestor is necessary.
Definition at line 268 of file qacceltree_p.h.
Referenced by namespaceBindings(), printStats(), and sendNamespaces().
Definition at line 277 of file qacceltree_p.h.
Referenced by sourceLocation().