Sophie

Sophie

distrib > Mageia > 6 > armv7hl > media > core-updates > by-pkgid > 9026c9fecbedd778b04292bd6f2d9049 > files > 99

qtxmlpatterns5-doc-5.9.4-1.mga6.noarch.rpm

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html>
<html lang="en">
<head>
  <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<!-- qxmlschemavalidator.cpp -->
  <title>QXmlSchemaValidator Class | Qt XML Patterns 5.9</title>
  <link rel="stylesheet" type="text/css" href="style/offline-simple.css" />
  <script type="text/javascript">
    document.getElementsByTagName("link").item(0).setAttribute("href", "style/offline.css");
    // loading style sheet breaks anchors that were jumped to before
    // so force jumping to anchor again
    setTimeout(function() {
        var anchor = location.hash;
        // need to jump to different anchor first (e.g. none)
        location.hash = "#";
        setTimeout(function() {
            location.hash = anchor;
        }, 0);
    }, 0);
  </script>
</head>
<body>
<div class="header" id="qtdocheader">
  <div class="main">
    <div class="main-rounded">
      <div class="navigationbar">
        <table><tr>
<td >Qt 5.9</td><td ><a href="qtxmlpatterns-index.html">Qt XML Patterns</a></td><td ><a href="qtxmlpatterns-module.html">C++ Classes</a></td><td >QXmlSchemaValidator</td></tr></table><table class="buildversion"><tr>
<td id="buildversion" width="100%" align="right">Qt 5.9.4 Reference Documentation</td>
        </tr></table>
      </div>
    </div>
