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

expat.h

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

Generated on Tue May 3 22:31:39 2005 for Autodesk DWF Toolkit by  doxygen 1.4.1