Qt 4.8
Public Types | Public Functions | Protected Functions | Properties | List of all members
QPatternist::XsdValidatedXmlNodeModel Class Reference

A delegate class that wraps around a QAbstractXmlNodeModel and provides additional validation specific information. More...

#include <qxsdvalidatedxmlnodemodel_p.h>

Inheritance diagram for QPatternist::XsdValidatedXmlNodeModel:
QAbstractXmlNodeModel QSharedData

Public Types

typedef QList< PtrList
 
typedef QExplicitlySharedDataPointer< XsdValidatedXmlNodeModelPtr
 
- Public Types inherited from QAbstractXmlNodeModel
typedef QList< PtrList
 A list of smart pointers to instances of QAbstractXmlNodeModel. More...
 
enum  NodeCopySetting { InheritNamespaces = 0x1, PreserveNamespaces = 0x2 }
 
typedef QFlags< NodeCopySettingNodeCopySettings
 
typedef QExplicitlySharedDataPointer< QAbstractXmlNodeModelPtr
 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

void addIdIdRefBinding (const QString &id, const NamedSchemaComponent::Ptr &binding)
 
XsdAttribute::Ptr assignedAttribute (const QXmlNodeModelIndex &index) const
 
XsdElement::Ptr assignedElement (const QXmlNodeModelIndex &index) const
 
SchemaType::Ptr assignedType (const QXmlNodeModelIndex &index) const
 
virtual QUrl baseUri (const QXmlNodeModelIndex &ni) const
 Returns the base URI for the node whose index is n. More...
 
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 &) const
 
virtual QUrl documentUri (const QXmlNodeModelIndex &ni) const
 Returns the document URI of n. More...
 
virtual QXmlNodeModelIndex elementById (const QXmlName &NCName) const
 Returns the index of the element identified as id. More...
 
QStringList idIdRefBindingIds () const
 
QSet< NamedSchemaComponent::PtridIdRefBindings (const QString &id) const
 
virtual bool isDeepEqual (const QXmlNodeModelIndex &ni1, const QXmlNodeModelIndex &ni2) const
 Determines whether ni1 is deep equal to ni2. More...
 
virtual QExplicitlySharedDataPointer< QAbstractXmlForwardIterator< QXmlNodeModelIndex > > 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...
 
virtual QXmlName name (const QXmlNodeModelIndex &ni) const
 Returns the name of ni. More...
 
virtual QVector< QXmlNamenamespaceBindings (const QXmlNodeModelIndex &n) const
 Returns the in-scope namespaces of n. More...
 
virtual QXmlName::NamespaceCode namespaceForPrefix (const QXmlNodeModelIndex &ni, const QXmlName::PrefixCode prefix) const
 Returns the namespace URI on ni that corresponds to prefix. More...
 
virtual QVector< QXmlNodeModelIndexnodesByIdref (const QXmlName &NCName) const
 Returns the elements and/or attributes that have an IDREF value equal to idref. More...
 
virtual QXmlNodeModelIndex root (const QXmlNodeModelIndex &n) const
 Returns the root node of the tree that contains the node whose index is n. More...
 
virtual void sendNamespaces (const QXmlNodeModelIndex &n, QAbstractXmlReceiver *const receiver) const
 
virtual QPatternist::ItemIteratorPtr sequencedTypedValue (const QXmlNodeModelIndex &ni) const
 
void setAssignedAttribute (const QXmlNodeModelIndex &index, const XsdAttribute::Ptr &attribute)
 
void setAssignedElement (const QXmlNodeModelIndex &index, const XsdElement::Ptr &element)
 
void setAssignedType (const QXmlNodeModelIndex &index, const SchemaType::Ptr &type)
 
virtual QString stringValue (const QXmlNodeModelIndex &n) const
 Returns the string value for node n. More...
 
virtual QPatternist::ItemTypePtr type (const QXmlNodeModelIndex &ni) const
 
virtual QVariant typedValue (const QXmlNodeModelIndex &n) const
 Returns the typed value for node node. More...
 
 XsdValidatedXmlNodeModel (const QAbstractXmlNodeModel *model)
 
virtual ~XsdValidatedXmlNodeModel ()
 
- Public Functions inherited from QAbstractXmlNodeModel
virtual void copyNodeTo (const QXmlNodeModelIndex &node, QAbstractXmlReceiver *const receiver, const NodeCopySettings &) const
 
 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...
 

