Changeset 38 for trunk/include
- Timestamp:
- Feb 17, 2001, 3:03:14 PM (25 years ago)
- Location:
- trunk/include
- Files:
-
- 9 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/include/expat/expat.h
r36 r38 31 31 typedef char XML_LChar; 32 32 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 33 enum 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 40 41 }; 41 42 42 enum XML_Content_Quant { 43 XML_CQUANT_NONE, 44 XML_CQUANT_OPT, 45 XML_CQUANT_REP, 46 XML_CQUANT_PLUS 43 enum XML_Content_Quant 44 { 45 XML_CQUANT_NONE, 46 XML_CQUANT_OPT, 47 XML_CQUANT_REP, 48 XML_CQUANT_PLUS 47 49 }; 48 50 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 87 typedef 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; 76 114 77 115 … … 82 120 83 121 typedef void (* EXPATENTRY XML_ElementDeclHandler) (void *userData, 84 const XML_Char *name,85 XML_Content*model);122 const XML_Char *name, 123 XMLCONTENT *model); 86 124 87 125 void XMLPARSEAPI XML_SetElementDeclHandler(XML_Parser parser, … … 292 330 have standalone="yes"). If this handler returns 0, then processing 293 331 will not continue, and the parser will return a 294 XML_ERROR_NOT_STANDALONE error. */332 ERROR_EXPAT_NOT_STANDALONE error. */ 295 333 296 334 typedef int (* EXPATENTRY XML_NotStandaloneHandler)(void *userData); … … 316 354 The handler should return 0 if processing should not continue because of 317 355 a fatal error in the handling of the external entity. 318 In this case the calling parser will return an XML_ERROR_EXTERNAL_ENTITY_HANDLING356 In this case the calling parser will return an ERROR_EXPAT_EXTERNAL_ENTITY_HANDLING 319 357 error. 320 358 Note that unlike other handlers the first argument is the parser, not userData. */ … … 406 444 } XML_Encoding; 407 445 408 /* This is called for an encoding that is unknown to the parser.409 The encodingHandlerData argument is that which was passed as the410 second argument to XML_SetUnknownEncodingHandler.411 The name argument gives the name of the encoding as specified in412 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 419 446 typedef int (* EXPATENTRY XML_UnknownEncodingHandler)(void *encodingHandlerData, 420 const XML_Char *name,421 XML_Encoding *info);447 const XML_Char *name, 448 XML_Encoding *info); 422 449 423 450 void XMLPARSEAPI XML_SetElementHandler(XML_Parser parser, 424 XML_StartElementHandler start,425 XML_EndElementHandler end);451 XML_StartElementHandler start, 452 XML_EndElementHandler end); 426 453 427 454 void XMLPARSEAPI XML_SetStartElementHandler(XML_Parser, XML_StartElementHandler); … … 430 457 431 458 void XMLPARSEAPI XML_SetCharacterDataHandler(XML_Parser parser, 432 XML_CharacterDataHandler handler);459 XML_CharacterDataHandler handler); 433 460 434 461 void XMLPARSEAPI XML_SetProcessingInstructionHandler(XML_Parser parser, 435 XML_ProcessingInstructionHandler handler);462 XML_ProcessingInstructionHandler handler); 436 463 void XMLPARSEAPI XML_SetCommentHandler(XML_Parser parser, 437 XML_CommentHandler handler);464 XML_CommentHandler handler); 438 465 439 466 void XMLPARSEAPI XML_SetCdataSectionHandler(XML_Parser parser, 440 XML_StartCdataSectionHandler start,441 XML_EndCdataSectionHandler end);467 XML_StartCdataSectionHandler start, 468 XML_EndCdataSectionHandler end); 442 469 443 470 void XMLPARSEAPI XML_SetStartCdataSectionHandler(XML_Parser parser, … … 594 621 }; 595 622 596 /* Controls parsing of parameter entities (including the external DTD597 subset). If parsing of parameter entities is enabled, then references598 to external parameter entities (including the external DTD subset)599 will be passed to the handler set with600 XML_SetExternalEntityRefHandler. The context passed will be 0.601 Unlike external general entities, external parameter entities can only602 be parsed synchronously. If the external parameter entity is to be603 parsed, it must be parsed during the call to the external entity ref604 handler: the complete sequence of XML_ExternalEntityParserCreate,605 XML_Parse/XML_ParseBuffer and XML_ParserFree calls must be made during606 this call. After XML_ExternalEntityParserCreate has been called to607 create the parser for the external parameter entity (context must be 0608 for this call), it is illegal to make any calls on the old parser609 until XML_ParserFree has been called on the newly created parser. If610 the library has been compiled without support for parameter entity611 parsing (ie without XML_DTD being defined), then612 XML_SetParamEntityParsing will return 0 if parsing of parameter613 entities is requested; otherwise it will return non-zero. */614 615 623 int 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 630 typedef 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; 644 660 645 661 /* If XML_Parse or XML_ParseBuffer have returned 0, then XML_GetErrorCode 646 662 returns information about the error. */ 647 663 648 enum XML_ErrorXMLPARSEAPI XML_GetErrorCode(XML_Parser parser);664 XMLERROR XMLPARSEAPI XML_GetErrorCode(XML_Parser parser); 649 665 650 666 /* These functions return information about the current parse location. … … 687 703 688 704 /* 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] 690 707 691 708 /* Return a string containing the version number of this expat */ -
trunk/include/expat/expat_setup.h
r36 r38 18 18 #define EXPATENTRY _Optlink 19 19 #endif 20 21 #define XML_DTD 1 22 20 23 #endif 21 24 -
trunk/include/expat/xmlrole.h
r36 r38 6 6 #ifndef XmlRole_INCLUDED 7 7 #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 8 12 9 13 #include "expat\xmltok.h" -
trunk/include/expat/xmltok.h
r36 r38 6 6 #ifndef XmlTok_INCLUDED 7 7 #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 8 12 9 13 #ifdef __cplusplus … … 154 158 const char *); 155 159 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 *); 159 163 int (* EXPATENTRY isPublicId)(const ENCODING *enc, 160 164 const char *ptr, -
trunk/include/helpers/linklist.h
r35 r38 153 153 typedef LSTQUERYFIRSTNODE *PLSTQUERYFIRSTNODE; 154 154 155 PLISTNODE XWPENTRY lstQueryLastNode(PLINKLIST pList); 156 typedef PLISTNODE XWPENTRY LSTQUERYLASTNODE(PLINKLIST pList); 157 typedef LSTQUERYLASTNODE *PLSTQUERYLASTNODE; 158 155 159 PLISTNODE XWPENTRY lstNodeFromIndex(PLINKLIST pList, unsigned long ulIndex); 156 160 typedef PLISTNODE XWPENTRY LSTNODEFROMINDEX(PLINKLIST pList, unsigned long ulIndex); -
trunk/include/helpers/stringh.h
r23 r38 35 35 36 36 PSZ strhdup(const char *pszSource); 37 38 int strhcmp(const char *p1, const char *p2); 37 39 38 40 PSZ strhistr(const char *string1, const char *string2); -
trunk/include/helpers/tree.h
r33 r38 107 107 // -- -1: t1 < t2 108 108 // -- +1: t1 > t2 109 typedef int (FNTREE_COMPARE_NODES)(TREE *t1, TREE *t2);110 typedef int (FNTREE_COMPARE_DATA)(TREE *t1, void *pData);109 typedef int XWPENTRY FNTREE_COMPARE_NODES(TREE *t1, TREE *t2); 110 typedef int XWPENTRY FNTREE_COMPARE_DATA(TREE *t1, void *pData); 111 111 112 112 // Define a function type for use with the tree traversal function 113 typedef void (TREE_PROCESS)(TREE *t, void *pUser);113 typedef void XWPENTRY TREE_PROCESS(TREE *t, void *pUser); 114 114 115 115 // Global variables -
trunk/include/helpers/xml.h
r35 r38 8 8 *@@added V0.9.6 (2000-10-29) [umoeller] 9 9 *@@include #include <os2.h> 10 *@@include #include "expat\expat.h" 10 *@@include #include "expat\expat.h" // must come before xml.h 11 11 *@@include #include "helpers\linklist.h" 12 *@@include #include "helpers\tree.h" 12 13 *@@include #include "helpers\xstring.h" 13 14 *@@include #include "helpers\xml.h" … … 36 37 #endif 37 38 38 #define ERROR_DOM_FIRST 14000 39 40 #define ERROR_DOM_INDEX_SIZE (ERROR_DOM_FIRST + 1) 41 #define ERROR_DOM_DOMSTRING_SIZE (ERROR_DOM_FIRST + 2) 42 #define ERROR_DOM_HIERARCHY_REQUEST (ERROR_DOM_FIRST + 3) 43 #define ERROR_DOM_WRONG_DOCUMENT (ERROR_DOM_FIRST + 4) 44 #define ERROR_DOM_INVALID_CHARACTER (ERROR_DOM_FIRST + 5) 45 #define ERROR_DOM_NO_DATA_ALLOWED (ERROR_DOM_FIRST + 6) 46 #define ERROR_DOM_NO_MODIFICATION_ALLOWED (ERROR_DOM_FIRST + 7) 47 #define ERROR_DOM_NOT_FOUND (ERROR_DOM_FIRST + 8) 48 #define ERROR_DOM_NOT_SUPPORTED (ERROR_DOM_FIRST + 9) 49 #define ERROR_DOM_INUSE_ATTRIBUTE (ERROR_DOM_FIRST + 10) 50 51 #define ERROR_DOM_PARSING (ERROR_DOM_FIRST + 11) 52 53 #define DOMNODE_ELEMENT 1 // node is an ELEMENT 54 #define DOMNODE_ATTRIBUTE 2 // node is an ATTRIBUTE 55 #define DOMNODE_TEXT 3 // node is a TEXT node 56 // #define DOMNODE_CDATA_SECTION 4 57 // #define DOMNODE_ENTITY_REFERENCE 5 58 // #define DOMNODE_ENTITY 6 59 // #define DOMNODE_PROCESSING_INSTRUCTION 7 60 #define DOMNODE_COMMENT 8 // node is a COMMENT 61 #define DOMNODE_DOCUMENT 9 // node is a document 62 #define DOMNODE_DOCUMENT_TYPE 10 // node is a DOCUMENTTYPE 63 // #define DOMNODE_DOCUMENT_FRAGMENT 11 64 // #define DOMNODE_NOTATION 12 39 typedef enum _DOMERROR 40 { 41 // validity errors: 42 // START MATCHING ERROR MESSAGES (xmlDescribeError) 43 ERROR_DOM_UNDECLARED_ELEMENT = ERROR_EXPAT_AFTER_LAST, 44 // invalidity: element is undeclared 45 ERROR_DOM_ROOT_ELEMENT_MISNAMED, 46 ERROR_DOM_INVALID_ROOT_ELEMENT, 47 ERROR_DOM_INVALID_SUBELEMENT, 48 // subelement may not appear in its parent element 49 ERROR_DOM_DUPLICATE_ELEMENT_DECL, 50 // more than one declaration for an element type 51 ERROR_DOM_DUPLICATE_ATTRIBUTE_DECL, 52 // more than one declaration for an attribute type 53 ERROR_DOM_UNDECLARED_ATTRIBUTE, 54 // END MATCHING ERROR MESSAGES (xmlDescribeError) 55 56 // error categories: 57 ERROR_DOM_PARSING, 58 ERROR_DOM_VALIDITY, 59 60 // additional DOM errors 61 ERROR_DOM_NODETYPE_NOT_SUPPORTED, 62 // invalid node type in xmlCreateNode 63 ERROR_DOM_NO_DOCUMENT, 64 // cannot find document node 65 ERROR_DOM_NO_ELEMENT, 66 ERROR_DOM_DUPLICATE_DOCTYPE, 67 ERROR_DOM_DOCTYPE_STRUCTURE, 68 // DOCTYPE is given and root element name does not match doctype name 69 ERROR_DOM_INTEGRITY, 70 ERROR_DOM_DUPLICATE_ATTRIBUTE 71 } DOMERROR; 72 73 /* ****************************************************************** 74 * 75 * Most basic node management 76 * 77 ********************************************************************/ 78 79 // content model node types: 80 typedef enum _NODEBASETYPE 81 { 82 DOMNODE_ELEMENT, // node is a DOM ELEMENT 83 DOMNODE_ATTRIBUTE, // node is a DOM ATTRIBUTE 84 DOMNODE_TEXT, // node is a DOM TEXT node 85 // DOMNODE_CDATA_SECTION 4 86 // DOMNODE_ENTITY_REFERENCE 5 87 // DOMNODE_ENTITY 6 88 DOMNODE_PROCESSING_INSTRUCTION, // node is a DOM PI 89 DOMNODE_COMMENT, // node is a DOM COMMENT 90 DOMNODE_DOCUMENT, // node is a DOM document 91 DOMNODE_DOCUMENT_TYPE, // node is a DOM DOCUMENTTYPE 92 // #define DOMNODE_DOCUMENT_FRAGMENT 11 93 // #define DOMNODE_NOTATION 12 94 95 // the following are all CMELEMENTPARTICLE nodes 96 ELEMENTPARTICLE_EMPTY, 97 ELEMENTPARTICLE_ANY, 98 ELEMENTPARTICLE_MIXED, 99 ELEMENTPARTICLE_CHOICE, 100 ELEMENTPARTICLE_SEQ, 101 ELEMENTPARTICLE_NAME, 102 103 ATTRIBUTE_DECLARATION_BASE, // node is a CMATTRIBUTEDECLBASE 104 ATTRIBUTE_DECLARATION, // node is a CMATTRIBUTEDECL 105 ATTRIBUTE_DECLARATION_ENUM // node is a plain NODEBASE, part of an attr value enum 106 } NODEBASETYPE; 107 108 /* 109 *@@ NODEBASE: 110 * "content model" node. With the DOM content models, 111 * this represents an entry in a DTD or XML schema. 112 * 113 *@@added V0.9.9 (2001-02-14) [umoeller] 114 */ 115 116 typedef struct _NODEBASE 117 { 118 TREE Tree; 119 120 NODEBASETYPE ulNodeType; 121 122 XSTRING strNodeName; 123 // node name; 124 // -- for the various DOMNODE_* items, see _DOMNODE; 125 // -- for CMELEMENTPARTICLE nodes, this is the particle's name 126 // -- for CMELEMENTDECLNODE nodes, element name being declared 127 // -- for CMATTRIBUTEDECLBASE nodes, name of element to which this 128 // attrib decl belongs 129 // -- for CMATTRIBUTEDECL nodes, name of attribute; 130 // -- for ATTRIBUTE_DECLARATION_ENUM, attribute value in the 131 // possible values list. 132 133 } NODEBASE, *PNODEBASE; 134 135 /* ****************************************************************** 136 * 137 * DOM level 1 138 * 139 ********************************************************************/ 65 140 66 141 /* 67 142 *@@ DOMNODE: 68 * this represents one node in an XML document. 69 * 70 * Per definition, each XML document is broken down into 71 * DOM nodes. The document itself is represented by a 72 * node with the DOMNODE_DOCUMENT type, which in turn 73 * contains all the other nodes. This thus forms a tree 74 * as shown with xmlParse. 143 * this represents one @DOM node in an @XML document. 144 * 145 * The document itself is represented by a node with the 146 * DOMNODE_DOCUMENT type, which is the root of a tree as 147 * shown with xmlParse. 75 148 * 76 149 * The contents of the members vary according 77 * to ulNodeType: 78 * 79 + ulNodeType pszNodeName pszNodeValue listAttributeNodes 150 * to ulNodeType (0 specifies that the field does not 151 * apply to that type). 152 * 153 * The first member of a DOMNODE is a NODEBASE to allow 154 * inserting these things in a tree. NODEBASE.ulNodeType 155 * _always_ specifies the various types that are using 156 * that structure to allow for type-safety (if we watch out). 157 * This is for faking inheritance. 158 * 159 * Note that we also implement specialized sub-structures of 160 * DOMNODE, whose first member is the DOMNODE (and therefore 161 * a NODEBASE as well): 162 * 163 * -- DOCUMENT nodes are given a _DOMDOCUMENTNODE structure. 164 * 165 * -- DOCTYPE nodes are given a _DOMDOCTYPENODE structure. 166 * 167 * Overview of member fields usage: 80 168 + 81 + ELEMENT tag name 0 named node map 169 + ulNodeType | strNodeName | strNodeValue | llChildren | llAttributes 170 + ======================================================================= 171 + | | | | 172 + DOCUMENT | name from | 0 | 1 root | 0 173 + | DOCTYPE or | | ELEMENT | 174 + | NULL | | | 175 + | | | | 176 + --------------+-------------+--------------+------------+-------------- 177 + | | | | 178 + ELEMENT | tag name | 0 8 | ELEMENT | ATTRIBUTE 179 + | | | nodes | nodes 180 + | | | | 181 + --------------+-------------+--------------+------------+-------------- 182 + | | | | 183 + ATTRIBUTE | attribute | attribute | 0 | 0 184 + | name | value | | 185 + | | | | 186 + --------------+-------------+--------------+------------+-------------- 187 + | | | | 188 + TEXT | 0 | text | 0 | 0 189 + | | contents | | 190 + | | | | 191 + --------------+-------------+--------------+------------+-------------- 192 + | | | | 193 + COMMENT | 0 | comment | 0 | 0 194 + | | contents | | 195 + | | | | 196 + --------------+-------------+--------------+------------+-------------- 197 + | | | | 198 + PI | PI target | PI data | 0 | 0 199 + | | | | 200 + | | | | 201 + --------------+-------------+--------------+------------+-------------- 202 + | | | | 203 + DOCTYPE | doctype | | 0 | 0 204 + | name | | | 205 + | | | | 82 206 + 83 + ATTRIBUTE attribute name attribute value 0 84 + 85 + TEXT 0 text contents 0 86 + 87 + COMMENT 0 comment contents 0 88 + 89 + DOCUMENT 0 0 0 207 * The xwphelpers implementation does not implement CDATA sections, 208 * for which we have no need because @expat properly converts these 209 * into plain @content. 210 * 211 * In addition, W3C DOM specifies that the "node name" members contain 212 * "#document", "#text", and "#comment" strings for DOCUMENT, 213 * TEXT, and COMMENT nodes, respectively. I see no point in this other 214 * than consuming memory, so these fields are empty with this implementation. 90 215 */ 91 216 92 217 typedef struct _DOMNODE 93 218 { 94 ULONG ulNodeType; 95 // one of: 96 // -- DOMNODE_ELEMENT 97 // -- DOMNODE_ATTRIBUTE 98 // -- DOMNODE_TEXT 99 // -- DOMNODE_CDATA_SECTION 100 // -- DOMNODE_ENTITY_REFERENCE 101 // -- DOMNODE_ENTITY 102 // -- DOMNODE_PROCESSING_INSTRUCTION 103 // -- DOMNODE_COMMENT 104 // -- DOMNODE_DOCUMENT: the root document. See @documents. 105 // -- DOMNODE_DOCUMENT_TYPE 106 // -- DOMNODE_DOCUMENT_FRAGMENT 107 // -- DOMNODE_NOTATION 108 109 XSTRING strNodeName; // malloc()'d 110 XSTRING strNodeValue; // malloc()'d 219 NODEBASE NodeBase; 220 221 // PXSTRING pstrNodeName; // ptr is NULL if none 222 PXSTRING pstrNodeValue; // ptr is NULL if none 111 223 112 224 struct _DOMNODE *pParentNode; 113 225 // the parent node; 114 // NULL for DOCUMENT, DOCUMENT_FRAGMENT and ATTR 115 116 LINKLIST llChildNodes; // of DOMNODE* pointers, no auto-free 117 118 LINKLIST llAttributeNodes; // of DOMNODE* pointers, no auto-free 226 // NULL for DOCUMENT, DOCUMENT_FRAGMENT. 227 // The DOM spec says that attribs have no parent, 228 // but even though the attribute is not added to 229 // the "children" list of an element (but to the 230 // attributes map instead), we specify the element 231 // as the attribute's parent here. 232 233 struct _DOMNODE *pDocumentNode; 234 // the document node, unless this is a DOCUMENT in itself. 235 236 LINKLIST llChildren; // of DOMNODE* pointers, no auto-free 237 238 TREE *AttributesMap; // of DOMNODE* pointers 119 239 120 240 } DOMNODE, *PDOMNODE; 121 241 122 #define XMLACTION_BREAKUP 1 123 #define XMLACTION_COPYASTEXT 2 124 125 typedef ULONG _Optlink FNVALIDATE(const char *pcszTag); 126 typedef FNVALIDATE *PFNVALIDATE; 127 128 PDOMNODE xmlCreateNode(PDOMNODE pParentNode, 129 ULONG ulNodeType); 242 /* 243 *@@ DOMDOCTYPENODE: 244 * specific _DOMNODE replacement structure which 245 * is used for DOCTYPE nodes. 246 * 247 * The DOMDOCTYPENODE is special (other than having 248 * extra fields) in that it is stored both in 249 * the document node's children list and in its 250 * pDocType field. 251 * 252 * DOMNODE.pstrNodeName is set to the name in the 253 * DOCTYPE statement by xmlCreateDocumentTypeNode, 254 * or is NULL if there's no DOCTYPE. 255 * 256 *@@added V0.9.9 (2001-02-14) [umoeller] 257 */ 258 259 typedef struct _DOMDOCTYPENODE 260 { 261 DOMNODE DomNode; 262 263 XSTRING strPublicID; 264 XSTRING strSystemID; 265 266 BOOL fHasInternalSubset; 267 268 TREE *ElementDeclsTree; 269 // tree with pointers to _CMELEMENTDECLNODE nodes 270 271 TREE *AttribDeclBasesTree; 272 // tree with pointers to _CMATTRIBUTEDEDECLBASE nodes 273 274 } DOMDOCTYPENODE, *PDOMDOCTYPENODE; 275 276 /* 277 *@@ DOMDOCUMENTNODE: 278 * specific _DOMNODE replacement structure which 279 * is used for DOCUMENT nodes. 280 * 281 *@@added V0.9.9 (2001-02-14) [umoeller] 282 */ 283 284 typedef struct _DOMDOCUMENTNODE 285 { 286 DOMNODE DomNode; 287 288 PDOMDOCTYPENODE pDocType; 289 // != NULL if DOCTYPE was found 290 291 } DOMDOCUMENTNODE, *PDOMDOCUMENTNODE; 292 293 APIRET xmlCreateNode(PDOMNODE pParentNode, 294 ULONG ulNodeType, 295 PDOMNODE *ppNew); 130 296 131 297 ULONG xmlDeleteNode(PDOMNODE pNode); 298 299 /* ****************************************************************** 300 * 301 * DOM level 3 content models 302 * 303 ********************************************************************/ 304 305 // data types (XML schemes): 306 #define STRING_DATATYPE 1 307 #define BOOLEAN_DATATYPE 2 308 #define FLOAT_DATATYPE 3 309 #define DOUBLE_DATATYPE 4 310 #define LONG_DATATYPE 5 311 #define INT_DATATYPE 6 312 #define SHORT_DATATYPE 7 313 #define BYTE_DATATYPE 8 314 315 /* 316 *@@ CMELEMENTPARTICLE: 317 * element declaration particle in a 318 * _CMELEMENTDECLNODE. 319 * 320 * One of these structures is a full 321 * (non-pointer) member in _CMELEMENTDECLNODE. 322 * This struct in turn has a linked list with 323 * possible subnodes. See _CMELEMENTDECLNODE. 324 * 325 *@@added V0.9.9 (2001-02-16) [umoeller] 326 */ 327 328 typedef struct _CMELEMENTPARTICLE 329 { 330 NODEBASE CMNode; // has TREE* as first item in turn 331 // NODEBASE.ulCMNodeType may be one of these: 332 // -- ELEMENTPARTICLE_EMPTY: 333 // ulRepeater will be XML_CQUANT_NONE, rest is NULL 334 // -- ELEMENTPARTICLE_ANY: 335 // ulRepeater will be XML_CQUANT_NONE, rest is NULL 336 // -- ELEMENTPARTICLE_MIXED: 337 // mixed content (with PCDATA); if the list contains 338 // something, the element may have PCDATA and sub-elements 339 // mixed 340 // -- ELEMENTPARTICLE_CHOICE: 341 // list is a choicelist 342 // -- ELEMENTPARTICLE_SEQ: 343 // list is a seqlist 344 // -- ELEMENTPARTICLE_NAME: 345 // used for terminal particles in a parent particle's 346 // list, which finally specifies the name of a sub-particle. 347 // This can never appear in a root particle. 348 349 ULONG ulRepeater; 350 // one of: 351 // -- XML_CQUANT_NONE --> all fields below are NULL 352 // -- XML_CQUANT_OPT, 353 // -- XML_CQUANT_REP, 354 // -- XML_CQUANT_PLUS 355 356 PLINKLIST pllSubNodes; 357 // linked list of sub-CMELEMENTPARTICLE structs 358 // (for mixed, choice, seq types); 359 // if NULL, there's no sub-CMELEMENTPARTICLE 360 361 } CMELEMENTPARTICLE, *PCMELEMENTPARTICLE; 362 363 /* 364 *@@ CMELEMENTDECLNODE: 365 * representation of an @element_declaration within a 366 * _DOMDOCTYPENODE (a document @DTD). 367 * 368 * This is complicated because element declarations 369 * are complicated with nested lists and content 370 * particles. For this, we introduce the representation 371 * of a _CMELEMENTPARTICLE, which is contained in the 372 * "Particle" member. 373 * 374 * For minimal memory consumption, the _CMELEMENTDECLNODE 375 * is an _CMELEMENTPARTICLE with extra fields, while the 376 * list in _CMELEMENTPARTICLE points to plain 377 * _CMELEMENTPARTICLE structs only. 378 * 379 * For the "root" element declaration in the DTD, 380 * Particle.NODEBASE.ulCMNodeType will always be one of the following: 381 * 382 * -- ELEMENTPARTICLE_EMPTY: element must be empty. 383 * 384 * -- ELEMENTPARTICLE_ANY: element can have any content. 385 * 386 * -- ELEMENTPARTICLE_CHOICE: _CMELEMENTPARTICLE has a choicelist with 387 * more _CMELEMENTPARTICLE structs. 388 * 389 * -- ELEMENTPARTICLE_SEQ: _CMELEMENTPARTICLE has a seqlist with 390 * more _CMELEMENTPARTICLE structs. 391 * 392 * -- ELEMENTPARTICLE_MIXED: element can have mixed content including #PCDATA. 393 * If there is no content particle list, then the element may 394 * ONLY have PCDATA. If there's a content particle list, then the 395 * element may have both sub-elements and PCDATA. Oh my. 396 * 397 *@@added V0.9.9 (2001-02-14) [umoeller] 398 */ 399 400 typedef struct _CMELEMENTDECLNODE 401 { 402 CMELEMENTPARTICLE Particle; 403 // root particle for this element decl; this may contain 404 // sub-particles... 405 // this has a NODEBASE as first member, which has TREE* as 406 // first item in turn 407 408 TREE *ParticleNamesTree; 409 // tree sorted by element names with all sub-particles, 410 // no matter how deeply nested; this is just for quickly 411 // checking if an element name is allowed as a sub-element 412 // at all. Tree items are _CMELEMENTPARTICLE nodes. 413 414 } CMELEMENTDECLNODE, *PCMELEMENTDECLNODE; 415 416 typedef enum _ATTRIBCONSTRAINT 417 { 418 CMAT_IMPLIED, 419 CMAT_REQUIRED, 420 CMAT_DEFAULT_VALUE, 421 CMAT_FIXED_VALUE 422 } ATTRIBCONSTRAINT; 423 424 typedef enum _ATTRIBTYPE 425 { 426 CMAT_CDATA, 427 CMAT_ID, 428 CMAT_IDREF, 429 CMAT_IDREFS, 430 CMAT_ENTITY, 431 CMAT_ENTITIES, 432 CMAT_NMTOKEN, 433 CMAT_NMTOKENS, 434 CMAT_ENUM 435 } ATTRIBTYPE; 436 437 /* 438 *@@ CMATTRIBUTEDECL: 439 * single attribute declaration within the attribute 440 * declarations tree in _CMATTRIBUTEDEDECLBASE. 441 * 442 *@@added V0.9.9 (2001-02-16) [umoeller] 443 */ 444 445 typedef struct _CMATTRIBUTEDECL 446 { 447 NODEBASE CMNode; // has TREE* as first item in turn 448 // CMNode.strName is attribute name 449 450 // XSTRING strType; 451 452 ATTRIBTYPE ulAttrType; 453 // one of: 454 // -- CMAT_CDATA 455 // -- CMAT_ID 456 // -- CMAT_IDREF 457 // -- CMAT_IDREFS 458 // -- CMAT_ENTITY 459 // -- CMAT_ENTITIES 460 // -- CMAT_NMTOKEN 461 // -- CMAT_NMTOKENS 462 // -- CMAT_ENUM: pllEnum lists the allowed values. 463 TREE *ValuesTree; 464 // enumeration of allowed values, if CMAT_ENUM; 465 // tree entries are plain NODEBASEs 466 467 ATTRIBCONSTRAINT ulConstraint; 468 // one of: 469 // -- CMAT_IMPLIED: attrib can have any value. 470 // -- CMAT_REQUIRED: attrib must be specified. 471 // -- CMAT_DEFAULT_VALUE: attrib is optional and has default 472 // value as in pstrDefaultValue. 473 // -- CMAT_FIXED_VALUE: attrib is optional, but must have 474 // fixed value as in pstrDefaultValue. 475 PXSTRING pstrDefaultValue; 476 // default value of this attribute; NULL with implied or required 477 478 } CMATTRIBUTEDECL, *PCMATTRIBUTEDECL; 479 480 /* 481 *@@ CMATTRIBUTEDEDECLBASE: 482 * representation of an @attribute_declaration. 483 * 484 * I'd love to have stored the attribute declarations with 485 * the element specifications, but the XML spec says that 486 * attribute declarations are allowed even if no element 487 * declaration exists for the element to which the attribute 488 * belongs. Now, whatever this is good for... anyway, this 489 * forces us to do a second tree in the _DOMDOCTYPENODE node 490 * according to attribute's element names. 491 * 492 *@@added V0.9.9 (2001-02-14) [umoeller] 493 */ 494 495 typedef struct _CMATTRIBUTEDEDECLBASE 496 { 497 NODEBASE CMNode; // has TREE* as first item in turn 498 // CMNode.strName is element name 499 500 TREE *AttribDeclsTree; 501 // root of tree with CMATTRIBUTEDECL; 502 503 } CMATTRIBUTEDEDECLBASE, *PCMATTRIBUTEDEDECLBASE; 504 505 /* 506 *@@ CMENTITYDECLNODE: 507 * 508 * See @entity_declaration. 509 * 510 *@@added V0.9.9 (2001-02-14) [umoeller] 511 */ 512 513 typedef struct _CMENTITYDECLNODE 514 { 515 NODEBASE CMNode; 516 } CMENTITYDECLNODE, *PCMENTITYDECLNODE; 517 518 /* 519 *@@ CMNOTATIONDECLNODE: 520 * 521 * See @notation_declaration. 522 * 523 *@@added V0.9.9 (2001-02-14) [umoeller] 524 */ 525 526 typedef struct _CMNOTATIONDECLNODE 527 { 528 NODEBASE CMNode; 529 } CMNOTATIONDECLNODE, *PCMNOTATIONDECLNODE; 132 530 133 531 /* ****************************************************************** … … 141 539 * DOM instance returned by xmlCreateDOM. 142 540 * 143 *@@added V0.9.9 (200 0-02-14) [umoeller]541 *@@added V0.9.9 (2001-02-14) [umoeller] 144 542 */ 145 543 … … 150 548 */ 151 549 152 PDOMNODE pDocumentNode; 153 154 enum XML_Error Error; 550 PDOMDOCUMENTNODE pDocumentNode; 551 552 PDOMDOCTYPENODE pDocTypeNode; 553 // != NULL only if the document has a DOCTYPE 554 555 APIRET arcDOM; // validation errors etc. 556 BOOL fInvalid; // TRUE after validation failed 557 155 558 const char *pcszErrorDescription; 156 559 ULONG ulErrorLine; 157 560 ULONG ulErrorColumn; 561 PXSTRING pxstrFailingNode; // element or attribute name 158 562 159 563 /* … … 169 573 170 574 PDOMNODE pLastWasTextNode; 575 576 PCMATTRIBUTEDEDECLBASE pAttListDeclCache; 577 // cache for attribute declarations according 578 // to attdecl element name 171 579 } XMLDOM, *PXMLDOM; 580 581 #define DF_PARSECOMMENTS 0x0001 582 #define DF_PARSEDTD 0x0002 172 583 173 584 APIRET xmlCreateDOM(ULONG flParserFlags, … … 181 592 APIRET xmlFreeDOM(PXMLDOM pDom); 182 593 594 PCMELEMENTDECLNODE xmlFindElementDecl(PXMLDOM pDom, 595 const XSTRING *pstrElementName); 596 597 PCMATTRIBUTEDEDECLBASE xmlFindAttribDeclBase(PXMLDOM pDom, 598 const XSTRING *pstrElementName); 599 600 PCMATTRIBUTEDECL xmlFindAttribDecl(PXMLDOM pDom, 601 const XSTRING *pstrElementName, 602 const XSTRING *pstrAttribName); 603 183 604 #endif 184 605 -
trunk/include/helpers/xstring.h
r32 r38 86 86 typedef XSTRCPY *PXSTRCPY; 87 87 88 ULONG XWPENTRY xstrcpys(PXSTRING pxstr, const XSTRING *pcstrSource); 89 typedef ULONG XWPENTRY XSTRCPYS(PXSTRING pxstr, const XSTRING *pcstrSource); 90 typedef XSTRCPYS *PXSTRCPYS; 91 88 92 ULONG XWPENTRY xstrcat(PXSTRING pxstr, const char *pcszSource, ULONG ulSourceLength); 89 93 typedef ULONG XWPENTRY XSTRCAT(PXSTRING pxstr, const char *pcszSource, ULONG ulSourceLength); … … 93 97 typedef ULONG XWPENTRY XSTRCATC(PXSTRING pxstr, CHAR c); 94 98 typedef XSTRCATC *PXSTRCATC; 99 100 ULONG XWPENTRY xstrcats(PXSTRING pxstr, const XSTRING *pcstrSource); 101 typedef ULONG XWPENTRY XSTRCATS(PXSTRING pxstr, const XSTRING *pcstrSource); 102 typedef XSTRCATS *PXSTRCATS; 95 103 96 104 /*
Note:
See TracChangeset
for help on using the changeset viewer.