Main Page   Namespace List   Class Hierarchy   Compound List   File List   Compound Members  

expat.h

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(__BEOS__)
00013 #    define XMLPARSEAPI(type) __declspec(dllimport) type __cdecl
00014 #  else
00015 #    define XMLPARSEAPI(type) type
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   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 XMLPARSEAPI(void)
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 XMLPARSEAPI(void)
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 XMLPARSEAPI(void)
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 XMLPARSEAPI(XML_Parser)
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 XMLPARSEAPI(XML_Parser)
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 XMLPARSEAPI(XML_Parser)
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 /* This is called for the start of the DOCTYPE declaration when the
00222 closing > is encountered, but after processing any external subset. */
00223 typedef void (*XML_EndDoctypeDeclHandler)(void *userData);
00224 
00225 /* This is called for entity declarations. The is_parameter_entity
00226    argument will be non-zero if the entity is a parameter entity, zero
00227    otherwise.
00228 
00229    For internal entities (<!ENTITY foo "bar">), value will
00230    be non-null and systemId, publicID, and notationName will be null.
00231    The value string is NOT null terminated; the length is provided in
00232    the value_length argument. Since it is legal to have zero-length
00233    values, do not use this argument to test for internal entities.
00234 
00235    For external entities, value will be null and systemId will be non-null.
00236    The publicId argument will be null unless a public identifier was
00237    provided. The notationName argument will have a non-null value only
00238    for unparsed entity declarations.
00239 */
00240 
00241 typedef void (*XML_EntityDeclHandler) (void *userData,
00242                                        const XML_Char *entityName,
00243                                        int is_parameter_entity,
00244                                        const XML_Char *value,
00245                                        int value_length,
00246                                        const XML_Char *base,
00247                                        const XML_Char *systemId,
00248                                        const XML_Char *publicId,
00249                                        const XML_Char *notationName);
00250                                        
00251 XMLPARSEAPI(void)
00252 XML_SetEntityDeclHandler(XML_Parser parser,
00253                          XML_EntityDeclHandler handler);
00254 
00255 /* OBSOLETE -- OBSOLETE -- OBSOLETE
00256    This handler has been superceded by the EntityDeclHandler above.
00257    It is provided here for backward compatibility.
00258 This is called for a declaration of an unparsed (NDATA)
00259 entity.  The base argument is whatever was set by XML_SetBase.
00260 The entityName, systemId and notationName arguments will never be null.
00261 The other arguments may be. */
00262 
00263 typedef void (*XML_UnparsedEntityDeclHandler)(void *userData,
00264                                               const XML_Char *entityName,
00265                                               const XML_Char *base,
00266                                               const XML_Char *systemId,
00267                                               const XML_Char *publicId,
00268                                               const XML_Char *notationName);
00269 
00270 /* This is called for a declaration of notation.
00271 The base argument is whatever was set by XML_SetBase.
00272 The notationName will never be null.  The other arguments can be. */
00273 
00274 typedef void (*XML_NotationDeclHandler)(void *userData,
00275                                         const XML_Char *notationName,
00276                                         const XML_Char *base,
00277                                         const XML_Char *systemId,
00278                                         const XML_Char *publicId);
00279 
00280 /* When namespace processing is enabled, these are called once for
00281 each namespace declaration. The call to the start and end element
00282 handlers occur between the calls to the start and end namespace
00283 declaration handlers. For an xmlns attribute, prefix will be null.
00284 For an xmlns="" attribute, uri will be null. */
00285 
00286 typedef void (*XML_StartNamespaceDeclHandler)(void *userData,
00287                                               const XML_Char *prefix,
00288                                               const XML_Char *uri);
00289 
00290 typedef void (*XML_EndNamespaceDeclHandler)(void *userData,
00291                                             const XML_Char *prefix);
00292 
00293 /* This is called if the document is not standalone (it has an
00294 external subset or a reference to a parameter entity, but does not
00295 have standalone="yes"). If this handler returns 0, then processing
00296 will not continue, and the parser will return a
00297 XML_ERROR_NOT_STANDALONE error. */
00298 
00299 typedef int (*XML_NotStandaloneHandler)(void *userData);
00300 
00301 /* This is called for a reference to an external parsed general entity.
00302 The referenced entity is not automatically parsed.
00303 The application can parse it immediately or later using
00304 XML_ExternalEntityParserCreate.
00305 The parser argument is the parser parsing the entity containing the reference;
00306 it can be passed as the parser argument to XML_ExternalEntityParserCreate.
00307 The systemId argument is the system identifier as specified in the entity
00308 declaration; it will not be null.
00309 The base argument is the system identifier that should be used as the base for
00310 resolving systemId if systemId was relative; this is set by XML_SetBase;
00311 it may be null.
00312 The publicId argument is the public identifier as specified in the entity
00313 declaration, or null if none was specified; the whitespace in the public
00314 identifier will have been normalized as required by the XML spec.
00315 The context argument specifies the parsing context in the format
00316 expected by the context argument to
00317 XML_ExternalEntityParserCreate; context is valid only until the handler
00318 returns, so if the referenced entity is to be parsed later, it must be copied.
00319 The handler should return 0 if processing should not continue because of
00320 a fatal error in the handling of the external entity.
00321 In this case the calling parser will return an
00322 XML_ERROR_EXTERNAL_ENTITY_HANDLING error.
00323 Note that unlike other handlers the first argument is the parser, not
00324 userData. */
00325 
00326 typedef int (*XML_ExternalEntityRefHandler)(XML_Parser parser,
00327                                             const XML_Char *context,
00328                                             const XML_Char *base,
00329                                             const XML_Char *systemId,
00330                                             const XML_Char *publicId);
00331 
00332 /* This structure is filled in by the XML_UnknownEncodingHandler
00333 to provide information to the parser about encodings that are unknown
00334 to the parser.
00335 The map[b] member gives information about byte sequences
00336 whose first byte is b.
00337 If map[b] is c where c is >= 0, then b by itself encodes the Unicode scalar
00338 value c.
00339 If map[b] is -1, then the byte sequence is malformed.
00340 If map[b] is -n, where n >= 2, then b is the first byte of an n-byte
00341 sequence that encodes a single Unicode scalar value.
00342 The data member will be passed as the first argument to the convert function.
00343 The convert function is used to convert multibyte sequences;
00344 s will point to a n-byte sequence where map[(unsigned char)*s] == -n.
00345 The convert function must return the Unicode scalar value
00346 represented by this byte sequence or -1 if the byte sequence is malformed.
00347 The convert function may be null if the encoding is a single-byte encoding,
00348 that is if map[b] >= -1 for all bytes b.
00349 When the parser is finished with the encoding, then if release is not null,
00350 it will call release passing it the data member;
00351 once release has been called, the convert function will not be called again.
00352 
00353 Expat places certain restrictions on the encodings that are supported
00354 using this mechanism.
00355 
00356 1. Every ASCII character that can appear in a well-formed XML document,
00357 other than the characters
00358 
00359   $@\^`{}~
00360 
00361 must be represented by a single byte, and that byte must be the
00362 same byte that represents that character in ASCII.
00363 
00364 2. No character may require more than 4 bytes to encode.
00365 
00366 3. All characters encoded must have Unicode scalar values <= 0xFFFF, (i.e.,
00367 characters that would be encoded by surrogates in UTF-16 are  not
00368 allowed).  Note that this restriction doesn't apply to the built-in
00369 support for UTF-8 and UTF-16.
00370 
00371 4. No Unicode character may be encoded by more than one distinct sequence
00372 of bytes. */
00373 
00374 typedef struct {
00375   int map[256];
00376   void *data;
00377   int (*convert)(void *data, const char *s);
00378   void (*release)(void *data);
00379 } XML_Encoding;
00380 
00381 /* This is called for an encoding that is unknown to the parser.
00382 The encodingHandlerData argument is that which was passed as the
00383 second argument to XML_SetUnknownEncodingHandler.
00384 The name argument gives the name of the encoding as specified in
00385 the encoding declaration.
00386 If the callback can provide information about the encoding,
00387 it must fill in the XML_Encoding structure, and return 1.
00388 Otherwise it must return 0.
00389 If info does not describe a suitable encoding,
00390 then the parser will return an XML_UNKNOWN_ENCODING error. */
00391 
00392 typedef int (*XML_UnknownEncodingHandler)(void *encodingHandlerData,
00393                                           const XML_Char *name,
00394                                           XML_Encoding *info);
00395 
00396 XMLPARSEAPI(void)
00397 XML_SetElementHandler(XML_Parser parser,
00398                       XML_StartElementHandler start,
00399                       XML_EndElementHandler end);
00400 
00401 XMLPARSEAPI(void)
00402 XML_SetStartElementHandler(XML_Parser, XML_StartElementHandler);
00403 
00404 XMLPARSEAPI(void)
00405 XML_SetEndElementHandler(XML_Parser, XML_EndElementHandler);
00406 
00407 XMLPARSEAPI(void)
00408 XML_SetCharacterDataHandler(XML_Parser parser,
00409                             XML_CharacterDataHandler handler);
00410 
00411 XMLPARSEAPI(void)
00412 XML_SetProcessingInstructionHandler(XML_Parser parser,
00413                                     XML_ProcessingInstructionHandler handler);
00414 XMLPARSEAPI(void)
00415 XML_SetCommentHandler(XML_Parser parser,
00416                       XML_CommentHandler handler);
00417 
00418 XMLPARSEAPI(void)
00419 XML_SetCdataSectionHandler(XML_Parser parser,
00420                            XML_StartCdataSectionHandler start,
00421                            XML_EndCdataSectionHandler end);
00422 
00423 XMLPARSEAPI(void)
00424 XML_SetStartCdataSectionHandler(XML_Parser parser,
00425                                 XML_StartCdataSectionHandler start);
00426 
00427 XMLPARSEAPI(void)
00428 XML_SetEndCdataSectionHandler(XML_Parser parser,
00429                               XML_EndCdataSectionHandler end);
00430 
00431 /* This sets the default handler and also inhibits expansion of
00432 internal entities.  The entity reference will be passed to the default
00433 handler. */
00434 
00435 XMLPARSEAPI(void)
00436 XML_SetDefaultHandler(XML_Parser parser,
00437                       XML_DefaultHandler handler);
00438 
00439 /* This sets the default handler but does not inhibit expansion of
00440 internal entities.  The entity reference will not be passed to the
00441 default handler. */
00442 
00443 XMLPARSEAPI(void)
00444 XML_SetDefaultHandlerExpand(XML_Parser parser,
00445                             XML_DefaultHandler handler);
00446 
00447 XMLPARSEAPI(void)
00448 XML_SetDoctypeDeclHandler(XML_Parser parser,
00449                           XML_StartDoctypeDeclHandler start,
00450                           XML_EndDoctypeDeclHandler end);
00451 
00452 XMLPARSEAPI(void)
00453 XML_SetStartDoctypeDeclHandler(XML_Parser parser,
00454                                XML_StartDoctypeDeclHandler start);
00455 
00456 XMLPARSEAPI(void)
00457 XML_SetEndDoctypeDeclHandler(XML_Parser parser,
00458                              XML_EndDoctypeDeclHandler end);
00459 
00460 XMLPARSEAPI(void)
00461 XML_SetUnparsedEntityDeclHandler(XML_Parser parser,
00462                                  XML_UnparsedEntityDeclHandler handler);
00463 
00464 XMLPARSEAPI(void)
00465 XML_SetNotationDeclHandler(XML_Parser parser,
00466                            XML_NotationDeclHandler handler);
00467 
00468 XMLPARSEAPI(void)
00469 XML_SetNamespaceDeclHandler(XML_Parser parser,
00470                             XML_StartNamespaceDeclHandler start,
00471                             XML_EndNamespaceDeclHandler end);
00472 
00473 XMLPARSEAPI(void)
00474 XML_SetStartNamespaceDeclHandler(XML_Parser parser,
00475                                  XML_StartNamespaceDeclHandler start);
00476 
00477 XMLPARSEAPI(void)
00478 XML_SetEndNamespaceDeclHandler(XML_Parser parser,
00479                                XML_EndNamespaceDeclHandler end);
00480 
00481 XMLPARSEAPI(void)
00482 XML_SetNotStandaloneHandler(XML_Parser parser,
00483                             XML_NotStandaloneHandler handler);
00484 
00485 XMLPARSEAPI(void)
00486 XML_SetExternalEntityRefHandler(XML_Parser parser,
00487                                 XML_ExternalEntityRefHandler handler);
00488 
00489 /* If a non-null value for arg is specified here, then it will be passed
00490 as the first argument to the external entity ref handler instead
00491 of the parser object. */
00492 XMLPARSEAPI(void)
00493 XML_SetExternalEntityRefHandlerArg(XML_Parser, void *arg);
00494 
00495 XMLPARSEAPI(void)
00496 XML_SetUnknownEncodingHandler(XML_Parser parser,
00497                               XML_UnknownEncodingHandler handler,
00498                               void *encodingHandlerData);
00499 
00500 /* This can be called within a handler for a start element, end element,
00501 processing instruction or character data.  It causes the corresponding
00502 markup to be passed to the default handler. */
00503 XMLPARSEAPI(void)
00504 XML_DefaultCurrent(XML_Parser parser);
00505 
00506 /* If do_nst is non-zero, and namespace processing is in effect, and
00507    a name has a prefix (i.e. an explicit namespace qualifier) then
00508    that name is returned as a triplet in a single
00509    string separated by the separator character specified when the parser
00510    was created: URI + sep + local_name + sep + prefix.
00511 
00512    If do_nst is zero, then namespace information is returned in the
00513    default manner (URI + sep + local_name) whether or not the names
00514    has a prefix.
00515 */
00516 
00517 XMLPARSEAPI(void)
00518 XML_SetReturnNSTriplet(XML_Parser parser, int do_nst);
00519 
00520 /* This value is passed as the userData argument to callbacks. */
00521 XMLPARSEAPI(void)
00522 XML_SetUserData(XML_Parser parser, void *userData);
00523 
00524 /* Returns the last value set by XML_SetUserData or null. */
00525 #define XML_GetUserData(parser) (*(void **)(parser))
00526 
00527 /* This is equivalent to supplying an encoding argument
00528 to XML_ParserCreate. It must not be called after XML_Parse
00529 or XML_ParseBuffer. */
00530 
00531 XMLPARSEAPI(int)
00532 XML_SetEncoding(XML_Parser parser, const XML_Char *encoding);
00533 
00534 /* If this function is called, then the parser will be passed
00535 as the first argument to callbacks instead of userData.
00536 The userData will still be accessible using XML_GetUserData. */
00537 
00538 XMLPARSEAPI(void)
00539 XML_UseParserAsHandlerArg(XML_Parser parser);
00540 
00541 /* Sets the base to be used for resolving relative URIs in system
00542 identifiers in declarations.  Resolving relative identifiers is left
00543 to the application: this value will be passed through as the base
00544 argument to the XML_ExternalEntityRefHandler, XML_NotationDeclHandler
00545 and XML_UnparsedEntityDeclHandler. The base argument will be copied.
00546 Returns zero if out of memory, non-zero otherwise. */
00547 
00548 XMLPARSEAPI(int)
00549 XML_SetBase(XML_Parser parser, const XML_Char *base);
00550 
00551 XMLPARSEAPI(const XML_Char *)
00552 XML_GetBase(XML_Parser parser);
00553 
00554 /* Returns the number of the attribute/value pairs passed in last call
00555 to the XML_StartElementHandler that were specified in the start-tag
00556 rather than defaulted. Each attribute/value pair counts as 2; thus
00557 this correspondds to an index into the atts array passed to the
00558 XML_StartElementHandler. */
00559 
00560 XMLPARSEAPI(int)
00561 XML_GetSpecifiedAttributeCount(XML_Parser parser);
00562 
00563 /* Returns the index of the ID attribute passed in the last call to
00564 XML_StartElementHandler, or -1 if there is no ID attribute.  Each
00565 attribute/value pair counts as 2; thus this correspondds to an index
00566 into the atts array passed to the XML_StartElementHandler. */
00567 
00568 XMLPARSEAPI(int)
00569 XML_GetIdAttributeIndex(XML_Parser parser);
00570 
00571 /* Parses some input. Returns 0 if a fatal error is detected.
00572 The last call to XML_Parse must have isFinal true;
00573 len may be zero for this call (or any other). */
00574 XMLPARSEAPI(int)
00575 XML_Parse(XML_Parser parser, const char *s, int len, int isFinal);
00576 
00577 XMLPARSEAPI(void *)
00578 XML_GetBuffer(XML_Parser parser, int len);
00579 
00580 XMLPARSEAPI(int)
00581 XML_ParseBuffer(XML_Parser parser, int len, int isFinal);
00582 
00583 /* Creates an XML_Parser object that can parse an external general
00584 entity; context is a '\0'-terminated string specifying the parse
00585 context; encoding is a '\0'-terminated string giving the name of the
00586 externally specified encoding, or null if there is no externally
00587 specified encoding.  The context string consists of a sequence of
00588 tokens separated by formfeeds (\f); a token consisting of a name
00589 specifies that the general entity of the name is open; a token of the
00590 form prefix=uri specifies the namespace for a particular prefix; a
00591 token of the form =uri specifies the default namespace.  This can be
00592 called at any point after the first call to an
00593 ExternalEntityRefHandler so longer as the parser has not yet been
00594 freed.  The new parser is completely independent and may safely be
00595 used in a separate thread.  The handlers and userData are initialized
00596 from the parser argument.  Returns 0 if out of memory.  Otherwise
00597 returns a new XML_Parser object. */
00598 XMLPARSEAPI(XML_Parser)
00599 XML_ExternalEntityParserCreate(XML_Parser parser,
00600                                const XML_Char *context,
00601                                const XML_Char *encoding);
00602 
00603 enum XML_ParamEntityParsing {
00604   XML_PARAM_ENTITY_PARSING_NEVER,
00605   XML_PARAM_ENTITY_PARSING_UNLESS_STANDALONE,
00606   XML_PARAM_ENTITY_PARSING_ALWAYS
00607 };
00608 
00609 /* Controls parsing of parameter entities (including the external DTD
00610 subset). If parsing of parameter entities is enabled, then references
00611 to external parameter entities (including the external DTD subset)
00612 will be passed to the handler set with
00613 XML_SetExternalEntityRefHandler.  The context passed will be 0.
00614 Unlike external general entities, external parameter entities can only
00615 be parsed synchronously.  If the external parameter entity is to be
00616 parsed, it must be parsed during the call to the external entity ref
00617 handler: the complete sequence of XML_ExternalEntityParserCreate,
00618 XML_Parse/XML_ParseBuffer and XML_ParserFree calls must be made during
00619 this call.  After XML_ExternalEntityParserCreate has been called to
00620 create the parser for the external parameter entity (context must be 0
00621 for this call), it is illegal to make any calls on the old parser
00622 until XML_ParserFree has been called on the newly created parser.  If
00623 the library has been compiled without support for parameter entity
00624 parsing (ie without XML_DTD being defined), then
00625 XML_SetParamEntityParsing will return 0 if parsing of parameter
00626 entities is requested; otherwise it will return non-zero. */
00627 
00628 XMLPARSEAPI(int)
00629 XML_SetParamEntityParsing(XML_Parser parser,
00630                           enum XML_ParamEntityParsing parsing);
00631 
00632 enum XML_Error {
00633   XML_ERROR_NONE,
00634   XML_ERROR_NO_MEMORY,
00635   XML_ERROR_SYNTAX,
00636   XML_ERROR_NO_ELEMENTS,
00637   XML_ERROR_INVALID_TOKEN,
00638   XML_ERROR_UNCLOSED_TOKEN,
00639   XML_ERROR_PARTIAL_CHAR,
00640   XML_ERROR_TAG_MISMATCH,
00641   XML_ERROR_DUPLICATE_ATTRIBUTE,
00642   XML_ERROR_JUNK_AFTER_DOC_ELEMENT,
00643   XML_ERROR_PARAM_ENTITY_REF,
00644   XML_ERROR_UNDEFINED_ENTITY,
00645   XML_ERROR_RECURSIVE_ENTITY_REF,
00646   XML_ERROR_ASYNC_ENTITY,
00647   XML_ERROR_BAD_CHAR_REF,
00648   XML_ERROR_BINARY_ENTITY_REF,
00649   XML_ERROR_ATTRIBUTE_EXTERNAL_ENTITY_REF,
00650   XML_ERROR_MISPLACED_XML_PI,
00651   XML_ERROR_UNKNOWN_ENCODING,
00652   XML_ERROR_INCORRECT_ENCODING,
00653   XML_ERROR_UNCLOSED_CDATA_SECTION,
00654   XML_ERROR_EXTERNAL_ENTITY_HANDLING,
00655   XML_ERROR_NOT_STANDALONE,
00656   XML_ERROR_UNEXPECTED_STATE
00657 };
00658 
00659 /* If XML_Parse or XML_ParseBuffer have returned 0, then XML_GetErrorCode
00660 returns information about the error. */
00661 
00662 XMLPARSEAPI(enum XML_Error)
00663 XML_GetErrorCode(XML_Parser parser);
00664 
00665 /* These functions return information about the current parse location.
00666 They may be called when XML_Parse or XML_ParseBuffer return 0;
00667 in this case the location is the location of the character at which
00668 the error was detected.
00669 They may also be called from any other callback called to report
00670 some parse event; in this the location is the location of the first
00671 of the sequence of characters that generated the event. */
00672 
00673 XMLPARSEAPI(int) XML_GetCurrentLineNumber(XML_Parser parser);
00674 XMLPARSEAPI(int) XML_GetCurrentColumnNumber(XML_Parser parser);
00675 XMLPARSEAPI(long) XML_GetCurrentByteIndex(XML_Parser parser);
00676 
00677 /* Return the number of bytes in the current event.
00678 Returns 0 if the event is in an internal entity. */
00679 
00680 XMLPARSEAPI(int)
00681 XML_GetCurrentByteCount(XML_Parser parser);
00682 
00683 /* If XML_CONTEXT_BYTES is defined, returns the input buffer, sets
00684    the integer pointed to by offset to the offset within this buffer
00685    of the current parse position, and sets the integer pointed to by size
00686    to the size of this buffer (the number of input bytes). Otherwise
00687    returns a null pointer. Also returns a null pointer if a parse isn't
00688    active.
00689 
00690    NOTE: The character pointer returned should not be used outside
00691    the handler that makes the call. */
00692 
00693 XMLPARSEAPI(const char *)
00694 XML_GetInputContext(XML_Parser parser,
00695                     int *offset,
00696                     int *size);
00697 
00698 /* For backwards compatibility with previous versions. */
00699 #define XML_GetErrorLineNumber XML_GetCurrentLineNumber
00700 #define XML_GetErrorColumnNumber XML_GetCurrentColumnNumber
00701 #define XML_GetErrorByteIndex XML_GetCurrentByteIndex
00702 
00703 /* Frees memory used by the parser. */
00704 XMLPARSEAPI(void)
00705 XML_ParserFree(XML_Parser parser);
00706 
00707 /* Returns a string describing the error. */
00708 XMLPARSEAPI(const XML_LChar *)
00709 XML_ErrorString(int code);
00710 
00711 /* Return a string containing the version number of this expat */
00712 XMLPARSEAPI(const XML_LChar *)
00713 XML_ExpatVersion(void);
00714 
00715 typedef struct {
00716   int major;
00717   int minor;
00718   int micro;
00719 } XML_Expat_Version;
00720 
00721 /* Return an XML_Expat_Version structure containing numeric version
00722    number information for this version of expat */
00723 
00724 XMLPARSEAPI(XML_Expat_Version)
00725 XML_ExpatVersionInfo(void);
00726 
00727 #define XML_MAJOR_VERSION 1
00728 #define XML_MINOR_VERSION 95
00729 #define XML_MICRO_VERSION 2
00730 
00731 #ifdef __cplusplus
00732 }
00733 #endif
00734 
00735 #endif /* not XmlParse_INCLUDED */

Generated on Thu Jul 24 13:31:50 2003 for jabberoo by doxygen1.3-rc3