Protected Functions

virtual QVector< QXmlNodeModelIndexattributes (const QXmlNodeModelIndex &element) const
 Returns the attributes of element. More...
 
virtual QXmlNodeModelIndex nextFromSimpleAxis (SimpleAxis axis, const QXmlNodeModelIndex &origin) 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)
 

Properties

QHash< QXmlNodeModelIndex, XsdAttribute::Ptrm_assignedAttributes
 
QHash< QXmlNodeModelIndex, XsdElement::Ptrm_assignedElements
 
QHash< QXmlNodeModelIndex, SchemaType::Ptrm_assignedTypes
 
QHash< QString, QSet< NamedSchemaComponent::Ptr > > m_idIdRefBindings
 
QExplicitlySharedDataPointer< const QAbstractXmlNodeModelm_internalModel
 

Additional Inherited Members

- Public Variables inherited from QSharedData
QAtomicInt ref
 
- Protected Variables inherited from QAbstractXmlNodeModel
QScopedPointer< QAbstractXmlNodeModelPrivated_ptr
 

Detailed Description

A delegate class that wraps around a QAbstractXmlNodeModel and provides additional validation specific information.

This class represents the input XML document enriched with additional type information that has been assigned during validation.

Author
Tobias Koenig tobia.nosp@m.s.ko.nosp@m.enig@.nosp@m.noki.nosp@m.a.com

Definition at line 78 of file qxsdvalidatedxmlnodemodel_p.h.

Typedefs

◆ List

Definition at line 82 of file qxsdvalidatedxmlnodemodel_p.h.

◆ Ptr

Definition at line 81 of file qxsdvalidatedxmlnodemodel_p.h.

Constructors and Destructors

◆ XsdValidatedXmlNodeModel()

XsdValidatedXmlNodeModel::XsdValidatedXmlNodeModel ( const QAbstractXmlNodeModel model)

Creates a new validated xml node model.

Definition at line 52 of file qxsdvalidatedxmlnodemodel.cpp.

53  : m_internalModel(model)
54 {
55 }
QExplicitlySharedDataPointer< const QAbstractXmlNodeModel > m_internalModel

◆ ~XsdValidatedXmlNodeModel()

XsdValidatedXmlNodeModel::~XsdValidatedXmlNodeModel ( )
virtual

Destroys the validated xml node model.

Definition at line 57 of file qxsdvalidatedxmlnodemodel.cpp.

58 {
59 }

Functions

◆ addIdIdRefBinding()

void XsdValidatedXmlNodeModel::addIdIdRefBinding ( const QString id,
const NamedSchemaComponent::Ptr binding 
)

Adds the attribute or element binding with the given id.

Definition at line 200 of file qxsdvalidatedxmlnodemodel.cpp.

Referenced by QPatternist::XsdValidatingInstanceReader::addIdIdRefBinding().

201 {
202  m_idIdRefBindings[id].insert(binding);
203 }
QHash< QString, QSet< NamedSchemaComponent::Ptr > > m_idIdRefBindings

◆ assignedAttribute()

XsdAttribute::Ptr XsdValidatedXmlNodeModel::assignedAttribute ( const QXmlNodeModelIndex index) const

Returns the attribute that is assigned to the xml node at index.

Definition at line 179 of file qxsdvalidatedxmlnodemodel.cpp.

180 {
181  if (m_assignedAttributes.contains(index))
182  return m_assignedAttributes.value(index);
183  else
184  return XsdAttribute::Ptr();
185 }
QHash< QXmlNodeModelIndex, XsdAttribute::Ptr > m_assignedAttributes
QExplicitlySharedDataPointer< XsdAttribute > Ptr

◆ assignedElement()

XsdElement::Ptr XsdValidatedXmlNodeModel::assignedElement ( const QXmlNodeModelIndex index) const

Returns the element that is assigned to the xml node at index.

Definition at line 166 of file qxsdvalidatedxmlnodemodel.cpp.

Referenced by QPatternist::XsdValidatingInstanceReader::validateKeyIdentityConstraint().

167 {
168  if (m_assignedElements.contains(index))
169  return m_assignedElements.value(index);
170  else
171  return XsdElement::Ptr();
172 }
QHash< QXmlNodeModelIndex, XsdElement::Ptr > m_assignedElements
QExplicitlySharedDataPointer< XsdElement > Ptr
Definition: qxsdelement_p.h:86

