Changeset 38 for trunk/include/expat


Ignore:
Timestamp:
Feb 17, 2001, 3:03:14 PM (25 years ago)
Author:
umoeller
Message:

Updates to XML.

Location:
trunk/include/expat
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/include/expat/expat.h

    r36 r38  
    3131typedef char XML_LChar;
    3232
    33 enum XML_Content_Type {
    34   XML_CTYPE_EMPTY = 1,
    35   XML_CTYPE_ANY,
    36   XML_CTYPE_MIXED,
    37   XML_CTYPE_NAME,
    38   XML_CTYPE_CHOICE,
    39   XML_CTYPE_SEQ
     33enum XML_Content_Type
     34{
     35    XML_CTYPE_EMPTY = 1,
     36    XML_CTYPE_ANY,
     37    XML_CTYPE_MIXED,
     38    XML_CTYPE_NAME,
     39    XML_CTYPE_CHOICE,
     40    XML_CTYPE_SEQ
    4041};
    4142
    42 enum XML_Content_Quant {
    43   XML_CQUANT_NONE,
    44   XML_CQUANT_OPT,
    45   XML_CQUANT_REP,
    46   XML_CQUANT_PLUS
     43enum XML_Content_Quant
     44{
     45    XML_CQUANT_NONE,
     46    XML_CQUANT_OPT,
     47    XML_CQUANT_REP,
     48    XML_CQUANT_PLUS
    4749};
    4850
    49 /* If type == XML_CTYPE_EMPTY or XML_CTYPE_ANY, then quant will be
    50    XML_CQUANT_NONE, and the other fields will be zero or NULL.
    51    If type == XML_CTYPE_MIXED, then quant will be NONE or REP and
    52    numchildren will contain number of elements that may be mixed in
    53    and children point to an array of XML_Content cells that will be
    54    all of XML_CTYPE_NAME type with no quantification.
    55 
    56    If type == XML_CTYPE_NAME, then the name points to the name, and
    57    the numchildren field will be zero and children will be NULL. The
    58    quant fields indicates any quantifiers placed on the name.
    59 
    60    CHOICE and SEQ will have name NULL, the number of children in
    61    numchildren and children will point, recursively, to an array
    62    of XML_Content cells.
    63 
    64    The EMPTY, ANY, and MIXED types will only occur at top level.
    65 */
    66 
    67 typedef struct XML_cp XML_Content;
    68 
    69 struct XML_cp {
    70   enum XML_Content_Type     type;
    71   enum XML_Content_Quant    quant;
    72   const XML_Char *      name;
    73   unsigned int          numchildren;
    74   XML_Content *         children;
    75 };
     51/*
     52 *@@ XMLCONTENT:
     53 *      structure passed with the @expat "element declaration handler"
     54 *      (see XML_SetElementDeclHandler).
     55 *
     56 *      The model argument is the root of a tree of XMLCONTENT
     57 *      nodes. If type equals XML_CTYPE_EMPTY or XML_CTYPE_ANY,
     58 *      then quant will be XML_CQUANT_NONE, and the other fields
     59 *      will be zero or NULL.
     60 *
     61 *      If type is XML_CTYPE_MIXED:
     62 *
     63 *      --  "quant" will be XML_CQUANT_NONE or XML_CQUANT_REP.
     64 *
     65 *      --  "numchildren" will contain the number of elements that
     66 *          are allowed to be mixed in.
     67 *
     68 *      --  "children" points to a sub-array of XMLCONTENT structures
     69 *          that will all have type XML_CTYPE_NAME with no quantification.
     70 *
     71 *      Only the root node can be type XML_CTYPE_EMPTY, XML_CTYPE_ANY,
     72 *      or XML_CTYPE_MIXED.
     73 *
     74 *      For type XML_CTYPE_NAME, the name field points to the
     75 *      name and the numchildren and children fields will be
     76 *      zero and NULL. The quant field will indicate any
     77 *      quantifiers placed on the name.
     78 *
     79 *      Types XML_CTYPE_CHOICE and XML_CTYPE_SEQ indicate a
     80 *      choice or sequence respectively. The numchildren field
     81 *      indicates how many nodes in the choice or sequence and
     82 *      children points to the nodes.
     83 *
     84 *@@added V0.9.9 (2001-02-14) [umoeller]
     85 */
     86
     87typedef struct _XMLCONTENT
     88{
     89    enum XML_Content_Type       type;
     90                    // one of:
     91                    // -- XML_CTYPE_EMPTY   --> quant will be XML_CQUANT_NONE, rest is NULL
     92                    // -- XML_CTYPE_ANY,    --> quant will be XML_CQUANT_NONE, rest is NULL
     93                    // -- XML_CTYPE_MIXED,  --> (#PCDATA) gives us this
     94                    // -- XML_CTYPE_CHOICE, --> choice ("|" list)
     95                    // -- XML_CTYPE_SEQ     --> sequence (comma list)
     96
     97                    // -- XML_CTYPE_NAME: used for sub-content if content has CML_CTYPE_MIXED;
     98                    //                    only "name" is valid for sub-content
     99
     100    enum XML_Content_Quant      quant;
     101                    // one of:
     102                    // -- XML_CQUANT_NONE   --> all fields below are NULL
     103                    // -- XML_CQUANT_OPT,
     104                    // -- XML_CQUANT_REP,
     105                    // -- XML_CQUANT_PLUS
     106
     107    const XML_Char              *name;
     108
     109    unsigned int                numchildren;
     110
     111    struct _XMLCONTENT          *children;
     112
     113} XMLCONTENT, *PXMLCONTENT;
    76114
    77115
     
    82120
    83121typedef void (* EXPATENTRY XML_ElementDeclHandler) (void *userData,
    84                     const XML_Char *name,
    85                     XML_Content *model);
     122                                                    const XML_Char *name,
     123                                                    XMLCONTENT *model);
    86124
    87125void XMLPARSEAPI XML_SetElementDeclHandler(XML_Parser parser,
     
    292330have standalone="yes"). If this handler returns 0, then processing
    293331will not continue, and the parser will return a
    294 XML_ERROR_NOT_STANDALONE error. */
     332ERROR_EXPAT_NOT_STANDALONE error. */
    295333
    296334typedef int (* EXPATENTRY XML_NotStandaloneHandler)(void *userData);
     
    316354The handler should return 0 if processing should not continue because of
    317355a fatal error in the handling of the external entity.
    318 In this case the calling parser will return an XML_ERROR_EXTERNAL_ENTITY_HANDLING
     356In this case the calling parser will return an ERROR_EXPAT_EXTERNAL_ENTITY_HANDLING
    319357error.
    320358Note that unlike other handlers the first argument is the parser, not userData. */
     
    406444} XML_Encoding;
    407445
    408 /* This is called for an encoding that is unknown to the parser.
    409 The encodingHandlerData argument is that which was passed as the
    410 second argument to XML_SetUnknownEncodingHandler.
    411 The name argument gives the name of the encoding as specified in
    412 the encoding declaration.
    413 If the callback can provide information about the encoding,
    414 it must fill in the XML_Encoding structure, and return 1.
    415 Otherwise it must return 0.
    416 If info does not describe a suitable encoding,
    417 then the parser will return an XML_UNKNOWN_ENCODING error. */
    418 
    419446typedef int (* EXPATENTRY XML_UnknownEncodingHandler)(void *encodingHandlerData,
    420                       const XML_Char *name,
    421                       XML_Encoding *info);
     447                                                      const XML_Char *name,
     448                                                      XML_Encoding *info);
    422449
    423450void XMLPARSEAPI XML_SetElementHandler(XML_Parser parser,
    424               XML_StartElementHandler start,
    425               XML_EndElementHandler end);
     451                                       XML_StartElementHandler start,
     452                                       XML_EndElementHandler end);
    426453
    427454void XMLPARSEAPI XML_SetStartElementHandler(XML_Parser, XML_StartElementHandler);
     
    430457
    431458void XMLPARSEAPI XML_SetCharacterDataHandler(XML_Parser parser,
    432                 XML_CharacterDataHandler handler);
     459                                             XML_CharacterDataHandler handler);
    433460
    434461void XMLPARSEAPI XML_SetProcessingInstructionHandler(XML_Parser parser,
    435                     XML_ProcessingInstructionHandler handler);
     462                                                     XML_ProcessingInstructionHandler handler);
    436463void XMLPARSEAPI XML_SetCommentHandler(XML_Parser parser,
    437                       XML_CommentHandler handler);
     464                                       XML_CommentHandler handler);
    438465
    439466void XMLPARSEAPI XML_SetCdataSectionHandler(XML_Parser parser,
    440                XML_StartCdataSectionHandler start,
    441                XML_EndCdataSectionHandler end);
     467                                            XML_StartCdataSectionHandler start,
     468                                            XML_EndCdataSectionHandler end);
    442469
    443470void XMLPARSEAPI XML_SetStartCdataSectionHandler(XML_Parser parser,
     
    594621};
    595622
    596 /* Controls parsing of parameter entities (including the external DTD
    597 subset). If parsing of parameter entities is enabled, then references
    598 to external parameter entities (including the external DTD subset)
    599 will be passed to the handler set with
    600 XML_SetExternalEntityRefHandler.  The context passed will be 0.
    601 Unlike external general entities, external parameter entities can only
    602 be parsed synchronously.  If the external parameter entity is to be
    603 parsed, it must be parsed during the call to the external entity ref
    604 handler: the complete sequence of XML_ExternalEntityParserCreate,
    605 XML_Parse/XML_ParseBuffer and XML_ParserFree calls must be made during
    606 this call.  After XML_ExternalEntityParserCreate has been called to
    607 create the parser for the external parameter entity (context must be 0
    608 for this call), it is illegal to make any calls on the old parser
    609 until XML_ParserFree has been called on the newly created parser.  If
    610 the library has been compiled without support for parameter entity
    611 parsing (ie without XML_DTD being defined), then
    612 XML_SetParamEntityParsing will return 0 if parsing of parameter
    613 entities is requested; otherwise it will return non-zero. */
    614 
    615623int XMLPARSEAPI XML_SetParamEntityParsing(XML_Parser parser,
    616               enum XML_ParamEntityParsing parsing);
    617 
    618 enum XML_Error {
    619   XML_ERROR_NONE,
    620   XML_ERROR_NO_MEMORY,
    621   XML_ERROR_SYNTAX,
    622   XML_ERROR_NO_ELEMENTS,
    623   XML_ERROR_INVALID_TOKEN,
    624   XML_ERROR_UNCLOSED_TOKEN,
    625   XML_ERROR_PARTIAL_CHAR,
    626   XML_ERROR_TAG_MISMATCH,
    627   XML_ERROR_DUPLICATE_ATTRIBUTE,
    628   XML_ERROR_JUNK_AFTER_DOC_ELEMENT,
    629   XML_ERROR_PARAM_ENTITY_REF,
    630   XML_ERROR_UNDEFINED_ENTITY,
    631   XML_ERROR_RECURSIVE_ENTITY_REF,
    632   XML_ERROR_ASYNC_ENTITY,
    633   XML_ERROR_BAD_CHAR_REF,
    634   XML_ERROR_BINARY_ENTITY_REF,
    635   XML_ERROR_ATTRIBUTE_EXTERNAL_ENTITY_REF,
    636   XML_ERROR_MISPLACED_XML_PI,
    637   XML_ERROR_UNKNOWN_ENCODING,
    638   XML_ERROR_INCORRECT_ENCODING,
    639   XML_ERROR_UNCLOSED_CDATA_SECTION,
    640   XML_ERROR_EXTERNAL_ENTITY_HANDLING,
    641   XML_ERROR_NOT_STANDALONE,
    642   XML_ERROR_UNEXPECTED_STATE
    643 };
     624                                          enum XML_ParamEntityParsing parsing);
     625
     626#define ERROR_EXPAT_NONE        0   // explicitly added V0.9.9 (2001-02-14) [umoeller]
     627
     628#define ERROR_XML_FIRST         40000   // first error code used
     629
     630typedef enum _XMLERROR
     631{
     632    // ERROR_EXPAT_NONE,            // removed to adhere with APIRET V0.9.9 (2001-02-14) [umoeller]
     633    ERROR_EXPAT_NO_MEMORY = ERROR_XML_FIRST,
     634    ERROR_EXPAT_SYNTAX,
     635    ERROR_EXPAT_NO_ELEMENTS,
     636    ERROR_EXPAT_INVALID_TOKEN,
     637    ERROR_EXPAT_UNCLOSED_TOKEN,
     638    ERROR_EXPAT_PARTIAL_CHAR,
     639    ERROR_EXPAT_TAG_MISMATCH,
     640    ERROR_EXPAT_DUPLICATE_ATTRIBUTE,
     641    ERROR_EXPAT_JUNK_AFTER_DOC_ELEMENT,
     642    ERROR_EXPAT_PARAM_ENTITY_REF,
     643    ERROR_EXPAT_UNDEFINED_ENTITY,
     644    ERROR_EXPAT_RECURSIVE_ENTITY_REF,
     645    ERROR_EXPAT_ASYNC_ENTITY,
     646    ERROR_EXPAT_BAD_CHAR_REF,
     647    ERROR_EXPAT_BINARY_ENTITY_REF,
     648    ERROR_EXPAT_ATTRIBUTE_EXTERNAL_ENTITY_REF,
     649    ERROR_EXPAT_MISPLACED_XML_PI,
     650    ERROR_EXPAT_UNKNOWN_ENCODING,
     651    ERROR_EXPAT_INCORRECT_ENCODING,
     652    ERROR_EXPAT_UNCLOSED_CDATA_SECTION,
     653    ERROR_EXPAT_EXTERNAL_ENTITY_HANDLING,
     654    ERROR_EXPAT_NOT_STANDALONE,
     655    ERROR_EXPAT_UNEXPECTED_STATE,
     656
     657    ERROR_EXPAT_AFTER_LAST      // added V0.9.9 (2001-02-14) [umoeller];
     658                                // xml.h builds on this
     659} XMLERROR;
    644660
    645661/* If XML_Parse or XML_ParseBuffer have returned 0, then XML_GetErrorCode
    646662returns information about the error. */
    647663
    648 enum XML_Error  XMLPARSEAPI XML_GetErrorCode(XML_Parser parser);
     664XMLERROR  XMLPARSEAPI XML_GetErrorCode(XML_Parser parser);
    649665
    650666/* These functions return information about the current parse location.
     
    687703
    688704/* Returns a string describing the error. */
    689 const XML_LChar XMLPARSEAPI * XML_ErrorString(int code);
     705// const XML_LChar XMLPARSEAPI * XML_ErrorString(int code);
     706        // moved this to xml.c V0.9.9 (2001-02-16) [umoeller]
    690707
    691708/* Return a string containing the version number of this expat */
  • trunk/include/expat/expat_setup.h

    r36 r38  
    1818        #define EXPATENTRY _Optlink
    1919    #endif
     20
     21    #define XML_DTD 1
     22
    2023#endif
    2124
  • trunk/include/expat/xmlrole.h

    r36 r38  
    66#ifndef XmlRole_INCLUDED
    77#define XmlRole_INCLUDED 1
     8
     9#include "expat\expat_setup.h"
     10                        // V0.9.9 (2001-02-10) [umoeller]
     11                        // to save the app from having to include this as well
    812
    913#include "expat\xmltok.h"
  • trunk/include/expat/xmltok.h

    r36 r38  
    66#ifndef XmlTok_INCLUDED
    77#define XmlTok_INCLUDED 1
     8
     9#include "expat\expat_setup.h"
     10                        // V0.9.9 (2001-02-10) [umoeller]
     11                        // to save the app from having to include this as well
    812
    913#ifdef __cplusplus
     
    154158                              const char *);
    155159  void (* EXPATENTRY updatePosition)(const ENCODING *,
    156                          const char *ptr,
    157                          const char *end,
    158                          POSITION *);
     160                                     const char *ptr,
     161                                     const char *end,
     162                                     POSITION *);
    159163  int (* EXPATENTRY isPublicId)(const ENCODING *enc,
    160164                    const char *ptr,
Note: See TracChangeset for help on using the changeset viewer.