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