Main Page | Modules | Namespace List | Class Hierarchy | Alphabetical List | Class List | File List | Namespace Members | Class Members | File Members | Related Pages

expat.h

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

Generated on Thu Apr 30 02:30:51 2009 for ACS C++ API by doxygen 1.3.8