◆ assignedType()

SchemaType::Ptr XsdValidatedXmlNodeModel::assignedType ( const QXmlNodeModelIndex index) const

Returns the type that is assigned to the xml node at index.

Definition at line 192 of file qxsdvalidatedxmlnodemodel.cpp.

Referenced by QPatternist::XsdValidatingInstanceReader::selectNodeSets().

193 {
194  if (m_assignedTypes.contains(index))
195  return m_assignedTypes.value(index);
196  else
197  return SchemaType::Ptr();
198 }
QExplicitlySharedDataPointer< SchemaType > Ptr
Definition: qschematype_p.h:82
QHash< QXmlNodeModelIndex, SchemaType::Ptr > m_assignedTypes

◆ attributes()

QVector< QXmlNodeModelIndex > XsdValidatedXmlNodeModel::attributes ( const QXmlNodeModelIndex element) const
protectedvirtual

Returns the attributes of element.

The caller guarantees that element is an element in this node model.

Implements QAbstractXmlNodeModel.

Definition at line 156 of file qxsdvalidatedxmlnodemodel.cpp.

157 {
159 }
QExplicitlySharedDataPointer< const QAbstractXmlNodeModel > m_internalModel
quint16 index
virtual QVector< QXmlNodeModelIndex > attributes(const QXmlNodeModelIndex &element) const =0
Returns the attributes of element.

◆ baseUri()

QUrl XsdValidatedXmlNodeModel::baseUri ( const QXmlNodeModelIndex n) const
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.

