83 |
83 |
84 |
84 |
85 <h2><a name="building"></a>Building</h2> |
85 <h2><a name="building"></a>Building</h2> |
86 |
86 |
87 <p> |
87 <p> |
88 LuaExpat could be built to Lua 5.0 or to Lua 5.1. |
88 LuaExpat could be built to Lua 5.1 or to Lua 5.2. |
89 In both cases, |
89 In both cases, |
90 the language library and headers files for the desired version |
90 the language library and headers files for the desired version |
91 must be installed properly. |
91 must be installed properly. |
92 LuaExpat also depends on Expat 2.0.0 which should also be installed. |
92 LuaExpat also depends on Expat 2.0.0+ which should also be installed. |
93 </p> |
93 </p> |
94 <p> |
94 <p> |
95 LuaExpat offers a Makefile and a separate configuration file, |
95 LuaExpat offers a Makefile and a separate configuration file, |
96 <code>config</code>, |
96 <code>config</code>, |
97 which should be edited to suit the particularities of the target platform |
97 which should be edited to suit the particularities of the target platform |
129 assume no behaviour for any undeclared callbacks.</p> |
129 assume no behaviour for any undeclared callbacks.</p> |
130 |
130 |
131 <h4>Constructor</h4> |
131 <h4>Constructor</h4> |
132 |
132 |
133 <dl class="reference"> |
133 <dl class="reference"> |
134 <dt><strong>lxp.new(<em>callbacks [, separator]</em>)</strong></dt> |
134 <dt><strong>lxp.new(<em>callbacks [, separator[, merge_character_data]]</em>)</strong></dt> |
135 <dd>The parser is created by a call to the function <strong>lxp.new</strong>, |
135 <dd>The parser is created by a call to the function <strong>lxp.new</strong>, |
136 which returns the created parser or raises a Lua error. It |
136 which returns the created parser or raises a Lua error. It |
137 receives the callbacks table and optionally the parser <a href="#separator"> |
137 receives the callbacks table and optionally the parser <a href="#separator"> |
138 separator character</a> used in the namespace expanded element names.</dd> |
138 separator character</a> used in the namespace expanded element names. |
|
139 If <em>merge_character_data</em> is false then LuaExpat will not combine multiple |
|
140 CharacterData calls into one. For more info on this behaviour see CharacterData below.</dd> |
139 </dl> |
141 </dl> |
140 |
142 |
141 <h4>Methods</h4> |
143 <h4>Methods</h4> |
142 |
144 |
143 <dl class="reference"> |
145 <dl class="reference"> |
165 |
167 |
166 <dt><strong>parser:pos()</strong></dt> |
168 <dt><strong>parser:pos()</strong></dt> |
167 <dd>Returns three results: the current parsing line, column, and |
169 <dd>Returns three results: the current parsing line, column, and |
168 absolute position.</dd> |
170 absolute position.</dd> |
169 |
171 |
|
172 <dt><strong>parser:getcurrentbytecount()</strong></dt> |
|
173 <dd>Return the number of bytes of input corresponding to the current |
|
174 event. This function can only be called inside a handler, in other |
|
175 contexts it will return 0. Do not use inside a CharacterData handler |
|
176 unless CharacterData merging has been disabled (see lxp.new).</dd> |
|
177 |
170 <dt><strong>parser:setbase(base)</strong></dt> |
178 <dt><strong>parser:setbase(base)</strong></dt> |
171 <dd>Sets the <em>base</em> to be used for resolving relative URIs in |
179 <dd>Sets the <em>base</em> to be used for resolving relative URIs in |
172 system identifiers.</dd> |
180 system identifiers.</dd> |
173 |
181 |
174 <dt><strong>parser:setencoding(encoding)</strong></dt> |
182 <dt><strong>parser:setencoding(encoding)</strong></dt> |
203 <em>Default</em>, <em>DefaultExpand</em>, <em>EndCDataSection</em>, |
211 <em>Default</em>, <em>DefaultExpand</em>, <em>EndCDataSection</em>, |
204 <em>EndElement</em>, <em>EndNamespaceDecl</em>, |
212 <em>EndElement</em>, <em>EndNamespaceDecl</em>, |
205 <em>ExternalEntityRef</em>, <em>NotStandalone</em>, |
213 <em>ExternalEntityRef</em>, <em>NotStandalone</em>, |
206 <em>NotationDecl</em>, <em>ProcessingInstruction</em>, |
214 <em>NotationDecl</em>, <em>ProcessingInstruction</em>, |
207 <em>StartCDataSection</em>, <em>StartElement</em>, |
215 <em>StartCDataSection</em>, <em>StartElement</em>, |
208 <em>StartNamespaceDecl</em>, <em>UnparsedEntityDecl</em> |
216 <em>StartNamespaceDecl</em>, <em>UnparsedEntityDecl</em>, |
209 and <em>StartDoctypeDecl</em>.</p> |
217 <em>XmlDecl</em> and <em>StartDoctypeDecl</em>.</p> |
210 |
218 |
211 <p>These indices can be references to functions with |
219 <p>These indices can be references to functions with |
212 specific signatures, as seen below. The parser constructor also |
220 specific signatures, as seen below. The parser constructor also |
213 checks the presence of a field called <em>_nonstrict</em> in the |
221 checks the presence of a field called <em>_nonstrict</em> in the |
214 callbacks table. If <em>_nonstrict</em> is absent, only valid |
222 callbacks table. If <em>_nonstrict</em> is absent, only valid |
224 calling parser itself, thus allowing the same functions to be used |
232 calling parser itself, thus allowing the same functions to be used |
225 for more than one parser for example.</p> |
233 for more than one parser for example.</p> |
226 |
234 |
227 <dl class="reference"> |
235 <dl class="reference"> |
228 <dt><strong>callbacks.CharacterData = function(parser, string)</strong></dt> |
236 <dt><strong>callbacks.CharacterData = function(parser, string)</strong></dt> |
229 <dd>Called when the <em>parser</em> recognizes an XML CDATA <em>string</em>.</dd> |
237 <dd>Called when the <em>parser</em> recognizes an XML CDATA <em>string</em>. |
|
238 Note that LuaExpat automatically combines multiple CharacterData events |
|
239 from Expat into a single call to this handler, unless <em>merge_character_data</em> |
|
240 is set to false when calling lxp.new().</dd> |
230 |
241 |
231 <dt><strong>callbacks.Comment = function(parser, string)</strong></dt> |
242 <dt><strong>callbacks.Comment = function(parser, string)</strong></dt> |
232 <dd>Called when the <em>parser</em> recognizes an XML comment |
243 <dd>Called when the <em>parser</em> recognizes an XML comment |
233 <em>string</em>.</dd> |
244 <em>string</em>.</dd> |
234 |
245 |
297 word.</dd> |
308 word.</dd> |
298 |
309 |
299 <dt><strong>callbacks.StartCdataSection = function(parser)</strong></dt> |
310 <dt><strong>callbacks.StartCdataSection = function(parser)</strong></dt> |
300 <dd>Called when the <em>parser</em> detects the begining of an XML |
311 <dd>Called when the <em>parser</em> detects the begining of an XML |
301 CDATA section.</dd> |
312 CDATA section.</dd> |
|
313 |
|
314 <dt><strong>callbacks.XmlDecl = function(parser, version, encoding)</strong></dt> |
|
315 <dd>Called when the <em>parser</em> encounters an XML document declaration (these are |
|
316 optional, and valid only at the start of the document). The callback receives |
|
317 the declared XML <em>version</em> and document <em>encoding</em>.</dd> |
302 |
318 |
303 <dt><strong>callbacks.StartElement = function(parser, elementName, attributes)</strong></dt> |
319 <dt><strong>callbacks.StartElement = function(parser, elementName, attributes)</strong></dt> |
304 <dd>Called when the <em>parser</em> detects the begining of an XML |
320 <dd>Called when the <em>parser</em> detects the begining of an XML |
305 element with <em>elementName</em>.<br/> |
321 element with <em>elementName</em>.<br/> |
306 The <em>attributes</em> parameter is a Lua table with all the |
322 The <em>attributes</em> parameter is a Lua table with all the |
369 </div> <!-- id="main" --> |
385 </div> <!-- id="main" --> |
370 |
386 |
371 <div id="about"> |
387 <div id="about"> |
372 <p><a href="http://validator.w3.org/check?uri=referer"> |
388 <p><a href="http://validator.w3.org/check?uri=referer"> |
373 <img src="http://www.w3.org/Icons/valid-xhtml10" alt="Valid XHTML 1.0!" height="31" width="88" /></a></p> |
389 <img src="http://www.w3.org/Icons/valid-xhtml10" alt="Valid XHTML 1.0!" height="31" width="88" /></a></p> |
374 <p><small>$Id: manual.html,v 1.27 2007/06/05 20:03:12 carregal Exp $</small></p> |
|
375 </div> <!-- id="about" --> |
390 </div> <!-- id="about" --> |
376 |
391 |
377 </div> <!-- id="container" --> |
392 </div> <!-- id="container" --> |
378 |
393 |
379 </body> |
394 </body> |