00001 /* Copyright (c) 1998, 1999, 2000 Thai Open Source Software Center Ltd 00002 See the file COPYING for copying permission. 00003 */ 00004 00005 #ifndef XmlParse_INCLUDED 00006 #define XmlParse_INCLUDED 1 00007 00008 #ifdef __VMS 00009 /* 0 1 2 3 0 1 2 3 00010 1234567890123456789012345678901 1234567890123456789012345678901 */ 00011 #define XML_SetProcessingInstructionHandler XML_SetProcessingInstrHandler 00012 #define XML_SetUnparsedEntityDeclHandler XML_SetUnparsedEntDeclHandler 00013 #define XML_SetStartNamespaceDeclHandler XML_SetStartNamespcDeclHandler 00014 #define XML_SetExternalEntityRefHandlerArg XML_SetExternalEntRefHandlerArg 00015 #endif 00016 00017 #include <stdlib.h> 00018 00019 #ifndef XMLPARSEAPI 00020 #if defined(_MSC_EXTENSIONS) && !defined(__BEOS__) && !defined(__CYGWIN__) && !defined(UNDER_CE) 00021 #ifdef _STATIC 00022 #define XMLPARSEAPI(type) type __cdecl 00023 #else 00024 #define XMLPARSEAPI(type) __declspec(dllimport) type __cdecl 00025 #endif 00026 #else 00027 #define XMLPARSEAPI(type) type 00028 #endif 00029 #endif /* not defined XMLPARSEAPI */ 00030 00031 #ifdef __cplusplus 00032 extern "C" { 00033 #endif 00034 00035 #ifdef _UNICODE 00036 #ifndef XML_UNICODE_WCHAR_T 00037 #define XML_UNICODE_WCHAR_T 00038 #endif 00039 #ifndef XML_UNICODE 00040 #define XML_UNICODE 00041 #endif 00042 #endif 00043 00044 #ifdef XML_UNICODE_WCHAR_T 00045 #define XML_UNICODE 00046 #endif 00047 00048 struct XML_ParserStruct; 00049 typedef struct XML_ParserStruct *XML_Parser; 00050 00051 #ifdef XML_UNICODE /* Information is UTF-16 encoded. */ 00052 #ifdef XML_UNICODE_WCHAR_T 00053 typedef wchar_t XML_Char; 00054 typedef wchar_t XML_LChar; 00055 #else 00056 typedef unsigned short XML_Char; 00057 typedef char XML_LChar; 00058 #endif /* XML_UNICODE_WCHAR_T */ 00059 #else /* Information is UTF-8 encoded. */ 00060 typedef char XML_Char; 00061 typedef char XML_LChar; 00062 #endif /* XML_UNICODE */ 00063 00064 /* Should this be defined using stdbool.h when C99 is available? */ 00065 typedef unsigned char XML_Bool; 00066 #define XML_TRUE ((XML_Bool) 1) 00067 #define XML_FALSE ((XML_Bool) 0) 00068 00069 enum XML_Error { 00070 XML_ERROR_NONE, 00071 XML_ERROR_NO_MEMORY, 00072 XML_ERROR_SYNTAX, 00073 XML_ERROR_NO_ELEMENTS, 00074 XML_ERROR_INVALID_TOKEN, 00075 XML_ERROR_UNCLOSED_TOKEN, 00076 XML_ERROR_PARTIAL_CHAR, 00077 XML_ERROR_TAG_MISMATCH, 00078 XML_ERROR_DUPLICATE_ATTRIBUTE, 00079 XML_ERROR_JUNK_AFTER_DOC_ELEMENT, 00080 XML_ERROR_PARAM_ENTITY_REF, 00081 XML_ERROR_UNDEFINED_ENTITY, 00082 XML_ERROR_RECURSIVE_ENTITY_REF, 00083 XML_ERROR_ASYNC_ENTITY, 00084 XML_ERROR_BAD_CHAR_REF, 00085 XML_ERROR_BINARY_ENTITY_REF, 00086 XML_ERROR_ATTRIBUTE_EXTERNAL_ENTITY_REF, 00087 XML_ERROR_MISPLACED_XML_PI, 00088 XML_ERROR_UNKNOWN_ENCODING, 00089 XML_ERROR_INCORRECT_ENCODING, 00090 XML_ERROR_UNCLOSED_CDATA_SECTION, 00091 XML_ERROR_EXTERNAL_ENTITY_HANDLING, 00092 XML_ERROR_NOT_STANDALONE, 00093 XML_ERROR_UNEXPECTED_STATE, 00094 XML_ERROR_ENTITY_DECLARED_IN_PE, 00095 XML_ERROR_FEATURE_REQUIRES_XML_DTD, 00096 XML_ERROR_CANT_CHANGE_FEATURE_ONCE_PARSING 00097 }; 00098 00099 enum XML_Content_Type { 00100 XML_CTYPE_EMPTY = 1, 00101 XML_CTYPE_ANY, 00102 XML_CTYPE_MIXED, 00103 XML_CTYPE_NAME, 00104 XML_CTYPE_CHOICE, 00105 XML_CTYPE_SEQ 00106 }; 00107 00108 enum XML_Content_Quant { 00109 XML_CQUANT_NONE, 00110 XML_CQUANT_OPT, 00111 XML_CQUANT_REP, 00112 XML_CQUANT_PLUS 00113 }; 00114 00115 /* If type == XML_CTYPE_EMPTY or XML_CTYPE_ANY, then quant will be 00116 XML_CQUANT_NONE, and the other fields will be zero or NULL. 00117 If type == XML_CTYPE_MIXED, then quant will be NONE or REP and 00118 numchildren will contain number of elements that may be mixed in 00119 and children point to an array of XML_Content cells that will be 00120 all of XML_CTYPE_NAME type with no quantification. 00121 00122 If type == XML_CTYPE_NAME, then the name points to the name, and 00123 the numchildren field will be zero and children will be NULL. The 00124 quant fields indicates any quantifiers placed on the name. 00125 00126 CHOICE and SEQ will have name NULL, the number of children in 00127 numchildren and children will point, recursively, to an array 00128 of XML_Content cells. 00129 00130 The EMPTY, ANY, and MIXED types will only occur at top level. 00131 */ 00132 00133 typedef struct XML_cp XML_Content; 00134 00135 struct XML_cp { 00136 enum XML_Content_Type type; 00137 enum XML_Content_Quant quant; 00138 XML_Char * name; 00139 unsigned int numchildren; 00140 XML_Content * children; 00141 }; 00142 00143 00144 /* This is called for an element declaration. See above for 00145 description of the model argument. It's the caller's responsibility 00146 to free model when finished with it. 00147 */ 00148 typedef void (*XML_ElementDeclHandler) (void *userData, 00149 const XML_Char *name, 00150 XML_Content *model); 00151 00152 XMLPARSEAPI(void) 00153 XML_SetElementDeclHandler(XML_Parser parser, 00154 XML_ElementDeclHandler eldecl); 00155 00156 /* The Attlist declaration handler is called for *each* attribute. So 00157 a single Attlist declaration with multiple attributes declared will 00158 generate multiple calls to this handler. The "default" parameter 00159 may be NULL in the case of the "#IMPLIED" or "#REQUIRED" 00160 keyword. The "isrequired" parameter will be true and the default 00161 value will be NULL in the case of "#REQUIRED". If "isrequired" is 00162 true and default is non-NULL, then this is a "#FIXED" default. 00163 */ 00164 typedef void (*XML_AttlistDeclHandler) (void *userData, 00165 const XML_Char *elname, 00166 const XML_Char *attname, 00167 const XML_Char *att_type, 00168 const XML_Char *dflt, 00169 int isrequired); 00170 00171 XMLPARSEAPI(void) 00172 XML_SetAttlistDeclHandler(XML_Parser parser, 00173 XML_AttlistDeclHandler attdecl); 00174 00175 /* The XML declaration handler is called for *both* XML declarations 00176 and text declarations. The way to distinguish is that the version 00177 parameter will be NULL for text declarations. The encoding 00178 parameter may be NULL for XML declarations. The standalone 00179 parameter will be -1, 0, or 1 indicating respectively that there 00180 was no standalone parameter in the declaration, that it was given 00181 as no, or that it was given as yes. 00182 */ 00183 typedef void (*XML_XmlDeclHandler) (void *userData, 00184 const XML_Char *version, 00185 const XML_Char *encoding, 00186 int standalone); 00187 00188 XMLPARSEAPI(void) 00189 XML_SetXmlDeclHandler(XML_Parser parser, 00190 XML_XmlDeclHandler xmldecl); 00191 00192 00193 typedef struct { 00194 #ifdef __SYMBIAN32__ 00195 void *(*malloc_fcn)(size_t size); 00196 void *(*realloc_fcn)(void *ptr, size_t size); 00197 void (*free_fcn)(void *ptr); 00198 #else 00199 void *(__cdecl *malloc_fcn)(size_t size); 00200 void *(__cdecl *realloc_fcn)(void *ptr, size_t size); 00201 void (__cdecl *free_fcn)(void *ptr); 00202 #endif 00203 } XML_Memory_Handling_Suite; 00204 00205 /* Constructs a new parser; encoding is the encoding specified by the 00206 external protocol or NULL if there is none specified. 00207 */ 00208 XMLPARSEAPI(XML_Parser) 00209 XML_ParserCreate(const XML_Char *encoding); 00210 00211 /* Constructs a new parser and namespace processor. Element type 00212 names and attribute names that belong to a namespace will be 00213 expanded; unprefixed attribute names are never expanded; unprefixed 00214 element type names are expanded only if there is a default 00215 namespace. The expanded name is the concatenation of the namespace 00216 URI, the namespace separator character, and the local part of the 00217 name. If the namespace separator is '\0' then the namespace URI 00218 and the local part will be concatenated without any separator. 00219 When a namespace is not declared, the name and prefix will be 00220 passed through without expansion. 00221 */ 00222 XMLPARSEAPI(XML_Parser) 00223 XML_ParserCreateNS(const XML_Char *encoding, XML_Char namespaceSeparator); 00224 00225 00226 /* Constructs a new parser using the memory management suit referred to 00227 by memsuite. If memsuite is NULL, then use the standard library memory 00228 suite. If namespaceSeparator is non-NULL it creates a parser with 00229 namespace processing as described above. The character pointed at 00230 will serve as the namespace separator. 00231 00232 All further memory operations used for the created parser will come from 00233 the given suite. 00234 */ 00235 XMLPARSEAPI(XML_Parser) 00236 XML_ParserCreate_MM(const XML_Char *encoding, 00237 const XML_Memory_Handling_Suite *memsuite, 00238 const XML_Char *namespaceSeparator); 00239 00240 /* Prepare a parser object to be re-used. This is particularly 00241 valuable when memory allocation overhead is disproportionatly high, 00242 such as when a large number of small documnents need to be parsed. 00243 All handlers are cleared from the parser, except for the 00244 unknownEncodingHandler. The parser's external state is re-initialized 00245 except for the values of ns and ns_triplets. 00246 00247 Added in Expat 1.95.3. 00248 */ 00249 XMLPARSEAPI(XML_Bool) 00250 XML_ParserReset(XML_Parser parser, const XML_Char *encoding); 00251 00252 /* atts is array of name/value pairs, terminated by 0; 00253 names and values are 0 terminated. 00254 */ 00255 typedef void (*XML_StartElementHandler)(void *userData, 00256 const XML_Char *name, 00257 const XML_Char **atts); 00258 00259 typedef void (*XML_EndElementHandler)(void *userData, 00260 const XML_Char *name); 00261 00262 00263 /* s is not 0 terminated. */ 00264 typedef void (*XML_CharacterDataHandler)(void *userData, 00265 const XML_Char *s, 00266 int len); 00267 00268 /* target and data are 0 terminated */ 00269 typedef void (*XML_ProcessingInstructionHandler)(void *userData, 00270 const XML_Char *target, 00271 const XML_Char *data); 00272 00273 /* data is 0 terminated */ 00274 typedef void (*XML_CommentHandler)(void *userData, const XML_Char *data); 00275 00276 typedef void (*XML_StartCdataSectionHandler)(void *userData); 00277 typedef void (*XML_EndCdataSectionHandler)(void *userData); 00278 00279 /* This is called for any characters in the XML document for which 00280 there is no applicable handler. This includes both characters that 00281 are part of markup which is of a kind that is not reported 00282 (comments, markup declarations), or characters that are part of a 00283 construct which could be reported but for which no handler has been 00284 supplied. The characters are passed exactly as they were in the XML 00285 document except that they will be encoded in UTF-8 or UTF-16. 00286 Line boundaries are not normalized. Note that a byte order mark 00287 character is not passed to the default handler. There are no 00288 guarantees about how characters are divided between calls to the 00289 default handler: for example, a comment might be split between 00290 multiple calls. 00291 */ 00292 typedef void (*XML_DefaultHandler)(void *userData, 00293 const XML_Char *s, 00294 int len); 00295 00296 /* This is called for the start of the DOCTYPE declaration, before 00297 any DTD or internal subset is parsed. 00298 */ 00299 typedef void (*XML_StartDoctypeDeclHandler)(void *userData, 00300 const XML_Char *doctypeName, 00301 const XML_Char *sysid, 00302 const XML_Char *pubid, 00303 int has_internal_subset); 00304 00305 /* This is called for the start of the DOCTYPE declaration when the 00306 closing > is encountered, but after processing any external 00307 subset. 00308 */ 00309 typedef void (*XML_EndDoctypeDeclHandler)(void *userData); 00310 00311 /* This is called for entity declarations. The is_parameter_entity 00312 argument will be non-zero if the entity is a parameter entity, zero 00313 otherwise. 00314 00315 For internal entities (<!ENTITY foo "bar">), value will 00316 be non-NULL and systemId, publicID, and notationName will be NULL. 00317 The value string is NOT nul-terminated; the length is provided in 00318 the value_length argument. Since it is legal to have zero-length 00319 values, do not use this argument to test for internal entities. 00320 00321 For external entities, value will be NULL and systemId will be 00322 non-NULL. The publicId argument will be NULL unless a public 00323 identifier was provided. The notationName argument will have a 00324 non-NULL value only for unparsed entity declarations. 00325 00326 Note that is_parameter_entity can't be changed to XML_Bool, since 00327 that would break binary compatibility. 00328 */ 00329 typedef void (*XML_EntityDeclHandler) (void *userData, 00330 const XML_Char *entityName, 00331 int is_parameter_entity, 00332 const XML_Char *value, 00333 int value_length, 00334 const XML_Char *base, 00335 const XML_Char *systemId, 00336 const XML_Char *publicId, 00337 const XML_Char *notationName); 00338 00339 XMLPARSEAPI(void) 00340 XML_SetEntityDeclHandler(XML_Parser parser, 00341 XML_EntityDeclHandler handler); 00342 00343 /* OBSOLETE -- OBSOLETE -- OBSOLETE 00344 This handler has been superceded by the EntityDeclHandler above. 00345 It is provided here for backward compatibility. 00346 00347 This is called for a declaration of an unparsed (NDATA) entity. 00348 The base argument is whatever was set by XML_SetBase. The 00349 entityName, systemId and notationName arguments will never be 00350 NULL. The other arguments may be. 00351 */ 00352 typedef void (*XML_UnparsedEntityDeclHandler)(void *userData, 00353 const XML_Char *entityName, 00354 const XML_Char *base, 00355 const XML_Char *systemId, 00356 const XML_Char *publicId, 00357 const XML_Char *notationName); 00358 00359 /* This is called for a declaration of notation. The base argument is 00360 whatever was set by XML_SetBase. The notationName will never be 00361 NULL. The other arguments can be. 00362 */ 00363 typedef void (*XML_NotationDeclHandler)(void *userData, 00364 const XML_Char *notationName, 00365 const XML_Char *base, 00366 const XML_Char *systemId, 00367 const XML_Char *publicId); 00368 00369 /* When namespace processing is enabled, these are called once for 00370 each namespace declaration. The call to the start and end element 00371 handlers occur between the calls to the start and end namespace 00372 declaration handlers. For an xmlns attribute, prefix will be 00373 NULL. For an xmlns="" attribute, uri will be NULL. 00374 */ 00375 typedef void (*XML_StartNamespaceDeclHandler)(void *userData, 00376 const XML_Char *prefix, 00377 const XML_Char *uri); 00378 00379 typedef void (*XML_EndNamespaceDeclHandler)(void *userData, 00380 const XML_Char *prefix); 00381 00382 /* This is called if the document is not standalone, that is, it has an 00383 external subset or a reference to a parameter entity, but does not 00384 have standalone="yes". If this handler returns 0, then processing 00385 will not continue, and the parser will return a 00386 XML_ERROR_NOT_STANDALONE error. 00387 If parameter entity parsing is enabled, then in addition to the 00388 conditions above this handler will only be called if the referenced 00389 entity was actually read. 00390 */ 00391 typedef int (*XML_NotStandaloneHandler)(void *userData); 00392 00393 /* This is called for a reference to an external parsed general 00394 entity. The referenced entity is not automatically parsed. The 00395 application can parse it immediately or later using 00396 XML_ExternalEntityParserCreate. 00397 00398 The parser argument is the parser parsing the entity containing the 00399 reference; it can be passed as the parser argument to 00400 XML_ExternalEntityParserCreate. The systemId argument is the 00401 system identifier as specified in the entity declaration; it will 00402 not be NULL. 00403 00404 The base argument is the system identifier that should be used as 00405 the base for resolving systemId if systemId was relative; this is 00406 set by XML_SetBase; it may be NULL. 00407 00408 The publicId argument is the public identifier as specified in the 00409 entity declaration, or NULL if none was specified; the whitespace 00410 in the public identifier will have been normalized as required by 00411 the XML spec. 00412 00413 The context argument specifies the parsing context in the format 00414 expected by the context argument to XML_ExternalEntityParserCreate; 00415 context is valid only until the handler returns, so if the 00416 referenced entity is to be parsed later, it must be copied. 00417 00418 The handler should return 0 if processing should not continue 00419 because of a fatal error in the handling of the external entity. 00420 In this case the calling parser will return an 00421 XML_ERROR_EXTERNAL_ENTITY_HANDLING error. 00422 00423 Note that unlike other handlers the first argument is the parser, 00424 not userData. 00425 */ 00426 typedef int (*XML_ExternalEntityRefHandler)(XML_Parser parser, 00427 const XML_Char *context, 00428 const XML_Char *base, 00429 const XML_Char *systemId, 00430 const XML_Char *publicId); 00431 00432 /* This is called in two situations: 00433 1) An entity reference is encountered for which no declaration 00434 has been read *and* this is not an error. 00435 2) An internal entity reference is read, but not expanded, because 00436 XML_SetDefaultHandler has been called. 00437 Note: skipped parameter entities in declarations and skipped general 00438 entities in attribute values cannot be reported, because 00439 the event would be out of sync with the reporting of the 00440 declarations or attribute values 00441 */ 00442 typedef void (*XML_SkippedEntityHandler)(void *userData, 00443 const XML_Char *entityName, 00444 int is_parameter_entity); 00445 00446 /* This structure is filled in by the XML_UnknownEncodingHandler to 00447 provide information to the parser about encodings that are unknown 00448 to the parser. 00449 00450 The map[b] member gives information about byte sequences whose 00451 first byte is b. 00452 00453 If map[b] is c where c is >= 0, then b by itself encodes the 00454 Unicode scalar value c. 00455 00456 If map[b] is -1, then the byte sequence is malformed. 00457 00458 If map[b] is -n, where n >= 2, then b is the first byte of an 00459 n-byte sequence that encodes a single Unicode scalar value. 00460 00461 The data member will be passed as the first argument to the convert 00462 function. 00463 00464 The convert function is used to convert multibyte sequences; s will 00465 point to a n-byte sequence where map[(unsigned char)*s] == -n. The 00466 convert function must return the Unicode scalar value represented 00467 by this byte sequence or -1 if the byte sequence is malformed. 00468 00469 The convert function may be NULL if the encoding is a single-byte 00470 encoding, that is if map[b] >= -1 for all bytes b. 00471 00472 When the parser is finished with the encoding, then if release is 00473 not NULL, it will call release passing it the data member; once 00474 release has been called, the convert function will not be called 00475 again. 00476 00477 Expat places certain restrictions on the encodings that are supported 00478 using this mechanism. 00479 00480 1. Every ASCII character that can appear in a well-formed XML document, 00481 other than the characters 00482 00483 $@\^`{}~ 00484 00485 must be represented by a single byte, and that byte must be the 00486 same byte that represents that character in ASCII. 00487 00488 2. No character may require more than 4 bytes to encode. 00489 00490 3. All characters encoded must have Unicode scalar values <= 00491 0xFFFF, (i.e., characters that would be encoded by surrogates in 00492 UTF-16 are not allowed). Note that this restriction doesn't 00493 apply to the built-in support for UTF-8 and UTF-16. 00494 00495 4. No Unicode character may be encoded by more than one distinct 00496 sequence of bytes. 00497 */ 00498 typedef struct { 00499 int map[256]; 00500 void *data; 00501 int (*convert)(void *data, const char *s); 00502 void (*release)(void *data); 00503 } XML_Encoding; 00504 00505 /* This is called for an encoding that is unknown to the parser. 00506 00507 The encodingHandlerData argument is that which was passed as the 00508 second argument to XML_SetUnknownEncodingHandler. 00509 00510 The name argument gives the name of the encoding as specified in 00511 the encoding declaration. 00512 00513 If the callback can provide information about the encoding, it must 00514 fill in the XML_Encoding structure, and return 1. Otherwise it 00515 must return 0. 00516 00517 If info does not describe a suitable encoding, then the parser will 00518 return an XML_UNKNOWN_ENCODING error. 00519 */ 00520 typedef int (*XML_UnknownEncodingHandler)(void *encodingHandlerData, 00521 const XML_Char *name, 00522 XML_Encoding *info); 00523 00524 XMLPARSEAPI(void) 00525 XML_SetElementHandler(XML_Parser parser, 00526 XML_StartElementHandler start, 00527 XML_EndElementHandler end); 00528 00529 XMLPARSEAPI(void) 00530 XML_SetStartElementHandler(XML_Parser, XML_StartElementHandler); 00531 00532 XMLPARSEAPI(void) 00533 XML_SetEndElementHandler(XML_Parser, XML_EndElementHandler); 00534 00535 XMLPARSEAPI(void) 00536 XML_SetCharacterDataHandler(XML_Parser parser, 00537 XML_CharacterDataHandler handler); 00538 00539 XMLPARSEAPI(void) 00540 XML_SetProcessingInstructionHandler(XML_Parser parser, 00541 XML_ProcessingInstructionHandler handler); 00542 XMLPARSEAPI(void) 00543 XML_SetCommentHandler(XML_Parser parser, 00544 XML_CommentHandler handler); 00545 00546 XMLPARSEAPI(void) 00547 XML_SetCdataSectionHandler(XML_Parser parser, 00548 XML_StartCdataSectionHandler start, 00549 XML_EndCdataSectionHandler end); 00550 00551 XMLPARSEAPI(void) 00552 XML_SetStartCdataSectionHandler(XML_Parser parser, 00553 XML_StartCdataSectionHandler start); 00554 00555 XMLPARSEAPI(void) 00556 XML_SetEndCdataSectionHandler(XML_Parser parser, 00557 XML_EndCdataSectionHandler end); 00558 00559 /* This sets the default handler and also inhibits expansion of 00560 internal entities. These entity references will be passed to the 00561 default handler, or to the skipped entity handler, if one is set. 00562 */ 00563 XMLPARSEAPI(void) 00564 XML_SetDefaultHandler(XML_Parser parser, 00565 XML_DefaultHandler handler); 00566 00567 /* This sets the default handler but does not inhibit expansion of 00568 internal entities. The entity reference will not be passed to the 00569 default handler. 00570 */ 00571 XMLPARSEAPI(void) 00572 XML_SetDefaultHandlerExpand(XML_Parser parser, 00573 XML_DefaultHandler handler); 00574 00575 XMLPARSEAPI(void) 00576 XML_SetDoctypeDeclHandler(XML_Parser parser, 00577 XML_StartDoctypeDeclHandler start, 00578 XML_EndDoctypeDeclHandler end); 00579 00580 XMLPARSEAPI(void) 00581 XML_SetStartDoctypeDeclHandler(XML_Parser parser, 00582 XML_StartDoctypeDeclHandler start); 00583 00584 XMLPARSEAPI(void) 00585 XML_SetEndDoctypeDeclHandler(XML_Parser parser, 00586 XML_EndDoctypeDeclHandler end); 00587 00588 XMLPARSEAPI(void) 00589 XML_SetUnparsedEntityDeclHandler(XML_Parser parser, 00590 XML_UnparsedEntityDeclHandler handler); 00591 00592 XMLPARSEAPI(void) 00593 XML_SetNotationDeclHandler(XML_Parser parser, 00594 XML_NotationDeclHandler handler); 00595 00596 XMLPARSEAPI(void) 00597 XML_SetNamespaceDeclHandler(XML_Parser parser, 00598 XML_StartNamespaceDeclHandler start, 00599 XML_EndNamespaceDeclHandler end); 00600 00601 XMLPARSEAPI(void) 00602 XML_SetStartNamespaceDeclHandler(XML_Parser parser, 00603 XML_StartNamespaceDeclHandler start); 00604 00605 XMLPARSEAPI(void) 00606 XML_SetEndNamespaceDeclHandler(XML_Parser parser, 00607 XML_EndNamespaceDeclHandler end); 00608 00609 XMLPARSEAPI(void) 00610 XML_SetNotStandaloneHandler(XML_Parser parser, 00611 XML_NotStandaloneHandler handler); 00612 00613 XMLPARSEAPI(void) 00614 XML_SetExternalEntityRefHandler(XML_Parser parser, 00615 XML_ExternalEntityRefHandler handler); 00616 00617 /* If a non-NULL value for arg is specified here, then it will be 00618 passed as the first argument to the external entity ref handler 00619 instead of the parser object. 00620 */ 00621 XMLPARSEAPI(void) 00622 XML_SetExternalEntityRefHandlerArg(XML_Parser, void *arg); 00623 00624 XMLPARSEAPI(void) 00625 XML_SetSkippedEntityHandler(XML_Parser parser, 00626 XML_SkippedEntityHandler handler); 00627 00628 XMLPARSEAPI(void) 00629 XML_SetUnknownEncodingHandler(XML_Parser parser, 00630 XML_UnknownEncodingHandler handler, 00631 void *encodingHandlerData); 00632 00633 /* This can be called within a handler for a start element, end 00634 element, processing instruction or character data. It causes the 00635 corresponding markup to be passed to the default handler. 00636 */ 00637 XMLPARSEAPI(void) 00638 XML_DefaultCurrent(XML_Parser parser); 00639 00640 /* If do_nst is non-zero, and namespace processing is in effect, and 00641 a name has a prefix (i.e. an explicit namespace qualifier) then 00642 that name is returned as a triplet in a single string separated by 00643 the separator character specified when the parser was created: URI 00644 + sep + local_name + sep + prefix. 00645 00646 If do_nst is zero, then namespace information is returned in the 00647 default manner (URI + sep + local_name) whether or not the name 00648 has a prefix. 00649 00650 Note: Calling XML_SetReturnNSTriplet after XML_Parse or 00651 XML_ParseBuffer has no effect. 00652 */ 00653 00654 XMLPARSEAPI(void) 00655 XML_SetReturnNSTriplet(XML_Parser parser, int do_nst); 00656 00657 /* This value is passed as the userData argument to callbacks. */ 00658 XMLPARSEAPI(void) 00659 XML_SetUserData(XML_Parser parser, void *userData); 00660 00661 /* Returns the last value set by XML_SetUserData or NULL. */ 00662 #define XML_GetUserData(parser) (*(void **)(parser)) 00663 00664 /* This is equivalent to supplying an encoding argument to 00665 XML_ParserCreate. On success XML_SetEncoding returns non-zero, 00666 zero otherwise. 00667 Note: Calling XML_SetEncoding after XML_Parse or XML_ParseBuffer 00668 has no effect and returns zero. 00669 */ 00670 XMLPARSEAPI(int) 00671 XML_SetEncoding(XML_Parser parser, const XML_Char *encoding); 00672 00673 /* If this function is called, then the parser will be passed as the 00674 first argument to callbacks instead of userData. The userData will 00675 still be accessible using XML_GetUserData. 00676 */ 00677 XMLPARSEAPI(void) 00678 XML_UseParserAsHandlerArg(XML_Parser parser); 00679 00680 /* If useDTD == XML_TRUE is passed to this function, then the parser 00681 will assume that there is an external subset, even if none is 00682 specified in the document. In such a case the parser will call the 00683 externalEntityRefHandler with a value of NULL for the systemId 00684 argument (the publicId and context arguments will be NULL as well). 00685 Note: If this function is called, then this must be done before 00686 the first call to XML_Parse or XML_ParseBuffer, since it will 00687 have no effect after that. Returns 00688 XML_ERROR_CANT_CHANGE_FEATURE_ONCE_PARSING. 00689 Note: If the document does not have a DOCTYPE declaration at all, 00690 then startDoctypeDeclHandler and endDoctypeDeclHandler will not 00691 be called, despite an external subset being parsed. 00692 Note: If XML_DTD is not defined when Expat is compiled, returns 00693 XML_ERROR_FEATURE_REQUIRES_XML_DTD. 00694 */ 00695 XMLPARSEAPI(enum XML_Error) 00696 XML_UseForeignDTD(XML_Parser parser, XML_Bool useDTD); 00697 00698 00699 /* Sets the base to be used for resolving relative URIs in system 00700 identifiers in declarations. Resolving relative identifiers is 00701 left to the application: this value will be passed through as the 00702 base argument to the XML_ExternalEntityRefHandler, 00703 XML_NotationDeclHandler and XML_UnparsedEntityDeclHandler. The base 00704 argument will be copied. Returns zero if out of memory, non-zero 00705 otherwise. 00706 */ 00707 XMLPARSEAPI(int) 00708 XML_SetBase(XML_Parser parser, const XML_Char *base); 00709 00710 XMLPARSEAPI(const XML_Char *) 00711 XML_GetBase(XML_Parser parser); 00712 00713 /* Returns the number of the attribute/value pairs passed in last call 00714 to the XML_StartElementHandler that were specified in the start-tag 00715 rather than defaulted. Each attribute/value pair counts as 2; thus 00716 this correspondds to an index into the atts array passed to the 00717 XML_StartElementHandler. 00718 */ 00719 XMLPARSEAPI(int) 00720 XML_GetSpecifiedAttributeCount(XML_Parser parser); 00721 00722 /* Returns the index of the ID attribute passed in the last call to 00723 XML_StartElementHandler, or -1 if there is no ID attribute. Each 00724 attribute/value pair counts as 2; thus this correspondds to an 00725 index into the atts array passed to the XML_StartElementHandler. 00726 */ 00727 XMLPARSEAPI(int) 00728 XML_GetIdAttributeIndex(XML_Parser parser); 00729 00730 /* Parses some input. Returns XML_STATUS_ERROR if a fatal error is 00731 detected. The last call to XML_Parse must have isFinal true; len 00732 may be zero for this call (or any other). 00733 00734 The XML_Status enum gives the possible return values for the 00735 XML_Parse and XML_ParseBuffer functions. Though the return values 00736 for these functions has always been described as a Boolean value, 00737 the implementation, at least for the 1.95.x series, has always 00738 returned exactly one of these values. The preprocessor #defines 00739 are included so this stanza can be added to code that still needs 00740 to support older versions of Expat 1.95.x: 00741 00742 #ifndef XML_STATUS_OK 00743 #define XML_STATUS_OK 1 00744 #define XML_STATUS_ERROR 0 00745 #endif 00746 00747 Otherwise, the #define hackery is quite ugly and would have been dropped. 00748 */ 00749 enum XML_Status { 00750 XML_STATUS_ERROR = 0, 00751 #define XML_STATUS_ERROR XML_STATUS_ERROR 00752 XML_STATUS_OK = 1 00753 #define XML_STATUS_OK XML_STATUS_OK 00754 }; 00755 00756 XMLPARSEAPI(enum XML_Status) 00757 XML_Parse(XML_Parser parser, const char *s, int len, int isFinal); 00758 00759 XMLPARSEAPI(void *) 00760 XML_GetBuffer(XML_Parser parser, int len); 00761 00762 XMLPARSEAPI(enum XML_Status) 00763 XML_ParseBuffer(XML_Parser parser, int len, int isFinal); 00764 00765 /* Creates an XML_Parser object that can parse an external general 00766 entity; context is a '\0'-terminated string specifying the parse 00767 context; encoding is a '\0'-terminated string giving the name of 00768 the externally specified encoding, or NULL if there is no 00769 externally specified encoding. The context string consists of a 00770 sequence of tokens separated by formfeeds (\f); a token consisting 00771 of a name specifies that the general entity of the name is open; a 00772 token of the form prefix=uri specifies the namespace for a 00773 particular prefix; a token of the form =uri specifies the default 00774 namespace. This can be called at any point after the first call to 00775 an ExternalEntityRefHandler so longer as the parser has not yet 00776 been freed. The new parser is completely independent and may 00777 safely be used in a separate thread. The handlers and userData are 00778 initialized from the parser argument. Returns 0 if out of memory. 00779 Otherwise returns a new XML_Parser object. 00780 */ 00781 XMLPARSEAPI(XML_Parser) 00782 XML_ExternalEntityParserCreate(XML_Parser parser, 00783 const XML_Char *context, 00784 const XML_Char *encoding); 00785 00786 enum XML_ParamEntityParsing { 00787 XML_PARAM_ENTITY_PARSING_NEVER, 00788 XML_PARAM_ENTITY_PARSING_UNLESS_STANDALONE, 00789 XML_PARAM_ENTITY_PARSING_ALWAYS 00790 }; 00791 00792 /* Controls parsing of parameter entities (including the external DTD 00793 subset). If parsing of parameter entities is enabled, then 00794 references to external parameter entities (including the external 00795 DTD subset) will be passed to the handler set with 00796 XML_SetExternalEntityRefHandler. The context passed will be 0. 00797 00798 Unlike external general entities, external parameter entities can 00799 only be parsed synchronously. If the external parameter entity is 00800 to be parsed, it must be parsed during the call to the external 00801 entity ref handler: the complete sequence of 00802 XML_ExternalEntityParserCreate, XML_Parse/XML_ParseBuffer and 00803 XML_ParserFree calls must be made during this call. After 00804 XML_ExternalEntityParserCreate has been called to create the parser 00805 for the external parameter entity (context must be 0 for this 00806 call), it is illegal to make any calls on the old parser until 00807 XML_ParserFree has been called on the newly created parser. 00808 If the library has been compiled without support for parameter 00809 entity parsing (ie without XML_DTD being defined), then 00810 XML_SetParamEntityParsing will return 0 if parsing of parameter 00811 entities is requested; otherwise it will return non-zero. 00812 Note: If XML_SetParamEntityParsing is called after XML_Parse or 00813 XML_ParseBuffer, then it has no effect and will always return 0. 00814 */ 00815 XMLPARSEAPI(int) 00816 XML_SetParamEntityParsing(XML_Parser parser, 00817 enum XML_ParamEntityParsing parsing); 00818 00819 /* If XML_Parse or XML_ParseBuffer have returned 0, then 00820 XML_GetErrorCode returns information about the error. 00821 */ 00822 XMLPARSEAPI(enum XML_Error) 00823 XML_GetErrorCode(XML_Parser parser); 00824 00825 /* These functions return information about the current parse 00826 location. They may be called when XML_Parse or XML_ParseBuffer 00827 return 0; in this case the location is the location of the 00828 character at which the error was detected. 00829 00830 They may also be called from any other callback called to report 00831 some parse event; in this the location is the location of the first 00832 of the sequence of characters that generated the event. 00833 */ 00834 XMLPARSEAPI(int) XML_GetCurrentLineNumber(XML_Parser parser); 00835 XMLPARSEAPI(int) XML_GetCurrentColumnNumber(XML_Parser parser); 00836 XMLPARSEAPI(long) XML_GetCurrentByteIndex(XML_Parser parser); 00837 00838 /* Return the number of bytes in the current event. 00839 Returns 0 if the event is in an internal entity. 00840 */ 00841 XMLPARSEAPI(int) 00842 XML_GetCurrentByteCount(XML_Parser parser); 00843 00844 /* If XML_CONTEXT_BYTES is defined, returns the input buffer, sets 00845 the integer pointed to by offset to the offset within this buffer 00846 of the current parse position, and sets the integer pointed to by size 00847 to the size of this buffer (the number of input bytes). Otherwise 00848 returns a NULL pointer. Also returns a NULL pointer if a parse isn't 00849 active. 00850 00851 NOTE: The character pointer returned should not be used outside 00852 the handler that makes the call. 00853 */ 00854 XMLPARSEAPI(const char *) 00855 XML_GetInputContext(XML_Parser parser, 00856 int *offset, 00857 int *size); 00858 00859 /* For backwards compatibility with previous versions. */ 00860 #define XML_GetErrorLineNumber XML_GetCurrentLineNumber 00861 #define XML_GetErrorColumnNumber XML_GetCurrentColumnNumber 00862 #define XML_GetErrorByteIndex XML_GetCurrentByteIndex 00863 00864 /* Frees memory used by the parser. */ 00865 XMLPARSEAPI(void) 00866 XML_ParserFree(XML_Parser parser); 00867 00868 /* Returns a string describing the error. */ 00869 XMLPARSEAPI(const XML_Char *) 00870 XML_ErrorString(enum XML_Error code); 00871 00872 /* Return a string containing the version number of this expat */ 00873 XMLPARSEAPI(const XML_LChar *) 00874 XML_ExpatVersion(void); 00875 00876 typedef struct { 00877 int major; 00878 int minor; 00879 int micro; 00880 } XML_Expat_Version; 00881 00882 /* Return an XML_Expat_Version structure containing numeric version 00883 number information for this version of expat. 00884 */ 00885 XMLPARSEAPI(XML_Expat_Version) 00886 XML_ExpatVersionInfo(void); 00887 00888 /* Added in Expat 1.95.5. */ 00889 enum XML_FeatureEnum { 00890 XML_FEATURE_END = 0, 00891 XML_FEATURE_UNICODE, 00892 XML_FEATURE_UNICODE_WCHAR_T, 00893 XML_FEATURE_DTD, 00894 XML_FEATURE_CONTEXT_BYTES, 00895 XML_FEATURE_MIN_SIZE, 00896 XML_FEATURE_SIZEOF_XML_CHAR, 00897 XML_FEATURE_SIZEOF_XML_LCHAR 00898 /* Additional features must be added to the end of this enum. */ 00899 }; 00900 00901 typedef struct { 00902 enum XML_FeatureEnum feature; 00903 XML_LChar *name; 00904 long int value; 00905 } XML_Feature; 00906 00907 #ifndef __SYMBIAN32__ 00908 XMLPARSEAPI(const XML_Feature *) 00909 XML_GetFeatureList(void); 00910 #endif 00911 00912 00913 /* Expat follows the GNU/Linux convention of odd number minor version for 00914 beta/development releases and even number minor version for stable 00915 releases. Micro is bumped with each release, and set to 0 with each 00916 change to major or minor version. 00917 */ 00918 #define XML_MAJOR_VERSION 1 00919 #define XML_MINOR_VERSION 95 00920 #define XML_MICRO_VERSION 5 00921 00922 #ifdef __cplusplus 00923 } 00924 #endif 00925 00926 #endif /* not XmlParse_INCLUDED */