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