SAX based XML parser
Dependents: giken9_HTMLServer_Temp_Sample
xmlrole.h@1:e96b2af301dd, 2011-05-26 (annotated)
- Committer:
- andrewbonney
- Date:
- Thu May 26 10:03:14 2011 +0000
- Revision:
- 1:e96b2af301dd
- Parent:
- 0:07919e3d6c56
Update to reduce buffer sizes
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
andrewbonney | 0:07919e3d6c56 | 1 | /* Copyright (c) 1998, 1999 Thai Open Source Software Center Ltd |
andrewbonney | 0:07919e3d6c56 | 2 | See the file COPYING for copying permission. |
andrewbonney | 0:07919e3d6c56 | 3 | */ |
andrewbonney | 0:07919e3d6c56 | 4 | |
andrewbonney | 0:07919e3d6c56 | 5 | #ifndef XmlRole_INCLUDED |
andrewbonney | 0:07919e3d6c56 | 6 | #define XmlRole_INCLUDED 1 |
andrewbonney | 0:07919e3d6c56 | 7 | |
andrewbonney | 0:07919e3d6c56 | 8 | #ifdef __VMS |
andrewbonney | 0:07919e3d6c56 | 9 | /* 0 1 2 3 0 1 2 3 |
andrewbonney | 0:07919e3d6c56 | 10 | 1234567890123456789012345678901 1234567890123456789012345678901 */ |
andrewbonney | 0:07919e3d6c56 | 11 | #define XmlPrologStateInitExternalEntity XmlPrologStateInitExternalEnt |
andrewbonney | 0:07919e3d6c56 | 12 | #endif |
andrewbonney | 0:07919e3d6c56 | 13 | |
andrewbonney | 0:07919e3d6c56 | 14 | #include "xmltok.h" |
andrewbonney | 0:07919e3d6c56 | 15 | |
andrewbonney | 0:07919e3d6c56 | 16 | #ifdef __cplusplus |
andrewbonney | 0:07919e3d6c56 | 17 | extern "C" { |
andrewbonney | 0:07919e3d6c56 | 18 | #endif |
andrewbonney | 0:07919e3d6c56 | 19 | |
andrewbonney | 0:07919e3d6c56 | 20 | enum { |
andrewbonney | 0:07919e3d6c56 | 21 | XML_ROLE_ERROR = -1, |
andrewbonney | 0:07919e3d6c56 | 22 | XML_ROLE_NONE = 0, |
andrewbonney | 0:07919e3d6c56 | 23 | XML_ROLE_XML_DECL, |
andrewbonney | 0:07919e3d6c56 | 24 | XML_ROLE_INSTANCE_START, |
andrewbonney | 0:07919e3d6c56 | 25 | XML_ROLE_DOCTYPE_NONE, |
andrewbonney | 0:07919e3d6c56 | 26 | XML_ROLE_DOCTYPE_NAME, |
andrewbonney | 0:07919e3d6c56 | 27 | XML_ROLE_DOCTYPE_SYSTEM_ID, |
andrewbonney | 0:07919e3d6c56 | 28 | XML_ROLE_DOCTYPE_PUBLIC_ID, |
andrewbonney | 0:07919e3d6c56 | 29 | XML_ROLE_DOCTYPE_INTERNAL_SUBSET, |
andrewbonney | 0:07919e3d6c56 | 30 | XML_ROLE_DOCTYPE_CLOSE, |
andrewbonney | 0:07919e3d6c56 | 31 | XML_ROLE_GENERAL_ENTITY_NAME, |
andrewbonney | 0:07919e3d6c56 | 32 | XML_ROLE_PARAM_ENTITY_NAME, |
andrewbonney | 0:07919e3d6c56 | 33 | XML_ROLE_ENTITY_NONE, |
andrewbonney | 0:07919e3d6c56 | 34 | XML_ROLE_ENTITY_VALUE, |
andrewbonney | 0:07919e3d6c56 | 35 | XML_ROLE_ENTITY_SYSTEM_ID, |
andrewbonney | 0:07919e3d6c56 | 36 | XML_ROLE_ENTITY_PUBLIC_ID, |
andrewbonney | 0:07919e3d6c56 | 37 | XML_ROLE_ENTITY_COMPLETE, |
andrewbonney | 0:07919e3d6c56 | 38 | XML_ROLE_ENTITY_NOTATION_NAME, |
andrewbonney | 0:07919e3d6c56 | 39 | XML_ROLE_NOTATION_NONE, |
andrewbonney | 0:07919e3d6c56 | 40 | XML_ROLE_NOTATION_NAME, |
andrewbonney | 0:07919e3d6c56 | 41 | XML_ROLE_NOTATION_SYSTEM_ID, |
andrewbonney | 0:07919e3d6c56 | 42 | XML_ROLE_NOTATION_NO_SYSTEM_ID, |
andrewbonney | 0:07919e3d6c56 | 43 | XML_ROLE_NOTATION_PUBLIC_ID, |
andrewbonney | 0:07919e3d6c56 | 44 | XML_ROLE_ATTRIBUTE_NAME, |
andrewbonney | 0:07919e3d6c56 | 45 | XML_ROLE_ATTRIBUTE_TYPE_CDATA, |
andrewbonney | 0:07919e3d6c56 | 46 | XML_ROLE_ATTRIBUTE_TYPE_ID, |
andrewbonney | 0:07919e3d6c56 | 47 | XML_ROLE_ATTRIBUTE_TYPE_IDREF, |
andrewbonney | 0:07919e3d6c56 | 48 | XML_ROLE_ATTRIBUTE_TYPE_IDREFS, |
andrewbonney | 0:07919e3d6c56 | 49 | XML_ROLE_ATTRIBUTE_TYPE_ENTITY, |
andrewbonney | 0:07919e3d6c56 | 50 | XML_ROLE_ATTRIBUTE_TYPE_ENTITIES, |
andrewbonney | 0:07919e3d6c56 | 51 | XML_ROLE_ATTRIBUTE_TYPE_NMTOKEN, |
andrewbonney | 0:07919e3d6c56 | 52 | XML_ROLE_ATTRIBUTE_TYPE_NMTOKENS, |
andrewbonney | 0:07919e3d6c56 | 53 | XML_ROLE_ATTRIBUTE_ENUM_VALUE, |
andrewbonney | 0:07919e3d6c56 | 54 | XML_ROLE_ATTRIBUTE_NOTATION_VALUE, |
andrewbonney | 0:07919e3d6c56 | 55 | XML_ROLE_ATTLIST_NONE, |
andrewbonney | 0:07919e3d6c56 | 56 | XML_ROLE_ATTLIST_ELEMENT_NAME, |
andrewbonney | 0:07919e3d6c56 | 57 | XML_ROLE_IMPLIED_ATTRIBUTE_VALUE, |
andrewbonney | 0:07919e3d6c56 | 58 | XML_ROLE_REQUIRED_ATTRIBUTE_VALUE, |
andrewbonney | 0:07919e3d6c56 | 59 | XML_ROLE_DEFAULT_ATTRIBUTE_VALUE, |
andrewbonney | 0:07919e3d6c56 | 60 | XML_ROLE_FIXED_ATTRIBUTE_VALUE, |
andrewbonney | 0:07919e3d6c56 | 61 | XML_ROLE_ELEMENT_NONE, |
andrewbonney | 0:07919e3d6c56 | 62 | XML_ROLE_ELEMENT_NAME, |
andrewbonney | 0:07919e3d6c56 | 63 | XML_ROLE_CONTENT_ANY, |
andrewbonney | 0:07919e3d6c56 | 64 | XML_ROLE_CONTENT_EMPTY, |
andrewbonney | 0:07919e3d6c56 | 65 | XML_ROLE_CONTENT_PCDATA, |
andrewbonney | 0:07919e3d6c56 | 66 | XML_ROLE_GROUP_OPEN, |
andrewbonney | 0:07919e3d6c56 | 67 | XML_ROLE_GROUP_CLOSE, |
andrewbonney | 0:07919e3d6c56 | 68 | XML_ROLE_GROUP_CLOSE_REP, |
andrewbonney | 0:07919e3d6c56 | 69 | XML_ROLE_GROUP_CLOSE_OPT, |
andrewbonney | 0:07919e3d6c56 | 70 | XML_ROLE_GROUP_CLOSE_PLUS, |
andrewbonney | 0:07919e3d6c56 | 71 | XML_ROLE_GROUP_CHOICE, |
andrewbonney | 0:07919e3d6c56 | 72 | XML_ROLE_GROUP_SEQUENCE, |
andrewbonney | 0:07919e3d6c56 | 73 | XML_ROLE_CONTENT_ELEMENT, |
andrewbonney | 0:07919e3d6c56 | 74 | XML_ROLE_CONTENT_ELEMENT_REP, |
andrewbonney | 0:07919e3d6c56 | 75 | XML_ROLE_CONTENT_ELEMENT_OPT, |
andrewbonney | 0:07919e3d6c56 | 76 | XML_ROLE_CONTENT_ELEMENT_PLUS, |
andrewbonney | 0:07919e3d6c56 | 77 | XML_ROLE_PI, |
andrewbonney | 0:07919e3d6c56 | 78 | XML_ROLE_COMMENT, |
andrewbonney | 0:07919e3d6c56 | 79 | #ifdef XML_DTD |
andrewbonney | 0:07919e3d6c56 | 80 | XML_ROLE_TEXT_DECL, |
andrewbonney | 0:07919e3d6c56 | 81 | XML_ROLE_IGNORE_SECT, |
andrewbonney | 0:07919e3d6c56 | 82 | XML_ROLE_INNER_PARAM_ENTITY_REF, |
andrewbonney | 0:07919e3d6c56 | 83 | #endif /* XML_DTD */ |
andrewbonney | 0:07919e3d6c56 | 84 | XML_ROLE_PARAM_ENTITY_REF |
andrewbonney | 0:07919e3d6c56 | 85 | }; |
andrewbonney | 0:07919e3d6c56 | 86 | |
andrewbonney | 0:07919e3d6c56 | 87 | typedef struct prolog_state { |
andrewbonney | 0:07919e3d6c56 | 88 | int (PTRCALL *handler) (struct prolog_state *state, |
andrewbonney | 0:07919e3d6c56 | 89 | int tok, |
andrewbonney | 0:07919e3d6c56 | 90 | const char *ptr, |
andrewbonney | 0:07919e3d6c56 | 91 | const char *end, |
andrewbonney | 0:07919e3d6c56 | 92 | const ENCODING *enc); |
andrewbonney | 0:07919e3d6c56 | 93 | unsigned level; |
andrewbonney | 0:07919e3d6c56 | 94 | int role_none; |
andrewbonney | 0:07919e3d6c56 | 95 | #ifdef XML_DTD |
andrewbonney | 0:07919e3d6c56 | 96 | unsigned includeLevel; |
andrewbonney | 0:07919e3d6c56 | 97 | int documentEntity; |
andrewbonney | 0:07919e3d6c56 | 98 | int inEntityValue; |
andrewbonney | 0:07919e3d6c56 | 99 | #endif /* XML_DTD */ |
andrewbonney | 0:07919e3d6c56 | 100 | } PROLOG_STATE; |
andrewbonney | 0:07919e3d6c56 | 101 | |
andrewbonney | 0:07919e3d6c56 | 102 | void XmlPrologStateInit(PROLOG_STATE *); |
andrewbonney | 0:07919e3d6c56 | 103 | #ifdef XML_DTD |
andrewbonney | 0:07919e3d6c56 | 104 | void XmlPrologStateInitExternalEntity(PROLOG_STATE *); |
andrewbonney | 0:07919e3d6c56 | 105 | #endif /* XML_DTD */ |
andrewbonney | 0:07919e3d6c56 | 106 | |
andrewbonney | 0:07919e3d6c56 | 107 | #define XmlTokenRole(state, tok, ptr, end, enc) \ |
andrewbonney | 0:07919e3d6c56 | 108 | (((state)->handler)(state, tok, ptr, end, enc)) |
andrewbonney | 0:07919e3d6c56 | 109 | |
andrewbonney | 0:07919e3d6c56 | 110 | #ifdef __cplusplus |
andrewbonney | 0:07919e3d6c56 | 111 | } |
andrewbonney | 0:07919e3d6c56 | 112 | #endif |
andrewbonney | 0:07919e3d6c56 | 113 | |
andrewbonney | 0:07919e3d6c56 | 114 | #endif /* not XmlRole_INCLUDED */ |