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 | b513f5a | 2000-09-10 14:01:12 +0000 | [diff] [blame] | 119 | void *userData; /* For SAX interface only, used by DOM build */ |
Daniel Veillard | 517752b | 1999-04-05 12:20:10 +0000 | [diff] [blame] | 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 | b513f5a | 2000-09-10 14:01:12 +0000 | [diff] [blame] | 126 | int html; /* an HTML(1)/Docbook(2) 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 | f0cc7cc | 2000-08-26 21:40:43 +0000 | [diff] [blame] | 185 | int pedantic; /* signal pedantic warnings */ |
Daniel Veillard | b513f5a | 2000-09-10 14:01:12 +0000 | [diff] [blame] | 186 | void *_private; /* For user data, libxml won't touch it */ |
Daniel Veillard | 71b656e | 2000-01-05 14:46:17 +0000 | [diff] [blame] | 187 | }; |
Daniel Veillard | 260a68f | 1998-08-13 03:39:55 +0000 | [diff] [blame] | 188 | |
Daniel Veillard | b05deb7 | 1999-08-10 19:04:08 +0000 | [diff] [blame] | 189 | /** |
Daniel Veillard | 260a68f | 1998-08-13 03:39:55 +0000 | [diff] [blame] | 190 | * a SAX Locator. |
| 191 | */ |
Daniel Veillard | 71b656e | 2000-01-05 14:46:17 +0000 | [diff] [blame] | 192 | typedef struct _xmlSAXLocator xmlSAXLocator; |
| 193 | typedef xmlSAXLocator *xmlSAXLocatorPtr; |
| 194 | struct _xmlSAXLocator { |
Daniel Veillard | dd6b367 | 1999-09-23 22:19:22 +0000 | [diff] [blame] | 195 | const xmlChar *(*getPublicId)(void *ctx); |
| 196 | const xmlChar *(*getSystemId)(void *ctx); |
Daniel Veillard | 27d8874 | 1999-05-29 11:51:49 +0000 | [diff] [blame] | 197 | int (*getLineNumber)(void *ctx); |
| 198 | int (*getColumnNumber)(void *ctx); |
Daniel Veillard | 71b656e | 2000-01-05 14:46:17 +0000 | [diff] [blame] | 199 | }; |
Daniel Veillard | 260a68f | 1998-08-13 03:39:55 +0000 | [diff] [blame] | 200 | |
Daniel Veillard | b05deb7 | 1999-08-10 19:04:08 +0000 | [diff] [blame] | 201 | /** |
| 202 | * a SAX handler is bunch of callbacks called by the parser when processing |
| 203 | * of the input generate data or structure informations. |
Daniel Veillard | 260a68f | 1998-08-13 03:39:55 +0000 | [diff] [blame] | 204 | */ |
| 205 | |
Daniel Veillard | 27d8874 | 1999-05-29 11:51:49 +0000 | [diff] [blame] | 206 | typedef xmlParserInputPtr (*resolveEntitySAXFunc) (void *ctx, |
Daniel Veillard | dd6b367 | 1999-09-23 22:19:22 +0000 | [diff] [blame] | 207 | const xmlChar *publicId, const xmlChar *systemId); |
| 208 | typedef void (*internalSubsetSAXFunc) (void *ctx, const xmlChar *name, |
| 209 | const xmlChar *ExternalID, const xmlChar *SystemID); |
Daniel Veillard | cf46199 | 2000-03-14 18:30:20 +0000 | [diff] [blame] | 210 | typedef void (*externalSubsetSAXFunc) (void *ctx, const xmlChar *name, |
| 211 | const xmlChar *ExternalID, const xmlChar *SystemID); |
Daniel Veillard | 27d8874 | 1999-05-29 11:51:49 +0000 | [diff] [blame] | 212 | typedef xmlEntityPtr (*getEntitySAXFunc) (void *ctx, |
Daniel Veillard | dd6b367 | 1999-09-23 22:19:22 +0000 | [diff] [blame] | 213 | const xmlChar *name); |
Daniel Veillard | b05deb7 | 1999-08-10 19:04:08 +0000 | [diff] [blame] | 214 | typedef xmlEntityPtr (*getParameterEntitySAXFunc) (void *ctx, |
Daniel Veillard | dd6b367 | 1999-09-23 22:19:22 +0000 | [diff] [blame] | 215 | const xmlChar *name); |
Daniel Veillard | 27d8874 | 1999-05-29 11:51:49 +0000 | [diff] [blame] | 216 | typedef void (*entityDeclSAXFunc) (void *ctx, |
Daniel Veillard | dd6b367 | 1999-09-23 22:19:22 +0000 | [diff] [blame] | 217 | const xmlChar *name, int type, const xmlChar *publicId, |
| 218 | const xmlChar *systemId, xmlChar *content); |
| 219 | typedef void (*notationDeclSAXFunc)(void *ctx, const xmlChar *name, |
| 220 | const xmlChar *publicId, const xmlChar *systemId); |
| 221 | typedef void (*attributeDeclSAXFunc)(void *ctx, const xmlChar *elem, |
| 222 | const xmlChar *name, int type, int def, |
| 223 | const xmlChar *defaultValue, xmlEnumerationPtr tree); |
| 224 | typedef void (*elementDeclSAXFunc)(void *ctx, const xmlChar *name, |
Daniel Veillard | 517752b | 1999-04-05 12:20:10 +0000 | [diff] [blame] | 225 | int type, xmlElementContentPtr content); |
Daniel Veillard | 27d8874 | 1999-05-29 11:51:49 +0000 | [diff] [blame] | 226 | typedef void (*unparsedEntityDeclSAXFunc)(void *ctx, |
Daniel Veillard | dd6b367 | 1999-09-23 22:19:22 +0000 | [diff] [blame] | 227 | const xmlChar *name, const xmlChar *publicId, |
| 228 | const xmlChar *systemId, const xmlChar *notationName); |
Daniel Veillard | 27d8874 | 1999-05-29 11:51:49 +0000 | [diff] [blame] | 229 | typedef void (*setDocumentLocatorSAXFunc) (void *ctx, |
Daniel Veillard | 260a68f | 1998-08-13 03:39:55 +0000 | [diff] [blame] | 230 | xmlSAXLocatorPtr loc); |
Daniel Veillard | 27d8874 | 1999-05-29 11:51:49 +0000 | [diff] [blame] | 231 | typedef void (*startDocumentSAXFunc) (void *ctx); |
| 232 | typedef void (*endDocumentSAXFunc) (void *ctx); |
Daniel Veillard | dd6b367 | 1999-09-23 22:19:22 +0000 | [diff] [blame] | 233 | typedef void (*startElementSAXFunc) (void *ctx, const xmlChar *name, |
| 234 | const xmlChar **atts); |
| 235 | typedef void (*endElementSAXFunc) (void *ctx, const xmlChar *name); |
| 236 | typedef void (*attributeSAXFunc) (void *ctx, const xmlChar *name, |
| 237 | const xmlChar *value); |
| 238 | typedef void (*referenceSAXFunc) (void *ctx, const xmlChar *name); |
| 239 | typedef void (*charactersSAXFunc) (void *ctx, const xmlChar *ch, |
Daniel Veillard | 517752b | 1999-04-05 12:20:10 +0000 | [diff] [blame] | 240 | int len); |
Daniel Veillard | 27d8874 | 1999-05-29 11:51:49 +0000 | [diff] [blame] | 241 | typedef void (*ignorableWhitespaceSAXFunc) (void *ctx, |
Daniel Veillard | dd6b367 | 1999-09-23 22:19:22 +0000 | [diff] [blame] | 242 | const xmlChar *ch, int len); |
Daniel Veillard | 27d8874 | 1999-05-29 11:51:49 +0000 | [diff] [blame] | 243 | typedef void (*processingInstructionSAXFunc) (void *ctx, |
Daniel Veillard | dd6b367 | 1999-09-23 22:19:22 +0000 | [diff] [blame] | 244 | const xmlChar *target, const xmlChar *data); |
| 245 | typedef void (*commentSAXFunc) (void *ctx, const xmlChar *value); |
| 246 | typedef void (*cdataBlockSAXFunc) (void *ctx, const xmlChar *value, int len); |
Daniel Veillard | 27d8874 | 1999-05-29 11:51:49 +0000 | [diff] [blame] | 247 | typedef void (*warningSAXFunc) (void *ctx, const char *msg, ...); |
| 248 | typedef void (*errorSAXFunc) (void *ctx, const char *msg, ...); |
| 249 | typedef void (*fatalErrorSAXFunc) (void *ctx, const char *msg, ...); |
| 250 | typedef int (*isStandaloneSAXFunc) (void *ctx); |
| 251 | typedef int (*hasInternalSubsetSAXFunc) (void *ctx); |
| 252 | typedef int (*hasExternalSubsetSAXFunc) (void *ctx); |
Daniel Veillard | 260a68f | 1998-08-13 03:39:55 +0000 | [diff] [blame] | 253 | |
Daniel Veillard | 71b656e | 2000-01-05 14:46:17 +0000 | [diff] [blame] | 254 | typedef struct _xmlSAXHandler xmlSAXHandler; |
| 255 | typedef xmlSAXHandler *xmlSAXHandlerPtr; |
| 256 | struct _xmlSAXHandler { |
Daniel Veillard | 517752b | 1999-04-05 12:20:10 +0000 | [diff] [blame] | 257 | internalSubsetSAXFunc internalSubset; |
| 258 | isStandaloneSAXFunc isStandalone; |
| 259 | hasInternalSubsetSAXFunc hasInternalSubset; |
| 260 | hasExternalSubsetSAXFunc hasExternalSubset; |
Daniel Veillard | 260a68f | 1998-08-13 03:39:55 +0000 | [diff] [blame] | 261 | resolveEntitySAXFunc resolveEntity; |
Daniel Veillard | 517752b | 1999-04-05 12:20:10 +0000 | [diff] [blame] | 262 | getEntitySAXFunc getEntity; |
| 263 | entityDeclSAXFunc entityDecl; |
Daniel Veillard | 260a68f | 1998-08-13 03:39:55 +0000 | [diff] [blame] | 264 | notationDeclSAXFunc notationDecl; |
Daniel Veillard | 517752b | 1999-04-05 12:20:10 +0000 | [diff] [blame] | 265 | attributeDeclSAXFunc attributeDecl; |
| 266 | elementDeclSAXFunc elementDecl; |
Daniel Veillard | 260a68f | 1998-08-13 03:39:55 +0000 | [diff] [blame] | 267 | unparsedEntityDeclSAXFunc unparsedEntityDecl; |
| 268 | setDocumentLocatorSAXFunc setDocumentLocator; |
| 269 | startDocumentSAXFunc startDocument; |
| 270 | endDocumentSAXFunc endDocument; |
| 271 | startElementSAXFunc startElement; |
| 272 | endElementSAXFunc endElement; |
Daniel Veillard | 517752b | 1999-04-05 12:20:10 +0000 | [diff] [blame] | 273 | referenceSAXFunc reference; |
Daniel Veillard | 260a68f | 1998-08-13 03:39:55 +0000 | [diff] [blame] | 274 | charactersSAXFunc characters; |
| 275 | ignorableWhitespaceSAXFunc ignorableWhitespace; |
| 276 | processingInstructionSAXFunc processingInstruction; |
Daniel Veillard | 517752b | 1999-04-05 12:20:10 +0000 | [diff] [blame] | 277 | commentSAXFunc comment; |
Daniel Veillard | 260a68f | 1998-08-13 03:39:55 +0000 | [diff] [blame] | 278 | warningSAXFunc warning; |
| 279 | errorSAXFunc error; |
| 280 | fatalErrorSAXFunc fatalError; |
Daniel Veillard | b05deb7 | 1999-08-10 19:04:08 +0000 | [diff] [blame] | 281 | getParameterEntitySAXFunc getParameterEntity; |
| 282 | cdataBlockSAXFunc cdataBlock; |
Daniel Veillard | cf46199 | 2000-03-14 18:30:20 +0000 | [diff] [blame] | 283 | externalSubsetSAXFunc externalSubset; |
Daniel Veillard | 71b656e | 2000-01-05 14:46:17 +0000 | [diff] [blame] | 284 | }; |
Daniel Veillard | 260a68f | 1998-08-13 03:39:55 +0000 | [diff] [blame] | 285 | |
Daniel Veillard | b05deb7 | 1999-08-10 19:04:08 +0000 | [diff] [blame] | 286 | /** |
Daniel Veillard | 686d6b6 | 2000-01-03 11:08:02 +0000 | [diff] [blame] | 287 | * External entity loaders types |
| 288 | */ |
| 289 | typedef xmlParserInputPtr (*xmlExternalEntityLoader)(const char *URL, |
| 290 | const char *ID, |
| 291 | xmlParserCtxtPtr context); |
| 292 | |
| 293 | /** |
Daniel Veillard | 6454aec | 1999-09-02 22:04:43 +0000 | [diff] [blame] | 294 | * Global variables: just the default SAX interface tables and XML |
| 295 | * version infos. |
Daniel Veillard | 260a68f | 1998-08-13 03:39:55 +0000 | [diff] [blame] | 296 | */ |
Daniel Veillard | 14fff06 | 1999-06-22 21:49:07 +0000 | [diff] [blame] | 297 | extern const char *xmlParserVersion; |
| 298 | |
Daniel Veillard | 151b1b0 | 1998-09-23 00:49:46 +0000 | [diff] [blame] | 299 | extern xmlSAXLocator xmlDefaultSAXLocator; |
| 300 | extern xmlSAXHandler xmlDefaultSAXHandler; |
Daniel Veillard | be70ff7 | 1999-07-05 16:50:46 +0000 | [diff] [blame] | 301 | extern xmlSAXHandler htmlDefaultSAXHandler; |
Daniel Veillard | b513f5a | 2000-09-10 14:01:12 +0000 | [diff] [blame] | 302 | extern xmlSAXHandler sgmlDefaultSAXHandler; |
Daniel Veillard | 260a68f | 1998-08-13 03:39:55 +0000 | [diff] [blame] | 303 | |
Daniel Veillard | 6454aec | 1999-09-02 22:04:43 +0000 | [diff] [blame] | 304 | /** |
| 305 | * entity substitution default behaviour. |
| 306 | */ |
| 307 | |
| 308 | extern int xmlSubstituteEntitiesDefaultValue; |
Daniel Veillard | cf46199 | 2000-03-14 18:30:20 +0000 | [diff] [blame] | 309 | extern int xmlGetWarningsDefaultValue; |
Daniel Veillard | 6454aec | 1999-09-02 22:04:43 +0000 | [diff] [blame] | 310 | |
Daniel Veillard | ccb0963 | 1998-10-27 06:21:04 +0000 | [diff] [blame] | 311 | |
Daniel Veillard | b05deb7 | 1999-08-10 19:04:08 +0000 | [diff] [blame] | 312 | /** |
Daniel Veillard | a819dac | 1999-11-24 18:04:22 +0000 | [diff] [blame] | 313 | * Cleanup |
| 314 | */ |
| 315 | void xmlCleanupParser (void); |
| 316 | |
| 317 | /** |
Daniel Veillard | e2d034d | 1999-07-27 19:52:06 +0000 | [diff] [blame] | 318 | * Input functions |
| 319 | */ |
Daniel Veillard | b96e643 | 1999-08-29 21:02:19 +0000 | [diff] [blame] | 320 | int xmlParserInputRead (xmlParserInputPtr in, |
| 321 | int len); |
| 322 | int xmlParserInputGrow (xmlParserInputPtr in, |
| 323 | int len); |
Daniel Veillard | e2d034d | 1999-07-27 19:52:06 +0000 | [diff] [blame] | 324 | |
Daniel Veillard | b05deb7 | 1999-08-10 19:04:08 +0000 | [diff] [blame] | 325 | /** |
Daniel Veillard | dd6b367 | 1999-09-23 22:19:22 +0000 | [diff] [blame] | 326 | * xmlChar handling |
Daniel Veillard | 260a68f | 1998-08-13 03:39:55 +0000 | [diff] [blame] | 327 | */ |
Daniel Veillard | 7a66ee6 | 1999-09-26 11:31:02 +0000 | [diff] [blame] | 328 | xmlChar * xmlStrdup (const xmlChar *cur); |
| 329 | xmlChar * xmlStrndup (const xmlChar *cur, |
Daniel Veillard | b96e643 | 1999-08-29 21:02:19 +0000 | [diff] [blame] | 330 | int len); |
Daniel Veillard | 7a66ee6 | 1999-09-26 11:31:02 +0000 | [diff] [blame] | 331 | xmlChar * xmlStrsub (const xmlChar *str, |
Daniel Veillard | b96e643 | 1999-08-29 21:02:19 +0000 | [diff] [blame] | 332 | int start, |
| 333 | int len); |
Daniel Veillard | dd6b367 | 1999-09-23 22:19:22 +0000 | [diff] [blame] | 334 | const xmlChar * xmlStrchr (const xmlChar *str, |
| 335 | xmlChar val); |
| 336 | const xmlChar * xmlStrstr (const xmlChar *str, |
| 337 | xmlChar *val); |
Daniel Veillard | b656ebe | 2000-09-22 13:51:48 +0000 | [diff] [blame] | 338 | const xmlChar * xmlStrcasestr (const xmlChar *str, |
| 339 | xmlChar *val); |
Daniel Veillard | dd6b367 | 1999-09-23 22:19:22 +0000 | [diff] [blame] | 340 | int xmlStrcmp (const xmlChar *str1, |
| 341 | const xmlChar *str2); |
| 342 | int xmlStrncmp (const xmlChar *str1, |
| 343 | const xmlChar *str2, |
Daniel Veillard | b96e643 | 1999-08-29 21:02:19 +0000 | [diff] [blame] | 344 | int len); |
Daniel Veillard | b656ebe | 2000-09-22 13:51:48 +0000 | [diff] [blame] | 345 | int xmlStrcasecmp (const xmlChar *str1, |
| 346 | const xmlChar *str2); |
| 347 | int xmlStrncasecmp (const xmlChar *str1, |
| 348 | const xmlChar *str2, |
| 349 | int len); |
Daniel Veillard | dd6b367 | 1999-09-23 22:19:22 +0000 | [diff] [blame] | 350 | int xmlStrlen (const xmlChar *str); |
Daniel Veillard | 7a66ee6 | 1999-09-26 11:31:02 +0000 | [diff] [blame] | 351 | xmlChar * xmlStrcat (xmlChar *cur, |
Daniel Veillard | dd6b367 | 1999-09-23 22:19:22 +0000 | [diff] [blame] | 352 | const xmlChar *add); |
Daniel Veillard | 7a66ee6 | 1999-09-26 11:31:02 +0000 | [diff] [blame] | 353 | xmlChar * xmlStrncat (xmlChar *cur, |
Daniel Veillard | dd6b367 | 1999-09-23 22:19:22 +0000 | [diff] [blame] | 354 | const xmlChar *add, |
Daniel Veillard | b96e643 | 1999-08-29 21:02:19 +0000 | [diff] [blame] | 355 | int len); |
Daniel Veillard | 260a68f | 1998-08-13 03:39:55 +0000 | [diff] [blame] | 356 | |
Daniel Veillard | b05deb7 | 1999-08-10 19:04:08 +0000 | [diff] [blame] | 357 | /** |
| 358 | * Basic parsing Interfaces |
Daniel Veillard | 39a1f9a | 1999-01-17 19:11:59 +0000 | [diff] [blame] | 359 | */ |
Daniel Veillard | dd6b367 | 1999-09-23 22:19:22 +0000 | [diff] [blame] | 360 | xmlDocPtr xmlParseDoc (xmlChar *cur); |
Daniel Veillard | b96e643 | 1999-08-29 21:02:19 +0000 | [diff] [blame] | 361 | xmlDocPtr xmlParseMemory (char *buffer, |
| 362 | int size); |
| 363 | xmlDocPtr xmlParseFile (const char *filename); |
| 364 | int xmlSubstituteEntitiesDefault(int val); |
Daniel Veillard | 3e6d237 | 2000-03-04 11:39:43 +0000 | [diff] [blame] | 365 | int xmlKeepBlanksDefault (int val); |
Daniel Veillard | 3f6f7f6 | 2000-06-30 17:58:25 +0000 | [diff] [blame] | 366 | void xmlStopParser (xmlParserCtxtPtr ctxt); |
Daniel Veillard | f0cc7cc | 2000-08-26 21:40:43 +0000 | [diff] [blame] | 367 | int xmlPedanticParserDefault(int val); |
Daniel Veillard | 39a1f9a | 1999-01-17 19:11:59 +0000 | [diff] [blame] | 368 | |
Daniel Veillard | b05deb7 | 1999-08-10 19:04:08 +0000 | [diff] [blame] | 369 | /** |
Daniel Veillard | 39a1f9a | 1999-01-17 19:11:59 +0000 | [diff] [blame] | 370 | * Recovery mode |
| 371 | */ |
Daniel Veillard | dd6b367 | 1999-09-23 22:19:22 +0000 | [diff] [blame] | 372 | xmlDocPtr xmlRecoverDoc (xmlChar *cur); |
Daniel Veillard | b96e643 | 1999-08-29 21:02:19 +0000 | [diff] [blame] | 373 | xmlDocPtr xmlRecoverMemory (char *buffer, |
| 374 | int size); |
| 375 | xmlDocPtr xmlRecoverFile (const char *filename); |
Daniel Veillard | 39a1f9a | 1999-01-17 19:11:59 +0000 | [diff] [blame] | 376 | |
Daniel Veillard | b05deb7 | 1999-08-10 19:04:08 +0000 | [diff] [blame] | 377 | /** |
| 378 | * Less common routines and SAX interfaces |
Daniel Veillard | 39a1f9a | 1999-01-17 19:11:59 +0000 | [diff] [blame] | 379 | */ |
Daniel Veillard | b96e643 | 1999-08-29 21:02:19 +0000 | [diff] [blame] | 380 | int xmlParseDocument (xmlParserCtxtPtr ctxt); |
Daniel Veillard | b1059e2 | 2000-09-16 14:02:43 +0000 | [diff] [blame] | 381 | int xmlParseExtParsedEnt (xmlParserCtxtPtr ctxt); |
Daniel Veillard | b96e643 | 1999-08-29 21:02:19 +0000 | [diff] [blame] | 382 | xmlDocPtr xmlSAXParseDoc (xmlSAXHandlerPtr sax, |
Daniel Veillard | dd6b367 | 1999-09-23 22:19:22 +0000 | [diff] [blame] | 383 | xmlChar *cur, |
Daniel Veillard | b96e643 | 1999-08-29 21:02:19 +0000 | [diff] [blame] | 384 | int recovery); |
Daniel Veillard | 7a66ee6 | 1999-09-26 11:31:02 +0000 | [diff] [blame] | 385 | int xmlSAXUserParseFile (xmlSAXHandlerPtr sax, |
| 386 | void *user_data, |
| 387 | const char *filename); |
| 388 | int xmlSAXUserParseMemory (xmlSAXHandlerPtr sax, |
| 389 | void *user_data, |
| 390 | char *buffer, |
| 391 | int size); |
Daniel Veillard | b96e643 | 1999-08-29 21:02:19 +0000 | [diff] [blame] | 392 | xmlDocPtr xmlSAXParseMemory (xmlSAXHandlerPtr sax, |
| 393 | char *buffer, |
| 394 | int size, |
| 395 | int recovery); |
| 396 | xmlDocPtr xmlSAXParseFile (xmlSAXHandlerPtr sax, |
| 397 | const char *filename, |
| 398 | int recovery); |
Daniel Veillard | b1059e2 | 2000-09-16 14:02:43 +0000 | [diff] [blame] | 399 | xmlDocPtr xmlSAXParseEntity (xmlSAXHandlerPtr sax, |
| 400 | const char *filename); |
| 401 | xmlDocPtr xmlParseEntity (const char *filename); |
Daniel Veillard | dd6b367 | 1999-09-23 22:19:22 +0000 | [diff] [blame] | 402 | xmlDtdPtr xmlParseDTD (const xmlChar *ExternalID, |
| 403 | const xmlChar *SystemID); |
Daniel Veillard | b96e643 | 1999-08-29 21:02:19 +0000 | [diff] [blame] | 404 | xmlDtdPtr xmlSAXParseDTD (xmlSAXHandlerPtr sax, |
Daniel Veillard | dd6b367 | 1999-09-23 22:19:22 +0000 | [diff] [blame] | 405 | const xmlChar *ExternalID, |
| 406 | const xmlChar *SystemID); |
Daniel Veillard | cf46199 | 2000-03-14 18:30:20 +0000 | [diff] [blame] | 407 | int xmlParseBalancedChunkMemory(xmlDocPtr doc, |
| 408 | xmlSAXHandlerPtr sax, |
| 409 | void *user_data, |
| 410 | int depth, |
| 411 | const xmlChar *string, |
| 412 | xmlNodePtr *list); |
| 413 | int xmlParseExternalEntity (xmlDocPtr doc, |
| 414 | xmlSAXHandlerPtr sax, |
| 415 | void *user_data, |
| 416 | int depth, |
| 417 | const xmlChar *URL, |
| 418 | const xmlChar *ID, |
| 419 | xmlNodePtr *list); |
Daniel Veillard | 87b9539 | 2000-08-12 21:12:04 +0000 | [diff] [blame] | 420 | int xmlParseCtxtExternalEntity(xmlParserCtxtPtr ctx, |
| 421 | const xmlChar *URL, |
| 422 | const xmlChar *ID, |
| 423 | xmlNodePtr *list); |
Daniel Veillard | cf46199 | 2000-03-14 18:30:20 +0000 | [diff] [blame] | 424 | |
Daniel Veillard | dbfd641 | 1999-12-28 16:35:14 +0000 | [diff] [blame] | 425 | /** |
| 426 | * SAX initialization routines |
| 427 | */ |
| 428 | void xmlDefaultSAXHandlerInit(void); |
| 429 | void htmlDefaultSAXHandlerInit(void); |
| 430 | |
| 431 | /** |
| 432 | * Parser contexts handling. |
| 433 | */ |
Daniel Veillard | b96e643 | 1999-08-29 21:02:19 +0000 | [diff] [blame] | 434 | void xmlInitParserCtxt (xmlParserCtxtPtr ctxt); |
| 435 | void xmlClearParserCtxt (xmlParserCtxtPtr ctxt); |
Daniel Veillard | dbfd641 | 1999-12-28 16:35:14 +0000 | [diff] [blame] | 436 | void xmlFreeParserCtxt (xmlParserCtxtPtr ctxt); |
Daniel Veillard | b96e643 | 1999-08-29 21:02:19 +0000 | [diff] [blame] | 437 | void xmlSetupParserForBuffer (xmlParserCtxtPtr ctxt, |
Daniel Veillard | dd6b367 | 1999-09-23 22:19:22 +0000 | [diff] [blame] | 438 | const xmlChar* buffer, |
Daniel Veillard | b96e643 | 1999-08-29 21:02:19 +0000 | [diff] [blame] | 439 | const char* filename); |
Daniel Veillard | dbfd641 | 1999-12-28 16:35:14 +0000 | [diff] [blame] | 440 | xmlParserCtxtPtr xmlCreateDocParserCtxt (xmlChar *cur); |
| 441 | |
| 442 | /** |
Daniel Veillard | 87b9539 | 2000-08-12 21:12:04 +0000 | [diff] [blame] | 443 | * Reading/setting optional parsing features. |
| 444 | */ |
| 445 | |
| 446 | int xmlGetFeaturesList (int *len, |
| 447 | const char **result); |
| 448 | int xmlGetFeature (xmlParserCtxtPtr ctxt, |
| 449 | const char *name, |
| 450 | void *result); |
| 451 | int xmlSetFeature (xmlParserCtxtPtr ctxt, |
| 452 | const char *name, |
| 453 | void *value); |
| 454 | |
| 455 | /** |
Daniel Veillard | dbfd641 | 1999-12-28 16:35:14 +0000 | [diff] [blame] | 456 | * Interfaces for the Push mode |
| 457 | */ |
| 458 | xmlParserCtxtPtr xmlCreatePushParserCtxt(xmlSAXHandlerPtr sax, |
| 459 | void *user_data, |
| 460 | const char *chunk, |
| 461 | int size, |
| 462 | const char *filename); |
| 463 | int xmlParseChunk (xmlParserCtxtPtr ctxt, |
| 464 | const char *chunk, |
| 465 | int size, |
| 466 | int terminate); |
Daniel Veillard | 260a68f | 1998-08-13 03:39:55 +0000 | [diff] [blame] | 467 | |
Daniel Veillard | b96e643 | 1999-08-29 21:02:19 +0000 | [diff] [blame] | 468 | /** |
Daniel Veillard | 5e873c4 | 2000-04-12 13:27:38 +0000 | [diff] [blame] | 469 | * Special I/O mode |
| 470 | */ |
| 471 | |
| 472 | xmlParserCtxtPtr xmlCreateIOParserCtxt (xmlSAXHandlerPtr sax, |
| 473 | void *user_data, |
| 474 | xmlInputReadCallback ioread, |
| 475 | xmlInputCloseCallback ioclose, |
| 476 | void *ioctx, |
| 477 | xmlCharEncoding enc); |
| 478 | |
| 479 | xmlParserInputPtr xmlNewIOInputStream (xmlParserCtxtPtr ctxt, |
| 480 | xmlParserInputBufferPtr input, |
| 481 | xmlCharEncoding enc); |
| 482 | |
| 483 | /** |
Daniel Veillard | b96e643 | 1999-08-29 21:02:19 +0000 | [diff] [blame] | 484 | * Node infos |
| 485 | */ |
| 486 | const xmlParserNodeInfo* |
| 487 | xmlParserFindNodeInfo (const xmlParserCtxt* ctxt, |
Daniel Veillard | 1e346af | 1999-02-22 10:33:01 +0000 | [diff] [blame] | 488 | const xmlNode* node); |
Daniel Veillard | b96e643 | 1999-08-29 21:02:19 +0000 | [diff] [blame] | 489 | void xmlInitNodeInfoSeq (xmlParserNodeInfoSeqPtr seq); |
| 490 | void xmlClearNodeInfoSeq (xmlParserNodeInfoSeqPtr seq); |
Daniel Veillard | 260a68f | 1998-08-13 03:39:55 +0000 | [diff] [blame] | 491 | unsigned long xmlParserFindNodeInfoIndex(const xmlParserNodeInfoSeq* seq, |
| 492 | const xmlNode* node); |
Daniel Veillard | b96e643 | 1999-08-29 21:02:19 +0000 | [diff] [blame] | 493 | void xmlParserAddNodeInfo (xmlParserCtxtPtr ctxt, |
| 494 | const xmlParserNodeInfo* info); |
Daniel Veillard | 260a68f | 1998-08-13 03:39:55 +0000 | [diff] [blame] | 495 | |
Daniel Veillard | b96e643 | 1999-08-29 21:02:19 +0000 | [diff] [blame] | 496 | /* |
| 497 | * External entities handling actually implemented in xmlIO |
| 498 | */ |
| 499 | |
| 500 | void xmlSetExternalEntityLoader(xmlExternalEntityLoader f); |
| 501 | xmlExternalEntityLoader |
| 502 | xmlGetExternalEntityLoader(void); |
| 503 | xmlParserInputPtr |
| 504 | xmlLoadExternalEntity (const char *URL, |
| 505 | const char *ID, |
Daniel Veillard | 686d6b6 | 2000-01-03 11:08:02 +0000 | [diff] [blame] | 506 | xmlParserCtxtPtr context); |
Daniel Veillard | 4a53eca | 1999-12-12 13:03:50 +0000 | [diff] [blame] | 507 | |
Daniel Veillard | 260a68f | 1998-08-13 03:39:55 +0000 | [diff] [blame] | 508 | #ifdef __cplusplus |
| 509 | } |
| 510 | #endif |
| 511 | |
| 512 | #endif /* __XML_PARSER_H__ */ |
| 513 | |