File: qxmlschema.html

package info (click to toggle)
python-qt4 4.9.3-4
  • links: PTS, VCS
  • area: main
  • in suites: wheezy
  • size: 34,432 kB
  • sloc: python: 34,126; cpp: 11,938; xml: 290; makefile: 223; php: 27
file content (202 lines) | stat: -rw-r--r-- 15,937 bytes parent folder | download
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
<?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">&#160;&#160;</td><td class="postheader" valign="center"><a href="index.html"><font color="#004faf">Home</font></a>&#160;&#183; <a href="classes.html"><font color="#004faf">All Classes</font></a>&#160;&#183; <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&#160;<i>source</i>)</li><li><div class="fn" />bool <b><a href="qxmlschema.html#load-2">load</a></b> (<i>self</i>, QIODevice&#160;<i>source</i>, QUrl&#160;<i>documentUri</i>&#160;=&#160;QUrl())</li><li><div class="fn" />bool <b><a href="qxmlschema.html#load-3">load</a></b> (<i>self</i>, QByteArray&#160;<i>data</i>, QUrl&#160;<i>documentUri</i>&#160;=&#160;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&#160;<i>handler</i>)</li><li><div class="fn" /><b><a href="qxmlschema.html#setNetworkAccessManager">setNetworkAccessManager</a></b> (<i>self</i>, QNetworkAccessManager&#160;<i>networkmanager</i>)</li><li><div class="fn" /><b><a href="qxmlschema.html#setUriResolver">setUriResolver</a></b> (<i>self</i>, QAbstractUriResolver&#160;<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">&lt;</span><span class="operator">&lt;</span> <span class="string">"schema is valid"</span>;
     <span class="keyword">else</span>
         <a href="qtcore.html#qDebug">qDebug</a>() <span class="operator">&lt;</span><span class="operator">&lt;</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>&#160;<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">&lt;</span><span class="operator">&lt;</span> <span class="string">"schema is valid"</span>;
     <span class="keyword">else</span>
         <a href="qtcore.html#qDebug">qDebug</a>() <span class="operator">&lt;</span><span class="operator">&lt;</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>&#160;<i>source</i>, <a href="qurl.html">QUrl</a>&#160;<i>documentUri</i>&#160;=&#160;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">&amp;</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">&lt;</span><span class="operator">&lt;</span> <span class="string">"schema is valid"</span>;
     <span class="keyword">else</span>
         <a href="qtcore.html#qDebug">qDebug</a>() <span class="operator">&lt;</span><span class="operator">&lt;</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>&#160;<i>data</i>, <a href="qurl.html">QUrl</a>&#160;<i>documentUri</i>&#160;=&#160;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">"&lt;?xml version=\"1.0\" encoding=\"UTF-8\"?&gt;"</span>
                      <span class="string">"&lt;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\"&gt;"</span>
                      <span class="string">"&lt;/xsd:schema&gt;"</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">&lt;</span><span class="operator">&lt;</span> <span class="string">"schema is valid"</span>;
     <span class="keyword">else</span>
         <a href="qtcore.html#qDebug">qDebug</a>() <span class="operator">&lt;</span><span class="operator">&lt;</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>&#160;<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> &amp; 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> &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 class="even" valign="top">
<td>const <a href="qsourcelocation.html">QSourceLocation</a> &amp;
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>&#160;<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>&#160;<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&#160;4.9.3 for X11</td><td align="center" width="50%">Copyright &#169; <a href="http://www.riverbankcomputing.com">Riverbank&#160;Computing&#160;Ltd</a> and <a href="http://www.qtsoftware.com">Nokia</a> 2012</td><td align="right" width="25%">Qt&#160;4.8.2</td></tr></table></div></address></body></html>