source: trunk/doc/html/qxmlcontenthandler.html@ 203

Last change on this file since 203 was 190, checked in by rudi, 14 years ago

reference documentation added

File size: 16.4 KB
Line 
1<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
2<!-- /home/espenr/tmp/qt-3.3.8-espenr-2499/qt-x11-free-3.3.8/src/xml/qxml.cpp:1207 -->
3<html>
4<head>
5<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
6<title>QXmlContentHandler Class</title>
7<style type="text/css"><!--
8fn { margin-left: 1cm; text-indent: -1cm; }
9a:link { color: #004faf; text-decoration: none }
10a:visited { color: #672967; text-decoration: none }
11body { background: #ffffff; color: black; }
12--></style>
13</head>
14<body>
15
16<table border="0" cellpadding="0" cellspacing="0" width="100%">
17<tr bgcolor="#E5E5E5">
18<td valign=center>
19 <a href="index.html">
20<font color="#004faf">Home</font></a>
21 | <a href="classes.html">
22<font color="#004faf">All&nbsp;Classes</font></a>
23 | <a href="mainclasses.html">
24<font color="#004faf">Main&nbsp;Classes</font></a>
25 | <a href="annotated.html">
26<font color="#004faf">Annotated</font></a>
27 | <a href="groups.html">
28<font color="#004faf">Grouped&nbsp;Classes</font></a>
29 | <a href="functions.html">
30<font color="#004faf">Functions</font></a>
31</td>
32<td align="right" valign="center"><img src="logo32.png" align="right" width="64" height="32" border="0"></td></tr></table><h1 align=center>QXmlContentHandler Class Reference<br><small>[<a href="xml.html">XML module</a>]</small></h1>
33
34<p>The QXmlContentHandler class provides an interface to
35report the logical content of XML data.
36<a href="#details">More...</a>
37<p>All the functions in this class are <a href="threads.html#reentrant">reentrant</a> when Qt is built with thread support.</p>
38<p><tt>#include &lt;<a href="qxml-h.html">qxml.h</a>&gt;</tt>
39<p>Inherited by <a href="qxmldefaulthandler.html">QXmlDefaultHandler</a>.
40<p><a href="qxmlcontenthandler-members.html">List of all member functions.</a>
41<h2>Public Members</h2>
42<ul>
43<li class=fn>virtual void <a href="#setDocumentLocator"><b>setDocumentLocator</b></a> ( QXmlLocator&nbsp;*&nbsp;locator ) = 0</li>
44<li class=fn>virtual bool <a href="#startDocument"><b>startDocument</b></a> () = 0</li>
45<li class=fn>virtual bool <a href="#endDocument"><b>endDocument</b></a> () = 0</li>
46<li class=fn>virtual bool <a href="#startPrefixMapping"><b>startPrefixMapping</b></a> ( const&nbsp;QString&nbsp;&amp;&nbsp;prefix, const&nbsp;QString&nbsp;&amp;&nbsp;uri ) = 0</li>
47<li class=fn>virtual bool <a href="#endPrefixMapping"><b>endPrefixMapping</b></a> ( const&nbsp;QString&nbsp;&amp;&nbsp;prefix ) = 0</li>
48<li class=fn>virtual bool <a href="#startElement"><b>startElement</b></a> ( const&nbsp;QString&nbsp;&amp;&nbsp;namespaceURI, const&nbsp;QString&nbsp;&amp;&nbsp;localName, const&nbsp;QString&nbsp;&amp;&nbsp;qName, const&nbsp;QXmlAttributes&nbsp;&amp;&nbsp;atts ) = 0</li>
49<li class=fn>virtual bool <a href="#endElement"><b>endElement</b></a> ( const&nbsp;QString&nbsp;&amp;&nbsp;namespaceURI, const&nbsp;QString&nbsp;&amp;&nbsp;localName, const&nbsp;QString&nbsp;&amp;&nbsp;qName ) = 0</li>
50<li class=fn>virtual bool <a href="#characters"><b>characters</b></a> ( const&nbsp;QString&nbsp;&amp;&nbsp;ch ) = 0</li>
51<li class=fn>virtual bool <a href="#ignorableWhitespace"><b>ignorableWhitespace</b></a> ( const&nbsp;QString&nbsp;&amp;&nbsp;ch ) = 0</li>
52<li class=fn>virtual bool <a href="#processingInstruction"><b>processingInstruction</b></a> ( const&nbsp;QString&nbsp;&amp;&nbsp;target, const&nbsp;QString&nbsp;&amp;&nbsp;data ) = 0</li>
53<li class=fn>virtual bool <a href="#skippedEntity"><b>skippedEntity</b></a> ( const&nbsp;QString&nbsp;&amp;&nbsp;name ) = 0</li>
54<li class=fn>virtual QString <a href="#errorString"><b>errorString</b></a> () = 0</li>
55</ul>
56<hr><a name="details"></a><h2>Detailed Description</h2>
57
58
59
60The QXmlContentHandler class provides an interface to
61report the logical content of XML data.
62
63<p>
64
65<p> If the application needs to be informed of basic parsing events,
66it can implement this interface and activate it using
67<a href="qxmlreader.html#setContentHandler">QXmlReader::setContentHandler</a>(). The reader can then report basic
68document-related events like the start and end of elements and
69character data through this interface.
70<p> The order of events in this interface is very important, and
71mirrors the order of information in the document itself. For
72example, all of an element's content (character data, processing
73instructions, and sub-elements) appears, in order, between the
74<a href="#startElement">startElement</a>() event and the corresponding <a href="#endElement">endElement</a>() event.
75<p> The class <a href="qxmldefaulthandler.html">QXmlDefaultHandler</a> provides a default implementation for
76this interface; subclassing from the QXmlDefaultHandler class is
77very convenient if you only want to be informed of some parsing
78events.
79<p> The <a href="#startDocument">startDocument</a>() function is called at the start of the
80document, and <a href="#endDocument">endDocument</a>() is called at the end. Before parsing
81begins <a href="#setDocumentLocator">setDocumentLocator</a>() is called. For each element
82startElement() is called, with endElement() being called at the
83end of each element. The <a href="#characters">characters</a>() function is called with
84chunks of character data; <a href="#ignorableWhitespace">ignorableWhitespace</a>() is called with
85chunks of whitespace and <a href="#processingInstruction">processingInstruction</a>() is called with
86processing instructions. If an entity is skipped <a href="#skippedEntity">skippedEntity</a>()
87is called. At the beginning of prefix-URI scopes
88<a href="#startPrefixMapping">startPrefixMapping</a>() is called.
89<p> See also the <a href="xml.html#sax2Intro">Introduction to SAX2</a>.
90<p> <p>See also <a href="qxmldtdhandler.html">QXmlDTDHandler</a>, <a href="qxmldeclhandler.html">QXmlDeclHandler</a>, <a href="qxmlentityresolver.html">QXmlEntityResolver</a>, <a href="qxmlerrorhandler.html">QXmlErrorHandler</a>, <a href="qxmllexicalhandler.html">QXmlLexicalHandler</a>, and <a href="xml-tools.html">XML</a>.
91
92<hr><h2>Member Function Documentation</h2>
93<h3 class=fn>bool <a name="characters"></a>QXmlContentHandler::characters ( const&nbsp;<a href="qstring.html">QString</a>&nbsp;&amp;&nbsp;ch )<tt> [pure virtual]</tt>
94</h3>
95
96<p> The reader calls this function when it has parsed a chunk of
97character data (either normal character data or character data
98inside a CDATA section; if you need to distinguish between those
99two types you must use <a href="qxmllexicalhandler.html#startCDATA">QXmlLexicalHandler::startCDATA</a>() and
100<a href="qxmllexicalhandler.html#endCDATA">QXmlLexicalHandler::endCDATA</a>()). The character data is reported in
101<em>ch</em>.
102<p> Some readers report whitespace in element content using the
103<a href="#ignorableWhitespace">ignorableWhitespace</a>() function rather than using this one.
104<p> A reader may report the character data of an element in more than
105one chunk; e.g. a reader might want to report "a&lt;b" in three
106<a href="#characters">characters</a>() events ("a ", "&lt;" and " b").
107<p> If this function returns FALSE the reader stops parsing and
108reports an error. The reader uses the function <a href="#errorString">errorString</a>() to
109get the error message.
110
111<h3 class=fn>bool <a name="endDocument"></a>QXmlContentHandler::endDocument ()<tt> [pure virtual]</tt>
112</h3>
113
114<p> The reader calls this function after it has finished parsing. It
115is called just once, and is the last handler function called. It
116is called after the reader has read all input or has abandoned
117parsing because of a fatal error.
118<p> If this function returns FALSE the reader stops parsing and
119reports an error. The reader uses the function <a href="#errorString">errorString</a>() to
120get the error message.
121<p> <p>See also <a href="#startDocument">startDocument</a>().
122
123<h3 class=fn>bool <a name="endElement"></a>QXmlContentHandler::endElement ( const&nbsp;<a href="qstring.html">QString</a>&nbsp;&amp;&nbsp;namespaceURI, const&nbsp;<a href="qstring.html">QString</a>&nbsp;&amp;&nbsp;localName, const&nbsp;<a href="qstring.html">QString</a>&nbsp;&amp;&nbsp;qName )<tt> [pure virtual]</tt>
124</h3>
125
126<p> The reader calls this function when it has parsed an end element
127tag with the qualified name <em>qName</em>, the local name <em>localName</em>
128and the namespace URI <em>namespaceURI</em>.
129<p> If this function returns FALSE the reader stops parsing and
130reports an error. The reader uses the function <a href="#errorString">errorString</a>() to
131get the error message.
132<p> See also the <a href="xml.html#sax2Namespaces">namespace description</a>.
133<p> <p>See also <a href="#startElement">startElement</a>().
134
135<p>Example: <a href="xml-sax-walkthrough.html#x2136">xml/tagreader/structureparser.cpp</a>.
136<h3 class=fn>bool <a name="endPrefixMapping"></a>QXmlContentHandler::endPrefixMapping ( const&nbsp;<a href="qstring.html">QString</a>&nbsp;&amp;&nbsp;prefix )<tt> [pure virtual]</tt>
137</h3>
138
139<p> The reader calls this function to signal the end of a prefix
140mapping for the prefix <em>prefix</em>.
141<p> If this function returns FALSE the reader stops parsing and
142reports an error. The reader uses the function <a href="#errorString">errorString</a>() to
143get the error message.
144<p> See also the <a href="xml.html#sax2Namespaces">namespace description</a>.
145<p> <p>See also <a href="#startPrefixMapping">startPrefixMapping</a>().
146
147<h3 class=fn><a href="qstring.html">QString</a> <a name="errorString"></a>QXmlContentHandler::errorString ()<tt> [pure virtual]</tt>
148</h3>
149
150<p> The reader calls this function to get an error string, e.g. if any
151of the handler functions returns FALSE.
152
153<h3 class=fn>bool <a name="ignorableWhitespace"></a>QXmlContentHandler::ignorableWhitespace ( const&nbsp;<a href="qstring.html">QString</a>&nbsp;&amp;&nbsp;ch )<tt> [pure virtual]</tt>
154</h3>
155
156<p> Some readers may use this function to report each chunk of
157whitespace in element content. The whitespace is reported in <em>ch</em>.
158<p> If this function returns FALSE the reader stops parsing and
159reports an error. The reader uses the function <a href="#errorString">errorString</a>() to
160get the error message.
161
162<h3 class=fn>bool <a name="processingInstruction"></a>QXmlContentHandler::processingInstruction ( const&nbsp;<a href="qstring.html">QString</a>&nbsp;&amp;&nbsp;target, const&nbsp;<a href="qstring.html">QString</a>&nbsp;&amp;&nbsp;data )<tt> [pure virtual]</tt>
163</h3>
164
165<p> The reader calls this function when it has parsed a processing
166instruction.
167<p> <em>target</em> is the target name of the processing instruction and <em>data</em> is the data in the processing instruction.
168<p> If this function returns FALSE the reader stops parsing and
169reports an error. The reader uses the function <a href="#errorString">errorString</a>() to
170get the error message.
171
172<h3 class=fn>void <a name="setDocumentLocator"></a>QXmlContentHandler::setDocumentLocator ( <a href="qxmllocator.html">QXmlLocator</a>&nbsp;*&nbsp;locator )<tt> [pure virtual]</tt>
173</h3>
174
175<p> The reader calls this function before it starts parsing the
176document. The argument <em>locator</em> is a pointer to a <a href="qxmllocator.html">QXmlLocator</a>
177which allows the application to get the parsing position within
178the document.
179<p> Do not destroy the <em>locator</em>; it is destroyed when the reader is
180destroyed. (Do not use the <em>locator</em> after the reader is
181destroyed).
182
183<h3 class=fn>bool <a name="skippedEntity"></a>QXmlContentHandler::skippedEntity ( const&nbsp;<a href="qstring.html">QString</a>&nbsp;&amp;&nbsp;name )<tt> [pure virtual]</tt>
184</h3>
185
186<p> Some readers may skip entities if they have not seen the
187declarations (e.g. because they are in an external DTD). If they
188do so they report that they skipped the entity called <em>name</em> by
189calling this function.
190<p> If this function returns FALSE the reader stops parsing and
191reports an error. The reader uses the function <a href="#errorString">errorString</a>() to
192get the error message.
193
194<h3 class=fn>bool <a name="startDocument"></a>QXmlContentHandler::startDocument ()<tt> [pure virtual]</tt>
195</h3>
196
197<p> The reader calls this function when it starts parsing the
198document. The reader calls this function just once, after the call
199to <a href="#setDocumentLocator">setDocumentLocator</a>(), and before any other functions in this
200class or in the <a href="qxmldtdhandler.html">QXmlDTDHandler</a> class are called.
201<p> If this function returns FALSE the reader stops parsing and
202reports an error. The reader uses the function <a href="#errorString">errorString</a>() to
203get the error message.
204<p> <p>See also <a href="#endDocument">endDocument</a>().
205
206<p>Example: <a href="xml-sax-walkthrough.html#x2137">xml/tagreader/structureparser.cpp</a>.
207<h3 class=fn>bool <a name="startElement"></a>QXmlContentHandler::startElement ( const&nbsp;<a href="qstring.html">QString</a>&nbsp;&amp;&nbsp;namespaceURI, const&nbsp;<a href="qstring.html">QString</a>&nbsp;&amp;&nbsp;localName, const&nbsp;<a href="qstring.html">QString</a>&nbsp;&amp;&nbsp;qName, const&nbsp;<a href="qxmlattributes.html">QXmlAttributes</a>&nbsp;&amp;&nbsp;atts )<tt> [pure virtual]</tt>
208</h3>
209
210<p> The reader calls this function when it has parsed a start element
211tag.
212<p> There is a corresponding <a href="#endElement">endElement</a>() call when the corresponding
213end element tag is read. The <a href="#startElement">startElement</a>() and endElement() calls
214are always nested correctly. Empty element tags (e.g. <tt>&lt;x/&gt;</tt>)
215cause a startElement() call to be immediately followed by an
216endElement() call.
217<p> The attribute list provided only contains attributes with explicit
218values. The attribute list contains attributes used for namespace
219declaration (i.e. attributes starting with xmlns) only if the
220namespace-prefix property of the reader is TRUE.
221<p> The argument <em>namespaceURI</em> is the namespace URI, or
222<a href="qstring.html#QString-null">QString::null</a> if the element has no namespace URI or if no
223namespace processing is done. <em>localName</em> is the local name
224(without prefix), or QString::null if no namespace processing is
225done, <em>qName</em> is the qualified name (with prefix) and <em>atts</em> are
226the attributes attached to the element. If there are no
227attributes, <em>atts</em> is an empty attributes object.
228<p> If this function returns FALSE the reader stops parsing and
229reports an error. The reader uses the function <a href="#errorString">errorString</a>() to
230get the error message.
231<p> See also the <a href="xml.html#sax2Namespaces">namespace description</a>.
232<p> <p>See also <a href="#endElement">endElement</a>().
233
234<p>Example: <a href="xml-sax-walkthrough.html#x2138">xml/tagreader/structureparser.cpp</a>.
235<h3 class=fn>bool <a name="startPrefixMapping"></a>QXmlContentHandler::startPrefixMapping ( const&nbsp;<a href="qstring.html">QString</a>&nbsp;&amp;&nbsp;prefix, const&nbsp;<a href="qstring.html">QString</a>&nbsp;&amp;&nbsp;uri )<tt> [pure virtual]</tt>
236</h3>
237
238<p> The reader calls this function to signal the begin of a prefix-URI
239namespace mapping scope. This information is not necessary for
240normal namespace processing since the reader automatically
241replaces prefixes for element and attribute names.
242<p> Note that <a href="#startPrefixMapping">startPrefixMapping</a>() and <a href="#endPrefixMapping">endPrefixMapping</a>() calls are
243not guaranteed to be properly nested relative to each other: all
244startPrefixMapping() events occur before the corresponding
245<a href="#startElement">startElement</a>() event, and all endPrefixMapping() events occur
246after the corresponding <a href="#endElement">endElement</a>() event, but their order is not
247otherwise guaranteed.
248<p> The argument <em>prefix</em> is the namespace prefix being declared and
249the argument <em>uri</em> is the namespace URI the prefix is mapped to.
250<p> If this function returns FALSE the reader stops parsing and
251reports an error. The reader uses the function <a href="#errorString">errorString</a>() to
252get the error message.
253<p> See also the <a href="xml.html#sax2Namespaces">namespace description</a>.
254<p> <p>See also <a href="#endPrefixMapping">endPrefixMapping</a>().
255
256<!-- eof -->
257<hr><p>
258This file is part of the <a href="index.html">Qt toolkit</a>.
259Copyright &copy; 1995-2007
260<a href="http://www.trolltech.com/">Trolltech</a>. All Rights Reserved.<p><address><hr><div align=center>
261<table width=100% cellspacing=0 border=0><tr>
262<td>Copyright &copy; 2007
263<a href="troll.html">Trolltech</a><td align=center><a href="trademarks.html">Trademarks</a>
264<td align=right><div align=right>Qt 3.3.8</div>
265</table></div></address></body>
266</html>
Note: See TracBrowser for help on using the repository browser.