<div class="content">
<div class="line">
<div class="content mainContent">
<div class="sidebar">
<div class="toc">
<h3><a name="toc">Contents</a></h3>
<ul>
<li class="level1"><a href="#public-functions">Public Functions</a></li>
<li class="level1"><a href="#details">Detailed Description</a></li>
<li class="level2"><a href="#xml-schema-version">XML Schema Version</a></li>
</ul>
</div>
<div class="sidebar-content" id="sidebar-content"></div></div>
<h1 class="title">QXmlSchemaValidator Class</h1>
<!-- $$$QXmlSchemaValidator-brief -->
<p>The <a href="qxmlschemavalidator.html">QXmlSchemaValidator</a> class validates XML instance documents against a W3C XML Schema. <a href="#details">More...</a></p>
<!-- @@@QXmlSchemaValidator -->
<div class="table"><table class="alignedsummary">
<tr><td class="memItemLeft rightAlign topAlign"> Header:</td><td class="memItemRight bottomAlign">   <span class="preprocessor">#include &lt;QXmlSchemaValidator&gt;</span>
</td></tr><tr><td class="memItemLeft rightAlign topAlign"> qmake:</td><td class="memItemRight bottomAlign"> QT += xmlpatterns</td></tr><tr><td class="memItemLeft rightAlign topAlign"> Since:</td><td class="memItemRight bottomAlign">  Qt 4.6</td></tr></table></div><ul>
<li><a href="qxmlschemavalidator-members.html">List of all members, including inherited members</a></li>
</ul>
<p><b>Note:</b> All functions in this class are reentrant.</p>
<a name="public-functions"></a>
<h2 id="public-functions">Public Functions</h2>
<div class="table"><table class="alignedsummary">
<tr><td class="memItemLeft rightAlign topAlign"> </td><td class="memItemRight bottomAlign"><b><a href="qxmlschemavalidator.html#QXmlSchemaValidator">QXmlSchemaValidator</a></b>()</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> </td><td class="memItemRight bottomAlign"><b><a href="qxmlschemavalidator.html#QXmlSchemaValidator-1">QXmlSchemaValidator</a></b>(const QXmlSchema &amp;<i>schema</i>)</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> </td><td class="memItemRight bottomAlign"><b><a href="qxmlschemavalidator.html#dtor.QXmlSchemaValidator">~QXmlSchemaValidator</a></b>()</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> QAbstractMessageHandler *</td><td class="memItemRight bottomAlign"><b><a href="qxmlschemavalidator.html#messageHandler">messageHandler</a></b>() const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> QXmlNamePool </td><td class="memItemRight bottomAlign"><b><a href="qxmlschemavalidator.html#namePool">namePool</a></b>() const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> QNetworkAccessManager *</td><td class="memItemRight bottomAlign"><b><a href="qxmlschemavalidator.html#networkAccessManager">networkAccessManager</a></b>() const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> QXmlSchema </td><td class="memItemRight bottomAlign"><b><a href="qxmlschemavalidator.html#schema">schema</a></b>() const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> void </td><td class="memItemRight bottomAlign"><b><a href="qxmlschemavalidator.html#setMessageHandler">setMessageHandler</a></b>(QAbstractMessageHandler *<i>handler</i>)</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> void </td><td class="memItemRight bottomAlign"><b><a href="qxmlschemavalidator.html#setNetworkAccessManager">setNetworkAccessManager</a></b>(QNetworkAccessManager *<i>manager</i>)</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> void </td><td class="memItemRight bottomAlign"><b><a href="qxmlschemavalidator.html#setSchema">setSchema</a></b>(const QXmlSchema &amp;<i>schema</i>)</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> void </td><td class="memItemRight bottomAlign"><b><a href="qxmlschemavalidator.html#setUriResolver">setUriResolver</a></b>(const QAbstractUriResolver *<i>resolver</i>)</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> const QAbstractUriResolver *</td><td class="memItemRight bottomAlign"><b><a href="qxmlschemavalidator.html#uriResolver">uriResolver</a></b>() const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> bool </td><td class="memItemRight bottomAlign"><b><a href="qxmlschemavalidator.html#validate">validate</a></b>(const QUrl &amp;<i>source</i>) const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> bool </td><td class="memItemRight bottomAlign"><b><a href="qxmlschemavalidator.html#validate-1">validate</a></b>(QIODevice *<i>source</i>, const QUrl &amp;<i>documentUri</i> = QUrl()) const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> bool </td><td class="memItemRight bottomAlign"><b><a href="qxmlschemavalidator.html#validate-2">validate</a></b>(const QByteArray &amp;<i>data</i>, const QUrl &amp;<i>documentUri</i> = QUrl()) const</td></tr>
</table></div>
<a name="details"></a>
<!-- $$$QXmlSchemaValidator-description -->
<div class="descr">
<h2 id="details">Detailed Description</h2>
<p>The <a href="qxmlschemavalidator.html">QXmlSchemaValidator</a> class validates XML instance documents against a W3C XML Schema.</p>
<p>The <a href="qxmlschemavalidator.html">QXmlSchemaValidator</a> class loads, parses an XML instance document and validates it against a W3C XML Schema that has been compiled with <a href="qxmlschema.html">QXmlSchema</a>.</p>
<p>The following example shows how to load a XML Schema from a local file, check whether it is a valid schema document and use it for validation of an XML instance document:</p>
<pre class="cpp">

      <span class="type">QUrl</span> schemaUrl(<span class="string">&quot;file:///home/user/schema.xsd&quot;</span>);

      <span class="type"><a href="qxmlschema.html">QXmlSchema</a></span> schema;
      schema<span class="operator">.</span>load(schemaUrl);

      <span class="keyword">if</span> (schema<span class="operator">.</span>isValid()) {
          <span class="type">QFile</span> file(<span class="string">&quot;test.xml&quot;</span>);
          file<span class="operator">.</span>open(<span class="type">QIODevice</span><span class="operator">::</span>ReadOnly);

          <span class="type"><a href="qxmlschemavalidator.html#QXmlSchemaValidator">QXmlSchemaValidator</a></span> validator(schema);
          <span class="keyword">if</span> (validator<span class="operator">.</span>validate(<span class="operator">&amp;</span>file<span class="operator">,</span> <span class="type">QUrl</span><span class="operator">::</span>fromLocalFile(file<span class="operator">.</span>fileName())))
              qDebug() <span class="operator">&lt;</span><span class="operator">&lt;</span> <span class="string">&quot;instance document is valid&quot;</span>;
          <span class="keyword">else</span>
              qDebug() <span class="operator">&lt;</span><span class="operator">&lt;</span> <span class="string">&quot;instance document is invalid&quot;</span>;
      }

</pre>
<a name="xml-schema-version"></a>
<h3 >XML Schema Version</h3>
<p>This class implements schema validation according to the XML Schema 1.0 specification.</p>
</div>
<p><b>See also </b><a href="qxmlschema.html">QXmlSchema</a> and <a href="qxmlschemavalidator.html#schema">XML Schema Validation Example</a>.</p>
<!-- @@@QXmlSchemaValidator -->
<div class="func">
<h2>Member Function Documentation</h2>
<!-- $$$QXmlSchemaValidator[overload1]$$$QXmlSchemaValidator -->
<h3 class="fn" id="QXmlSchemaValidator"><a name="QXmlSchemaValidator"></a>QXmlSchemaValidator::<span class="name">QXmlSchemaValidator</span>()</h3>
<p>Constructs a schema validator. The schema used for validation must be referenced in the XML instance document via the <code>xsi:schemaLocation</code> or <code>xsi:noNamespaceSchemaLocation</code> attribute.</p>
<!-- @@@QXmlSchemaValidator -->
<!-- $$$QXmlSchemaValidator$$$QXmlSchemaValidatorconstQXmlSchema& -->
<h3 class="fn" id="QXmlSchemaValidator-1"><a name="QXmlSchemaValidator-1"></a>QXmlSchemaValidator::<span class="name">QXmlSchemaValidator</span>(const <span class="type"><a href="qxmlschema.html">QXmlSchema</a></span> &amp;<i>schema</i>)</h3>
<p>Constructs a schema validator that will use <i>schema</i> for validation. If an empty <a href="qxmlschema.html">QXmlSchema</a> schema is passed to the validator, the schema used for validation must be referenced in the XML instance document via the <code>xsi:schemaLocation</code> or <code>xsi:noNamespaceSchemaLocation</code> attribute.</p>
<!-- @@@QXmlSchemaValidator -->
<!-- $$$~QXmlSchemaValidator[overload1]$$$~QXmlSchemaValidator -->
<h3 class="fn" id="dtor.QXmlSchemaValidator"><a name="dtor.QXmlSchemaValidator"></a>QXmlSchemaValidator::<span class="name">~QXmlSchemaValidator</span>()</h3>
<p>Destroys this <a href="qxmlschemavalidator.html">QXmlSchemaValidator</a>.</p>
<!-- @@@~QXmlSchemaValidator -->
<!-- $$$messageHandler[overload1]$$$messageHandler -->
<h3 class="fn" id="messageHandler"><a name="messageHandler"></a><span class="type"><a href="qabstractmessagehandler.html">QAbstractMessageHandler</a></span> *QXmlSchemaValidator::<span class="name">messageHandler</span>() const</h3>
<p>Returns the message handler that handles parsing and validation messages for this <a href="qxmlschemavalidator.html">QXmlSchemaValidator</a>.</p>
<p><b>See also </b><a href="qxmlschemavalidator.html#setMessageHandler">setMessageHandler</a>().</p>
<!-- @@@messageHandler -->
<!-- $$$namePool[overload1]$$$namePool -->
<h3 class="fn" id="namePool"><a name="namePool"></a><span class="type"><a href="qxmlnamepool.html">QXmlNamePool</a></span> QXmlSchemaValidator::<span class="name">namePool</span>() const</h3>
<p>Returns the name pool used by this <a href="qxmlschemavalidator.html">QXmlSchemaValidator</a> for constructing <a href="qxmlname.html">names</a>. There is no setter for the name pool, because mixing name pools causes errors due to name confusion.</p>
<!-- @@@namePool -->
<!-- $$$networkAccessManager[overload1]$$$networkAccessManager -->
<h3 class="fn" id="networkAccessManager"><a name="networkAccessManager"></a><span class="type">QNetworkAccessManager</span> *QXmlSchemaValidator::<span class="name">networkAccessManager</span>() const</h3>
<p>Returns the network manager, or 0 if it has not been set.</p>
<p><b>See also </b><a href="qxmlschemavalidator.html#setNetworkAccessManager">setNetworkAccessManager</a>().</p>
<!-- @@@networkAccessManager -->
<!-- $$$schema[overload1]$$$schema -->
<h3 class="fn" id="schema"><a name="schema"></a><span class="type"><a href="qxmlschema.html">QXmlSchema</a></span> QXmlSchemaValidator::<span class="name">schema</span>() const</h3>
<p>Returns the schema that is used for validation.</p>
<p><b>See also </b><a href="qxmlschemavalidator.html#setSchema">setSchema</a>().</p>
<!-- @@@schema -->
<!-- $$$setMessageHandler[overload1]$$$setMessageHandlerQAbstractMessageHandler* -->
<h3 class="fn" id="setMessageHandler"><a name="setMessageHandler"></a><span class="type">void</span> QXmlSchemaValidator::<span class="name">setMessageHandler</span>(<span class="type"><a href="qabstractmessagehandler.html">QAbstractMessageHandler</a></span> *<i>handler</i>)</h3>
<p>Changes the <a href="qabstractmessagehandler.html">message handler</a> for this <a href="qxmlschemavalidator.html">QXmlSchemaValidator</a> to <i>handler</i>. The schema validator sends all parsing and validation messages to this message handler. <a href="qxmlschemavalidator.html">QXmlSchemaValidator</a> does not take ownership of <i>handler</i>.</p>
<p>Normally, the default message handler is sufficient. It writes compile and validation messages to <i>stderr</i>. The default message handler includes color codes if <i>stderr</i> can render colors.</p>
<p>When <a href="qxmlschemavalidator.html">QXmlSchemaValidator</a> calls <a href="qabstractmessagehandler.html#message">QAbstractMessageHandler::message</a>(), the arguments are as follows:</p>
<div class="table"><table class="generic">
 <thead><tr class="qt-style"><th >message() argument</th><th >Semantics</th></tr></thead>
<tr valign="top" class="odd"><td >QtMsgType type</td><td >Only QtWarningMsg and QtFatalMsg are used. The former identifies a warning, while the latter identifies an error.</td></tr>
<tr valign="top" class="even"><td >const QString &amp; description</td><td >An XHTML document which is the actual message. It is translated into the current language.</td></tr>
<tr valign="top" class="odd"><td >const QUrl &amp;identifier</td><td >Identifies the error with a URI, where the fragment is the error code, and the rest of the URI is the error namespace.</td></tr>
<tr valign="top" class="even"><td >const <a href="qsourcelocation.html">QSourceLocation</a> &amp; sourceLocation</td><td >Identifies where the error occurred.</td></tr>
</table></div>
<p><b>See also </b><a href="qxmlschemavalidator.html#messageHandler">messageHandler</a>().</p>
<!-- @@@setMessageHandler -->
<!-- $$$setNetworkAccessManager[overload1]$$$setNetworkAccessManagerQNetworkAccessManager* -->
<h3 class="fn" id="setNetworkAccessManager"><a name="setNetworkAccessManager"></a><span class="type">void</span> QXmlSchemaValidator::<span class="name">setNetworkAccessManager</span>(<span class="type">QNetworkAccessManager</span> *<i>manager</i>)</h3>
<p>Sets the network manager to <i>manager</i>. <a href="qxmlschemavalidator.html">QXmlSchemaValidator</a> does not take ownership of <i>manager</i>.</p>
<p><b>See also </b><a href="qxmlschemavalidator.html#networkAccessManager">networkAccessManager</a>().</p>
<!-- @@@setNetworkAccessManager -->
<!-- $$$setSchema[overload1]$$$setSchemaconstQXmlSchema& -->
<h3 class="fn" id="setSchema"><a name="setSchema"></a><span class="type">void</span> QXmlSchemaValidator::<span class="name">setSchema</span>(const <span class="type"><a href="qxmlschema.html">QXmlSchema</a></span> &amp;<i>schema</i>)</h3>
<p>Sets the <i>schema</i> that shall be used for further validation. If the schema is empty, the schema used for validation must be referenced in the XML instance document via the <code>xsi:schemaLocation</code> or <code>xsi:noNamespaceSchemaLocation</code> attribute.</p>
<p><b>See also </b><a href="qxmlschemavalidator.html#schema">schema</a>().</p>
<!-- @@@setSchema -->
<!-- $$$setUriResolver[overload1]$$$setUriResolverconstQAbstractUriResolver* -->
<h3 class="fn" id="setUriResolver"><a name="setUriResolver"></a><span class="type">void</span> QXmlSchemaValidator::<span class="name">setUriResolver</span>(const <span class="type"><a href="qabstracturiresolver.html">QAbstractUriResolver</a></span> *<i>resolver</i>)</h3>
<p>Sets the URI resolver to <i>resolver</i>. <a href="qxmlschemavalidator.html">QXmlSchemaValidator</a> does not take ownership of <i>resolver</i>.</p>
<p><b>See also </b><a href="qxmlschemavalidator.html#uriResolver">uriResolver</a>().</p>
<!-- @@@setUriResolver -->
<!-- $$$uriResolver[overload1]$$$uriResolver -->
<h3 class="fn" id="uriResolver"><a name="uriResolver"></a>const <span class="type"><a href="qabstracturiresolver.html">QAbstractUriResolver</a></span> *QXmlSchemaValidator::<span class="name">uriResolver</span>() const</h3>
<p>Returns the schema's URI resolver. If no URI resolver has been set, Qt XML Patterns will use the URIs in instance documents as they are.</p>
<p>The URI resolver provides a level of abstraction, or <i>polymorphic URIs</i>. A resolver can rewrite <i>logical</i> URIs to physical ones, or it can translate obsolete or invalid URIs to valid ones.</p>
<p>When Qt XML Patterns calls <a href="qabstracturiresolver.html#resolve">QAbstractUriResolver::resolve</a>() the absolute URI is the URI mandated by the schema specification, and the relative URI is the URI specified by the user.</p>
<p><b>See also </b><a href="qxmlschemavalidator.html#setUriResolver">setUriResolver</a>().</p>
<!-- @@@uriResolver -->
<!-- $$$validate[overload1]$$$validateconstQUrl& -->
<h3 class="fn" id="validate"><a name="validate"></a><span class="type">bool</span> QXmlSchemaValidator::<span class="name">validate</span>(const <span class="type">QUrl</span> &amp;<i>source</i>) const</h3>
<p>Validates the XML instance document read from <i>source</i> against the schema.</p>
<p>Returns <code>true</code> if the XML instance document is valid according to the schema, <code>false</code> otherwise.</p>
<p>Example:</p>
<pre class="cpp">

      <span class="keyword">const</span> <span class="type"><a href="qxmlschema.html">QXmlSchema</a></span> schema <span class="operator">=</span> getSchema();

      <span class="keyword">const</span> <span class="type">QUrl</span> url(<span class="string">&quot;http://www.schema-example.org/test.xml&quot;</span>);

      <span class="type"><a href="qxmlschemavalidator.html#QXmlSchemaValidator">QXmlSchemaValidator</a></span> validator(schema);
      <span class="keyword">if</span> (validator<span class="operator">.</span>validate(url))
          qDebug() <span class="operator">&lt;</span><span class="operator">&lt;</span> <span class="string">&quot;instance document is valid&quot;</span>;
      <span class="keyword">else</span>
          qDebug() <span class="operator">&lt;</span><span class="operator">&lt;</span> <span class="string">&quot;instance document is invalid&quot;</span>;

</pre>
<!-- @@@validate -->
<!-- $$$validate$$$validateQIODevice*constQUrl& -->
<h3 class="fn" id="validate-1"><a name="validate-1"></a><span class="type">bool</span> QXmlSchemaValidator::<span class="name">validate</span>(<span class="type">QIODevice</span> *<i>source</i>, const <span class="type">QUrl</span> &amp;<i>documentUri</i> = QUrl()) const</h3>
<p>Validates the XML instance document read from <i>source</i> with the given <i>documentUri</i> against the schema.</p>
<p>Returns <code>true</code> if the XML instance document is valid according to the schema, <code>false</code> otherwise.</p>
<p>Example:</p>
<pre class="cpp">

      <span class="keyword">const</span> <span class="type"><a href="qxmlschema.html">QXmlSchema</a></span> schema <span class="operator">=</span> getSchema();

      <span class="type">QFile</span> file(<span class="string">&quot;test.xml&quot;</span>);
      file<span class="operator">.</span>open(<span class="type">QIODevice</span><span class="operator">::</span>ReadOnly);

      <span class="type"><a href="qxmlschemavalidator.html#QXmlSchemaValidator">QXmlSchemaValidator</a></span> validator(schema);
      <span class="keyword">if</span> (validator<span class="operator">.</span>validate(<span class="operator">&amp;</span>file<span class="operator">,</span> <span class="type">QUrl</span><span class="operator">::</span>fromLocalFile(file<span class="operator">.</span>fileName())))
          qDebug() <span class="operator">&lt;</span><span class="operator">&lt;</span> <span class="string">&quot;instance document is valid&quot;</span>;
      <span class="keyword">else</span>
          qDebug() <span class="operator">&lt;</span><span class="operator">&lt;</span> <span class="string">&quot;instance document is invalid&quot;</span>;

</pre>
<!-- @@@validate -->
<!-- $$$validate$$$validateconstQByteArray&constQUrl& -->
<h3 class="fn" id="validate-2"><a name="validate-2"></a><span class="type">bool</span> QXmlSchemaValidator::<span class="name">validate</span>(const <span class="type">QByteArray</span> &amp;<i>data</i>, const <span class="type">QUrl</span> &amp;<i>documentUri</i> = QUrl()) const</h3>
<p>Validates the XML instance document read from <i>data</i> with the given <i>documentUri</i> against the schema.</p>
<p>Returns <code>true</code> if the XML instance document is valid according to the schema, <code>false</code> otherwise.</p>
<p>Example:</p>
<pre class="cpp">

      <span class="keyword">const</span> <span class="type"><a href="qxmlschema.html">QXmlSchema</a></span> schema <span class="operator">=</span> getSchema();

      <span class="type">QByteArray</span> data(<span class="string">&quot;&lt;?xml version=\&quot;1.0\&quot; encoding=\&quot;UTF-8\&quot;?&gt;&quot;</span>
                      <span class="string">&quot;&lt;test&gt;&lt;/test&gt;&quot;</span>);

      <span class="type">QBuffer</span> buffer(<span class="operator">&amp;</span>data);
      buffer<span class="operator">.</span>open(<span class="type">QIODevice</span><span class="operator">::</span>ReadOnly);

      <span class="type"><a href="qxmlschemavalidator.html#QXmlSchemaValidator">QXmlSchemaValidator</a></span> validator(schema);
      <span class="keyword">if</span> (validator<span class="operator">.</span>validate(<span class="operator">&amp;</span>buffer))
          qDebug() <span class="operator">&lt;</span><span class="operator">&lt;</span> <span class="string">&quot;instance document is valid&quot;</span>;
      <span class="keyword">else</span>
          qDebug() <span class="operator">&lt;</span><span class="operator">&lt;</span> <span class="string">&quot;instance document is invalid&quot;</span>;

</pre>
<!-- @@@validate -->
</div>
        </div>
       </div>
   </div>
   </div>
</div>
<div class="footer">
   <p>
   <acronym title="Copyright">&copy;</acronym> 2017 The Qt Company Ltd.
   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>    Qt and respective logos are trademarks of The Qt Company Ltd.     in Finland and/or other countries worldwide. All other trademarks are property
   of their respective owners. </p>
</div>
</body>
</html>