/usr/share/qt5/doc/qtxmlpatterns/qabstractxmlnodemodel.html is in qtxmlpatterns5-doc-html 5.3.2-2.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 | <?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en_US" lang="en_US">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<!-- qabstractxmlnodemodel.cpp -->
<title>QAbstractXmlNodeModel Class | QtXmlPatterns </title>
<link rel="stylesheet" type="text/css" href="style/offline.css" />
</head>
<body>
<div class="header" id="qtdocheader">
<div class="main">
<div class="main-rounded">
<div class="navigationbar">
<ul>
<li>Qt 5.3</li>
<li><a href="qtxmlpatterns-index.html">Qt XML Patterns</a></li>
<li><a href="qtxmlpatterns-module.html">C++ Classes</a></li>
<li>QAbstractXmlNodeModel</li>
<li id="buildversion">
Qt 5.3.2 Reference Documentation</li>
</ul>
</div>
</div>
<div class="content">
<div class="line">
<div class="content mainContent">
<div class="toc">
<h3><a name="toc">Contents</a></h3>
<ul>
<li class="level1"><a href="#public-types">Public Types</a></li>
<li class="level1"><a href="#public-functions">Public Functions</a></li>
<li class="level1"><a href="#protected-functions">Protected Functions</a></li>
<li class="level1"><a href="#details">Detailed Description</a></li>
<li class="level2"><a href="#usage">Usage</a></li>
<li class="level2"><a href="#subclassing">Subclassing</a></li>
<li class="level2"><a href="#thread-safety">Thread Safety</a></li>
</ul>
</div>
<h1 class="title">QAbstractXmlNodeModel Class</h1>
<!-- $$$QAbstractXmlNodeModel-brief -->
<p>The QAbstractXmlNodeModel class is an abstract base class for modeling non-XML data to look like XML for <a href="qxmlquery.html">QXmlQuery</a>. <a href="#details">More...</a></p>
<!-- @@@QAbstractXmlNodeModel -->
<table class="alignedsummary">
<tr><td class="memItemLeft rightAlign topAlign"> Header:</td><td class="memItemRight bottomAlign"> </b><tt><span class="preprocessor">#include <QAbstractXmlNodeModel></span>
</tt></td></tr><tr><td class="memItemLeft rightAlign topAlign"> qmake:</td><td class="memItemRight bottomAlign"> <tt>QT += xmlpatterns</tt></td></tr><tr><td class="memItemLeft rightAlign topAlign"> Since:</td><td class="memItemRight bottomAlign"> Qt 4.4</td></tr><tr><td class="memItemLeft rightAlign topAlign"> Inherited By:</td><td class="memItemRight bottomAlign"> <p><a href="qsimplexmlnodemodel.html">QSimpleXmlNodeModel</a>.</p>
</td></tr></table><p><b>Note:</b> All functions in this class are thread-safe.</p>
<ul>
<li><a href="qabstractxmlnodemodel-members.html">List of all members, including inherited members</a></li>
</ul>
<a name="public-types"></a>
<h2>Public Types</h2>
<table class="alignedsummary">
<tr><td class="memItemLeft rightAlign topAlign"> typedef </td><td class="memItemRight bottomAlign"><b><a href="qabstractxmlnodemodel.html#List-typedef">List</a></b></td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> typedef </td><td class="memItemRight bottomAlign"><b><a href="qabstractxmlnodemodel.html#Ptr-typedef">Ptr</a></b></td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> enum </td><td class="memItemRight bottomAlign"><b><a href="qabstractxmlnodemodel.html#SimpleAxis-enum">SimpleAxis</a></b> { Parent, FirstChild, PreviousSibling, NextSibling }</td></tr>
</table>
<a name="public-functions"></a>
<h2>Public Functions</h2>
<table class="alignedsummary">
<tr><td class="memItemLeft rightAlign topAlign"> </td><td class="memItemRight bottomAlign"><b><a href="qabstractxmlnodemodel.html#QAbstractXmlNodeModel">QAbstractXmlNodeModel</a></b>()</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> virtual </td><td class="memItemRight bottomAlign"><b><a href="qabstractxmlnodemodel.html#dtor.QAbstractXmlNodeModel">~QAbstractXmlNodeModel</a></b>()</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> virtual QUrl </td><td class="memItemRight bottomAlign"><b><a href="qabstractxmlnodemodel.html#baseUri">baseUri</a></b>(const QXmlNodeModelIndex &<i> n</i>) const = 0</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> virtual QXmlNodeModelIndex::DocumentOrder </td><td class="memItemRight bottomAlign"><b><a href="qabstractxmlnodemodel.html#compareOrder">compareOrder</a></b>(const QXmlNodeModelIndex &<i> ni1</i>, const QXmlNodeModelIndex &<i> ni2</i>) const = 0</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> virtual QUrl </td><td class="memItemRight bottomAlign"><b><a href="qabstractxmlnodemodel.html#documentUri">documentUri</a></b>(const QXmlNodeModelIndex &<i> n</i>) const = 0</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> virtual QXmlNodeModelIndex </td><td class="memItemRight bottomAlign"><b><a href="qabstractxmlnodemodel.html#elementById">elementById</a></b>(const QXmlName &<i> id</i>) const = 0</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> virtual QXmlNodeModelIndex::NodeKind </td><td class="memItemRight bottomAlign"><b><a href="qabstractxmlnodemodel.html#kind">kind</a></b>(const QXmlNodeModelIndex &<i> ni</i>) const = 0</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> virtual QXmlName </td><td class="memItemRight bottomAlign"><b><a href="qabstractxmlnodemodel.html#name">name</a></b>(const QXmlNodeModelIndex &<i> ni</i>) const = 0</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> virtual QVector<QXmlName> </td><td class="memItemRight bottomAlign"><b><a href="qabstractxmlnodemodel.html#namespaceBindings">namespaceBindings</a></b>(const QXmlNodeModelIndex &<i> n</i>) const = 0</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> virtual QVector<QXmlNodeModelIndex> </td><td class="memItemRight bottomAlign"><b><a href="qabstractxmlnodemodel.html#nodesByIdref">nodesByIdref</a></b>(const QXmlName &<i> idref</i>) const = 0</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> virtual QXmlNodeModelIndex </td><td class="memItemRight bottomAlign"><b><a href="qabstractxmlnodemodel.html#root">root</a></b>(const QXmlNodeModelIndex &<i> n</i>) const = 0</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> QSourceLocation </td><td class="memItemRight bottomAlign"><b><a href="qabstractxmlnodemodel.html#sourceLocation">sourceLocation</a></b>(const QXmlNodeModelIndex &<i> index</i>) const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> virtual QString </td><td class="memItemRight bottomAlign"><b><a href="qabstractxmlnodemodel.html#stringValue">stringValue</a></b>(const QXmlNodeModelIndex &<i> n</i>) const = 0</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> virtual QVariant </td><td class="memItemRight bottomAlign"><b><a href="qabstractxmlnodemodel.html#typedValue">typedValue</a></b>(const QXmlNodeModelIndex &<i> node</i>) const = 0</td></tr>
</table>
<a name="protected-functions"></a>
<h2>Protected Functions</h2>
<table class="alignedsummary">
<tr><td class="memItemLeft rightAlign topAlign"> virtual QVector<QXmlNodeModelIndex> </td><td class="memItemRight bottomAlign"><b><a href="qabstractxmlnodemodel.html#attributes">attributes</a></b>(const QXmlNodeModelIndex &<i> element</i>) const = 0</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> QXmlNodeModelIndex </td><td class="memItemRight bottomAlign"><b><a href="qabstractxmlnodemodel.html#createIndex">createIndex</a></b>(qint64<i> data</i>) const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> QXmlNodeModelIndex </td><td class="memItemRight bottomAlign"><b><a href="qabstractxmlnodemodel.html#createIndex-2">createIndex</a></b>(void *<i> pointer</i>, qint64<i> additionalData</i> = 0) const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> QXmlNodeModelIndex </td><td class="memItemRight bottomAlign"><b><a href="qabstractxmlnodemodel.html#createIndex-3">createIndex</a></b>(qint64<i> data</i>, qint64<i> additionalData</i>) const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> virtual QXmlNodeModelIndex </td><td class="memItemRight bottomAlign"><b><a href="qabstractxmlnodemodel.html#nextFromSimpleAxis">nextFromSimpleAxis</a></b>(SimpleAxis<i> axis</i>, const QXmlNodeModelIndex &<i> origin</i>) const = 0</td></tr>
</table>
<a name="details"></a>
<!-- $$$QAbstractXmlNodeModel-description -->
<div class="descr">
<h2>Detailed Description</h2>
<p>The QAbstractXmlNodeModel class is an abstract base class for modeling non-XML data to look like XML for <a href="qxmlquery.html">QXmlQuery</a>.</p>
<p>The QAbstractXmlNodeModel specifies the interface that a node model must implement for that node model be accessible to the query engine for processing <a href="xmlprocessing.html">XQuery</a> queries. A node model represents data as a structure that can be queried as if the data were XML.</p>
<p>The node model represented by a subclass of QAbstractXmlNodeModel is meant to be accessed by the Qt XML Patterns query engine. If the API seems a little strange in a few places, it is because the member functions are called by the query engine as it evaluates an <a href="xmlprocessing.html">XQuery</a>. They aren't meant to be used programatically.</p>
<a name="usage"></a>
<h3>Usage</h3>
<p>QAbstractXmlNodeModel bridges the gap between the arbitrary structure of the non-XML data to be queried and the well-defined structure of XML data understood by <a href="qxmlquery.html">QXmlQuery</a>.</p>
<p>Consider a chemistry application that reads the file <tt>chemistryData</tt>, which contains non-XML data that represents a chemical structure composed of molecules and atoms. The application will query this chemistry data with an <a href="xmlprocessing.html">XQuery</a> it reads from file <tt>queryFile</tt>. We write a custom subclass of QAbstractXmlNodeModel (<tt>ChemistryNodeModel</tt>) that reads <tt>chemistryData</tt> and builds a data structure, perhaps composed of objects of our own classes <tt>molecule</tt> and <tt>atom</tt>. Clearly, this data structure is not XML. Our custom subclass will know how to traverse this non-XML structure and present it through the <a href="http://www.w3.org/TR/xpath-datamodel/">XPath Data Model interface</a>.</p>
<pre class="cpp"><span class="type">QFile</span> queryFile(argv<span class="operator">[</span><span class="number">1</span><span class="operator">]</span>);
<span class="type">QFile</span> chemistryData(argv<span class="operator">[</span><span class="number">2</span><span class="operator">]</span>);
<span class="type">QString</span> moleculeName <span class="operator">=</span> argv<span class="operator">[</span><span class="number">3</span><span class="operator">]</span>;
<span class="type"><a href="qxmlquery.html">QXmlQuery</a></span> query;
query<span class="operator">.</span>setQuery(<span class="operator">&</span>queryFile<span class="operator">,</span> <span class="type">QUrl</span><span class="operator">::</span>fromLocalFile(queryFile<span class="operator">.</span>fileName()));
ChemistryNodeModel myNodeModel(query<span class="operator">.</span>namePool()<span class="operator">,</span> chemistryData);
<span class="type"><a href="qxmlnodemodelindex.html">QXmlNodeModelIndex</a></span> startNode <span class="operator">=</span> myNodeModel<span class="operator">.</span>nodeFor(moleculeName);
query<span class="operator">.</span>bindVariable(<span class="string">"queryRoot"</span><span class="operator">,</span> startNode);
<span class="type">QFile</span> out;
out<span class="operator">.</span>open(stdout<span class="operator">,</span> <span class="type">QIODevice</span><span class="operator">::</span>WriteOnly);
<span class="type"><a href="qxmlserializer.html">QXmlSerializer</a></span> serializer(query<span class="operator">,</span> <span class="operator">&</span>out);
query<span class="operator">.</span>evaluateTo(<span class="operator">&</span>serializer);</pre>
<p>The application first creates an instance of <a href="qxmlquery.html">QXmlQuery</a> and calls <a href="qxmlquery.html#setQuery">setQuery()</a> to read <tt>queryFile</tt> containing the <a href="xmlprocessing.html">XQuery</a> we want to run. Then it creates an instance of our custom node model class, <tt>ChemistryNodeModel</tt>, which is a subclass of QAbstractXmlNodeModel. Its constructor is called with the <a href="qxmlnamepool.html">name pool</a> obtained from our <a href="qxmlquery.html">QXmlQuery</a>, and with the <tt>chemistryFile</tt> containing the structure of molecules and atoms to be queried. The <a href="qxmlnamepool.html">name pool</a> is required because our custom node model has the member function <a href="qabstractxmlnodemodel.html#name">name()</a>, which returns the <a href="qxmlname.html">name</a> of any node in the model. The <a href="qxmlquery.html">query</a> and the custom node model must use the same name pool for constructing these <a href="qxmlname.html">names</a>. The constructor would then read <tt>chemistryFile</tt> and build the custom node model structure.</p>
<p>To connect the <tt>query</tt> to the custom node model, we must bind a variable name used in the query to a node in the model. The variable can then be used in the query as a starting node. First, an <a href="qxmlnodemodelindex.html">index</a> for the desired starting node is retrieved by calling <a href="qabstractxmlnodemodel.html#createIndex">QAbstractXmlNodeModel::createIndex</a>(). Then the index is bound to a variable name, in this case <tt>queryRoot</tt>, by passing the name and the index to <a href="qxmlquery.html#bindVariable">QXmlQuery::bindVariable</a>(). The query can then use a variable reference <tt>$queryRoot</tt> to refer to the starting node. Note that if the <a href="qxmlquery.html">query</a> uses multiple variable references, a call to <a href="qxmlquery.html#bindVariable">QXmlQuery::bindVariable</a>() is required to bind each different variable name to a node in the model.</p>
<p>The query is executed when the application calls one of the <a href="qxmlquery.html">QXmlQuery</a> evaluation functions. The application uses QXmlQuery::evaluateTo(<a href="qabstractxmlreceiver.html">QAbstractXmlReceiver</a> *), because it then uses a <a href="qxmlserializer.html">serializer</a> to out the query result as XML to <tt>stdout</tt>. We could have used QXmlQuery::evaluateTo(<a href="qxmlresultitems.html">QXmlResultItems</a> *) to get a list of result items, or QXmlQuery::evaluateTo(QStringList *) if the query evaluated to a sequence of <tt>xs:string</tt> values.</p>
<p>During query execution, the engine iterates over the node model using <a href="qabstractxmlnodemodel.html#nextFromSimpleAxis">nextFromSimpleAxis</a>() to get the <a href="qxmlnodemodelindex.html">index</a> of the next node to be visited. The engine can get the name of a node by calling <a href="qabstractxmlnodemodel.html#name">name</a>() with the node's <a href="qxmlnodemodelindex.html">index</a>. <a href="qabstractxmlnodemodel.html#stringValue">stringValue</a>(), <a href="qabstractxmlnodemodel.html#baseUri">baseUri</a>(), <a href="qabstractxmlnodemodel.html#documentUri">documentUri</a>() and <a href="qabstractxmlnodemodel.html#kind">kind</a>() are also called as needed with a node <a href="qxmlnodemodelindex.html">index</a>.</p>
<p>The example demonstrates the standard pattern for using a subclass of QAbstractXmlNodeModel in combination with <a href="qxmlquery.html">QXmlQuery</a> to perform an <a href="xmlprocessing.html">XQuery</a>.</p>
<ol class="1">
<li>Instantiate <a href="qxmlquery.html">QXmlQuery</a> and give it the <a href="xmlprocessing.html">XQuery</a> to be run;</li>
<li>Instantiate a subclass of QAbstractXmlNodeModel or <a href="qsimplexmlnodemodel.html">QSimpleXmlNodeModel</a>;</li>
<li>Retrieve a <a href="qxmlnodemodelindex.html">QXmlNodeModelIndex</a> for the node in the model where the <a href="qxmlquery.html">QXmlQuery</a> should start the query;</li>
<li>Use <a href="qxmlquery.html#bindVariable">QXmlQuery::bindVariable</a>() to bind the <a href="qxmlnodemodelindex.html">QXmlNodeModelIndex</a> to <tt>$variable name</tt>;</li>
<li>Call one of the <a href="qxmlquery.html">QXmlQuery</a> evaluation functions to run the query.</li>
</ol>
<a name="subclassing"></a>
<h3>Subclassing</h3>
<p>Because the <a href="http://www.w3.org/TR/xpath-datamodel/">XPath Data Model interface</a> presented by QAbstractXmlNodeModel allows <a href="qxmlquery.html">QXmlQuery</a> to operate on non-XML data as if it were XML, implementing subclasses of QAbstractXmlNodeModel can involve a significant amount of work. The <a href="qsimplexmlnodemodel.html">QSimpleXmlNodeModel</a> class is provided to simplify the implementation for many common use cases.</p>
<a name="thread-safety"></a>
<h3>Thread Safety</h3>
<p>Because the node model can be accessed concurrently by threads in the Qt XML Patterns module, subclasses of QAbstractXmlNodeModel must be written to be <a href="qxmlquery.html#reentrancy-and-thread-safety">thread-safe</a>. Classes that simplify implementing thread-safety include QReadLocker and QWriteLocker.</p>
<p>See the example <a href="qtxmlpatterns-xmlpatterns-filetree-example.html">File System Example</a> for a demonstration.</p>
</div>
<!-- @@@QAbstractXmlNodeModel -->
<div class="types">
<h2>Member Type Documentation</h2>
<!-- $$$List -->
<h3 class="fn"><a name="List-typedef"></a>typedef QAbstractXmlNodeModel::<span class="name">List</span></h3>
<p>A list of smart pointers to instances of <a href="qabstractxmlnodemodel.html">QAbstractXmlNodeModel</a>.</p>
<p><b>See also </b>QExplicitlySharedDataPointer.</p>
<!-- @@@List -->
<!-- $$$Ptr -->
<h3 class="fn"><a name="Ptr-typedef"></a>typedef QAbstractXmlNodeModel::<span class="name">Ptr</span></h3>
<p>A smart pointer to an instance of <a href="qabstractxmlnodemodel.html">QAbstractXmlNodeModel</a>.</p>
<p><b>See also </b>QExplicitlySharedDataPointer.</p>
<!-- @@@Ptr -->
<!-- $$$SimpleAxis$$$Parent$$$FirstChild$$$PreviousSibling$$$NextSibling -->
<h3 class="fn"><a name="SimpleAxis-enum"></a>enum QAbstractXmlNodeModel::<span class="name">SimpleAxis</span></h3>
<p>Four axes that each contain one node only.</p>
<table class="valuelist"><tr valign="top" class="odd"><th class="tblConst">Constant</th><th class="tblval">Value</th><th class="tbldscr">Description</th></tr>
<tr><td class="topAlign"><tt>QAbstractXmlNodeModel::Parent</tt></td><td class="topAlign"><tt>0</tt></td><td class="topAlign">The parent of the context node</td></tr>
<tr><td class="topAlign"><tt>QAbstractXmlNodeModel::FirstChild</tt></td><td class="topAlign"><tt>1</tt></td><td class="topAlign">The first child of the context node</td></tr>
<tr><td class="topAlign"><tt>QAbstractXmlNodeModel::PreviousSibling</tt></td><td class="topAlign"><tt>2</tt></td><td class="topAlign">The previous child of the context node</td></tr>
<tr><td class="topAlign"><tt>QAbstractXmlNodeModel::NextSibling</tt></td><td class="topAlign"><tt>3</tt></td><td class="topAlign">The next child of the context node</td></tr>
</table>
<!-- @@@SimpleAxis -->
</div>
<div class="func">
<h2>Member Function Documentation</h2>
<!-- $$$QAbstractXmlNodeModel[overload1]$$$QAbstractXmlNodeModel -->
<h3 class="fn"><a name="QAbstractXmlNodeModel"></a>QAbstractXmlNodeModel::<span class="name">QAbstractXmlNodeModel</span>()</h3>
<p>Default constructor.</p>
<!-- @@@QAbstractXmlNodeModel -->
<!-- $$$~QAbstractXmlNodeModel[overload1]$$$~QAbstractXmlNodeModel -->
<h3 class="fn"><a name="dtor.QAbstractXmlNodeModel"></a>QAbstractXmlNodeModel::<span class="name">~QAbstractXmlNodeModel</span>()<tt> [virtual]</tt></h3>
<p>Destructor.</p>
<!-- @@@~QAbstractXmlNodeModel -->
<!-- $$$attributes[overload1]$$$attributesconstQXmlNodeModelIndex& -->
<h3 class="fn"><a name="attributes"></a><span class="type">QVector</span><<span class="type"><a href="qxmlnodemodelindex.html">QXmlNodeModelIndex</a></span>> QAbstractXmlNodeModel::<span class="name">attributes</span>(const <span class="type"><a href="qxmlnodemodelindex.html">QXmlNodeModelIndex</a></span> &<i> element</i>) const<tt> [pure virtual protected]</tt></h3>
<p>Returns the attributes of <i>element</i>. The caller guarantees that <i>element</i> is an element in this node model.</p>
<!-- @@@attributes -->
<!-- $$$baseUri[overload1]$$$baseUriconstQXmlNodeModelIndex& -->
<h3 class="fn"><a name="baseUri"></a><span class="type">QUrl</span> QAbstractXmlNodeModel::<span class="name">baseUri</span>(const <span class="type"><a href="qxmlnodemodelindex.html">QXmlNodeModelIndex</a></span> &<i> n</i>) const<tt> [pure virtual]</tt></h3>
<p>Returns the base URI for the node whose index is <i>n</i>. The caller guarantees that <i>n</i> is not <tt>null</tt> and that it belongs to a node in this node model.</p>
<p>The base URI of a node can be extracted using the <tt>fn:base-uri()</tt> 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.</p>
<p>This function maps to the <tt>dm:base-uri</tt> accessor, which returns a base URI according to the following:</p>
<ul>
<li>For document nodes, the base URI and the document URI are the same.</li>
<li>For elements, the base URI is the URI appearing in the element's <tt>xml:base</tt> attribute, if present, or it is resolved to the parent element's base URI.</li>
<li>Namespace nodes have no base URI.</li>
<li>The base URI for a processing instruction, comment, attribute, or text node is the base URI of the node's parent element.</li>
</ul>
<p>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.</p>
<p><b>See also </b><a href="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</a>.</p>
<!-- @@@baseUri -->
<!-- $$$compareOrder[overload1]$$$compareOrderconstQXmlNodeModelIndex&constQXmlNodeModelIndex& -->
<h3 class="fn"><a name="compareOrder"></a><span class="type"><a href="qxmlnodemodelindex.html#DocumentOrder-enum">QXmlNodeModelIndex::DocumentOrder</a></span> QAbstractXmlNodeModel::<span class="name">compareOrder</span>(const <span class="type"><a href="qxmlnodemodelindex.html">QXmlNodeModelIndex</a></span> &<i> ni1</i>, const <span class="type"><a href="qxmlnodemodelindex.html">QXmlNodeModelIndex</a></span> &<i> ni2</i>) const<tt> [pure virtual]</tt></h3>
<p>This function returns the relative document order for the nodes indexed by <i>ni1</i> and <i>ni2</i>. It is used for the <tt>Is</tt> operator and for sorting nodes in document order.</p>
<p>The caller guarantees that <i>ni1</i> and <i>ni2</i> are not <tt>null</tt> and that both identify nodes in this node model.</p>
<p>If <i>ni1</i> is identical to <i>ni2</i>, <a href="qxmlnodemodelindex.html#DocumentOrder-enum">QXmlNodeModelIndex::Is</a> is returned. If <i>ni1</i> precedes <i>ni2</i> in document order, <a href="qxmlnodemodelindex.html#DocumentOrder-enum">QXmlNodeModelIndex::Precedes</a> is returned. If <i>ni1</i> follows <i>ni2</i> in document order, <a href="qxmlnodemodelindex.html#DocumentOrder-enum">QXmlNodeModelIndex::Follows</a> is returned.</p>
<p><b>See also </b><a href="http://www.w3.org/TR/xpath-datamodel/#document-order">XQuery 1.0 and XPath 2.0 Data Model (XDM), 2.4 Document Order</a>.</p>
<!-- @@@compareOrder -->
<!-- $$$createIndex[overload1]$$$createIndexqint64 -->
<h3 class="fn"><a name="createIndex"></a><span class="type"><a href="qxmlnodemodelindex.html">QXmlNodeModelIndex</a></span> QAbstractXmlNodeModel::<span class="name">createIndex</span>(<span class="type">qint64</span><i> data</i>) const<tt> [protected]</tt></h3>
<p>Creates a node index with <i>data</i> as its internal data. <i>data</i> is not constrained.</p>
<!-- @@@createIndex -->
<!-- $$$createIndex$$$createIndexvoid*qint64 -->
<h3 class="fn"><a name="createIndex-2"></a><span class="type"><a href="qxmlnodemodelindex.html">QXmlNodeModelIndex</a></span> QAbstractXmlNodeModel::<span class="name">createIndex</span>(<span class="type">void</span> *<i> pointer</i>, <span class="type">qint64</span><i> additionalData</i> = 0) const<tt> [protected]</tt></h3>
<p>Creates a node index with <i>pointer</i> and <i>additionalData</i> as its internal data.</p>
<p>What <i>pointer</i> and <i>additionalData</i> is, is not constrained.</p>
<!-- @@@createIndex -->
<!-- $$$createIndex$$$createIndexqint64qint64 -->
<h3 class="fn"><a name="createIndex-3"></a><span class="type"><a href="qxmlnodemodelindex.html">QXmlNodeModelIndex</a></span> QAbstractXmlNodeModel::<span class="name">createIndex</span>(<span class="type">qint64</span><i> data</i>, <span class="type">qint64</span><i> additionalData</i>) const<tt> [protected]</tt></h3>
<p>This is an overloaded function.</p>
<p>Creates a <a href="qxmlnodemodelindex.html">QXmlNodeModelIndex</a> containing <i>data</i> and <i>additionalData</i>.</p>
<!-- @@@createIndex -->
<!-- $$$documentUri[overload1]$$$documentUriconstQXmlNodeModelIndex& -->
<h3 class="fn"><a name="documentUri"></a><span class="type">QUrl</span> QAbstractXmlNodeModel::<span class="name">documentUri</span>(const <span class="type"><a href="qxmlnodemodelindex.html">QXmlNodeModelIndex</a></span> &<i> n</i>) const<tt> [pure virtual]</tt></h3>
<p>Returns the document URI of <i>n</i>. The document URI identifies the resource which is the document. For example, the document could be a regular file, e.g., <tt>file:/</tt>, or it could be the <tt>http://</tt> URL of the location of a file. The document URI is used for resolving URIs and to simply know where the document is.</p>
<p>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.</p>
<p>The caller guarantees that <i>n</i> is not <tt>null</tt> and that it belongs to this <a href="qabstractxmlnodemodel.html">QAbstractXmlNodeModel</a>.</p>
<p>This function maps to the <tt>dm:document-uri</tt> accessor, which returns a document URI according to the following:</p>
<ul>
<li>If <i>n</i> 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.</li>
<li>For all other nodes, return a default constructed QUrl.</li>
</ul>
<p><b>See also </b><a href="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</a>, QUrl::isValid(), and QUrl::isRelative().</p>
<!-- @@@documentUri -->
<!-- $$$elementById[overload1]$$$elementByIdconstQXmlName& -->
<h3 class="fn"><a name="elementById"></a><span class="type"><a href="qxmlnodemodelindex.html">QXmlNodeModelIndex</a></span> QAbstractXmlNodeModel::<span class="name">elementById</span>(const <span class="type"><a href="qxmlname.html">QXmlName</a></span> &<i> id</i>) const<tt> [pure virtual]</tt></h3>
<p>Returns the index of the element identified as <i>id</i>. <a href="xmlprocessing.html">XQuery</a>'s <tt>id()</tt> function calls this function.</p>
<p>The node index returned will be the element node whose value is of type <tt>ID</tt> and equals <i>id</i>, or it will be the element node that has an attribute whose typed value is of type <tt>ID</tt> and equals <i>id</i>. If there is no such element, a default constructed <a href="qxmlnodemodelindex.html">QXmlNodeModelIndex</a> instance is returned. The implementor guarantees that if the returned node index is not null, it identifies an element.</p>
<p>It is not sufficient for an attribute or element to merely be called <tt>id</tt>. Its value type must also be <tt>ID</tt>. However, the reserved name <tt>xml:id</tt> is sufficient.</p>
<p>In <i>id</i>, the <tt>namespace URI</tt> and the <tt>prefix</tt> are undefined, and the <tt>local name</tt> is the ID that should be looked up.</p>
<p><b>See also </b><a href="http://www.w3.org/TR/xpath-functions/#func-id">XQuery 1.0 and XPath 2.0 Functions and Operators, 15.5.2 fn:id</a>.</p>
<!-- @@@elementById -->
<!-- $$$kind[overload1]$$$kindconstQXmlNodeModelIndex& -->
<h3 class="fn"><a name="kind"></a><span class="type"><a href="qxmlnodemodelindex.html#NodeKind-enum">QXmlNodeModelIndex::NodeKind</a></span> QAbstractXmlNodeModel::<span class="name">kind</span>(const <span class="type"><a href="qxmlnodemodelindex.html">QXmlNodeModelIndex</a></span> &<i> ni</i>) const<tt> [pure virtual]</tt></h3>
<p>Returns a value indicating the kind of node identified by <i>ni</i>. The caller guarantees that <i>ni</i> is not null and that it identifies a node in this node model. This function maps to the <tt>dm:node-kind()</tt> accessor.</p>
<p><b>See also </b><a href="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</a>.</p>
<!-- @@@kind -->
<!-- $$$name[overload1]$$$nameconstQXmlNodeModelIndex& -->
<h3 class="fn"><a name="name"></a><span class="type"><a href="qxmlname.html">QXmlName</a></span> QAbstractXmlNodeModel::<span class="name">name</span>(const <span class="type"><a href="qxmlnodemodelindex.html">QXmlNodeModelIndex</a></span> &<i> ni</i>) const<tt> [pure virtual]</tt></h3>
<p>Returns the name of <i>ni</i>. The caller guarantees that <i>ni</i> is not <tt>null</tt> and that it belongs to this <a href="qabstractxmlnodemodel.html">QAbstractXmlNodeModel</a>.</p>
<p>If a node does not have a name, e.g., comment nodes, a null <a href="qxmlname.html">QXmlName</a> is returned. QXmlNames must be created with the instance of <a href="qxmlquery.html">QXmlQuery</a> that is being used for evaluating queries using this <a href="qabstractxmlnodemodel.html">QAbstractXmlNodeModel</a>.</p>
<p>This function maps to the <tt>dm:node-name()</tt> accessor.</p>
<p>If <i>ni</i> is a processing instruction, a <a href="qxmlname.html">QXmlName</a> is returned with the local name as the target name and the namespace URI and prefix both empty.</p>
<p><b>See also </b><a href="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</a> and <a href="qxmlname.html">QXmlName</a>.</p>
<!-- @@@name -->
<!-- $$$namespaceBindings[overload1]$$$namespaceBindingsconstQXmlNodeModelIndex& -->
<h3 class="fn"><a name="namespaceBindings"></a><span class="type">QVector</span><<span class="type"><a href="qxmlname.html">QXmlName</a></span>> QAbstractXmlNodeModel::<span class="name">namespaceBindings</span>(const <span class="type"><a href="qxmlnodemodelindex.html">QXmlNodeModelIndex</a></span> &<i> n</i>) const<tt> [pure virtual]</tt></h3>
<p>Returns the in-scope namespaces of <i>n</i>. The caller guarantees that <i>n</i> is not <tt>null</tt> and that it belongs to this <a href="qabstractxmlnodemodel.html">QAbstractXmlNodeModel</a>.</p>
<p>This function corresponds to the <tt>dm:namespace-nodes</tt> accessor.</p>
<p>The returned vector of namespace declarations includes namespaces of the ancestors of <i>n</i>.</p>
<p>The caller guarantees that <i>n</i> is an Element that belongs to this <a href="qabstractxmlnodemodel.html">QAbstractXmlNodeModel</a>.</p>
<!-- @@@namespaceBindings -->
<!-- $$$nextFromSimpleAxis[overload1]$$$nextFromSimpleAxisSimpleAxisconstQXmlNodeModelIndex& -->
<h3 class="fn"><a name="nextFromSimpleAxis"></a><span class="type"><a href="qxmlnodemodelindex.html">QXmlNodeModelIndex</a></span> QAbstractXmlNodeModel::<span class="name">nextFromSimpleAxis</span>(<span class="type"><a href="qabstractxmlnodemodel.html#SimpleAxis-enum">SimpleAxis</a></span><i> axis</i>, const <span class="type"><a href="qxmlnodemodelindex.html">QXmlNodeModelIndex</a></span> &<i> origin</i>) const<tt> [pure virtual protected]</tt></h3>
<p>When Qt XML Patterns evaluate path expressions, it emulate them through a combination of calls with <a href="qabstractxmlnodemodel.html#SimpleAxis-enum">QSimpleXmlNodeModel::SimpleAxis</a> values. Therefore, the implementation of this function must return the node, if any, that appears on the <i>axis</i> emanating from the <i>origin</i>.</p>
<p>If no such node is available, a default constructed <a href="qxmlnodemodelindex.html">QXmlNodeModelIndex</a> is returned.</p>
<p><a href="qsimplexmlnodemodel.html">QSimpleXmlNodeModel</a> eliminates the need to handle redundant corner cases by guaranteeing that it will never ask for:</p>
<ul>
<li>Children or siblings for attributes.</li>
<li>Children for comments, processing instructions, and text nodes.</li>
<li>Siblings or parents for document nodes.</li>
</ul>
<p>A typical implementation performs a <tt>switch</tt> on the value of <i>axis</i>:</p>
<pre class="cpp"><span class="type"><a href="qxmlnodemodelindex.html">QXmlNodeModelIndex</a></span> MyTreeModel<span class="operator">::</span>nextFromSimpleAxis(SimpleAxis axis<span class="operator">,</span> <span class="keyword">const</span> <span class="type"><a href="qxmlnodemodelindex.html">QXmlNodeModelIndex</a></span> <span class="operator">&</span>origin) <span class="keyword">const</span>
{
<span class="comment">// Convert the QXmlNodeModelIndex to a value that is specific to what we represent.</span>
<span class="keyword">const</span> MyValue value <span class="operator">=</span> toMyValue(ni);
<span class="keyword">switch</span>(axis)
{
<span class="keyword">case</span> Parent:
<span class="keyword">return</span> toNodeIndex(value<span class="operator">.</span>parent());
<span class="keyword">case</span> FirstChild:
<span class="keyword">case</span> PreviousSibling:
<span class="keyword">case</span> NextSibling:
<span class="comment">// and so on</span>
}
}</pre>
<!-- @@@nextFromSimpleAxis -->
<!-- $$$nodesByIdref[overload1]$$$nodesByIdrefconstQXmlName& -->
<h3 class="fn"><a name="nodesByIdref"></a><span class="type">QVector</span><<span class="type"><a href="qxmlnodemodelindex.html">QXmlNodeModelIndex</a></span>> QAbstractXmlNodeModel::<span class="name">nodesByIdref</span>(const <span class="type"><a href="qxmlname.html">QXmlName</a></span> &<i> idref</i>) const<tt> [pure virtual]</tt></h3>
<p>Returns the elements and/or attributes that have an <tt>IDREF</tt> value equal to <i>idref</i>. <a href="xmlprocessing.html">XQuery</a>'s <tt>idref()</tt> function calls this function.</p>
<p>The implementor guarantees that the nodes identified by the returned indexes are elements or attributes.</p>
<p>It is not sufficient for an attribute or element to merely be called <tt>idref</tt>. It must also be of type <tt>IDREF</tt>. Elements must be typed as <tt>xs:IDREF</tt> or <tt>xs:IDREFS</tt>, or, in the case of attributes, as <tt>IDREF</tt> or <tt>IDREFS</tt> in the schema.</p>
<p>In <i>idref</i>, the <tt>namespace URI</tt> and the <tt>prefix</tt> are undefined, and the <tt>local name</tt> is the ID that should be looked up.</p>
<p><b>See also </b><a href="http://www.w3.org/TR/xpath-functions/#func-idref">XQuery 1.0 and XPath 2.0 Functions and Operators, 15.5.3 fn:idref</a>.</p>
<!-- @@@nodesByIdref -->
<!-- $$$root[overload1]$$$rootconstQXmlNodeModelIndex& -->
<h3 class="fn"><a name="root"></a><span class="type"><a href="qxmlnodemodelindex.html">QXmlNodeModelIndex</a></span> QAbstractXmlNodeModel::<span class="name">root</span>(const <span class="type"><a href="qxmlnodemodelindex.html">QXmlNodeModelIndex</a></span> &<i> n</i>) const<tt> [pure virtual]</tt></h3>
<p>Returns the root node of the tree that contains the node whose index is <i>n</i>. The caller guarantees that <i>n</i> is not <tt>null</tt> and that it identifies a node in this node model.</p>
<p>If <i>n</i> identifies a node that is a direct child of the root, parent() would return the same <a href="qxmlnodemodelindex.html">QXmlNodeModelIndex</a> returned by this function.</p>
<!-- @@@root -->
<!-- $$$sourceLocation[overload1]$$$sourceLocationconstQXmlNodeModelIndex& -->
<h3 class="fn"><a name="sourceLocation"></a><span class="type"><a href="qsourcelocation.html">QSourceLocation</a></span> QAbstractXmlNodeModel::<span class="name">sourceLocation</span>(const <span class="type"><a href="qxmlnodemodelindex.html">QXmlNodeModelIndex</a></span> &<i> index</i>) const</h3>
<p>Returns the source location for the object with the given <i>index</i> or a default constructed <a href="qsourcelocation.html">QSourceLocation</a> in case no location information is available.</p>
<p>This function was introduced in Qt 4.6.</p>
<!-- @@@sourceLocation -->
<!-- $$$stringValue[overload1]$$$stringValueconstQXmlNodeModelIndex& -->
<h3 class="fn"><a name="stringValue"></a><span class="type">QString</span> QAbstractXmlNodeModel::<span class="name">stringValue</span>(const <span class="type"><a href="qxmlnodemodelindex.html">QXmlNodeModelIndex</a></span> &<i> n</i>) const<tt> [pure virtual]</tt></h3>
<p>Returns the string value for node <i>n</i>.</p>
<p>The caller guarantees that <i>n</i> is not <tt>null</tt> and that it belong to this <a href="qabstractxmlnodemodel.html">QAbstractXmlNodeModel</a> instance.</p>
<p>This function maps to the <tt>dm:string-value()</tt> accessor, which the specification completely specifies. Here's a summary:</p>
<ul>
<li>For processing instructions, the string value is the data section(excluding any whitespace appearing between the name and the data).</li>
<li>For text nodes, the string value equals the text node.</li>
<li>For comments, the content of the comment</li>
<li>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.</li>
<li>For document nodes, the concatenation of all text nodes in the document.</li>
</ul>
<p><b>See also </b><a href="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</a>.</p>
<!-- @@@stringValue -->
<!-- $$$typedValue[overload1]$$$typedValueconstQXmlNodeModelIndex& -->
<h3 class="fn"><a name="typedValue"></a><span class="type">QVariant</span> QAbstractXmlNodeModel::<span class="name">typedValue</span>(const <span class="type"><a href="qxmlnodemodelindex.html">QXmlNodeModelIndex</a></span> &<i> node</i>) const<tt> [pure virtual]</tt></h3>
<p>Returns the typed value for node <i>node</i>.</p>
<p>The typed value is an atomic value, which an element or attribute contains.</p>
<p>The caller guarantees that <i>node</i> is either an element or an attribute. The implementor guarantees that the returned QVariant has a value which is supported in <a href="xmlprocessing.html">XQuery</a>. It cannot be an arbitrary QVariant value. The implementor also guarantees that <a href="qabstractxmlnodemodel.html#stringValue">stringValue</a>() returns a lexical representation of typedValue()(this is guaranteed by <a href="qsimplexmlnodemodel.html#stringValue">QSimpleXmlNodeModel::stringValue</a>()).</p>
<p>If the return QVariant is a default constructed variant, it signals that <i>node</i> has no typed value.</p>
<!-- @@@typedValue -->
</div>
</div>
</div>
</div>
</div>
</div>
<div class="footer">
<p>
<acronym title="Copyright">©</acronym> 2014 Digia Plc and/or its
subsidiaries. Documentation contributions included herein are the copyrights of
their respective owners.<br> The documentation provided herein is licensed under the terms of the <a href="http://www.gnu.org/licenses/fdl.html">GNU Free Documentation License version 1.3</a> as published by the Free Software Foundation.<br> Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide. All other trademarks are property
of their respective owners. </p>
</div>
</body>
</html>
|