See also
{http://www.w3.org/TR/xpath-datamodel/#dm-base-uri}{XQuery 1.0 and XPath 2.0 Data Model (XDM), 5.2 base-uri Accessor}

Implements QAbstractXmlNodeModel.

Definition at line 61 of file qxsdvalidatedxmlnodemodel.cpp.

62 {
63  return m_internalModel->baseUri(index);
64 }
virtual QUrl baseUri(const QXmlNodeModelIndex &ni) const =0
Returns the base URI for the node whose index is n.
QExplicitlySharedDataPointer< const QAbstractXmlNodeModel > m_internalModel
quint16 index

◆ compareOrder()

QXmlNodeModelIndex::DocumentOrder XsdValidatedXmlNodeModel::compareOrder ( const QXmlNodeModelIndex ni1,
const QXmlNodeModelIndex ni2 
) const
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.

See also
{http://www.w3.org/TR/xpath-datamodel/#document-order}{XQuery 1.0 and XPath 2.0 Data Model (XDM), 2.4 Document Order}

Implements QAbstractXmlNodeModel.

Definition at line 76 of file qxsdvalidatedxmlnodemodel.cpp.

77 {
78  return m_internalModel->compareOrder(index, otherIndex);
79 }
QExplicitlySharedDataPointer< const QAbstractXmlNodeModel > m_internalModel
quint16 index
virtual QXmlNodeModelIndex::DocumentOrder compareOrder(const QXmlNodeModelIndex &ni1, const QXmlNodeModelIndex &ni2) const =0
This function returns the relative document order for the nodes indexed by ni1 and ni2...

◆ copyNodeTo()

void XsdValidatedXmlNodeModel::copyNodeTo ( const QXmlNodeModelIndex node,
QAbstractXmlReceiver *const  receiver,
const NodeCopySettings settings 
) const
virtual

Definition at line 146 of file qxsdvalidatedxmlnodemodel.cpp.

147 {
148  return m_internalModel->copyNodeTo(index, receiver, settings);
149 }
QExplicitlySharedDataPointer< const QAbstractXmlNodeModel > m_internalModel
quint16 index
virtual void copyNodeTo(const QXmlNodeModelIndex &node, QAbstractXmlReceiver *const receiver, const NodeCopySettings &) const

◆ documentUri()

QUrl XsdValidatedXmlNodeModel::documentUri ( const QXmlNodeModelIndex n) const
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.

See also
{http://www.w3.org/TR/xpath-datamodel/#dm-document-uri}{XQuery 1.0 and XPath 2.0 Data Model (XDM), 5.4 document-uri Accessor}
QUrl::isValid(), QUrl::isRelative()

Implements QAbstractXmlNodeModel.

Definition at line 66 of file qxsdvalidatedxmlnodemodel.cpp.

67 {
69 }
virtual QUrl documentUri(const QXmlNodeModelIndex &ni) const =0
Returns the document URI of n.
QExplicitlySharedDataPointer< const QAbstractXmlNodeModel > m_internalModel
quint16 index

◆ elementById()

QXmlNodeModelIndex XsdValidatedXmlNodeModel::elementById ( const QXmlName id) const
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.

See also
{http://www.w3.org/TR/xpath-functions/#func-id}{XQuery 1.0 and XPath 2.0 Functions and Operators, 15.5.2 fn:id}

Implements QAbstractXmlNodeModel.

Definition at line 136 of file qxsdvalidatedxmlnodemodel.cpp.

137 {
139 }
virtual QXmlNodeModelIndex elementById(const QXmlName &NCName) const =0
Returns the index of the element identified as id.
virtual QXmlName name(const QXmlNodeModelIndex &ni) const
Returns the name of ni.
QExplicitlySharedDataPointer< const QAbstractXmlNodeModel > m_internalModel

◆ idIdRefBindingIds()

QStringList XsdValidatedXmlNodeModel::idIdRefBindingIds ( ) const

Returns a list of all binding ids.

Definition at line 205 of file qxsdvalidatedxmlnodemodel.cpp.

Referenced by QPatternist::XsdValidatingInstanceReader::read().

206 {
207  return m_idIdRefBindings.keys();
208 }
QHash< QString, QSet< NamedSchemaComponent::Ptr > > m_idIdRefBindings

◆ idIdRefBindings()

QSet< NamedSchemaComponent::Ptr > XsdValidatedXmlNodeModel::idIdRefBindings ( const QString id) const

Returns the set of bindings with the given id.

Definition at line 210 of file qxsdvalidatedxmlnodemodel.cpp.

Referenced by QPatternist::XsdValidatingInstanceReader::addIdIdRefBinding().

211 {
212  return m_idIdRefBindings.value(id);
213 }
QHash< QString, QSet< NamedSchemaComponent::Ptr > > m_idIdRefBindings

◆ isDeepEqual()

bool XsdValidatedXmlNodeModel::isDeepEqual ( const QXmlNodeModelIndex n1,
const QXmlNodeModelIndex n2 
) const
virtual

Determines whether ni1 is deep equal to ni2.

Warning
This function is not part of the public interface.

isDeepEqual() is defined as evaluating the expression fn:deep-equal($n1, $n2) where $n1 is ni1 and $n1 is ni2. This function is associative, meaning the same value is returned regardless of if isDeepEqual() is invoked with ni1 as first argument or second. It is guaranteed that ni1 and ni2 are nodes, as opposed to the definition of fn:deep-equal().

Returns true if ni1 is deep-equal to ni2, otherwise false

See also
{"http://www.w3.org/TR/xpath-functions/#func-deep-equal"}{XQuery 1.0 and XPath 2.0 Functions and Operators, 15.3.1 fn:deep-equal}

Reimplemented from QAbstractXmlNodeModel.

Definition at line 121 of file qxsdvalidatedxmlnodemodel.cpp.

122 {
123  return m_internalModel->isDeepEqual(index, otherIndex);
124 }
QExplicitlySharedDataPointer< const QAbstractXmlNodeModel > m_internalModel
quint16 index
virtual bool isDeepEqual(const QXmlNodeModelIndex &ni1, const QXmlNodeModelIndex &ni2) const
Determines whether ni1 is deep equal to ni2.

◆ iterate()

QExplicitlySharedDataPointer< QAbstractXmlForwardIterator< QXmlNodeModelIndex > > XsdValidatedXmlNodeModel::iterate ( const QXmlNodeModelIndex ni,
QXmlNodeModelIndex::Axis  axis 
) const
virtual

Performs navigation, starting from ni, by returning an QAbstractXmlForwardIterator that returns nodes the axis emanating from ni.

Warning
This function is not part of the public interface.

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.

See also
QSimpleXmlNodeModel
QXmlNodeModelIndex::Axis
{http://www.w3.org/TR/xquery/#axes}{XQuery 1.0: An XML Query Language, 3.2.1.1 Axes}
{http://www.w3.org/TR/xpath-datamodel/}{W3CXQuery 1.0 and XPath 2.0 Data Model (XDM)}

Reimplemented from QAbstractXmlNodeModel.

Definition at line 101 of file qxsdvalidatedxmlnodemodel.cpp.

102 {
103  return m_internalModel->iterate(index, axis);
104 }
virtual QExplicitlySharedDataPointer< QAbstractXmlForwardIterator< QXmlNodeModelIndex > > iterate(const QXmlNodeModelIndex &ni, QXmlNodeModelIndex::Axis axis) const
Performs navigation, starting from ni, by returning an QAbstractXmlForwardIterator that returns nodes...
QExplicitlySharedDataPointer< const QAbstractXmlNodeModel > m_internalModel
quint16 index

◆ kind()

QXmlNodeModelIndex::NodeKind XsdValidatedXmlNodeModel::kind ( const QXmlNodeModelIndex ni) const
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.

See also
{http://www.w3.org/TR/xpath-datamodel/#dm-node-kind}{XQuery 1.0 and XPath 2.0 Data Model (XDM), 5.10 node-kind Accessor}

Implements QAbstractXmlNodeModel.

Definition at line 71 of file qxsdvalidatedxmlnodemodel.cpp.

Referenced by QPatternist::XsdValidatingInstanceReader::validateKeyIdentityConstraint().

72 {
73  return m_internalModel->kind(index);
74 }
virtual QXmlNodeModelIndex::NodeKind kind(const QXmlNodeModelIndex &ni) const =0
Returns a value indicating the kind of node identified by ni.
QExplicitlySharedDataPointer< const QAbstractXmlNodeModel > m_internalModel
quint16 index

◆ name()

QXmlName XsdValidatedXmlNodeModel::name ( const QXmlNodeModelIndex ni) const
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.

See also
{http://www.w3.org/TR/xpath-datamodel/#dm-node-name}{XQuery 1.0 and XPath 2.0 Data Model (XDM), 5.11 node-name Accessor}
QXmlName

Implements QAbstractXmlNodeModel.

Definition at line 86 of file qxsdvalidatedxmlnodemodel.cpp.

87 {
88  return m_internalModel->name(index);
89 }
QExplicitlySharedDataPointer< const QAbstractXmlNodeModel > m_internalModel
virtual QXmlName name(const QXmlNodeModelIndex &ni) const =0
Returns the name of ni.
quint16 index

◆ namespaceBindings()

QVector< QXmlName > XsdValidatedXmlNodeModel::namespaceBindings ( const QXmlNodeModelIndex n) const
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 131 of file qxsdvalidatedxmlnodemodel.cpp.

132 {
134 }
QExplicitlySharedDataPointer< const QAbstractXmlNodeModel > m_internalModel
quint16 index
virtual QVector< QXmlName > namespaceBindings(const QXmlNodeModelIndex &n) const =0
Returns the in-scope namespaces of n.

◆ namespaceForPrefix()

QXmlName::NamespaceCode XsdValidatedXmlNodeModel::namespaceForPrefix ( const QXmlNodeModelIndex ni,
const QXmlName::PrefixCode  prefix 
) const
virtual

Returns the namespace URI on ni that corresponds to prefix.

Warning
This function is not part of the public interface.

If prefix is StandardPrefixes::empty, the namespace URI for the default namespace is returned.

The default implementation use namespaceBindings(), in a straight forward manner.

If no namespace exists for prefix, NamespaceResolver::NoBinding is returned.

The caller guarantees to only call this function for element nodes.

Reimplemented from QAbstractXmlNodeModel.

Definition at line 116 of file qxsdvalidatedxmlnodemodel.cpp.

117 {
118  return m_internalModel->namespaceForPrefix(index, prefix);
119 }
virtual QXmlName::NamespaceCode namespaceForPrefix(const QXmlNodeModelIndex &ni, const QXmlName::PrefixCode prefix) const
Returns the namespace URI on ni that corresponds to prefix.
QExplicitlySharedDataPointer< const QAbstractXmlNodeModel > m_internalModel
quint16 index

◆ nextFromSimpleAxis()

QXmlNodeModelIndex XsdValidatedXmlNodeModel::nextFromSimpleAxis ( SimpleAxis  axis,
const QXmlNodeModelIndex origin 
) const
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:

  • Children or siblings for attributes.
  • Children for comments, processing instructions, and text nodes.
  • Siblings or parents for document nodes.

A typical implementation performs a switch on the value of axis:

QXmlNodeModelIndex 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:
// and so on
}
}

Implements QAbstractXmlNodeModel.

Definition at line 151 of file qxsdvalidatedxmlnodemodel.cpp.

152 {
153  return m_internalModel->nextFromSimpleAxis(axis, origin);
154 }
virtual QXmlNodeModelIndex nextFromSimpleAxis(SimpleAxis axis, const QXmlNodeModelIndex &origin) const =0
When QtXmlPatterns evaluate path expressions, it emulate them through a combination of calls with QSi...
QExplicitlySharedDataPointer< const QAbstractXmlNodeModel > m_internalModel

◆ nodesByIdref()

QVector< QXmlNodeModelIndex > XsdValidatedXmlNodeModel::nodesByIdref ( const QXmlName idref) const
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.

See also
{http://www.w3.org/TR/xpath-functions/#func-idref}{XQuery 1.0 and XPath 2.0 Functions and Operators, 15.5.3 fn:idref}

Implements QAbstractXmlNodeModel.

Definition at line 141 of file qxsdvalidatedxmlnodemodel.cpp.

142 {
144 }
virtual QXmlName name(const QXmlNodeModelIndex &ni) const
Returns the name of ni.
QExplicitlySharedDataPointer< const QAbstractXmlNodeModel > m_internalModel
virtual QVector< QXmlNodeModelIndex > nodesByIdref(const QXmlName &NCName) const =0
Returns the elements and/or attributes that have an IDREF value equal to idref.

◆ root()

QXmlNodeModelIndex XsdValidatedXmlNodeModel::root ( const QXmlNodeModelIndex n) const
virtual

Returns the root node of the tree that contains the node whose index is n.

The caller guarantees that n is not null and that it identifies a node in this node model.

If n identifies a node that is a direct child of the root, parent() would return the same QXmlNodeModelIndex returned by this function.

Implements QAbstractXmlNodeModel.

Definition at line 81 of file qxsdvalidatedxmlnodemodel.cpp.

82 {
83  return m_internalModel->root(index);
84 }
QExplicitlySharedDataPointer< const QAbstractXmlNodeModel > m_internalModel
virtual QXmlNodeModelIndex root(const QXmlNodeModelIndex &n) const =0
Returns the root node of the tree that contains the node whose index is n.
quint16 index

◆ sendNamespaces()

void XsdValidatedXmlNodeModel::sendNamespaces ( const QXmlNodeModelIndex n,
QAbstractXmlReceiver *const  receiver 
) const
virtual

Definition at line 126 of file qxsdvalidatedxmlnodemodel.cpp.

127 {
129 }
QExplicitlySharedDataPointer< const QAbstractXmlNodeModel > m_internalModel
virtual void sendNamespaces(const QXmlNodeModelIndex &n, QAbstractXmlReceiver *const receiver) const
Sends the namespaces declared on n to receiver.
quint16 index

◆ sequencedTypedValue()

QPatternist::ItemIteratorPtr XsdValidatedXmlNodeModel::sequencedTypedValue ( const QXmlNodeModelIndex ni) const
virtual
Warning
This function is not part of the public interface.

Reimplemented from QAbstractXmlNodeModel.

Definition at line 106 of file qxsdvalidatedxmlnodemodel.cpp.

107 {
109 }
virtual QPatternist::ItemIteratorPtr sequencedTypedValue(const QXmlNodeModelIndex &ni) const
QExplicitlySharedDataPointer< const QAbstractXmlNodeModel > m_internalModel
quint16 index

◆ setAssignedAttribute()

void XsdValidatedXmlNodeModel::setAssignedAttribute ( const QXmlNodeModelIndex index,
const XsdAttribute::Ptr attribute 
)

Sets the attribute that is assigned to the xml node at index.

Definition at line 174 of file qxsdvalidatedxmlnodemodel.cpp.

Referenced by QPatternist::XsdValidatingInstanceReader::validateAttribute().

175 {
176  m_assignedAttributes.insert(index, attribute);
177 }
QHash< QXmlNodeModelIndex, XsdAttribute::Ptr > m_assignedAttributes

◆ setAssignedElement()

void XsdValidatedXmlNodeModel::setAssignedElement ( const QXmlNodeModelIndex index,
const XsdElement::Ptr element 
)

Sets the element that is assigned to the xml node at index.

Definition at line 161 of file qxsdvalidatedxmlnodemodel.cpp.

Referenced by QPatternist::XsdValidatingInstanceReader::read().

162 {
163  m_assignedElements.insert(index, element);
164 }
QHash< QXmlNodeModelIndex, XsdElement::Ptr > m_assignedElements

◆ setAssignedType()

void XsdValidatedXmlNodeModel::setAssignedType ( const QXmlNodeModelIndex index,
const SchemaType::Ptr type 
)

Sets the type that is assigned to the xml node at index.

Note
The type can be a different than the type of the element or attribute that is assigned to the index, since the instance document can overwrite it by xsi:type.

Definition at line 187 of file qxsdvalidatedxmlnodemodel.cpp.

Referenced by QPatternist::XsdValidatingInstanceReader::validate(), QPatternist::XsdValidatingInstanceReader::validateAttribute(), QPatternist::XsdValidatingInstanceReader::validateElementComplexType(), and QPatternist::XsdValidatingInstanceReader::validateElementSimpleType().

188 {
189  m_assignedTypes.insert(index, type);
190 }
QHash< QXmlNodeModelIndex, SchemaType::Ptr > m_assignedTypes

◆ stringValue()

QString XsdValidatedXmlNodeModel::stringValue ( const QXmlNodeModelIndex n) const
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.

See also
{http://www.w3.org/TR/xpath-datamodel/#dm-string-value}{XQuery 1.0 and XPath 2.0 Data Model (XDM), 5.13 string-value Accessor}

Implements QAbstractXmlNodeModel.

Definition at line 91 of file qxsdvalidatedxmlnodemodel.cpp.

Referenced by QPatternist::XsdValidatingInstanceReader::selectNodeSets().

92 {
94 }
QExplicitlySharedDataPointer< const QAbstractXmlNodeModel > m_internalModel
quint16 index
virtual QString stringValue(const QXmlNodeModelIndex &n) const =0
Returns the string value for node n.

◆ type()

QPatternist::ItemTypePtr XsdValidatedXmlNodeModel::type ( const QXmlNodeModelIndex ni) const
virtual
Warning
This function is not part of the public interface.

Reimplemented from QAbstractXmlNodeModel.

Definition at line 111 of file qxsdvalidatedxmlnodemodel.cpp.

112 {
113  return m_internalModel->type(index);
114 }
QExplicitlySharedDataPointer< const QAbstractXmlNodeModel > m_internalModel
virtual QPatternist::ItemTypePtr type(const QXmlNodeModelIndex &ni) const
quint16 index

◆ typedValue()

QVariant XsdValidatedXmlNodeModel::typedValue ( const QXmlNodeModelIndex node) const
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 96 of file qxsdvalidatedxmlnodemodel.cpp.

97 {
99 }
QExplicitlySharedDataPointer< const QAbstractXmlNodeModel > m_internalModel
virtual QVariant typedValue(const QXmlNodeModelIndex &n) const =0
Returns the typed value for node node.
quint16 index

Properties

◆ m_assignedAttributes

QHash<QXmlNodeModelIndex, XsdAttribute::Ptr> QPatternist::XsdValidatedXmlNodeModel::m_assignedAttributes
private

Definition at line 169 of file qxsdvalidatedxmlnodemodel_p.h.

Referenced by assignedAttribute(), and setAssignedAttribute().

◆ m_assignedElements

QHash<QXmlNodeModelIndex, XsdElement::Ptr> QPatternist::XsdValidatedXmlNodeModel::m_assignedElements
private

Definition at line 168 of file qxsdvalidatedxmlnodemodel_p.h.

Referenced by assignedElement(), and setAssignedElement().

◆ m_assignedTypes

QHash<QXmlNodeModelIndex, SchemaType::Ptr> QPatternist::XsdValidatedXmlNodeModel::m_assignedTypes
private

Definition at line 170 of file qxsdvalidatedxmlnodemodel_p.h.

Referenced by assignedType(), and setAssignedType().

◆ m_idIdRefBindings

QHash<QString, QSet<NamedSchemaComponent::Ptr> > QPatternist::XsdValidatedXmlNodeModel::m_idIdRefBindings
private

◆ m_internalModel

QExplicitlySharedDataPointer<const QAbstractXmlNodeModel> QPatternist::XsdValidatedXmlNodeModel::m_internalModel
private

The documentation for this class was generated from the following files: