1 | /*
|
---|
2 | Copyright (c) 1998, 1999, 2000 Thai Open Source Software Center Ltd
|
---|
3 | See the file COPYING for copying permission.
|
---|
4 | */
|
---|
5 |
|
---|
6 | #ifndef XmlParse_INCLUDED
|
---|
7 | #define XmlParse_INCLUDED 1
|
---|
8 |
|
---|
9 | #include <stdlib.h>
|
---|
10 |
|
---|
11 | #include "expat\expat_setup.h"
|
---|
12 | // V0.9.9 (2001-02-10) [umoeller]
|
---|
13 | // to save the app from having to include this as well
|
---|
14 |
|
---|
15 | #ifndef XMLPARSEAPI
|
---|
16 | # ifdef __declspec
|
---|
17 | # define XMLPARSEAPI __declspec(dllimport)
|
---|
18 | # else
|
---|
19 | # define XMLPARSEAPI /* nothing */
|
---|
20 | # endif
|
---|
21 | #endif /* not defined XMLPARSEAPI */
|
---|
22 |
|
---|
23 | #ifdef __cplusplus
|
---|
24 | extern "C" {
|
---|
25 | #endif
|
---|
26 |
|
---|
27 | typedef void *XML_Parser;
|
---|
28 |
|
---|
29 | /* Information is UTF-8 encoded. */
|
---|
30 | typedef char XML_Char;
|
---|
31 | typedef char XML_LChar;
|
---|
32 |
|
---|
33 | enum XML_Content_Type
|
---|
34 | {
|
---|
35 | XML_CTYPE_EMPTY = 1,
|
---|
36 | XML_CTYPE_ANY,
|
---|
37 | XML_CTYPE_MIXED,
|
---|
38 | XML_CTYPE_NAME,
|
---|
39 | XML_CTYPE_CHOICE,
|
---|
40 | XML_CTYPE_SEQ
|
---|
41 | };
|
---|
42 |
|
---|
43 | enum XML_Content_Quant
|
---|
44 | {
|
---|
45 | XML_CQUANT_NONE,
|
---|
46 | XML_CQUANT_OPT,
|
---|
47 | XML_CQUANT_REP,
|
---|
48 | XML_CQUANT_PLUS
|
---|
49 | };
|
---|
50 |
|
---|
51 | /*
|
---|
52 | *@@ XMLCONTENT:
|
---|
53 | * structure passed with the @expat "element declaration handler"
|
---|
54 | * (see XML_SetElementDeclHandler).
|
---|
55 | *
|
---|
56 | * The model argument is the root of a tree of XMLCONTENT
|
---|
57 | * nodes. If type equals XML_CTYPE_EMPTY or XML_CTYPE_ANY,
|
---|
58 | * then quant will be XML_CQUANT_NONE, and the other fields
|
---|
59 | * will be zero or NULL.
|
---|
60 | *
|
---|
61 | * If type is XML_CTYPE_MIXED:
|
---|
62 | *
|
---|
63 | * -- "quant" will be XML_CQUANT_NONE or XML_CQUANT_REP.
|
---|
64 | *
|
---|
65 | * -- "numchildren" will contain the number of elements that
|
---|
66 | * are allowed to be mixed in.
|
---|
67 | *
|
---|
68 | * -- "children" points to a sub-array of XMLCONTENT structures
|
---|
69 | * that will all have type XML_CTYPE_NAME with no quantification.
|
---|
70 | *
|
---|
71 | * Only the root node can be type XML_CTYPE_EMPTY, XML_CTYPE_ANY,
|
---|
72 | * or XML_CTYPE_MIXED.
|
---|
73 | *
|
---|
74 | * For type XML_CTYPE_NAME, the name field points to the
|
---|
75 | * name and the numchildren and children fields will be
|
---|
76 | * zero and NULL. The quant field will indicate any
|
---|
77 | * quantifiers placed on the name.
|
---|
78 | *
|
---|
79 | * Types XML_CTYPE_CHOICE and XML_CTYPE_SEQ indicate a
|
---|
80 | * choice or sequence respectively. The numchildren field
|
---|
81 | * indicates how many nodes in the choice or sequence and
|
---|
82 | * children points to the nodes.
|
---|
83 | *
|
---|
84 | *@@added V0.9.9 (2001-02-14) [umoeller]
|
---|
85 | */
|
---|
86 |
|
---|
87 | typedef struct _XMLCONTENT
|
---|
88 | {
|
---|
89 | enum XML_Content_Type type;
|
---|
90 | // one of:
|
---|
91 | // -- XML_CTYPE_EMPTY --> quant will be XML_CQUANT_NONE, rest is NULL
|
---|
92 | // -- XML_CTYPE_ANY, --> quant will be XML_CQUANT_NONE, rest is NULL
|
---|
93 | // -- XML_CTYPE_MIXED, --> (#PCDATA) gives us this
|
---|
94 | // -- XML_CTYPE_CHOICE, --> choice ("|" list)
|
---|
95 | // -- XML_CTYPE_SEQ --> sequence (comma list)
|
---|
96 |
|
---|
97 | // -- XML_CTYPE_NAME: used for sub-content if content has CML_CTYPE_MIXED;
|
---|
98 | // only "name" is valid for sub-content
|
---|
99 |
|
---|
100 | enum XML_Content_Quant quant;
|
---|
101 | // one of:
|
---|
102 | // -- XML_CQUANT_NONE --> all fields below are NULL
|
---|
103 | // -- XML_CQUANT_OPT, question mark
|
---|
104 | // -- XML_CQUANT_REP, asterisk
|
---|
105 | // -- XML_CQUANT_PLUS plus sign
|
---|
106 |
|
---|
107 | const XML_Char *name;
|
---|
108 |
|
---|
109 | unsigned int numchildren;
|
---|
110 |
|
---|
111 | struct _XMLCONTENT *children;
|
---|
112 |
|
---|
113 | } XMLCONTENT, *PXMLCONTENT;
|
---|
114 |
|
---|
115 |
|
---|
116 | /* This is called for an element declaration. See above for
|
---|
117 | description of the model argument. It's the caller's responsibility
|
---|
118 | to free model when finished with it.
|
---|
119 | */
|
---|
120 |
|
---|
121 | typedef void (* EXPATENTRY XML_ElementDeclHandler) (void *userData,
|
---|
122 | const XML_Char *name,
|
---|
123 | XMLCONTENT *model);
|
---|
124 |
|
---|
125 | void XMLPARSEAPI XML_SetElementDeclHandler(XML_Parser parser,
|
---|
126 | XML_ElementDeclHandler eldecl);
|
---|
127 |
|
---|
128 | /*
|
---|
129 | The Attlist declaration handler is called for *each* attribute. So
|
---|
130 | a single Attlist declaration with multiple attributes declared will
|
---|
131 | generate multiple calls to this handler. The "default" parameter
|
---|
132 | may be NULL in the case of the "#IMPLIED" or "#REQUIRED" keyword.
|
---|
133 | The "isrequired" parameter will be true and the default value will
|
---|
134 | be NULL in the case of "#REQUIRED". If "isrequired" is true and
|
---|
135 | default is non-NULL, then this is a "#FIXED" default.
|
---|
136 | */
|
---|
137 |
|
---|
138 | typedef void (* EXPATENTRY XML_AttlistDeclHandler) (void *userData,
|
---|
139 | const XML_Char *elname,
|
---|
140 | const XML_Char *attname,
|
---|
141 | const XML_Char *att_type,
|
---|
142 | const XML_Char *dflt,
|
---|
143 | int isrequired);
|
---|
144 |
|
---|
145 | void XMLPARSEAPI XML_SetAttlistDeclHandler(XML_Parser parser,
|
---|
146 | XML_AttlistDeclHandler attdecl);
|
---|
147 |
|
---|
148 |
|
---|
149 | /* The XML declaration handler is called for *both* XML declarations and
|
---|
150 | text declarations. The way to distinguish is that the version parameter
|
---|
151 | will be null for text declarations. The encoding parameter may be null
|
---|
152 | for XML declarations. The standalone parameter will be -1, 0, or 1
|
---|
153 | indicating respectively that there was no standalone parameter in
|
---|
154 | the declaration, that it was given as no, or that it was given as yes.
|
---|
155 | */
|
---|
156 |
|
---|
157 | typedef void (* EXPATENTRY XML_XmlDeclHandler) (void *userData,
|
---|
158 | const XML_Char *version,
|
---|
159 | const XML_Char *encoding,
|
---|
160 | int standalone);
|
---|
161 |
|
---|
162 | void XMLPARSEAPI XML_SetXmlDeclHandler(XML_Parser parser,
|
---|
163 | XML_XmlDeclHandler xmldecl);
|
---|
164 |
|
---|
165 |
|
---|
166 | typedef struct {
|
---|
167 | void *(*malloc_fcn)(size_t size);
|
---|
168 | void *(*realloc_fcn)(void *ptr, size_t size);
|
---|
169 | void (*free_fcn)(void *ptr);
|
---|
170 | } XML_Memory_Handling_Suite;
|
---|
171 |
|
---|
172 | /* Constructs a new parser; encoding is the encoding specified by the external
|
---|
173 | protocol or null if there is none specified. */
|
---|
174 |
|
---|
175 | XML_Parser XMLPARSEAPI XML_ParserCreate(const XML_Char *encoding);
|
---|
176 |
|
---|
177 | /* Constructs a new parser and namespace processor. Element type names
|
---|
178 | and attribute names that belong to a namespace will be expanded;
|
---|
179 | unprefixed attribute names are never expanded; unprefixed element type
|
---|
180 | names are expanded only if there is a default namespace. The expanded
|
---|
181 | name is the concatenation of the namespace URI, the namespace separator character,
|
---|
182 | and the local part of the name. If the namespace separator is '\0' then
|
---|
183 | the namespace URI and the local part will be concatenated without any
|
---|
184 | separator. When a namespace is not declared, the name and prefix will be
|
---|
185 | passed through without expansion. */
|
---|
186 |
|
---|
187 | XML_Parser XMLPARSEAPI XML_ParserCreateNS(const XML_Char *encoding, XML_Char namespaceSeparator);
|
---|
188 |
|
---|
189 |
|
---|
190 | /* Constructs a new parser using the memory management suit referred to
|
---|
191 | by memsuite. If memsuite is NULL, then use the standard library memory
|
---|
192 | suite. If namespaceSeparator is non-NULL it creates a parser with
|
---|
193 | namespace processing as described above. The character pointed at
|
---|
194 | will serve as the namespace separator.
|
---|
195 |
|
---|
196 | All further memory operations used for the created parser will come from
|
---|
197 | the given suite.
|
---|
198 | */
|
---|
199 |
|
---|
200 | XML_Parser XMLPARSEAPI XML_ParserCreate_MM(const XML_Char *encoding,
|
---|
201 | const XML_Memory_Handling_Suite *memsuite,
|
---|
202 | const XML_Char *namespaceSeparator);
|
---|
203 |
|
---|
204 | /* atts is array of name/value pairs, terminated by 0;
|
---|
205 | names and values are 0 terminated. */
|
---|
206 |
|
---|
207 | typedef void (* EXPATENTRY XML_StartElementHandler)(void *userData,
|
---|
208 | const XML_Char *name,
|
---|
209 | const XML_Char **atts);
|
---|
210 |
|
---|
211 | typedef void (* EXPATENTRY XML_EndElementHandler)(void *userData,
|
---|
212 | const XML_Char *name);
|
---|
213 |
|
---|
214 |
|
---|
215 | /* s is not 0 terminated. */
|
---|
216 | typedef void (* EXPATENTRY XML_CharacterDataHandler)(void *userData,
|
---|
217 | const XML_Char *s,
|
---|
218 | int len);
|
---|
219 |
|
---|
220 | /* target and data are 0 terminated */
|
---|
221 | typedef void (* EXPATENTRY XML_ProcessingInstructionHandler)(void *userData,
|
---|
222 | const XML_Char *target,
|
---|
223 | const XML_Char *data);
|
---|
224 |
|
---|
225 | /* data is 0 terminated */
|
---|
226 | typedef void (* EXPATENTRY XML_CommentHandler)(void *userData, const XML_Char *data);
|
---|
227 |
|
---|
228 | typedef void (* EXPATENTRY XML_StartCdataSectionHandler)(void *userData);
|
---|
229 | typedef void (* EXPATENTRY XML_EndCdataSectionHandler)(void *userData);
|
---|
230 |
|
---|
231 | /* This is called for any characters in the XML document for
|
---|
232 | which there is no applicable handler. This includes both
|
---|
233 | characters that are part of markup which is of a kind that is
|
---|
234 | not reported (comments, markup declarations), or characters
|
---|
235 | that are part of a construct which could be reported but
|
---|
236 | for which no handler has been supplied. The characters are passed
|
---|
237 | exactly as they were in the XML document except that
|
---|
238 | they will be encoded in UTF-8. Line boundaries are not normalized.
|
---|
239 | Note that a byte order mark character is not passed to the default handler.
|
---|
240 | There are no guarantees about how characters are divided between calls
|
---|
241 | to the default handler: for example, a comment might be split between
|
---|
242 | multiple calls. */
|
---|
243 |
|
---|
244 | typedef void (* EXPATENTRY XML_DefaultHandler)(void *userData,
|
---|
245 | const XML_Char *s,
|
---|
246 | int len);
|
---|
247 |
|
---|
248 | /* This is called for the start of the DOCTYPE declaration, before
|
---|
249 | any DTD or internal subset is parsed. */
|
---|
250 |
|
---|
251 | typedef void (* EXPATENTRY XML_StartDoctypeDeclHandler)(void *userData,
|
---|
252 | const XML_Char *doctypeName,
|
---|
253 | const XML_Char *sysid,
|
---|
254 | const XML_Char *pubid,
|
---|
255 | int has_internal_subset);
|
---|
256 |
|
---|
257 | /* This is called for the start of the DOCTYPE declaration when the
|
---|
258 | closing > is encountered, but after processing any external subset. */
|
---|
259 | typedef void (* EXPATENTRY XML_EndDoctypeDeclHandler)(void *userData);
|
---|
260 |
|
---|
261 | /* This is called for entity declarations. The is_parameter_entity
|
---|
262 | argument will be non-zero if the entity is a parameter entity, zero
|
---|
263 | otherwise.
|
---|
264 |
|
---|
265 | For internal entities (<!ENTITY foo "bar">), value will
|
---|
266 | be non-null and systemId, publicID, and notationName will be null.
|
---|
267 | The value string is NOT null terminated; the length is provided in
|
---|
268 | the value_length argument. Since it is legal to have zero-length
|
---|
269 | values, do not use this argument to test for internal entities.
|
---|
270 |
|
---|
271 | For external entities, value will be null and systemId will be non-null.
|
---|
272 | The publicId argument will be null unless a public identifier was
|
---|
273 | provided. The notationName argument will have a non-null value only
|
---|
274 | for unparsed entity declarations.
|
---|
275 | */
|
---|
276 |
|
---|
277 | typedef void (* EXPATENTRY XML_EntityDeclHandler)(void *userData,
|
---|
278 | const XML_Char *entityName,
|
---|
279 | int is_parameter_entity,
|
---|
280 | const XML_Char *value,
|
---|
281 | int value_length,
|
---|
282 | const XML_Char *base,
|
---|
283 | const XML_Char *systemId,
|
---|
284 | const XML_Char *publicId,
|
---|
285 | const XML_Char *notationName);
|
---|
286 |
|
---|
287 | void XMLPARSEAPI XML_SetEntityDeclHandler(XML_Parser parser,
|
---|
288 | XML_EntityDeclHandler handler);
|
---|
289 |
|
---|
290 | /* OBSOLETE -- OBSOLETE -- OBSOLETE
|
---|
291 | This handler has been superceded by the EntityDeclHandler above.
|
---|
292 | It is provided here for backward compatibility.
|
---|
293 | This is called for a declaration of an unparsed (NDATA)
|
---|
294 | entity. The base argument is whatever was set by XML_SetBase.
|
---|
295 | The entityName, systemId and notationName arguments will never be null.
|
---|
296 | The other arguments may be. */
|
---|
297 |
|
---|
298 | typedef void (* EXPATENTRY XML_UnparsedEntityDeclHandler)(void *userData,
|
---|
299 | const XML_Char *entityName,
|
---|
300 | const XML_Char *base,
|
---|
301 | const XML_Char *systemId,
|
---|
302 | const XML_Char *publicId,
|
---|
303 | const XML_Char *notationName);
|
---|
304 |
|
---|
305 | /* This is called for a declaration of notation.
|
---|
306 | The base argument is whatever was set by XML_SetBase.
|
---|
307 | The notationName will never be null. The other arguments can be. */
|
---|
308 |
|
---|
309 | typedef void (* EXPATENTRY XML_NotationDeclHandler)(void *userData,
|
---|
310 | const XML_Char *notationName,
|
---|
311 | const XML_Char *base,
|
---|
312 | const XML_Char *systemId,
|
---|
313 | const XML_Char *publicId);
|
---|
314 |
|
---|
315 | /* When namespace processing is enabled, these are called once for
|
---|
316 | each namespace declaration. The call to the start and end element
|
---|
317 | handlers occur between the calls to the start and end namespace
|
---|
318 | declaration handlers. For an xmlns attribute, prefix will be null.
|
---|
319 | For an xmlns="" attribute, uri will be null. */
|
---|
320 |
|
---|
321 | typedef void (* EXPATENTRY XML_StartNamespaceDeclHandler)(void *userData,
|
---|
322 | const XML_Char *prefix,
|
---|
323 | const XML_Char *uri);
|
---|
324 |
|
---|
325 | typedef void (* EXPATENTRY XML_EndNamespaceDeclHandler)(void *userData,
|
---|
326 | const XML_Char *prefix);
|
---|
327 |
|
---|
328 | /* This is called if the document is not standalone (it has an
|
---|
329 | external subset or a reference to a parameter entity, but does not
|
---|
330 | have standalone="yes"). If this handler returns 0, then processing
|
---|
331 | will not continue, and the parser will return a
|
---|
332 | ERROR_EXPAT_NOT_STANDALONE error. */
|
---|
333 |
|
---|
334 | typedef int (* EXPATENTRY XML_NotStandaloneHandler)(void *userData);
|
---|
335 |
|
---|
336 | /* This is called for a reference to an external parsed general entity.
|
---|
337 | The referenced entity is not automatically parsed.
|
---|
338 | The application can parse it immediately or later using
|
---|
339 | XML_ExternalEntityParserCreate.
|
---|
340 | The parser argument is the parser parsing the entity containing the reference;
|
---|
341 | it can be passed as the parser argument to XML_ExternalEntityParserCreate.
|
---|
342 | The systemId argument is the system identifier as specified in the entity declaration;
|
---|
343 | it will not be null.
|
---|
344 | The base argument is the system identifier that should be used as the base for
|
---|
345 | resolving systemId if systemId was relative; this is set by XML_SetBase;
|
---|
346 | it may be null.
|
---|
347 | The publicId argument is the public identifier as specified in the entity declaration,
|
---|
348 | or null if none was specified; the whitespace in the public identifier
|
---|
349 | will have been normalized as required by the XML spec.
|
---|
350 | The context argument specifies the parsing context in the format
|
---|
351 | expected by the context argument to
|
---|
352 | XML_ExternalEntityParserCreate; context is valid only until the handler
|
---|
353 | returns, so if the referenced entity is to be parsed later, it must be copied.
|
---|
354 | The handler should return 0 if processing should not continue because of
|
---|
355 | a fatal error in the handling of the external entity.
|
---|
356 | In this case the calling parser will return an ERROR_EXPAT_EXTERNAL_ENTITY_HANDLING
|
---|
357 | error.
|
---|
358 | Note that unlike other handlers the first argument is the parser, not userData. */
|
---|
359 |
|
---|
360 | typedef int (* EXPATENTRY XML_ExternalEntityRefHandler)(XML_Parser parser,
|
---|
361 | const XML_Char *context,
|
---|
362 | const XML_Char *base,
|
---|
363 | const XML_Char *systemId,
|
---|
364 | const XML_Char *publicId);
|
---|
365 |
|
---|
366 | /* This structure is filled in by the XML_UnknownEncodingHandler
|
---|
367 | to provide information to the parser about encodings that are unknown
|
---|
368 | to the parser.
|
---|
369 | The map[b] member gives information about byte sequences
|
---|
370 | whose first byte is b.
|
---|
371 | If map[b] is c where c is >= 0, then b by itself encodes the Unicode scalar value c.
|
---|
372 | If map[b] is -1, then the byte sequence is malformed.
|
---|
373 | If map[b] is -n, where n >= 2, then b is the first byte of an n-byte
|
---|
374 | sequence that encodes a single Unicode scalar value.
|
---|
375 | The data member will be passed as the first argument to the convert function.
|
---|
376 | The convert function is used to convert multibyte sequences;
|
---|
377 | s will point to a n-byte sequence where map[(unsigned char)*s] == -n.
|
---|
378 | The convert function must return the Unicode scalar value
|
---|
379 | represented by this byte sequence or -1 if the byte sequence is malformed.
|
---|
380 | The convert function may be null if the encoding is a single-byte encoding,
|
---|
381 | that is if map[b] >= -1 for all bytes b.
|
---|
382 | When the parser is finished with the encoding, then if release is not null,
|
---|
383 | it will call release passing it the data member;
|
---|
384 | once release has been called, the convert function will not be called again.
|
---|
385 |
|
---|
386 | Expat places certain restrictions on the encodings that are supported
|
---|
387 | using this mechanism.
|
---|
388 |
|
---|
389 | 1. Every ASCII character that can appear in a well-formed XML document,
|
---|
390 | other than the characters
|
---|
391 |
|
---|
392 | $@\^`{}~
|
---|
393 |
|
---|
394 | must be represented by a single byte, and that byte must be the
|
---|
395 | same byte that represents that character in ASCII.
|
---|
396 |
|
---|
397 | 2. No character may require more than 4 bytes to encode.
|
---|
398 |
|
---|
399 | 3. All characters encoded must have Unicode scalar values <= 0xFFFF,
|
---|
400 | (ie characters that would be encoded by surrogates in UTF-16
|
---|
401 | are not allowed). Note that this restriction doesn't apply to
|
---|
402 | the built-in support for UTF-8 and UTF-16.
|
---|
403 |
|
---|
404 | 4. No Unicode character may be encoded by more than one distinct sequence
|
---|
405 | of bytes. */
|
---|
406 |
|
---|
407 | /*
|
---|
408 | *@@ XML_Encoding:
|
---|
409 | * structure passed with the UnknownEncodingHandler (see
|
---|
410 | * XML_SetUnknownEncodingHandler).
|
---|
411 | *
|
---|
412 | * The map array contains information for every possible
|
---|
413 | * possible leading byte in a byte sequence.
|
---|
414 | *
|
---|
415 | * -- If the corresponding value is >= 0, then it's a single byte
|
---|
416 | * sequence and the byte encodes that Unicode value.
|
---|
417 | *
|
---|
418 | * -- If the value is -1, then that byte is invalid as the
|
---|
419 | * initial byte in a sequence.
|
---|
420 | *
|
---|
421 | * -- If the value is -2, -3, or -4, then the byte is the beginning
|
---|
422 | * of a 2, 3, or 4 byte sequence, respectively. The actual
|
---|
423 | * conversion is then accomplished by a call to the function
|
---|
424 | * pointed at by "convert". This function should return the
|
---|
425 | * Unicode scalar value for the sequence or -1 if the sequence
|
---|
426 | * is malformed.
|
---|
427 | *
|
---|
428 | * The "convert" pointer may be null if there are only
|
---|
429 | * single byte codes. The data parameter passed to the
|
---|
430 | * convert function is the data pointer from
|
---|
431 | * XML_Encoding. The string s is NOT null terminated and
|
---|
432 | * points at the sequence of bytes to be converted.
|
---|
433 | *
|
---|
434 | * The function pointed at by "release" is called by the parser
|
---|
435 | * when it is finished with the encoding. It may be null.
|
---|
436 | */
|
---|
437 |
|
---|
438 | typedef struct _XML_Encoding
|
---|
439 | {
|
---|
440 | int map[256];
|
---|
441 | void *data;
|
---|
442 | int (* EXPATENTRY convert)(void *data, const char *s);
|
---|
443 | void (* EXPATENTRY release)(void *data);
|
---|
444 | } XML_Encoding;
|
---|
445 |
|
---|
446 | typedef int (* EXPATENTRY XML_UnknownEncodingHandler)(void *encodingHandlerData,
|
---|
447 | const XML_Char *name,
|
---|
448 | XML_Encoding *info);
|
---|
449 |
|
---|
450 | void XMLPARSEAPI XML_SetElementHandler(XML_Parser parser,
|
---|
451 | XML_StartElementHandler start,
|
---|
452 | XML_EndElementHandler end);
|
---|
453 |
|
---|
454 | void XMLPARSEAPI XML_SetStartElementHandler(XML_Parser, XML_StartElementHandler);
|
---|
455 |
|
---|
456 | void XMLPARSEAPI XML_SetEndElementHandler(XML_Parser, XML_EndElementHandler);
|
---|
457 |
|
---|
458 | void XMLPARSEAPI XML_SetCharacterDataHandler(XML_Parser parser,
|
---|
459 | XML_CharacterDataHandler handler);
|
---|
460 |
|
---|
461 | void XMLPARSEAPI XML_SetProcessingInstructionHandler(XML_Parser parser,
|
---|
462 | XML_ProcessingInstructionHandler handler);
|
---|
463 | void XMLPARSEAPI XML_SetCommentHandler(XML_Parser parser,
|
---|
464 | XML_CommentHandler handler);
|
---|
465 |
|
---|
466 | void XMLPARSEAPI XML_SetCdataSectionHandler(XML_Parser parser,
|
---|
467 | XML_StartCdataSectionHandler start,
|
---|
468 | XML_EndCdataSectionHandler end);
|
---|
469 |
|
---|
470 | void XMLPARSEAPI XML_SetStartCdataSectionHandler(XML_Parser parser,
|
---|
471 | XML_StartCdataSectionHandler start);
|
---|
472 |
|
---|
473 | void XMLPARSEAPI XML_SetEndCdataSectionHandler(XML_Parser parser,
|
---|
474 | XML_EndCdataSectionHandler end);
|
---|
475 |
|
---|
476 | /* This sets the default handler and also inhibits expansion of internal entities.
|
---|
477 | The entity reference will be passed to the default handler. */
|
---|
478 |
|
---|
479 | void XMLPARSEAPI XML_SetDefaultHandler(XML_Parser parser,
|
---|
480 | XML_DefaultHandler handler);
|
---|
481 |
|
---|
482 | /* This sets the default handler but does not inhibit expansion of internal entities.
|
---|
483 | The entity reference will not be passed to the default handler. */
|
---|
484 |
|
---|
485 | void XMLPARSEAPI XML_SetDefaultHandlerExpand(XML_Parser parser,
|
---|
486 | XML_DefaultHandler handler);
|
---|
487 |
|
---|
488 | void XMLPARSEAPI XML_SetDoctypeDeclHandler(XML_Parser parser,
|
---|
489 | XML_StartDoctypeDeclHandler start,
|
---|
490 | XML_EndDoctypeDeclHandler end);
|
---|
491 |
|
---|
492 | void XMLPARSEAPI XML_SetStartDoctypeDeclHandler(XML_Parser parser,
|
---|
493 | XML_StartDoctypeDeclHandler start);
|
---|
494 |
|
---|
495 | void XMLPARSEAPI XML_SetEndDoctypeDeclHandler(XML_Parser parser,
|
---|
496 | XML_EndDoctypeDeclHandler end);
|
---|
497 |
|
---|
498 | void XMLPARSEAPI XML_SetUnparsedEntityDeclHandler(XML_Parser parser,
|
---|
499 | XML_UnparsedEntityDeclHandler handler);
|
---|
500 |
|
---|
501 | void XMLPARSEAPI XML_SetNotationDeclHandler(XML_Parser parser,
|
---|
502 | XML_NotationDeclHandler handler);
|
---|
503 |
|
---|
504 | void XMLPARSEAPI XML_SetNamespaceDeclHandler(XML_Parser parser,
|
---|
505 | XML_StartNamespaceDeclHandler start,
|
---|
506 | XML_EndNamespaceDeclHandler end);
|
---|
507 |
|
---|
508 | void XMLPARSEAPI XML_SetStartNamespaceDeclHandler(XML_Parser parser,
|
---|
509 | XML_StartNamespaceDeclHandler start);
|
---|
510 |
|
---|
511 | void XMLPARSEAPI XML_SetEndNamespaceDeclHandler(XML_Parser parser,
|
---|
512 | XML_EndNamespaceDeclHandler end);
|
---|
513 |
|
---|
514 | void XMLPARSEAPI XML_SetNotStandaloneHandler(XML_Parser parser,
|
---|
515 | XML_NotStandaloneHandler handler);
|
---|
516 |
|
---|
517 | void XMLPARSEAPI XML_SetExternalEntityRefHandler(XML_Parser parser,
|
---|
518 | XML_ExternalEntityRefHandler handler);
|
---|
519 |
|
---|
520 | /* If a non-null value for arg is specified here, then it will be passed
|
---|
521 | as the first argument to the external entity ref handler instead
|
---|
522 | of the parser object. */
|
---|
523 | void XMLPARSEAPI XML_SetExternalEntityRefHandlerArg(XML_Parser, void *arg);
|
---|
524 |
|
---|
525 | void XMLPARSEAPI XML_SetUnknownEncodingHandler(XML_Parser parser,
|
---|
526 | XML_UnknownEncodingHandler handler,
|
---|
527 | void *encodingHandlerData);
|
---|
528 |
|
---|
529 | /* This can be called within a handler for a start element, end element,
|
---|
530 | processing instruction or character data. It causes the corresponding
|
---|
531 | markup to be passed to the default handler. */
|
---|
532 | void XML_DefaultCurrent(XML_Parser parser);
|
---|
533 |
|
---|
534 | /* If do_nst is non-zero, and namespace processing is in effect, and
|
---|
535 | a name has a prefix (i.e. an explicit namespace qualifier) then
|
---|
536 | that name is returned as a triplet in a single
|
---|
537 | string separated by the separator character specified when the parser
|
---|
538 | was created: URI + sep + local_name + sep + prefix.
|
---|
539 |
|
---|
540 | If do_nst is zero, then namespace information is returned in the
|
---|
541 | default manner (URI + sep + local_name) whether or not the names
|
---|
542 | has a prefix.
|
---|
543 | */
|
---|
544 |
|
---|
545 | void XMLPARSEAPI XML_SetReturnNSTriplet(XML_Parser parser, int do_nst);
|
---|
546 |
|
---|
547 | /* This value is passed as the userData argument to callbacks. */
|
---|
548 | void XMLPARSEAPI XML_SetUserData(XML_Parser parser, void *userData);
|
---|
549 |
|
---|
550 | /* Returns the last value set by XML_SetUserData or null. */
|
---|
551 | #define XML_GetUserData(parser) (*(void **)(parser))
|
---|
552 |
|
---|
553 | /* This is equivalent to supplying an encoding argument
|
---|
554 | to XML_ParserCreate. It must not be called after XML_Parse
|
---|
555 | or XML_ParseBuffer. */
|
---|
556 |
|
---|
557 | int XMLPARSEAPI XML_SetEncoding(XML_Parser parser, const XML_Char *encoding);
|
---|
558 |
|
---|
559 | /* If this function is called, then the parser will be passed
|
---|
560 | as the first argument to callbacks instead of userData.
|
---|
561 | The userData will still be accessible using XML_GetUserData. */
|
---|
562 |
|
---|
563 | void XMLPARSEAPI XML_UseParserAsHandlerArg(XML_Parser parser);
|
---|
564 |
|
---|
565 | /* Sets the base to be used for resolving relative URIs in system identifiers in
|
---|
566 | declarations. Resolving relative identifiers is left to the application:
|
---|
567 | this value will be passed through as the base argument to the
|
---|
568 | XML_ExternalEntityRefHandler, XML_NotationDeclHandler
|
---|
569 | and XML_UnparsedEntityDeclHandler. The base argument will be copied.
|
---|
570 | Returns zero if out of memory, non-zero otherwise. */
|
---|
571 |
|
---|
572 | int XMLPARSEAPI XML_SetBase(XML_Parser parser, const XML_Char *base);
|
---|
573 |
|
---|
574 | const XML_Char XMLPARSEAPI * XML_GetBase(XML_Parser parser);
|
---|
575 |
|
---|
576 | /* Returns the number of the attribute/value pairs passed in last call
|
---|
577 | to the XML_StartElementHandler that were specified in the start-tag
|
---|
578 | rather than defaulted. Each attribute/value pair counts as 2; thus
|
---|
579 | this correspondds to an index into the atts array passed to the
|
---|
580 | XML_StartElementHandler. */
|
---|
581 |
|
---|
582 | int XMLPARSEAPI XML_GetSpecifiedAttributeCount(XML_Parser parser);
|
---|
583 |
|
---|
584 | /* Returns the index of the ID attribute passed in the last call to
|
---|
585 | XML_StartElementHandler, or -1 if there is no ID attribute. Each
|
---|
586 | attribute/value pair counts as 2; thus this correspondds to an index
|
---|
587 | into the atts array passed to the XML_StartElementHandler. */
|
---|
588 |
|
---|
589 | int XMLPARSEAPI XML_GetIdAttributeIndex(XML_Parser parser);
|
---|
590 |
|
---|
591 | /* Parses some input. Returns 0 if a fatal error is detected.
|
---|
592 | The last call to XML_Parse must have isFinal true;
|
---|
593 | len may be zero for this call (or any other). */
|
---|
594 | int XMLPARSEAPI XML_Parse(XML_Parser parser, const char *s, int len, int isFinal);
|
---|
595 |
|
---|
596 | void XMLPARSEAPI * XML_GetBuffer(XML_Parser parser, int len);
|
---|
597 |
|
---|
598 | int XMLPARSEAPI XML_ParseBuffer(XML_Parser parser, int len, int isFinal);
|
---|
599 |
|
---|
600 | /* Creates an XML_Parser object that can parse an external general entity;
|
---|
601 | context is a '\0'-terminated string specifying the parse context;
|
---|
602 | encoding is a '\0'-terminated string giving the name of the externally specified encoding,
|
---|
603 | or null if there is no externally specified encoding.
|
---|
604 | The context string consists of a sequence of tokens separated by formfeeds (\f);
|
---|
605 | a token consisting of a name specifies that the general entity of the name
|
---|
606 | is open; a token of the form prefix=uri specifies the namespace for a particular
|
---|
607 | prefix; a token of the form =uri specifies the default namespace.
|
---|
608 | This can be called at any point after the first call to an ExternalEntityRefHandler
|
---|
609 | so longer as the parser has not yet been freed.
|
---|
610 | The new parser is completely independent and may safely be used in a separate thread.
|
---|
611 | The handlers and userData are initialized from the parser argument.
|
---|
612 | Returns 0 if out of memory. Otherwise returns a new XML_Parser object. */
|
---|
613 | XML_Parser XMLPARSEAPI XML_ExternalEntityParserCreate(XML_Parser parser,
|
---|
614 | const XML_Char *context,
|
---|
615 | const XML_Char *encoding);
|
---|
616 |
|
---|
617 | enum XML_ParamEntityParsing {
|
---|
618 | XML_PARAM_ENTITY_PARSING_NEVER,
|
---|
619 | XML_PARAM_ENTITY_PARSING_UNLESS_STANDALONE,
|
---|
620 | XML_PARAM_ENTITY_PARSING_ALWAYS
|
---|
621 | };
|
---|
622 |
|
---|
623 | int XMLPARSEAPI XML_SetParamEntityParsing(XML_Parser parser,
|
---|
624 | enum XML_ParamEntityParsing parsing);
|
---|
625 |
|
---|
626 | #define ERROR_XML_FIRST 40000 // first error code used
|
---|
627 |
|
---|
628 | typedef unsigned long XMLERROR; // V0.9.12 (2001-05-20) [umoeller]
|
---|
629 |
|
---|
630 | #define ERROR_EXPAT_NONE 0
|
---|
631 | #define ERROR_EXPAT_NO_MEMORY (ERROR_XML_FIRST)
|
---|
632 | #define ERROR_EXPAT_SYNTAX (ERROR_XML_FIRST + 1)
|
---|
633 | #define ERROR_EXPAT_NO_ELEMENTS (ERROR_XML_FIRST + 2)
|
---|
634 | #define ERROR_EXPAT_INVALID_TOKEN (ERROR_XML_FIRST + 3)
|
---|
635 | #define ERROR_EXPAT_UNCLOSED_TOKEN (ERROR_XML_FIRST + 4)
|
---|
636 | #define ERROR_EXPAT_PARTIAL_CHAR (ERROR_XML_FIRST + 5)
|
---|
637 | #define ERROR_EXPAT_TAG_MISMATCH (ERROR_XML_FIRST + 6)
|
---|
638 | #define ERROR_EXPAT_DUPLICATE_ATTRIBUTE (ERROR_XML_FIRST + 7)
|
---|
639 | #define ERROR_EXPAT_JUNK_AFTER_DOC_ELEMENT (ERROR_XML_FIRST + 8)
|
---|
640 | #define ERROR_EXPAT_PARAM_ENTITY_REF (ERROR_XML_FIRST + 10)
|
---|
641 | #define ERROR_EXPAT_UNDEFINED_ENTITY (ERROR_XML_FIRST + 11)
|
---|
642 | #define ERROR_EXPAT_RECURSIVE_ENTITY_REF (ERROR_XML_FIRST + 12)
|
---|
643 | #define ERROR_EXPAT_ASYNC_ENTITY (ERROR_XML_FIRST + 13)
|
---|
644 | #define ERROR_EXPAT_BAD_CHAR_REF (ERROR_XML_FIRST + 14)
|
---|
645 | #define ERROR_EXPAT_BINARY_ENTITY_REF (ERROR_XML_FIRST + 15)
|
---|
646 | #define ERROR_EXPAT_ATTRIBUTE_EXTERNAL_ENTITY_REF (ERROR_XML_FIRST + 16)
|
---|
647 | #define ERROR_EXPAT_MISPLACED_XML_PI (ERROR_XML_FIRST + 17)
|
---|
648 | #define ERROR_EXPAT_UNKNOWN_ENCODING (ERROR_XML_FIRST + 18)
|
---|
649 | #define ERROR_EXPAT_INCORRECT_ENCODING (ERROR_XML_FIRST + 19)
|
---|
650 | #define ERROR_EXPAT_UNCLOSED_CDATA_SECTION (ERROR_XML_FIRST + 20)
|
---|
651 | #define ERROR_EXPAT_EXTERNAL_ENTITY_HANDLING (ERROR_XML_FIRST + 21)
|
---|
652 | #define ERROR_EXPAT_NOT_STANDALONE (ERROR_XML_FIRST + 22)
|
---|
653 | #define ERROR_EXPAT_UNEXPECTED_STATE (ERROR_XML_FIRST + 23)
|
---|
654 |
|
---|
655 | /* If XML_Parse or XML_ParseBuffer have returned 0, then XML_GetErrorCode
|
---|
656 | returns information about the error. */
|
---|
657 |
|
---|
658 | XMLERROR XMLPARSEAPI XML_GetErrorCode(XML_Parser parser);
|
---|
659 |
|
---|
660 | /* These functions return information about the current parse location.
|
---|
661 | They may be called when XML_Parse or XML_ParseBuffer return 0;
|
---|
662 | in this case the location is the location of the character at which
|
---|
663 | the error was detected.
|
---|
664 | They may also be called from any other callback called to report
|
---|
665 | some parse event; in this the location is the location of the first
|
---|
666 | of the sequence of characters that generated the event. */
|
---|
667 |
|
---|
668 | int XMLPARSEAPI XML_GetCurrentLineNumber(XML_Parser parser);
|
---|
669 | int XMLPARSEAPI XML_GetCurrentColumnNumber(XML_Parser parser);
|
---|
670 | long XMLPARSEAPI XML_GetCurrentByteIndex(XML_Parser parser);
|
---|
671 |
|
---|
672 | /* Return the number of bytes in the current event.
|
---|
673 | Returns 0 if the event is in an internal entity. */
|
---|
674 |
|
---|
675 | int XMLPARSEAPI XML_GetCurrentByteCount(XML_Parser parser);
|
---|
676 |
|
---|
677 | /* If XML_CONTEXT_BYTES is defined, returns the input buffer, sets
|
---|
678 | the integer pointed to by offset to the offset within this buffer
|
---|
679 | of the current parse position, and sets the integer pointed to by size
|
---|
680 | to the size of this buffer (the number of input bytes). Otherwise
|
---|
681 | returns a null pointer. Also returns a null pointer if a parse isn't active.
|
---|
682 |
|
---|
683 | NOTE: The character pointer returned should not be used outside
|
---|
684 | the handler that makes the call. */
|
---|
685 |
|
---|
686 | const char XMLPARSEAPI * XML_GetInputContext(XML_Parser parser,
|
---|
687 | int *offset,
|
---|
688 | int *size);
|
---|
689 |
|
---|
690 | /* For backwards compatibility with previous versions. */
|
---|
691 | #define XML_GetErrorLineNumber XML_GetCurrentLineNumber
|
---|
692 | #define XML_GetErrorColumnNumber XML_GetCurrentColumnNumber
|
---|
693 | #define XML_GetErrorByteIndex XML_GetCurrentByteIndex
|
---|
694 |
|
---|
695 | /* Frees memory used by the parser. */
|
---|
696 | void XMLPARSEAPI XML_ParserFree(XML_Parser parser);
|
---|
697 |
|
---|
698 | /* Returns a string describing the error. */
|
---|
699 | // const XML_LChar XMLPARSEAPI * XML_ErrorString(int code);
|
---|
700 | // moved this to xml.c V0.9.9 (2001-02-16) [umoeller]
|
---|
701 |
|
---|
702 | /* Return a string containing the version number of this expat */
|
---|
703 | const XML_LChar XMLPARSEAPI *XML_ExpatVersion(void);
|
---|
704 |
|
---|
705 | #ifdef __cplusplus
|
---|
706 | }
|
---|
707 | #endif
|
---|
708 |
|
---|
709 | #endif /* not XmlParse_INCLUDED */
|
---|