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