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

Generated on Thu Aug 20 22:33:05 2009 for OpenXDAS by  doxygen 1.5.6