173 |
173 |
174 <dt><strong>parser:setencoding(encoding)</strong></dt> |
174 <dt><strong>parser:setencoding(encoding)</strong></dt> |
175 <dd>Set the encoding to be used by the parser. There are four |
175 <dd>Set the encoding to be used by the parser. There are four |
176 built-in encodings, passed as strings: "US-ASCII", |
176 built-in encodings, passed as strings: "US-ASCII", |
177 "UTF-8", "UTF-16", and "ISO-8859-1".</dd> |
177 "UTF-8", "UTF-16", and "ISO-8859-1".</dd> |
|
178 |
|
179 <dt><strong>parser:stop()</strong></dt> |
|
180 <dd>Abort the parser and prevent it from parsing any further |
|
181 through the data it was last passed. Use to halt parsing the |
|
182 document when an error is discovered inside a callback, for |
|
183 example. The parser object cannot accept more data after |
|
184 this call.</dd> |
178 </dl> |
185 </dl> |
179 |
186 |
180 <h4>Callbacks</h4> |
187 <h4>Callbacks</h4> |
181 |
188 |
182 <p>The Lua callbacks define the handlers of the parser events. The |
189 <p>The Lua callbacks define the handlers of the parser events. The |
196 <em>Default</em>, <em>DefaultExpand</em>, <em>EndCDataSection</em>, |
203 <em>Default</em>, <em>DefaultExpand</em>, <em>EndCDataSection</em>, |
197 <em>EndElement</em>, <em>EndNamespaceDecl</em>, |
204 <em>EndElement</em>, <em>EndNamespaceDecl</em>, |
198 <em>ExternalEntityRef</em>, <em>NotStandalone</em>, |
205 <em>ExternalEntityRef</em>, <em>NotStandalone</em>, |
199 <em>NotationDecl</em>, <em>ProcessingInstruction</em>, |
206 <em>NotationDecl</em>, <em>ProcessingInstruction</em>, |
200 <em>StartCDataSection</em>, <em>StartElement</em>, |
207 <em>StartCDataSection</em>, <em>StartElement</em>, |
201 <em>StartNamespaceDecl</em>, and <em>UnparsedEntityDecl</em>.</p> |
208 <em>StartNamespaceDecl</em>, <em>UnparsedEntityDecl</em> |
|
209 and <em>StartDoctypeDecl</em>.</p> |
202 |
210 |
203 <p>These indices can be references to functions with |
211 <p>These indices can be references to functions with |
204 specific signatures, as seen below. The parser constructor also |
212 specific signatures, as seen below. The parser constructor also |
205 checks the presence of a field called <em>_nonstrict</em> in the |
213 checks the presence of a field called <em>_nonstrict</em> in the |
206 callbacks table. If <em>_nonstrict</em> is absent, only valid |
214 callbacks table. If <em>_nonstrict</em> is absent, only valid |
335 <em>entityName</em> would be "logo", <em>systemId</em> would be |
343 <em>entityName</em> would be "logo", <em>systemId</em> would be |
336 "images/logo.gif" and <em>notationName</em> would be "gif". |
344 "images/logo.gif" and <em>notationName</em> would be "gif". |
337 For this example the <em>publicId</em> parameter would be nil. |
345 For this example the <em>publicId</em> parameter would be nil. |
338 The <em>base</em> parameter would be whatever has been set with |
346 The <em>base</em> parameter would be whatever has been set with |
339 <code>parser:setbase</code>. If not set, it would be nil.</dd> |
347 <code>parser:setbase</code>. If not set, it would be nil.</dd> |
|
348 |
|
349 <dt><strong>callbacks.StartDoctypeDecl = function(parser, name, sysid, pubid, has_internal_subset)</strong></dt> |
|
350 <dd>Called when the <em>parser</em> detects the beginning of an XML |
|
351 DTD (DOCTYPE) section. These precede the XML root element and take |
|
352 the form: |
|
353 <pre class="example"> |
|
354 <!DOCTYPE root_elem PUBLIC "example"> |
|
355 </pre> |
|
356 </dd> |
340 </dl> |
357 </dl> |
341 |
358 |
342 <h4><a name="separator"></a>The separator character</h4> |
359 <h4><a name="separator"></a>The separator character</h4> |
343 |
360 |
344 <p>The optional separator character in the parser constructor |
361 <p>The optional separator character in the parser constructor |