Commit | Line | Data |
---|---|---|
86530b38 AT |
1 | <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> |
2 | <html> | |
3 | <head> | |
4 | <link rel="STYLESHEET" href="lib.css" type='text/css' /> | |
5 | <link rel="SHORTCUT ICON" href="../icons/pyfav.png" type="image/png" /> | |
6 | <link rel='start' href='../index.html' title='Python Documentation Index' /> | |
7 | <link rel="first" href="lib.html" title='Python Library Reference' /> | |
8 | <link rel='contents' href='contents.html' title="Contents" /> | |
9 | <link rel='index' href='genindex.html' title='Index' /> | |
10 | <link rel='last' href='about.html' title='About this document...' /> | |
11 | <link rel='help' href='about.html' title='About this document...' /> | |
12 | <link rel="next" href="incremental-parser-objects.html" /> | |
13 | <link rel="prev" href="module-xml.sax.xmlreader.html" /> | |
14 | <link rel="parent" href="module-xml.sax.xmlreader.html" /> | |
15 | <link rel="next" href="incremental-parser-objects.html" /> | |
16 | <meta name='aesop' content='information' /> | |
17 | <title>13.12.1 XMLReader Objects </title> | |
18 | </head> | |
19 | <body> | |
20 | <DIV CLASS="navigation"> | |
21 | <div id='top-navigation-panel' xml:id='top-navigation-panel'> | |
22 | <table align="center" width="100%" cellpadding="0" cellspacing="2"> | |
23 | <tr> | |
24 | <td class='online-navigation'><a rel="prev" title="13.12 xml.sax.xmlreader " | |
25 | href="module-xml.sax.xmlreader.html"><img src='../icons/previous.png' | |
26 | border='0' height='32' alt='Previous Page' width='32' /></A></td> | |
27 | <td class='online-navigation'><a rel="parent" title="13.12 xml.sax.xmlreader " | |
28 | href="module-xml.sax.xmlreader.html"><img src='../icons/up.png' | |
29 | border='0' height='32' alt='Up One Level' width='32' /></A></td> | |
30 | <td class='online-navigation'><a rel="next" title="13.12.2 IncrementalParser Objects" | |
31 | href="incremental-parser-objects.html"><img src='../icons/next.png' | |
32 | border='0' height='32' alt='Next Page' width='32' /></A></td> | |
33 | <td align="center" width="100%">Python Library Reference</td> | |
34 | <td class='online-navigation'><a rel="contents" title="Table of Contents" | |
35 | href="contents.html"><img src='../icons/contents.png' | |
36 | border='0' height='32' alt='Contents' width='32' /></A></td> | |
37 | <td class='online-navigation'><a href="modindex.html" title="Module Index"><img src='../icons/modules.png' | |
38 | border='0' height='32' alt='Module Index' width='32' /></a></td> | |
39 | <td class='online-navigation'><a rel="index" title="Index" | |
40 | href="genindex.html"><img src='../icons/index.png' | |
41 | border='0' height='32' alt='Index' width='32' /></A></td> | |
42 | </tr></table> | |
43 | <div class='online-navigation'> | |
44 | <b class="navlabel">Previous:</b> | |
45 | <a class="sectref" rel="prev" href="module-xml.sax.xmlreader.html">13.12 xml.sax.xmlreader </A> | |
46 | <b class="navlabel">Up:</b> | |
47 | <a class="sectref" rel="parent" href="module-xml.sax.xmlreader.html">13.12 xml.sax.xmlreader </A> | |
48 | <b class="navlabel">Next:</b> | |
49 | <a class="sectref" rel="next" href="incremental-parser-objects.html">13.12.2 IncrementalParser Objects</A> | |
50 | </div> | |
51 | <hr /></div> | |
52 | </DIV> | |
53 | <!--End of Navigation Panel--> | |
54 | ||
55 | <H2><A NAME="SECTION00151210000000000000000"></A><A NAME="xmlreader-objects"></A> | |
56 | <BR> | |
57 | 13.12.1 XMLReader Objects | |
58 | </H2> | |
59 | ||
60 | <P> | |
61 | The <tt class="class">XMLReader</tt> interface supports the following methods: | |
62 | ||
63 | <P> | |
64 | <dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline"> | |
65 | <td><nobr><b><tt id='l2h-4522' xml:id='l2h-4522' class="method">parse</tt></b>(</nobr></td> | |
66 | <td><var>source</var>)</td></tr></table></dt> | |
67 | <dd> | |
68 | Process an input source, producing SAX events. The <var>source</var> | |
69 | object can be a system identifier (a string identifying the | |
70 | input source - typically a file name or an URL), a file-like | |
71 | object, or an <tt class="class">InputSource</tt> object. When <tt class="method">parse()</tt> | |
72 | returns, the input is completely processed, and the parser object | |
73 | can be discarded or reset. As a limitation, the current implementation | |
74 | only accepts byte streams; processing of character streams is for | |
75 | further study. | |
76 | </dl> | |
77 | ||
78 | <P> | |
79 | <dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline"> | |
80 | <td><nobr><b><tt id='l2h-4523' xml:id='l2h-4523' class="method">getContentHandler</tt></b>(</nobr></td> | |
81 | <td><var></var>)</td></tr></table></dt> | |
82 | <dd> | |
83 | Return the current <tt class="class">ContentHandler</tt>. | |
84 | </dl> | |
85 | ||
86 | <P> | |
87 | <dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline"> | |
88 | <td><nobr><b><tt id='l2h-4524' xml:id='l2h-4524' class="method">setContentHandler</tt></b>(</nobr></td> | |
89 | <td><var>handler</var>)</td></tr></table></dt> | |
90 | <dd> | |
91 | Set the current <tt class="class">ContentHandler</tt>. If no | |
92 | <tt class="class">ContentHandler</tt> is set, content events will be discarded. | |
93 | </dl> | |
94 | ||
95 | <P> | |
96 | <dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline"> | |
97 | <td><nobr><b><tt id='l2h-4525' xml:id='l2h-4525' class="method">getDTDHandler</tt></b>(</nobr></td> | |
98 | <td><var></var>)</td></tr></table></dt> | |
99 | <dd> | |
100 | Return the current <tt class="class">DTDHandler</tt>. | |
101 | </dl> | |
102 | ||
103 | <P> | |
104 | <dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline"> | |
105 | <td><nobr><b><tt id='l2h-4526' xml:id='l2h-4526' class="method">setDTDHandler</tt></b>(</nobr></td> | |
106 | <td><var>handler</var>)</td></tr></table></dt> | |
107 | <dd> | |
108 | Set the current <tt class="class">DTDHandler</tt>. If no <tt class="class">DTDHandler</tt> is | |
109 | set, DTD events will be discarded. | |
110 | </dl> | |
111 | ||
112 | <P> | |
113 | <dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline"> | |
114 | <td><nobr><b><tt id='l2h-4527' xml:id='l2h-4527' class="method">getEntityResolver</tt></b>(</nobr></td> | |
115 | <td><var></var>)</td></tr></table></dt> | |
116 | <dd> | |
117 | Return the current <tt class="class">EntityResolver</tt>. | |
118 | </dl> | |
119 | ||
120 | <P> | |
121 | <dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline"> | |
122 | <td><nobr><b><tt id='l2h-4528' xml:id='l2h-4528' class="method">setEntityResolver</tt></b>(</nobr></td> | |
123 | <td><var>handler</var>)</td></tr></table></dt> | |
124 | <dd> | |
125 | Set the current <tt class="class">EntityResolver</tt>. If no | |
126 | <tt class="class">EntityResolver</tt> is set, attempts to resolve an external | |
127 | entity will result in opening the system identifier for the entity, | |
128 | and fail if it is not available. | |
129 | </dl> | |
130 | ||
131 | <P> | |
132 | <dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline"> | |
133 | <td><nobr><b><tt id='l2h-4529' xml:id='l2h-4529' class="method">getErrorHandler</tt></b>(</nobr></td> | |
134 | <td><var></var>)</td></tr></table></dt> | |
135 | <dd> | |
136 | Return the current <tt class="class">ErrorHandler</tt>. | |
137 | </dl> | |
138 | ||
139 | <P> | |
140 | <dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline"> | |
141 | <td><nobr><b><tt id='l2h-4530' xml:id='l2h-4530' class="method">setErrorHandler</tt></b>(</nobr></td> | |
142 | <td><var>handler</var>)</td></tr></table></dt> | |
143 | <dd> | |
144 | Set the current error handler. If no <tt class="class">ErrorHandler</tt> is set, | |
145 | errors will be raised as exceptions, and warnings will be printed. | |
146 | </dl> | |
147 | ||
148 | <P> | |
149 | <dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline"> | |
150 | <td><nobr><b><tt id='l2h-4531' xml:id='l2h-4531' class="method">setLocale</tt></b>(</nobr></td> | |
151 | <td><var>locale</var>)</td></tr></table></dt> | |
152 | <dd> | |
153 | Allow an application to set the locale for errors and warnings. | |
154 | ||
155 | <P> | |
156 | SAX parsers are not required to provide localization for errors and | |
157 | warnings; if they cannot support the requested locale, however, they | |
158 | must throw a SAX exception. Applications may request a locale change | |
159 | in the middle of a parse. | |
160 | </dl> | |
161 | ||
162 | <P> | |
163 | <dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline"> | |
164 | <td><nobr><b><tt id='l2h-4532' xml:id='l2h-4532' class="method">getFeature</tt></b>(</nobr></td> | |
165 | <td><var>featurename</var>)</td></tr></table></dt> | |
166 | <dd> | |
167 | Return the current setting for feature <var>featurename</var>. If the | |
168 | feature is not recognized, <tt class="exception">SAXNotRecognizedException</tt> is | |
169 | raised. The well-known featurenames are listed in the module | |
170 | <tt class="module">xml.sax.handler</tt>. | |
171 | </dl> | |
172 | ||
173 | <P> | |
174 | <dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline"> | |
175 | <td><nobr><b><tt id='l2h-4533' xml:id='l2h-4533' class="method">setFeature</tt></b>(</nobr></td> | |
176 | <td><var>featurename, value</var>)</td></tr></table></dt> | |
177 | <dd> | |
178 | Set the <var>featurename</var> to <var>value</var>. If the feature is not | |
179 | recognized, <tt class="exception">SAXNotRecognizedException</tt> is raised. If the | |
180 | feature or its setting is not supported by the parser, | |
181 | <var>SAXNotSupportedException</var> is raised. | |
182 | </dl> | |
183 | ||
184 | <P> | |
185 | <dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline"> | |
186 | <td><nobr><b><tt id='l2h-4534' xml:id='l2h-4534' class="method">getProperty</tt></b>(</nobr></td> | |
187 | <td><var>propertyname</var>)</td></tr></table></dt> | |
188 | <dd> | |
189 | Return the current setting for property <var>propertyname</var>. If the | |
190 | property is not recognized, a <tt class="exception">SAXNotRecognizedException</tt> | |
191 | is raised. The well-known propertynames are listed in the module | |
192 | <tt class="module">xml.sax.handler</tt>. | |
193 | </dl> | |
194 | ||
195 | <P> | |
196 | <dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline"> | |
197 | <td><nobr><b><tt id='l2h-4535' xml:id='l2h-4535' class="method">setProperty</tt></b>(</nobr></td> | |
198 | <td><var>propertyname, value</var>)</td></tr></table></dt> | |
199 | <dd> | |
200 | Set the <var>propertyname</var> to <var>value</var>. If the property is not | |
201 | recognized, <tt class="exception">SAXNotRecognizedException</tt> is raised. If the | |
202 | property or its setting is not supported by the parser, | |
203 | <var>SAXNotSupportedException</var> is raised. | |
204 | </dl> | |
205 | ||
206 | <P> | |
207 | ||
208 | <DIV CLASS="navigation"> | |
209 | <div class='online-navigation'> | |
210 | <p></p><hr /> | |
211 | <table align="center" width="100%" cellpadding="0" cellspacing="2"> | |
212 | <tr> | |
213 | <td class='online-navigation'><a rel="prev" title="13.12 xml.sax.xmlreader " | |
214 | href="module-xml.sax.xmlreader.html"><img src='../icons/previous.png' | |
215 | border='0' height='32' alt='Previous Page' width='32' /></A></td> | |
216 | <td class='online-navigation'><a rel="parent" title="13.12 xml.sax.xmlreader " | |
217 | href="module-xml.sax.xmlreader.html"><img src='../icons/up.png' | |
218 | border='0' height='32' alt='Up One Level' width='32' /></A></td> | |
219 | <td class='online-navigation'><a rel="next" title="13.12.2 IncrementalParser Objects" | |
220 | href="incremental-parser-objects.html"><img src='../icons/next.png' | |
221 | border='0' height='32' alt='Next Page' width='32' /></A></td> | |
222 | <td align="center" width="100%">Python Library Reference</td> | |
223 | <td class='online-navigation'><a rel="contents" title="Table of Contents" | |
224 | href="contents.html"><img src='../icons/contents.png' | |
225 | border='0' height='32' alt='Contents' width='32' /></A></td> | |
226 | <td class='online-navigation'><a href="modindex.html" title="Module Index"><img src='../icons/modules.png' | |
227 | border='0' height='32' alt='Module Index' width='32' /></a></td> | |
228 | <td class='online-navigation'><a rel="index" title="Index" | |
229 | href="genindex.html"><img src='../icons/index.png' | |
230 | border='0' height='32' alt='Index' width='32' /></A></td> | |
231 | </tr></table> | |
232 | <div class='online-navigation'> | |
233 | <b class="navlabel">Previous:</b> | |
234 | <a class="sectref" rel="prev" href="module-xml.sax.xmlreader.html">13.12 xml.sax.xmlreader </A> | |
235 | <b class="navlabel">Up:</b> | |
236 | <a class="sectref" rel="parent" href="module-xml.sax.xmlreader.html">13.12 xml.sax.xmlreader </A> | |
237 | <b class="navlabel">Next:</b> | |
238 | <a class="sectref" rel="next" href="incremental-parser-objects.html">13.12.2 IncrementalParser Objects</A> | |
239 | </div> | |
240 | </div> | |
241 | <hr /> | |
242 | <span class="release-info">Release 2.4.2, documentation updated on 28 September 2005.</span> | |
243 | </DIV> | |
244 | <!--End of Navigation Panel--> | |
245 | <ADDRESS> | |
246 | See <i><a href="about.html">About this document...</a></i> for information on suggesting changes. | |
247 | </ADDRESS> | |
248 | </BODY> | |
249 | </HTML> |