Daniel Veillard | 260a68f | 1998-08-13 03:39:55 +0000 | [diff] [blame] | 1 | /* |
Daniel Veillard | b05deb7 | 1999-08-10 19:04:08 +0000 | [diff] [blame] | 2 | * parser.h : Interfaces, constants and types related to the XML parser. |
Daniel Veillard | 260a68f | 1998-08-13 03:39:55 +0000 | [diff] [blame] | 3 | * |
| 4 | * See Copyright for the status of this software. |
| 5 | * |
Daniel Veillard | 39a1f9a | 1999-01-17 19:11:59 +0000 | [diff] [blame] | 6 | * Daniel.Veillard@w3.org |
Daniel Veillard | 260a68f | 1998-08-13 03:39:55 +0000 | [diff] [blame] | 7 | */ |
| 8 | |
| 9 | #ifndef __XML_PARSER_H__ |
| 10 | #define __XML_PARSER_H__ |
| 11 | |
Daniel Veillard | 361d845 | 2000-04-03 19:48:13 +0000 | [diff] [blame] | 12 | #include <libxml/tree.h> |
| 13 | #include <libxml/valid.h> |
| 14 | #include <libxml/xmlIO.h> |
| 15 | #include <libxml/entities.h> |
Daniel Veillard | 4a53eca | 1999-12-12 13:03:50 +0000 | [diff] [blame] | 16 | |
Daniel Veillard | 260a68f | 1998-08-13 03:39:55 +0000 | [diff] [blame] | 17 | |
| 18 | #ifdef __cplusplus |
| 19 | extern "C" { |
| 20 | #endif |
| 21 | |
| 22 | /* |
| 23 | * Constants. |
| 24 | */ |
| 25 | #define XML_DEFAULT_VERSION "1.0" |
| 26 | |
Daniel Veillard | b05deb7 | 1999-08-10 19:04:08 +0000 | [diff] [blame] | 27 | /** |
| 28 | * an xmlParserInput is an input flow for the XML processor. |
| 29 | * Each entity parsed is associated an xmlParserInput (except the |
| 30 | * few predefined ones). This is the case both for internal entities |
| 31 | * - in which case the flow is already completely in memory - or |
| 32 | * external entities - in which case we use the buf structure for |
| 33 | * progressive reading and I18N conversions to the internal UTF-8 format. |
| 34 | */ |
| 35 | |
Daniel Veillard | dd6b367 | 1999-09-23 22:19:22 +0000 | [diff] [blame] | 36 | typedef void (* xmlParserInputDeallocate)(xmlChar *); |
Daniel Veillard | 71b656e | 2000-01-05 14:46:17 +0000 | [diff] [blame] | 37 | typedef struct _xmlParserInput xmlParserInput; |
| 38 | typedef xmlParserInput *xmlParserInputPtr; |
| 39 | struct _xmlParserInput { |
Daniel Veillard | 14fff06 | 1999-06-22 21:49:07 +0000 | [diff] [blame] | 40 | /* Input buffer */ |
| 41 | xmlParserInputBufferPtr buf; /* UTF-8 encoded buffer */ |
| 42 | |
Daniel Veillard | 260a68f | 1998-08-13 03:39:55 +0000 | [diff] [blame] | 43 | const char *filename; /* The file analyzed, if any */ |
Daniel Veillard | b05deb7 | 1999-08-10 19:04:08 +0000 | [diff] [blame] | 44 | const char *directory; /* the directory/base of teh file */ |
Daniel Veillard | dbfd641 | 1999-12-28 16:35:14 +0000 | [diff] [blame] | 45 | const xmlChar *base; /* Base of the array to parse */ |
| 46 | const xmlChar *cur; /* Current char being parsed */ |
| 47 | int length; /* length if known */ |
Daniel Veillard | 260a68f | 1998-08-13 03:39:55 +0000 | [diff] [blame] | 48 | int line; /* Current line */ |
| 49 | int col; /* Current column */ |
Daniel Veillard | dbfd641 | 1999-12-28 16:35:14 +0000 | [diff] [blame] | 50 | int consumed; /* How many xmlChars already consumed */ |
Daniel Veillard | d692aa4 | 1999-02-28 21:54:31 +0000 | [diff] [blame] | 51 | xmlParserInputDeallocate free; /* function to deallocate the base */ |
Daniel Veillard | cf46199 | 2000-03-14 18:30:20 +0000 | [diff] [blame] | 52 | const xmlChar *encoding; /* the encoding string for entity */ |
| 53 | const xmlChar *version; /* the version string for entity */ |
| 54 | int standalone; /* Was that entity marked standalone */ |
Daniel Veillard | 71b656e | 2000-01-05 14:46:17 +0000 | [diff] [blame] | 55 | }; |
Daniel Veillard | 260a68f | 1998-08-13 03:39:55 +0000 | [diff] [blame] | 56 | |
Daniel Veillard | b05deb7 | 1999-08-10 19:04:08 +0000 | [diff] [blame] | 57 | /** |
| 58 | * the parser can be asked to collect Node informations, i.e. at what |
| 59 | * place in the file they were detected. |
| 60 | * NOTE: This is off by default and not very well tested. |
| 61 | */ |
Daniel Veillard | 71b656e | 2000-01-05 14:46:17 +0000 | [diff] [blame] | 62 | typedef struct _xmlParserNodeInfo xmlParserNodeInfo; |
| 63 | typedef xmlParserNodeInfo *xmlParserNodeInfoPtr; |
| 64 | |
| 65 | struct _xmlParserNodeInfo { |
| 66 | const struct _xmlNode* node; |
Daniel Veillard | 260a68f | 1998-08-13 03:39:55 +0000 | [diff] [blame] | 67 | /* Position & line # that text that created the node begins & ends on */ |
| 68 | unsigned long begin_pos; |
| 69 | unsigned long begin_line; |
| 70 | unsigned long end_pos; |
| 71 | unsigned long end_line; |
Daniel Veillard | 71b656e | 2000-01-05 14:46:17 +0000 | [diff] [blame] | 72 | }; |
Daniel Veillard | 260a68f | 1998-08-13 03:39:55 +0000 | [diff] [blame] | 73 | |
Daniel Veillard | 71b656e | 2000-01-05 14:46:17 +0000 | [diff] [blame] | 74 | typedef struct _xmlParserNodeInfoSeq xmlParserNodeInfoSeq; |
| 75 | typedef xmlParserNodeInfoSeq *xmlParserNodeInfoSeqPtr; |
| 76 | struct _xmlParserNodeInfoSeq { |
Daniel Veillard | 260a68f | 1998-08-13 03:39:55 +0000 | [diff] [blame] | 77 | unsigned long maximum; |
| 78 | unsigned long length; |
| 79 | xmlParserNodeInfo* buffer; |
Daniel Veillard | 71b656e | 2000-01-05 14:46:17 +0000 | [diff] [blame] | 80 | }; |
Daniel Veillard | 260a68f | 1998-08-13 03:39:55 +0000 | [diff] [blame] | 81 | |
Daniel Veillard | b05deb7 | 1999-08-10 19:04:08 +0000 | [diff] [blame] | 82 | /** |
Daniel Veillard | 71b656e | 2000-01-05 14:46:17 +0000 | [diff] [blame] | 83 | * The parser is now working also as a state based parser |
| 84 | * The recursive one use the stagte info for entities processing |
Daniel Veillard | b05deb7 | 1999-08-10 19:04:08 +0000 | [diff] [blame] | 85 | */ |
Daniel Veillard | 00fdf37 | 1999-10-08 09:40:39 +0000 | [diff] [blame] | 86 | typedef enum { |
Daniel Veillard | dbfd641 | 1999-12-28 16:35:14 +0000 | [diff] [blame] | 87 | XML_PARSER_EOF = -1, /* nothing is to be parsed */ |
| 88 | XML_PARSER_START = 0, /* nothing has been parsed */ |
| 89 | XML_PARSER_MISC, /* Misc* before int subset */ |
| 90 | XML_PARSER_PI, /* Whithin a processing instruction */ |
| 91 | XML_PARSER_DTD, /* within some DTD content */ |
| 92 | XML_PARSER_PROLOG, /* Misc* after internal subset */ |
| 93 | XML_PARSER_COMMENT, /* within a comment */ |
| 94 | XML_PARSER_START_TAG, /* within a start tag */ |
| 95 | XML_PARSER_CONTENT, /* within the content */ |
| 96 | XML_PARSER_CDATA_SECTION, /* within a CDATA section */ |
| 97 | XML_PARSER_END_TAG, /* within a closing tag */ |
| 98 | XML_PARSER_ENTITY_DECL, /* within an entity declaration */ |
| 99 | XML_PARSER_ENTITY_VALUE, /* within an entity value in a decl */ |
| 100 | XML_PARSER_ATTRIBUTE_VALUE, /* within an attribute value */ |
Daniel Veillard | cf46199 | 2000-03-14 18:30:20 +0000 | [diff] [blame] | 101 | XML_PARSER_SYSTEM_LITERAL, /* within a SYSTEM value */ |
Daniel Veillard | dbfd641 | 1999-12-28 16:35:14 +0000 | [diff] [blame] | 102 | XML_PARSER_EPILOG /* the Misc* after the last end tag */ |
Daniel Veillard | b05deb7 | 1999-08-10 19:04:08 +0000 | [diff] [blame] | 103 | } xmlParserInputState; |
| 104 | |
| 105 | /** |
| 106 | * The parser context. |
| 107 | * NOTE This doesn't completely defines the parser state, the (current ?) |
| 108 | * design of the parser uses recursive function calls since this allow |
| 109 | * and easy mapping from the production rules of the specification |
| 110 | * to the actual code. The drawback is that the actual function call |
| 111 | * also reflect the parser state. However most of the parsing routines |
| 112 | * takes as the only argument the parser context pointer, so migrating |
| 113 | * to a state based parser for progressive parsing shouldn't be too hard. |
| 114 | */ |
Daniel Veillard | 71b656e | 2000-01-05 14:46:17 +0000 | [diff] [blame] | 115 | typedef struct _xmlParserCtxt xmlParserCtxt; |
| 116 | typedef xmlParserCtxt *xmlParserCtxtPtr; |
| 117 | struct _xmlParserCtxt { |
| 118 | struct _xmlSAXHandler *sax; /* The SAX handler */ |
Daniel Veillard | 517752b | 1999-04-05 12:20:10 +0000 | [diff] [blame] | 119 | void *userData; /* the document being built */ |
| 120 | xmlDocPtr myDoc; /* the document being built */ |
Daniel Veillard | 7f7d111 | 1999-09-22 09:46:25 +0000 | [diff] [blame] | 121 | int wellFormed; /* is the document well formed */ |
Daniel Veillard | 011b63c | 1999-06-02 17:44:04 +0000 | [diff] [blame] | 122 | int replaceEntities; /* shall we replace entities ? */ |
Daniel Veillard | be80396 | 2000-06-28 23:40:59 +0000 | [diff] [blame] | 123 | const xmlChar *version; /* the XML version string */ |
| 124 | const xmlChar *encoding; /* the declared encoding, if any */ |
Daniel Veillard | b05deb7 | 1999-08-10 19:04:08 +0000 | [diff] [blame] | 125 | int standalone; /* standalone document */ |
Daniel Veillard | b05deb7 | 1999-08-10 19:04:08 +0000 | [diff] [blame] | 126 | int html; /* are we parsing an HTML document */ |
Daniel Veillard | 260a68f | 1998-08-13 03:39:55 +0000 | [diff] [blame] | 127 | |
| 128 | /* Input stream stack */ |
| 129 | xmlParserInputPtr input; /* Current input stream */ |
| 130 | int inputNr; /* Number of current input streams */ |
| 131 | int inputMax; /* Max number of input streams */ |
| 132 | xmlParserInputPtr *inputTab; /* stack of inputs */ |
| 133 | |
Daniel Veillard | b05deb7 | 1999-08-10 19:04:08 +0000 | [diff] [blame] | 134 | /* Node analysis stack only used for DOM building */ |
Daniel Veillard | 260a68f | 1998-08-13 03:39:55 +0000 | [diff] [blame] | 135 | xmlNodePtr node; /* Current parsed Node */ |
| 136 | int nodeNr; /* Depth of the parsing stack */ |
| 137 | int nodeMax; /* Max depth of the parsing stack */ |
| 138 | xmlNodePtr *nodeTab; /* array of nodes */ |
| 139 | |
| 140 | int record_info; /* Whether node info should be kept */ |
| 141 | xmlParserNodeInfoSeq node_seq; /* info about each node parsed */ |
Daniel Veillard | 7f7d111 | 1999-09-22 09:46:25 +0000 | [diff] [blame] | 142 | |
Daniel Veillard | dd6b367 | 1999-09-23 22:19:22 +0000 | [diff] [blame] | 143 | int errNo; /* error code */ |
Daniel Veillard | 7f7d111 | 1999-09-22 09:46:25 +0000 | [diff] [blame] | 144 | |
| 145 | int hasExternalSubset; /* reference and external subset */ |
| 146 | int hasPErefs; /* the internal subset has PE refs */ |
| 147 | int external; /* are we parsing an external entity */ |
| 148 | |
| 149 | int valid; /* is the document valid */ |
| 150 | int validate; /* shall we try to validate ? */ |
| 151 | xmlValidCtxt vctxt; /* The validity context */ |
| 152 | |
| 153 | xmlParserInputState instate; /* current type of input */ |
| 154 | int token; /* next char look-ahead */ |
| 155 | |
| 156 | char *directory; /* the data directory */ |
Daniel Veillard | 2673d3c | 1999-10-08 14:37:09 +0000 | [diff] [blame] | 157 | |
Daniel Veillard | cf46199 | 2000-03-14 18:30:20 +0000 | [diff] [blame] | 158 | /* Node name stack */ |
Daniel Veillard | 2673d3c | 1999-10-08 14:37:09 +0000 | [diff] [blame] | 159 | xmlChar *name; /* Current parsed Node */ |
| 160 | int nameNr; /* Depth of the parsing stack */ |
| 161 | int nameMax; /* Max depth of the parsing stack */ |
| 162 | xmlChar * *nameTab; /* array of nodes */ |
| 163 | |
Daniel Veillard | af78a0e | 1999-12-12 13:03:50 +0000 | [diff] [blame] | 164 | long nbChars; /* number of xmlChar processed */ |
Daniel Veillard | dbfd641 | 1999-12-28 16:35:14 +0000 | [diff] [blame] | 165 | long checkIndex; /* used by progressive parsing lookup */ |
Daniel Veillard | 83a30e7 | 2000-03-02 03:33:32 +0000 | [diff] [blame] | 166 | int keepBlanks; /* ugly but ... */ |
Daniel Veillard | cf46199 | 2000-03-14 18:30:20 +0000 | [diff] [blame] | 167 | int disableSAX; /* SAX callbacks are disabled */ |
| 168 | int inSubset; /* Parsing is in int 1/ext 2 subset */ |
| 169 | xmlChar * intSubName; /* name of subset */ |
| 170 | xmlChar * extSubURI; /* URI of external subset */ |
| 171 | xmlChar * extSubSystem; /* SYSTEM ID of external subset */ |
| 172 | |
| 173 | /* xml:space values */ |
| 174 | int * space; /* Should the parser preserve spaces */ |
| 175 | int spaceNr; /* Depth of the parsing stack */ |
| 176 | int spaceMax; /* Max depth of the parsing stack */ |
| 177 | int * spaceTab; /* array of space infos */ |
| 178 | |
| 179 | int depth; /* to prevent entity substitution loops */ |
Daniel Veillard | be80396 | 2000-06-28 23:40:59 +0000 | [diff] [blame] | 180 | xmlParserInputPtr entity; /* used to check entities boundaries */ |
| 181 | int charset; /* encoding of the in-memory content |
| 182 | actually an xmlCharEncoding */ |
| 183 | int nodelen; /* Those two fields are there to */ |
| 184 | int nodemem; /* Speed up large node parsing */ |
Daniel Veillard | 71b656e | 2000-01-05 14:46:17 +0000 | [diff] [blame] | 185 | }; |
Daniel Veillard | 260a68f | 1998-08-13 03:39:55 +0000 | [diff] [blame] | 186 | |
Daniel Veillard | b05deb7 | 1999-08-10 19:04:08 +0000 | [diff] [blame] | 187 | /** |
Daniel Veillard | 260a68f | 1998-08-13 03:39:55 +0000 | [diff] [blame] | 188 | * a SAX Locator. |
| 189 | */ |
Daniel Veillard | 71b656e | 2000-01-05 14:46:17 +0000 | [diff] [blame] | 190 | typedef struct _xmlSAXLocator xmlSAXLocator; |
| 191 | typedef xmlSAXLocator *xmlSAXLocatorPtr; |
| 192 | struct _xmlSAXLocator { |
Daniel Veillard | dd6b367 | 1999-09-23 22:19:22 +0000 | [diff] [blame] | 193 | const xmlChar *(*getPublicId)(void *ctx); |
| 194 | const xmlChar *(*getSystemId)(void *ctx); |
Daniel Veillard | 27d8874 | 1999-05-29 11:51:49 +0000 | [diff] [blame] | 195 | int (*getLineNumber)(void *ctx); |
| 196 | int (*getColumnNumber)(void *ctx); |
Daniel Veillard | 71b656e | 2000-01-05 14:46:17 +0000 | [diff] [blame] | 197 | }; |
Daniel Veillard | 260a68f | 1998-08-13 03:39:55 +0000 | [diff] [blame] | 198 | |
Daniel Veillard | b05deb7 | 1999-08-10 19:04:08 +0000 | [diff] [blame] | 199 | /** |
| 200 | * a SAX handler is bunch of callbacks called by the parser when processing |
| 201 | * of the input generate data or structure informations. |
Daniel Veillard | 260a68f | 1998-08-13 03:39:55 +0000 | [diff] [blame] | 202 | */ |
| 203 | |
Daniel Veillard | 27d8874 | 1999-05-29 11:51:49 +0000 | [diff] [blame] | 204 | typedef xmlParserInputPtr (*resolveEntitySAXFunc) (void *ctx, |
Daniel Veillard | dd6b367 | 1999-09-23 22:19:22 +0000 | [diff] [blame] | 205 | const xmlChar *publicId, const xmlChar *systemId); |
| 206 | typedef void (*internalSubsetSAXFunc) (void *ctx, const xmlChar *name, |
| 207 | const xmlChar *ExternalID, const xmlChar *SystemID); |
Daniel Veillard | cf46199 | 2000-03-14 18:30:20 +0000 | [diff] [blame] | 208 | typedef void (*externalSubsetSAXFunc) (void *ctx, const xmlChar *name, |
| 209 | const xmlChar *ExternalID, const xmlChar *SystemID); |
Daniel Veillard | 27d8874 | 1999-05-29 11:51:49 +0000 | [diff] [blame] | 210 | typedef xmlEntityPtr (*getEntitySAXFunc) (void *ctx, |
Daniel Veillard | dd6b367 | 1999-09-23 22:19:22 +0000 | [diff] [blame] | 211 | const xmlChar *name); |
Daniel Veillard | b05deb7 | 1999-08-10 19:04:08 +0000 | [diff] [blame] | 212 | typedef xmlEntityPtr (*getParameterEntitySAXFunc) (void *ctx, |
Daniel Veillard | dd6b367 | 1999-09-23 22:19:22 +0000 | [diff] [blame] | 213 | const xmlChar *name); |
Daniel Veillard | 27d8874 | 1999-05-29 11:51:49 +0000 | [diff] [blame] | 214 | typedef void (*entityDeclSAXFunc) (void *ctx, |
Daniel Veillard | dd6b367 | 1999-09-23 22:19:22 +0000 | [diff] [blame] | 215 | const xmlChar *name, int type, const xmlChar *publicId, |
| 216 | const xmlChar *systemId, xmlChar *content); |
| 217 | typedef void (*notationDeclSAXFunc)(void *ctx, const xmlChar *name, |
| 218 | const xmlChar *publicId, const xmlChar *systemId); |
| 219 | typedef void (*attributeDeclSAXFunc)(void *ctx, const xmlChar *elem, |
| 220 | const xmlChar *name, int type, int def, |
| 221 | const xmlChar *defaultValue, xmlEnumerationPtr tree); |
| 222 | typedef void (*elementDeclSAXFunc)(void *ctx, const xmlChar *name, |
Daniel Veillard | 517752b | 1999-04-05 12:20:10 +0000 | [diff] [blame] | 223 | int type, xmlElementContentPtr content); |
Daniel Veillard | 27d8874 | 1999-05-29 11:51:49 +0000 | [diff] [blame] | 224 | typedef void (*unparsedEntityDeclSAXFunc)(void *ctx, |
Daniel Veillard | dd6b367 | 1999-09-23 22:19:22 +0000 | [diff] [blame] | 225 | const xmlChar *name, const xmlChar *publicId, |
| 226 | const xmlChar *systemId, const xmlChar *notationName); |
Daniel Veillard | 27d8874 | 1999-05-29 11:51:49 +0000 | [diff] [blame] | 227 | typedef void (*setDocumentLocatorSAXFunc) (void *ctx, |
Daniel Veillard | 260a68f | 1998-08-13 03:39:55 +0000 | [diff] [blame] | 228 | xmlSAXLocatorPtr loc); |
Daniel Veillard | 27d8874 | 1999-05-29 11:51:49 +0000 | [diff] [blame] | 229 | typedef void (*startDocumentSAXFunc) (void *ctx); |
| 230 | typedef void (*endDocumentSAXFunc) (void *ctx); |
Daniel Veillard | dd6b367 | 1999-09-23 22:19:22 +0000 | [diff] [blame] | 231 | typedef void (*startElementSAXFunc) (void *ctx, const xmlChar *name, |
| 232 | const xmlChar **atts); |
| 233 | typedef void (*endElementSAXFunc) (void *ctx, const xmlChar *name); |
| 234 | typedef void (*attributeSAXFunc) (void *ctx, const xmlChar *name, |
| 235 | const xmlChar *value); |
| 236 | typedef void (*referenceSAXFunc) (void *ctx, const xmlChar *name); |
| 237 | typedef void (*charactersSAXFunc) (void *ctx, const xmlChar *ch, |
Daniel Veillard | 517752b | 1999-04-05 12:20:10 +0000 | [diff] [blame] | 238 | int len); |
Daniel Veillard | 27d8874 | 1999-05-29 11:51:49 +0000 | [diff] [blame] | 239 | typedef void (*ignorableWhitespaceSAXFunc) (void *ctx, |
Daniel Veillard | dd6b367 | 1999-09-23 22:19:22 +0000 | [diff] [blame] | 240 | const xmlChar *ch, int len); |
Daniel Veillard | 27d8874 | 1999-05-29 11:51:49 +0000 | [diff] [blame] | 241 | typedef void (*processingInstructionSAXFunc) (void *ctx, |
Daniel Veillard | dd6b367 | 1999-09-23 22:19:22 +0000 | [diff] [blame] | 242 | const xmlChar *target, const xmlChar *data); |
| 243 | typedef void (*commentSAXFunc) (void *ctx, const xmlChar *value); |
| 244 | typedef void (*cdataBlockSAXFunc) (void *ctx, const xmlChar *value, int len); |
Daniel Veillard | 27d8874 | 1999-05-29 11:51:49 +0000 | [diff] [blame] | 245 | typedef void (*warningSAXFunc) (void *ctx, const char *msg, ...); |
| 246 | typedef void (*errorSAXFunc) (void *ctx, const char *msg, ...); |
| 247 | typedef void (*fatalErrorSAXFunc) (void *ctx, const char *msg, ...); |
| 248 | typedef int (*isStandaloneSAXFunc) (void *ctx); |
| 249 | typedef int (*hasInternalSubsetSAXFunc) (void *ctx); |
| 250 | typedef int (*hasExternalSubsetSAXFunc) (void *ctx); |
Daniel Veillard | 260a68f | 1998-08-13 03:39:55 +0000 | [diff] [blame] | 251 | |
Daniel Veillard | 71b656e | 2000-01-05 14:46:17 +0000 | [diff] [blame] | 252 | typedef struct _xmlSAXHandler xmlSAXHandler; |
| 253 | typedef xmlSAXHandler *xmlSAXHandlerPtr; |
| 254 | struct _xmlSAXHandler { |
Daniel Veillard | 517752b | 1999-04-05 12:20:10 +0000 | [diff] [blame] | 255 | internalSubsetSAXFunc internalSubset; |
| 256 | isStandaloneSAXFunc isStandalone; |
| 257 | hasInternalSubsetSAXFunc hasInternalSubset; |
| 258 | hasExternalSubsetSAXFunc hasExternalSubset; |
Daniel Veillard | 260a68f | 1998-08-13 03:39:55 +0000 | [diff] [blame] | 259 | resolveEntitySAXFunc resolveEntity; |
Daniel Veillard | 517752b | 1999-04-05 12:20:10 +0000 | [diff] [blame] | 260 | getEntitySAXFunc getEntity; |
| 261 | entityDeclSAXFunc entityDecl; |
Daniel Veillard | 260a68f | 1998-08-13 03:39:55 +0000 | [diff] [blame] | 262 | notationDeclSAXFunc notationDecl; |
Daniel Veillard | 517752b | 1999-04-05 12:20:10 +0000 | [diff] [blame] | 263 | attributeDeclSAXFunc attributeDecl; |
| 264 | elementDeclSAXFunc elementDecl; |
Daniel Veillard | 260a68f | 1998-08-13 03:39:55 +0000 | [diff] [blame] | 265 | unparsedEntityDeclSAXFunc unparsedEntityDecl; |
| 266 | setDocumentLocatorSAXFunc setDocumentLocator; |
| 267 | startDocumentSAXFunc startDocument; |
| 268 | endDocumentSAXFunc endDocument; |
| 269 | startElementSAXFunc startElement; |
| 270 | endElementSAXFunc endElement; |
Daniel Veillard | 517752b | 1999-04-05 12:20:10 +0000 | [diff] [blame] | 271 | referenceSAXFunc reference; |
Daniel Veillard | 260a68f | 1998-08-13 03:39:55 +0000 | [diff] [blame] | 272 | charactersSAXFunc characters; |
| 273 | ignorableWhitespaceSAXFunc ignorableWhitespace; |
| 274 | processingInstructionSAXFunc processingInstruction; |
Daniel Veillard | 517752b | 1999-04-05 12:20:10 +0000 | [diff] [blame] | 275 | commentSAXFunc comment; |
Daniel Veillard | 260a68f | 1998-08-13 03:39:55 +0000 | [diff] [blame] | 276 | warningSAXFunc warning; |
| 277 | errorSAXFunc error; |
| 278 | fatalErrorSAXFunc fatalError; |
Daniel Veillard | b05deb7 | 1999-08-10 19:04:08 +0000 | [diff] [blame] | 279 | getParameterEntitySAXFunc getParameterEntity; |
| 280 | cdataBlockSAXFunc cdataBlock; |
Daniel Veillard | cf46199 | 2000-03-14 18:30:20 +0000 | [diff] [blame] | 281 | externalSubsetSAXFunc externalSubset; |
Daniel Veillard | 71b656e | 2000-01-05 14:46:17 +0000 | [diff] [blame] | 282 | }; |
Daniel Veillard | 260a68f | 1998-08-13 03:39:55 +0000 | [diff] [blame] | 283 | |
Daniel Veillard | b05deb7 | 1999-08-10 19:04:08 +0000 | [diff] [blame] | 284 | /** |
Daniel Veillard | 686d6b6 | 2000-01-03 11:08:02 +0000 | [diff] [blame] | 285 | * External entity loaders types |
| 286 | */ |
| 287 | typedef xmlParserInputPtr (*xmlExternalEntityLoader)(const char *URL, |
| 288 | const char *ID, |
| 289 | xmlParserCtxtPtr context); |
| 290 | |
| 291 | /** |
Daniel Veillard | 6454aec | 1999-09-02 22:04:43 +0000 | [diff] [blame] | 292 | * Global variables: just the default SAX interface tables and XML |
| 293 | * version infos. |
Daniel Veillard | 260a68f | 1998-08-13 03:39:55 +0000 | [diff] [blame] | 294 | */ |
Daniel Veillard | 14fff06 | 1999-06-22 21:49:07 +0000 | [diff] [blame] | 295 | extern const char *xmlParserVersion; |
| 296 | |
Daniel Veillard | 151b1b0 | 1998-09-23 00:49:46 +0000 | [diff] [blame] | 297 | extern xmlSAXLocator xmlDefaultSAXLocator; |
| 298 | extern xmlSAXHandler xmlDefaultSAXHandler; |
Daniel Veillard | be70ff7 | 1999-07-05 16:50:46 +0000 | [diff] [blame] | 299 | extern xmlSAXHandler htmlDefaultSAXHandler; |
Daniel Veillard | 260a68f | 1998-08-13 03:39:55 +0000 | [diff] [blame] | 300 | |
Daniel Veillard | 6454aec | 1999-09-02 22:04:43 +0000 | [diff] [blame] | 301 | /** |
| 302 | * entity substitution default behaviour. |
| 303 | */ |
| 304 | |
| 305 | extern int xmlSubstituteEntitiesDefaultValue; |
Daniel Veillard | cf46199 | 2000-03-14 18:30:20 +0000 | [diff] [blame] | 306 | extern int xmlGetWarningsDefaultValue; |
Daniel Veillard | 6454aec | 1999-09-02 22:04:43 +0000 | [diff] [blame] | 307 | |
Daniel Veillard | ccb0963 | 1998-10-27 06:21:04 +0000 | [diff] [blame] | 308 | |
Daniel Veillard | b05deb7 | 1999-08-10 19:04:08 +0000 | [diff] [blame] | 309 | /** |
Daniel Veillard | a819dac | 1999-11-24 18:04:22 +0000 | [diff] [blame] | 310 | * Cleanup |
| 311 | */ |
| 312 | void xmlCleanupParser (void); |
| 313 | |
| 314 | /** |
Daniel Veillard | e2d034d | 1999-07-27 19:52:06 +0000 | [diff] [blame] | 315 | * Input functions |
| 316 | */ |
Daniel Veillard | b96e643 | 1999-08-29 21:02:19 +0000 | [diff] [blame] | 317 | int xmlParserInputRead (xmlParserInputPtr in, |
| 318 | int len); |
| 319 | int xmlParserInputGrow (xmlParserInputPtr in, |
| 320 | int len); |
Daniel Veillard | e2d034d | 1999-07-27 19:52:06 +0000 | [diff] [blame] | 321 | |
Daniel Veillard | b05deb7 | 1999-08-10 19:04:08 +0000 | [diff] [blame] | 322 | /** |
Daniel Veillard | dd6b367 | 1999-09-23 22:19:22 +0000 | [diff] [blame] | 323 | * xmlChar handling |
Daniel Veillard | 260a68f | 1998-08-13 03:39:55 +0000 | [diff] [blame] | 324 | */ |
Daniel Veillard | 7a66ee6 | 1999-09-26 11:31:02 +0000 | [diff] [blame] | 325 | xmlChar * xmlStrdup (const xmlChar *cur); |
| 326 | xmlChar * xmlStrndup (const xmlChar *cur, |
Daniel Veillard | b96e643 | 1999-08-29 21:02:19 +0000 | [diff] [blame] | 327 | int len); |
Daniel Veillard | 7a66ee6 | 1999-09-26 11:31:02 +0000 | [diff] [blame] | 328 | xmlChar * xmlStrsub (const xmlChar *str, |
Daniel Veillard | b96e643 | 1999-08-29 21:02:19 +0000 | [diff] [blame] | 329 | int start, |
| 330 | int len); |
Daniel Veillard | dd6b367 | 1999-09-23 22:19:22 +0000 | [diff] [blame] | 331 | const xmlChar * xmlStrchr (const xmlChar *str, |
| 332 | xmlChar val); |
| 333 | const xmlChar * xmlStrstr (const xmlChar *str, |
| 334 | xmlChar *val); |
| 335 | int xmlStrcmp (const xmlChar *str1, |
| 336 | const xmlChar *str2); |
| 337 | int xmlStrncmp (const xmlChar *str1, |
| 338 | const xmlChar *str2, |
Daniel Veillard | b96e643 | 1999-08-29 21:02:19 +0000 | [diff] [blame] | 339 | int len); |
Daniel Veillard | dd6b367 | 1999-09-23 22:19:22 +0000 | [diff] [blame] | 340 | int xmlStrlen (const xmlChar *str); |
Daniel Veillard | 7a66ee6 | 1999-09-26 11:31:02 +0000 | [diff] [blame] | 341 | xmlChar * xmlStrcat (xmlChar *cur, |
Daniel Veillard | dd6b367 | 1999-09-23 22:19:22 +0000 | [diff] [blame] | 342 | const xmlChar *add); |
Daniel Veillard | 7a66ee6 | 1999-09-26 11:31:02 +0000 | [diff] [blame] | 343 | xmlChar * xmlStrncat (xmlChar *cur, |
Daniel Veillard | dd6b367 | 1999-09-23 22:19:22 +0000 | [diff] [blame] | 344 | const xmlChar *add, |
Daniel Veillard | b96e643 | 1999-08-29 21:02:19 +0000 | [diff] [blame] | 345 | int len); |
Daniel Veillard | 260a68f | 1998-08-13 03:39:55 +0000 | [diff] [blame] | 346 | |
Daniel Veillard | b05deb7 | 1999-08-10 19:04:08 +0000 | [diff] [blame] | 347 | /** |
| 348 | * Basic parsing Interfaces |
Daniel Veillard | 39a1f9a | 1999-01-17 19:11:59 +0000 | [diff] [blame] | 349 | */ |
Daniel Veillard | dd6b367 | 1999-09-23 22:19:22 +0000 | [diff] [blame] | 350 | xmlDocPtr xmlParseDoc (xmlChar *cur); |
Daniel Veillard | b96e643 | 1999-08-29 21:02:19 +0000 | [diff] [blame] | 351 | xmlDocPtr xmlParseMemory (char *buffer, |
| 352 | int size); |
| 353 | xmlDocPtr xmlParseFile (const char *filename); |
| 354 | int xmlSubstituteEntitiesDefault(int val); |
Daniel Veillard | 3e6d237 | 2000-03-04 11:39:43 +0000 | [diff] [blame] | 355 | int xmlKeepBlanksDefault (int val); |
Daniel Veillard | 3f6f7f6 | 2000-06-30 17:58:25 +0000 | [diff] [blame] | 356 | void xmlStopParser (xmlParserCtxtPtr ctxt); |
Daniel Veillard | 39a1f9a | 1999-01-17 19:11:59 +0000 | [diff] [blame] | 357 | |
Daniel Veillard | b05deb7 | 1999-08-10 19:04:08 +0000 | [diff] [blame] | 358 | /** |
Daniel Veillard | 39a1f9a | 1999-01-17 19:11:59 +0000 | [diff] [blame] | 359 | * Recovery mode |
| 360 | */ |
Daniel Veillard | dd6b367 | 1999-09-23 22:19:22 +0000 | [diff] [blame] | 361 | xmlDocPtr xmlRecoverDoc (xmlChar *cur); |
Daniel Veillard | b96e643 | 1999-08-29 21:02:19 +0000 | [diff] [blame] | 362 | xmlDocPtr xmlRecoverMemory (char *buffer, |
| 363 | int size); |
| 364 | xmlDocPtr xmlRecoverFile (const char *filename); |
Daniel Veillard | 39a1f9a | 1999-01-17 19:11:59 +0000 | [diff] [blame] | 365 | |
Daniel Veillard | b05deb7 | 1999-08-10 19:04:08 +0000 | [diff] [blame] | 366 | /** |
| 367 | * Less common routines and SAX interfaces |
Daniel Veillard | 39a1f9a | 1999-01-17 19:11:59 +0000 | [diff] [blame] | 368 | */ |
Daniel Veillard | b96e643 | 1999-08-29 21:02:19 +0000 | [diff] [blame] | 369 | int xmlParseDocument (xmlParserCtxtPtr ctxt); |
| 370 | xmlDocPtr xmlSAXParseDoc (xmlSAXHandlerPtr sax, |
Daniel Veillard | dd6b367 | 1999-09-23 22:19:22 +0000 | [diff] [blame] | 371 | xmlChar *cur, |
Daniel Veillard | b96e643 | 1999-08-29 21:02:19 +0000 | [diff] [blame] | 372 | int recovery); |
Daniel Veillard | 7a66ee6 | 1999-09-26 11:31:02 +0000 | [diff] [blame] | 373 | int xmlSAXUserParseFile (xmlSAXHandlerPtr sax, |
| 374 | void *user_data, |
| 375 | const char *filename); |
| 376 | int xmlSAXUserParseMemory (xmlSAXHandlerPtr sax, |
| 377 | void *user_data, |
| 378 | char *buffer, |
| 379 | int size); |
Daniel Veillard | b96e643 | 1999-08-29 21:02:19 +0000 | [diff] [blame] | 380 | xmlDocPtr xmlSAXParseMemory (xmlSAXHandlerPtr sax, |
| 381 | char *buffer, |
| 382 | int size, |
| 383 | int recovery); |
| 384 | xmlDocPtr xmlSAXParseFile (xmlSAXHandlerPtr sax, |
| 385 | const char *filename, |
| 386 | int recovery); |
Daniel Veillard | dd6b367 | 1999-09-23 22:19:22 +0000 | [diff] [blame] | 387 | xmlDtdPtr xmlParseDTD (const xmlChar *ExternalID, |
| 388 | const xmlChar *SystemID); |
Daniel Veillard | b96e643 | 1999-08-29 21:02:19 +0000 | [diff] [blame] | 389 | xmlDtdPtr xmlSAXParseDTD (xmlSAXHandlerPtr sax, |
Daniel Veillard | dd6b367 | 1999-09-23 22:19:22 +0000 | [diff] [blame] | 390 | const xmlChar *ExternalID, |
| 391 | const xmlChar *SystemID); |
Daniel Veillard | cf46199 | 2000-03-14 18:30:20 +0000 | [diff] [blame] | 392 | int xmlParseBalancedChunkMemory(xmlDocPtr doc, |
| 393 | xmlSAXHandlerPtr sax, |
| 394 | void *user_data, |
| 395 | int depth, |
| 396 | const xmlChar *string, |
| 397 | xmlNodePtr *list); |
| 398 | int xmlParseExternalEntity (xmlDocPtr doc, |
| 399 | xmlSAXHandlerPtr sax, |
| 400 | void *user_data, |
| 401 | int depth, |
| 402 | const xmlChar *URL, |
| 403 | const xmlChar *ID, |
| 404 | xmlNodePtr *list); |
Daniel Veillard | 87b9539 | 2000-08-12 21:12:04 +0000 | [diff] [blame] | 405 | int xmlParseCtxtExternalEntity(xmlParserCtxtPtr ctx, |
| 406 | const xmlChar *URL, |
| 407 | const xmlChar *ID, |
| 408 | xmlNodePtr *list); |
Daniel Veillard | cf46199 | 2000-03-14 18:30:20 +0000 | [diff] [blame] | 409 | |
Daniel Veillard | dbfd641 | 1999-12-28 16:35:14 +0000 | [diff] [blame] | 410 | /** |
| 411 | * SAX initialization routines |
| 412 | */ |
| 413 | void xmlDefaultSAXHandlerInit(void); |
| 414 | void htmlDefaultSAXHandlerInit(void); |
| 415 | |
| 416 | /** |
| 417 | * Parser contexts handling. |
| 418 | */ |
Daniel Veillard | b96e643 | 1999-08-29 21:02:19 +0000 | [diff] [blame] | 419 | void xmlInitParserCtxt (xmlParserCtxtPtr ctxt); |
| 420 | void xmlClearParserCtxt (xmlParserCtxtPtr ctxt); |
Daniel Veillard | dbfd641 | 1999-12-28 16:35:14 +0000 | [diff] [blame] | 421 | void xmlFreeParserCtxt (xmlParserCtxtPtr ctxt); |
Daniel Veillard | b96e643 | 1999-08-29 21:02:19 +0000 | [diff] [blame] | 422 | void xmlSetupParserForBuffer (xmlParserCtxtPtr ctxt, |
Daniel Veillard | dd6b367 | 1999-09-23 22:19:22 +0000 | [diff] [blame] | 423 | const xmlChar* buffer, |
Daniel Veillard | b96e643 | 1999-08-29 21:02:19 +0000 | [diff] [blame] | 424 | const char* filename); |
Daniel Veillard | dbfd641 | 1999-12-28 16:35:14 +0000 | [diff] [blame] | 425 | xmlParserCtxtPtr xmlCreateDocParserCtxt (xmlChar *cur); |
| 426 | |
| 427 | /** |
Daniel Veillard | 87b9539 | 2000-08-12 21:12:04 +0000 | [diff] [blame] | 428 | * Reading/setting optional parsing features. |
| 429 | */ |
| 430 | |
| 431 | int xmlGetFeaturesList (int *len, |
| 432 | const char **result); |
| 433 | int xmlGetFeature (xmlParserCtxtPtr ctxt, |
| 434 | const char *name, |
| 435 | void *result); |
| 436 | int xmlSetFeature (xmlParserCtxtPtr ctxt, |
| 437 | const char *name, |
| 438 | void *value); |
| 439 | |
| 440 | /** |
Daniel Veillard | dbfd641 | 1999-12-28 16:35:14 +0000 | [diff] [blame] | 441 | * Interfaces for the Push mode |
| 442 | */ |
| 443 | xmlParserCtxtPtr xmlCreatePushParserCtxt(xmlSAXHandlerPtr sax, |
| 444 | void *user_data, |
| 445 | const char *chunk, |
| 446 | int size, |
| 447 | const char *filename); |
| 448 | int xmlParseChunk (xmlParserCtxtPtr ctxt, |
| 449 | const char *chunk, |
| 450 | int size, |
| 451 | int terminate); |
Daniel Veillard | 260a68f | 1998-08-13 03:39:55 +0000 | [diff] [blame] | 452 | |
Daniel Veillard | b96e643 | 1999-08-29 21:02:19 +0000 | [diff] [blame] | 453 | /** |
Daniel Veillard | 5e873c4 | 2000-04-12 13:27:38 +0000 | [diff] [blame] | 454 | * Special I/O mode |
| 455 | */ |
| 456 | |
| 457 | xmlParserCtxtPtr xmlCreateIOParserCtxt (xmlSAXHandlerPtr sax, |
| 458 | void *user_data, |
| 459 | xmlInputReadCallback ioread, |
| 460 | xmlInputCloseCallback ioclose, |
| 461 | void *ioctx, |
| 462 | xmlCharEncoding enc); |
| 463 | |
| 464 | xmlParserInputPtr xmlNewIOInputStream (xmlParserCtxtPtr ctxt, |
| 465 | xmlParserInputBufferPtr input, |
| 466 | xmlCharEncoding enc); |
| 467 | |
| 468 | /** |
Daniel Veillard | b96e643 | 1999-08-29 21:02:19 +0000 | [diff] [blame] | 469 | * Node infos |
| 470 | */ |
| 471 | const xmlParserNodeInfo* |
| 472 | xmlParserFindNodeInfo (const xmlParserCtxt* ctxt, |
Daniel Veillard | 1e346af | 1999-02-22 10:33:01 +0000 | [diff] [blame] | 473 | const xmlNode* node); |
Daniel Veillard | b96e643 | 1999-08-29 21:02:19 +0000 | [diff] [blame] | 474 | void xmlInitNodeInfoSeq (xmlParserNodeInfoSeqPtr seq); |
| 475 | void xmlClearNodeInfoSeq (xmlParserNodeInfoSeqPtr seq); |
Daniel Veillard | 260a68f | 1998-08-13 03:39:55 +0000 | [diff] [blame] | 476 | unsigned long xmlParserFindNodeInfoIndex(const xmlParserNodeInfoSeq* seq, |
| 477 | const xmlNode* node); |
Daniel Veillard | b96e643 | 1999-08-29 21:02:19 +0000 | [diff] [blame] | 478 | void xmlParserAddNodeInfo (xmlParserCtxtPtr ctxt, |
| 479 | const xmlParserNodeInfo* info); |
Daniel Veillard | 260a68f | 1998-08-13 03:39:55 +0000 | [diff] [blame] | 480 | |
Daniel Veillard | b96e643 | 1999-08-29 21:02:19 +0000 | [diff] [blame] | 481 | /* |
| 482 | * External entities handling actually implemented in xmlIO |
| 483 | */ |
| 484 | |
| 485 | void xmlSetExternalEntityLoader(xmlExternalEntityLoader f); |
| 486 | xmlExternalEntityLoader |
| 487 | xmlGetExternalEntityLoader(void); |
| 488 | xmlParserInputPtr |
| 489 | xmlLoadExternalEntity (const char *URL, |
| 490 | const char *ID, |
Daniel Veillard | 686d6b6 | 2000-01-03 11:08:02 +0000 | [diff] [blame] | 491 | xmlParserCtxtPtr context); |
Daniel Veillard | 4a53eca | 1999-12-12 13:03:50 +0000 | [diff] [blame] | 492 | |
Daniel Veillard | 260a68f | 1998-08-13 03:39:55 +0000 | [diff] [blame] | 493 | #ifdef __cplusplus |
| 494 | } |
| 495 | #endif |
| 496 | |
| 497 | #endif /* __XML_PARSER_H__ */ |
| 498 | |