<?xml version="1.0" encoding="iso-8859-1"?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "DTD/xhtml1-strict.dtd"> <html><head><title>QXmlSchema Class Reference</title><style>h3.fn,span.fn { margin-left: 1cm; text-indent: -1cm } a:link { color: #004faf; text-decoration: none } a:visited { color: #672967; text-decoration: none } td.postheader { font-family: sans-serif } tr.address { font-family: sans-serif } body { background: #ffffff; color: black; } </style></head><body><table border="0" cellpadding="0" cellspacing="0" width="100%"><tr /><td align="left" valign="top" width="32"><img align="left" border="0" height="32" src="images/rb-logo.png" width="32" /></td><td width="1">  </td><td class="postheader" valign="center"><a href="index.html"><font color="#004faf">Home</font></a> · <a href="classes.html"><font color="#004faf">All Classes</font></a> · <a href="modules.html"><font color="#004faf">Modules</font></a></td></table><h1 align="center">QXmlSchema Class Reference<br /><sup><sup>[<a href="qtxmlpatterns.html">QtXmlPatterns</a> module]</sup></sup></h1><p>The QXmlSchema class provides loading and validation of a W3C XML Schema. <a href="#details">More...</a></p> <h3>Methods</h3><ul><li><div class="fn" /><b><a href="qxmlschema.html#QXmlSchema">__init__</a></b> (<i>self</i>)</li><li><div class="fn" />QUrl <b><a href="qxmlschema.html#documentUri">documentUri</a></b> (<i>self</i>)</li><li><div class="fn" />bool <b><a href="qxmlschema.html#isValid">isValid</a></b> (<i>self</i>)</li><li><div class="fn" />bool <b><a href="qxmlschema.html#load">load</a></b> (<i>self</i>, QUrl <i>source</i>)</li><li><div class="fn" />bool <b><a href="qxmlschema.html#load-2">load</a></b> (<i>self</i>, QIODevice <i>source</i>, QUrl <i>documentUri</i> = QUrl())</li><li><div class="fn" />bool <b><a href="qxmlschema.html#load-3">load</a></b> (<i>self</i>, QByteArray <i>data</i>, QUrl <i>documentUri</i> = QUrl())</li><li><div class="fn" />QAbstractMessageHandler <b><a href="qxmlschema.html#messageHandler">messageHandler</a></b> (<i>self</i>)</li><li><div class="fn" />QXmlNamePool <b><a href="qxmlschema.html#namePool">namePool</a></b> (<i>self</i>)</li><li><div class="fn" />QNetworkAccessManager <b><a href="qxmlschema.html#networkAccessManager">networkAccessManager</a></b> (<i>self</i>)</li><li><div class="fn" /><b><a href="qxmlschema.html#setMessageHandler">setMessageHandler</a></b> (<i>self</i>, QAbstractMessageHandler <i>handler</i>)</li><li><div class="fn" /><b><a href="qxmlschema.html#setNetworkAccessManager">setNetworkAccessManager</a></b> (<i>self</i>, QNetworkAccessManager <i>networkmanager</i>)</li><li><div class="fn" /><b><a href="qxmlschema.html#setUriResolver">setUriResolver</a></b> (<i>self</i>, QAbstractUriResolver <i>resolver</i>)</li><li><div class="fn" />QAbstractUriResolver <b><a href="qxmlschema.html#uriResolver">uriResolver</a></b> (<i>self</i>)</li></ul><a name="details" /><hr /><h2>Detailed Description</h2><p>The QXmlSchema class provides loading and validation of a W3C XML Schema.</p> <p>The QXmlSchema class loads, compiles and validates W3C XML Schema files that can be used further for validation of XML instance documents via <a href="qxmlschemavalidator.html">QXmlSchemaValidator</a>.</p> <p>The following example shows how to load a XML Schema file from the network and test whether it is a valid schema document:</p> <pre class="cpp"> <span class="type"><a href="qurl.html">QUrl</a></span> url(<span class="string">"http://www.schema-example.org/myschema.xsd"</span>); <span class="type">QXmlSchema</span> schema; <span class="keyword">if</span> (schema<span class="operator">.</span>load(url) <span class="operator">=</span><span class="operator">=</span> <span class="keyword">true</span>) <a href="qtcore.html#qDebug">qDebug</a>() <span class="operator"><</span><span class="operator"><</span> <span class="string">"schema is valid"</span>; <span class="keyword">else</span> <a href="qtcore.html#qDebug">qDebug</a>() <span class="operator"><</span><span class="operator"><</span> <span class="string">"schema is invalid"</span>; </pre> <a id="xml-schema-version" name="xml-schema-version" /> <h3>XML Schema Version</h3> <p>This class is used to represent schemas that conform to the <a href="http://www.w3.org/XML/Schema">XML Schema</a> 1.0 specification.</p> <hr /><h2>Method Documentation</h2><h3 class="fn"><a name="QXmlSchema" />QXmlSchema.__init__ (<i>self</i>)</h3><p>Constructs an invalid, empty schema that cannot be used until <a href="qxmlschema.html#load">load</a>() is called.</p> <h3 class="fn"><a name="documentUri" /><a href="qurl.html">QUrl</a> QXmlSchema.documentUri (<i>self</i>)</h3><p>Returns the document URI of the schema or an empty URI if no schema has been set.</p> <h3 class="fn"><a name="isValid" />bool QXmlSchema.isValid (<i>self</i>)</h3><p>Returns true if this schema is valid. Examples of invalid schemas are ones that contain syntax errors or that do not conform the W3C XML Schema specification.</p> <h3 class="fn"><a name="load" />bool QXmlSchema.load (<i>self</i>, <a href="qurl.html">QUrl</a> <i>source</i>)</h3><p>Sets this <a href="qxmlschema.html">QXmlSchema</a> to a schema loaded from the <i>source</i> URI.</p> <p>If the schema <a href="qxmlschema.html#isValid">is invalid</a>, <tt>false</tt> is returned and the behavior is undefined.</p> <p>Example:</p> <pre class="cpp"> <span class="type"><a href="qurl.html">QUrl</a></span> url(<span class="string">"http://www.schema-example.org/myschema.xsd"</span>); <span class="type"><a href="qxmlschema.html">QXmlSchema</a></span> schema; <span class="keyword">if</span> (schema<span class="operator">.</span>load(url) <span class="operator">=</span><span class="operator">=</span> <span class="keyword">true</span>) <a href="qtcore.html#qDebug">qDebug</a>() <span class="operator"><</span><span class="operator"><</span> <span class="string">"schema is valid"</span>; <span class="keyword">else</span> <a href="qtcore.html#qDebug">qDebug</a>() <span class="operator"><</span><span class="operator"><</span> <span class="string">"schema is invalid"</span>; </pre> <p><b>See also</b> <a href="qxmlschema.html#isValid">isValid</a>().</p> <h3 class="fn"><a name="load-2" />bool QXmlSchema.load (<i>self</i>, <a href="qiodevice.html">QIODevice</a> <i>source</i>, <a href="qurl.html">QUrl</a> <i>documentUri</i> = QUrl())</h3><p>Sets this <a href="qxmlschema.html">QXmlSchema</a> to a schema read from the <i>source</i> device. The device must have been opened with at least <a href="qiodevice.html#OpenModeFlag-enum">QIODevice.ReadOnly</a>.</p> <p><i>documentUri</i> represents the schema obtained from the <i>source</i> device. It is the base URI of the schema, that is used internally to resolve relative URIs that appear in the schema, and for message reporting.</p> <p>If <i>source</i> is <tt>null</tt> or not readable, or if <i>documentUri</i> is not a valid URI, behavior is undefined.</p> <p>If the schema <a href="qxmlschema.html#isValid">is invalid</a>, <tt>false</tt> is returned and the behavior is undefined.</p> <p>Example:</p> <pre class="cpp"> <span class="type"><a href="qfile.html">QFile</a></span> file(<span class="string">"myschema.xsd"</span>); file<span class="operator">.</span>open(<span class="type"><a href="qiodevice.html">QIODevice</a></span><span class="operator">.</span>ReadOnly); <span class="type"><a href="qxmlschema.html">QXmlSchema</a></span> schema; schema<span class="operator">.</span>load(<span class="operator">&</span>file<span class="operator">,</span> <span class="type"><a href="qurl.html">QUrl</a></span><span class="operator">.</span>fromLocalFile(file<span class="operator">.</span>fileName())); <span class="keyword">if</span> (schema<span class="operator">.</span>isValid()) <a href="qtcore.html#qDebug">qDebug</a>() <span class="operator"><</span><span class="operator"><</span> <span class="string">"schema is valid"</span>; <span class="keyword">else</span> <a href="qtcore.html#qDebug">qDebug</a>() <span class="operator"><</span><span class="operator"><</span> <span class="string">"schema is invalid"</span>; </pre> <p><b>See also</b> <a href="qxmlschema.html#isValid">isValid</a>().</p> <h3 class="fn"><a name="load-3" />bool QXmlSchema.load (<i>self</i>, <a href="qbytearray.html">QByteArray</a> <i>data</i>, <a href="qurl.html">QUrl</a> <i>documentUri</i> = QUrl())</h3><p>Sets this <a href="qxmlschema.html">QXmlSchema</a> to a schema read from the <i>data</i></p> <p><i>documentUri</i> represents the schema obtained from the <i>data</i>. It is the base URI of the schema, that is used internally to resolve relative URIs that appear in the schema, and for message reporting.</p> <p>If <i>documentUri</i> is not a valid URI, behavior is undefined.</p> <p>If the schema <a href="qxmlschema.html#isValid">is invalid</a>, <tt>false</tt> is returned and the behavior is undefined.</p> <p>Example:</p> <pre class="cpp"> <span class="type"><a href="qbytearray.html">QByteArray</a></span> data( <span class="string">"<?xml version=\"1.0\" encoding=\"UTF-8\"?>"</span> <span class="string">"<xsd:schema"</span> <span class="string">" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\""</span> <span class="string">" xmlns=\"http://qt.nokia.com/xmlschematest\""</span> <span class="string">" targetNamespace=\"http://qt.nokia.com/xmlschematest\""</span> <span class="string">" version=\"1.0\""</span> <span class="string">" elementFormDefault=\"qualified\">"</span> <span class="string">"</xsd:schema>"</span> ); <span class="type"><a href="qxmlschema.html">QXmlSchema</a></span> schema; schema<span class="operator">.</span>load(data); <span class="keyword">if</span> (schema<span class="operator">.</span>isValid()) <a href="qtcore.html#qDebug">qDebug</a>() <span class="operator"><</span><span class="operator"><</span> <span class="string">"schema is valid"</span>; <span class="keyword">else</span> <a href="qtcore.html#qDebug">qDebug</a>() <span class="operator"><</span><span class="operator"><</span> <span class="string">"schema is invalid"</span>; </pre> <p><b>See also</b> <a href="qxmlschema.html#isValid">isValid</a>() and <a href="qxmlschema.html#isValid">isValid</a>().</p> <h3 class="fn"><a name="messageHandler" /><a href="qabstractmessagehandler.html">QAbstractMessageHandler</a> QXmlSchema.messageHandler (<i>self</i>)</h3><p>Returns the message handler that handles compile and validation messages for this <a href="qxmlschema.html">QXmlSchema</a>.</p> <p><b>See also</b> <a href="qxmlschema.html#setMessageHandler">setMessageHandler</a>().</p> <h3 class="fn"><a name="namePool" /><a href="qxmlnamepool.html">QXmlNamePool</a> QXmlSchema.namePool (<i>self</i>)</h3><p>Returns the name pool used by this <a href="qxmlschema.html">QXmlSchema</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> <h3 class="fn"><a name="networkAccessManager" /><a href="qnetworkaccessmanager.html">QNetworkAccessManager</a> QXmlSchema.networkAccessManager (<i>self</i>)</h3><p>Returns the network manager, or 0 if it has not been set.</p> <p><b>See also</b> <a href="qxmlschema.html#setNetworkAccessManager">setNetworkAccessManager</a>().</p> <h3 class="fn"><a name="setMessageHandler" />QXmlSchema.setMessageHandler (<i>self</i>, <a href="qabstractmessagehandler.html">QAbstractMessageHandler</a> <i>handler</i>)</h3><p>Changes the <a href="qabstractmessagehandler.html">message handler</a> for this <a href="qxmlschema.html">QXmlSchema</a> to <i>handler</i>. The schema sends all compile and validation messages to this message handler. <a href="qxmlschema.html">QXmlSchema</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="qxmlschema.html">QXmlSchema</a> calls <a href="qabstractmessagehandler.html#message">QAbstractMessageHandler.message</a>(), the arguments are as follows:</p> <table class="generic"> <thead> <tr class="qt-style"> <th>message() argument</th> <th>Semantics</th> </tr> </thead> <tr class="odd" valign="top"> <td><a href="qtcore.html#QtMsgType-enum">QtMsgType</a> type</td> <td>Only <a href="qtcore.html#QtMsgType-enum">QtWarningMsg</a> and <a href="qtcore.html#QtMsgType-enum">QtFatalMsg</a> are used. The former identifies a warning, while the latter identifies an error.</td> </tr> <tr class="even" valign="top"> <td>const <a href="qstring.html">QString</a> & description</td> <td>An XHTML document which is the actual message. It is translated into the current language.</td> </tr> <tr class="odd" valign="top"> <td>const <a href="qurl.html">QUrl</a> &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 class="even" valign="top"> <td>const <a href="qsourcelocation.html">QSourceLocation</a> & sourceLocation</td> <td>Identifies where the error occurred.</td> </tr> </table> <p><b>See also</b> <a href="qxmlschema.html#messageHandler">messageHandler</a>().</p> <h3 class="fn"><a name="setNetworkAccessManager" />QXmlSchema.setNetworkAccessManager (<i>self</i>, <a href="qnetworkaccessmanager.html">QNetworkAccessManager</a> <i>networkmanager</i>)</h3><p>Sets the network manager to <i>manager</i>. <a href="qxmlschema.html">QXmlSchema</a> does not take ownership of <i>manager</i>.</p> <p><b>See also</b> <a href="qxmlschema.html#networkAccessManager">networkAccessManager</a>().</p> <h3 class="fn"><a name="setUriResolver" />QXmlSchema.setUriResolver (<i>self</i>, <a href="qabstracturiresolver.html">QAbstractUriResolver</a> <i>resolver</i>)</h3><p>Sets the URI resolver to <i>resolver</i>. <a href="qxmlschema.html">QXmlSchema</a> does not take ownership of <i>resolver</i>.</p> <p><b>See also</b> <a href="qxmlschema.html#uriResolver">uriResolver</a>().</p> <h3 class="fn"><a name="uriResolver" /><a href="qabstracturiresolver.html">QAbstractUriResolver</a> QXmlSchema.uriResolver (<i>self</i>)</h3><p>Returns the schema's URI resolver. If no URI resolver has been set, <a href="qtxmlpatterns.html">QtXmlPatterns</a> will use the URIs in schemas 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 <a href="qtxmlpatterns.html">QtXmlPatterns</a> 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="qxmlschema.html#setUriResolver">setUriResolver</a>().</p> <address><hr /><div align="center"><table border="0" cellspacing="0" width="100%"><tr class="address"><td align="left" width="25%">PyQt 4.10.3 for X11</td><td align="center" width="50%">Copyright © <a href="http://www.riverbankcomputing.com">Riverbank Computing Ltd</a> and <a href="http://www.qtsoftware.com">Nokia</a> 2012</td><td align="right" width="25%">Qt 4.8.5</td></tr></table></div></address></body></html>