1
<?xml version="1.0" encoding="iso-8859-1"?>
2
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "DTD/xhtml1-strict.dtd">
3
<html><head><title>QXmlName Class Reference</title><style>h3.fn,span.fn { margin-left: 1cm; text-indent: -1cm }
4
a:link { color: #004faf; text-decoration: none }
5
a:visited { color: #672967; text-decoration: none }
6
td.postheader { font-family: sans-serif }
7
tr.address { font-family: sans-serif }
8
body { background: #ffffff; color: black; }
9
</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">QXmlName Class Reference<br /><sup><sup>[<a href="qtxmlpatterns.html">QtXmlPatterns</a> module]</sup></sup></h1><p>The QXmlName class represents the name of an XML node, in an
10
efficient, namespace-aware way. <a href="#details">More...</a></p>
12
<h3>Methods</h3><ul><li><div class="fn" /><b><a href="qxmlname.html#QXmlName">__init__</a></b> (<i>self</i>)</li><li><div class="fn" /><b><a href="qxmlname.html#QXmlName-2">__init__</a></b> (<i>self</i>, QXmlNamePool <i>namePool</i>, QString <i>localName</i>, QString <i>namespaceUri</i> = QString(), QString <i>prefix</i> = QString())</li><li><div class="fn" /><b><a href="qxmlname.html#QXmlName-3">__init__</a></b> (<i>self</i>, QXmlName)</li><li><div class="fn" />bool <b><a href="qxmlname.html#isNull">isNull</a></b> (<i>self</i>)</li><li><div class="fn" />QString <b><a href="qxmlname.html#localName">localName</a></b> (<i>self</i>, QXmlNamePool <i>query</i>)</li><li><div class="fn" />QString <b><a href="qxmlname.html#namespaceUri">namespaceUri</a></b> (<i>self</i>, QXmlNamePool <i>query</i>)</li><li><div class="fn" />QString <b><a href="qxmlname.html#prefix">prefix</a></b> (<i>self</i>, QXmlNamePool <i>query</i>)</li><li><div class="fn" />QString <b><a href="qxmlname.html#toClarkName">toClarkName</a></b> (<i>self</i>, QXmlNamePool <i>query</i>)</li></ul><h3>Static Methods</h3><ul><li><div class="fn" />QXmlName <b><a href="qxmlname.html#fromClarkName">fromClarkName</a></b> (QString <i>clarkName</i>, QXmlNamePool <i>namePool</i>)</li><li><div class="fn" />bool <b><a href="qxmlname.html#isNCName">isNCName</a></b> (QString <i>candidate</i>)</li></ul><h3>Special Methods</h3><ul><li><div class="fn" />bool <b><a href="qxmlname.html#__eq__">__eq__</a></b> (<i>self</i>, QXmlName <i>other</i>)</li><li><div class="fn" />int <b><a href="qxmlname.html#__hash__">__hash__</a></b> (<i>self</i>)</li><li><div class="fn" />bool <b><a href="qxmlname.html#__ne__">__ne__</a></b> (<i>self</i>, QXmlName <i>other</i>)</li></ul><a name="details" /><hr /><h2>Detailed Description</h2><p>The QXmlName class represents the name of an XML node, in an
13
efficient, namespace-aware way.</p>
14
<p>QXmlName represents the name of an XML node in a way that is
15
both efficient and safe for comparing names. Normally, an XML node
16
represents an XML element or attribute, but QXmlName can also
17
represent the names of other kinds of nodes, e.g., <a href="qabstractxmlreceiver.html#processingInstruction">QAbstractXmlReceiver.processingInstruction</a>()
18
and <a href="qabstractxmlreceiver.html#namespaceBinding">QAbstractXmlReceiver.namespaceBinding</a>().</p>
19
<p>The name of an XML node has three components: The <i>namespace
20
URI</i>, the <i>local name</i>, and the <i>prefix</i>. To see what
21
these refer to in XML, consider the following snippet.</p>
23
<book xmlns:dc='http://purl.org/dc/elements/1.1'
24
xmlns='http://example.com/MyDefault'>
25
<dc:title>Mobey Dick</dc:title> ...
28
<p>For the element named <i>book</i>, <a href="qxmlname.html#localName">localName</a>() returns <i>book</i>,
29
<a href="qxmlname.html#namespaceUri">namespaceUri</a>() returns
30
<i>http://example.com/MyDefault</i>, and <a href="qxmlname.html#prefix">prefix</a>() returns an empty string. For
31
the element named <i>title</i>, <a href="qxmlname.html#localName">localName</a>() returns <i>title</i>,
32
<a href="qxmlname.html#namespaceUri">namespaceUri</a>() returns
33
<i>http://purl.org/dc/elements/1.1</i>, and <a href="qxmlname.html#prefix">prefix</a>() returns <i>dc</i>.</p>
34
<p>To ensure that operations with QXmlName are efficient, e.g.,
35
copying names and comparing them, each instance of QXmlName is
36
associated with a <a href="qxmlnamepool.html">name pool</a>, which
37
must be specified at QXmlName construction time. The three
38
components of the QXmlName, i.e., the namespace URI, the local
39
name, and the prefix, are stored in the name pool mapped to
40
identifiers so they can be shared. For this reason, the only way to
41
create a valid instance of QXmlName is to use the class
42
constructor, where the <a href="qxmlnamepool.html">name pool</a>,
43
local name, namespace URI, and prefix must all be specified.</p>
44
<p>Note that QXmlName's default constructor constructs a null
45
instance. It is typically used for allocating unused entries in
46
collections of QXmlName.</p>
47
<p>A side effect of associating each instance of QXmlName with a
48
<a href="qxmlnamepool.html">name pool</a> is that each instance of
49
QXmlName is tied to the <a href="qxmlnamepool.html">QXmlNamePool</a> with which it was created.
50
However, the QXmlName class does not keep track of the name pool,
51
so all the accessor functions, e.g., <a href="qxmlname.html#namespaceUri">namespaceUri</a>(), <a href="qxmlname.html#prefix">prefix</a>(), <a href="qxmlname.html#localName">localName</a>(), and <a href="qxmlname.html#toClarkName">toClarkName</a>() require that the
52
correct name pool be passed to them. Failure to provide the correct
53
name pool to these accessor functions results in undefined
55
<p>Note that a <a href="qxmlnamepool.html">name pool</a> is
56
<i>not</i> an XML namespace. One <a href="qxmlnamepool.html">name
57
pool</a> can represent instances of QXmlName from different XML
58
namespaces, and the instances of QXmlName from one XML namespace
59
can be distributed over multiple <a href="qxmlnamepool.html">name
61
<a id="comparing-qxmlnames" name="comparing-qxmlnames" /><a id="comparing-qxmlnames" name="comparing-qxmlnames" />
62
<h3>Comparing QXmlNames</h3>
63
<p>To determine what a QXmlName refers to, the <i>namespace URI</i>
64
and the <i>local name</i> are used. The <i>prefix</i> is not used
65
because the prefix is simply a shorthand name for use in place of
66
the normally much longer namespace URI. Nor is the prefix used in
67
name comparisons. For example, the following two element nodes
68
represent the same element and compare equal.</p>
70
<svg xmlns="http://www.w3.org/2000/svg"/>
73
<x:svg xmlns:x="http://www.w3.org/2000/svg"/>
75
<p>Although the second name has the prefix <i>x</i>, the two names
76
compare equal as instances of QXmlName, because the prefix is not
77
used in the comparison.</p>
78
<p>A local name can never be an empty string, although the prefix
79
and namespace URI can. If the prefix is not empty, the namespace
80
URI cannot be empty. Local names and prefixes must be valid
81
<a href="http://www.w3.org/TR/REC-xml-names/#NT-NCName">NCNames</a>,
82
e.g., <i>abc.def</i> or <i>abc123</i>.</p>
83
<p>QXmlName represents what is sometimes called an <i>expanded
84
QName</i>, or simply a QName.</p>
85
<hr /><h2>Method Documentation</h2><h3 class="fn"><a name="QXmlName" />QXmlName.__init__ (<i>self</i>)</h3><p>Constructs an uninitialized <a href="qxmlname.html">QXmlName</a>. To build a valid <a href="qxmlname.html">QXmlName</a>, you normally use the other
86
constructor, which takes a <a href="qxmlnamepool.html">name
87
pool</a>, namespace URI, local name, and prefix as parameters. But
88
you can also use this constructor to build a null <a href="qxmlname.html">QXmlName</a> and then assign an existing <a href="qxmlname.html">QXmlName</a> to it.</p>
89
<p><b>See also</b> <a href="qxmlname.html#isNull">isNull</a>().</p>
92
<h3 class="fn"><a name="QXmlName-2" />QXmlName.__init__ (<i>self</i>, <a href="qxmlnamepool.html">QXmlNamePool</a> <i>namePool</i>, QString <i>localName</i>, QString <i>namespaceUri</i> = QString(), QString <i>prefix</i> = QString())</h3><p>Constructs a <a href="qxmlname.html">QXmlName</a> instance that
93
inserts <i>localName</i>, <i>namespaceURI</i> and <i>prefix</i>
94
into <i>namePool</i> if they aren't already there. The accessor
95
functions <a href="qxmlname.html#namespaceUri">namespaceUri</a>(),
96
<a href="qxmlname.html#prefix">prefix</a>(), <a href="qxmlname.html#localName">localName</a>(), and <a href="qxmlname.html#toClarkName">toClarkName</a>() must be passed the
97
<i>namePool</i> used here, so the <i>namePool</i> must remain in
98
scope while the accessor functions might be used. However, two
99
instances can be compared with <i>==</i> or <i>!=</i> and copied
100
without the <i>namePool</i>.</p>
101
<p>The user guarantees that the string components are valid for a
102
QName. In particular, the local name, and the prefix (if present),
103
must be valid <a href="http://www.w3.org/TR/REC-xml-names/#NT-NCName">NCNames</a>. The
104
function <a href="qxmlname.html#isNCName">isNCName</a>() can be
105
used to test validity of these names. The namespace URI should be
106
an absolute URI. <a href="qurl.html#isRelative">QUrl.isRelative</a>() can be used to test
107
whether the namespace URI is relative or absolute. Finally,
108
providing a prefix is not valid when no namespace URI is
110
<p><i>namePool</i> is not copied. Nor is the reference to it
111
retained in this instance. This constructor inserts the three
112
strings into <i>namePool</i>.</p>
115
<h3 class="fn"><a name="QXmlName-3" />QXmlName.__init__ (<i>self</i>, <a href="qxmlname.html">QXmlName</a>)</h3><h3 class="fn"><a name="fromClarkName" /><a href="qxmlname.html">QXmlName</a> QXmlName.fromClarkName (QString <i>clarkName</i>, <a href="qxmlnamepool.html">QXmlNamePool</a> <i>namePool</i>)</h3><p>Converts <i>clarkName</i> into a <a href="qxmlname.html">QXmlName</a>, inserts into <i>namePool</i>, and
117
<p>A clark name is a way to present a full QName with only one
118
string, where the namespace cannot contain braces. Here are a
119
couple of examples:</p>
120
<table class="generic">
122
<tr class="qt-style">
127
<tr class="odd" valign="top">
128
<td><tt>html</tt></td>
129
<td>The local name <tt>html</tt>, in no namespace</td>
131
<tr class="even" valign="top">
132
<td><tt>http://www.w3.org/1999/xhtml</tt>html</td>
133
<td>The local name <tt>html</tt>, in the XHTML namespace</td>
135
<tr class="odd" valign="top">
136
<td><tt>http://www.w3.org/1999/xhtml</tt>my:html</td>
137
<td>The local name <tt>html</tt>, in the XHTML namespace, with the
138
prefix <tt>my</tt></td>
141
<p>If the namespace contains braces, the returned value is either
142
invalid or has undefined content.</p>
143
<p>If <i>clarkName</i> is an invalid name, a default constructed
144
<a href="qxmlname.html">QXmlName</a> is returned.</p>
145
<p>This function was introduced in Qt 4.5.</p>
146
<p><b>See also</b> <a href="qxmlname.html#toClarkName">toClarkName</a>().</p>
149
<h3 class="fn"><a name="isNCName" />bool QXmlName.isNCName (QString <i>candidate</i>)</h3><p>Returns true if <i>candidate</i> is an <tt>NCName</tt>. An
150
<tt>NCName</tt> is a string that can be used as a name in XML and
151
<a href="xmlprocessing.html">XQuery</a>, e.g., the prefix or local
152
name in an element or attribute, or the name of a variable.</p>
153
<p><b>See also</b> <a href="http://www.w3.org/TR/REC-xml-names/#NT-NCName">Namespaces in XML
154
1.0 (Second Edition), [4] NCName</a>.</p>
157
<h3 class="fn"><a name="isNull" />bool QXmlName.isNull (<i>self</i>)</h3><p>Returns true if this <a href="qxmlname.html">QXmlName</a> is not
158
initialized with a valid combination of <i>namespace URI</i>,
159
<i>local name</i>, and <i>prefix</i>.</p>
160
<p>A valid local name is always required. The prefix and namespace
161
URI can be empty, but if the prefix is not empty, the namespace URI
162
must not be empty. Local names and prefixes must be valid <a href="http://www.w3.org/TR/REC-xml-names/#NT-NCName">NCNames</a>, e.g.,
163
<i>abc.def</i> or <i>abc123</i>.</p>
166
<h3 class="fn"><a name="localName" />QString QXmlName.localName (<i>self</i>, <a href="qxmlnamepool.html">QXmlNamePool</a> <i>query</i>)</h3><p>Returns the local name.</p>
167
<p>Note that for efficiency, the local name string is not stored in
168
the <a href="qxmlname.html">QXmlName</a> but in the <a href="qxmlnamepool.html">QXmlNamePool</a> that was passed to the
169
constructor. Hence, that same <i>namePool</i> must be passed to
170
this function, so it can be used for looking up the local name.</p>
173
<h3 class="fn"><a name="namespaceUri" />QString QXmlName.namespaceUri (<i>self</i>, <a href="qxmlnamepool.html">QXmlNamePool</a> <i>query</i>)</h3><p>Returns the namespace URI.</p>
174
<p>Note that for efficiency, the namespace URI string is not stored
175
in the <a href="qxmlname.html">QXmlName</a> but in the <a href="qxmlnamepool.html">QXmlNamePool</a> that was passed to the
176
constructor. Hence, that same <i>namePool</i> must be passed to
177
this function, so it can be used for looking up the namespace
181
<h3 class="fn"><a name="prefix" />QString QXmlName.prefix (<i>self</i>, <a href="qxmlnamepool.html">QXmlNamePool</a> <i>query</i>)</h3><p>Returns the prefix.</p>
182
<p>Note that for efficiency, the prefix string is not stored in the
183
<a href="qxmlname.html">QXmlName</a> but in the <a href="qxmlnamepool.html">QXmlNamePool</a> that was passed to the
184
constructor. Hence, that same <i>namePool</i> must be passed to
185
this function, so it can be used for looking up the prefix.</p>
188
<h3 class="fn"><a name="toClarkName" />QString QXmlName.toClarkName (<i>self</i>, <a href="qxmlnamepool.html">QXmlNamePool</a> <i>query</i>)</h3><p>Returns this <a href="qxmlname.html">QXmlName</a> formatted as a
189
Clark Name. For example, if the local name is <tt>html</tt>, the
190
prefix is <tt>x</tt>, and the namespace URI is
191
<tt>http://www.w3.org/1999/xhtml/</tt>, then the Clark Name
194
{http:<span class="comment">//www.w3.org/1999/xhtml/}x:html.</span>
196
<p>If the local name is <i>MyWidget</i> and the namespace is empty,
197
the Clark Name returned is:</p>
201
<p>Note that for efficiency, the namespace URI, local name, and
202
prefix strings are not stored in the <a href="qxmlname.html">QXmlName</a> but in the <a href="qxmlnamepool.html">QXmlNamePool</a> that was passed to the
203
constructor. Hence, that same <i>namePool</i> must be passed to
204
this function, so it can be used for looking up the three string
206
<p>This function can be useful for debugging.</p>
207
<p><b>See also</b> <a href="http://www.jclark.com/xml/xmlns.htm">XML Namespaces, James
208
Clark</a> and <a href="qxmlname.html#fromClarkName">fromClarkName</a>().</p>
211
<h3 class="fn"><a name="__eq__" />bool QXmlName.__eq__ (<i>self</i>, <a href="qxmlname.html">QXmlName</a> <i>other</i>)</h3><h3 class="fn"><a name="__hash__" />int QXmlName.__hash__ (<i>self</i>)</h3><h3 class="fn"><a name="__ne__" />bool QXmlName.__ne__ (<i>self</i>, <a href="qxmlname.html">QXmlName</a> <i>other</i>)</h3><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>
b'\\ No newline at end of file'