blob: e02751ca3758cc21c0820c03ba308723b500178e [file] [log] [blame]
Daniel Veillard260a68f1998-08-13 03:39:55 +00001/*
Daniel Veillardb05deb71999-08-10 19:04:08 +00002 * parser.h : Interfaces, constants and types related to the XML parser.
Daniel Veillard260a68f1998-08-13 03:39:55 +00003 *
4 * See Copyright for the status of this software.
5 *
Daniel Veillard39a1f9a1999-01-17 19:11:59 +00006 * Daniel.Veillard@w3.org
Daniel Veillard260a68f1998-08-13 03:39:55 +00007 */
8
9#ifndef __XML_PARSER_H__
10#define __XML_PARSER_H__
11
12#include "tree.h"
Daniel Veillardb05deb71999-08-10 19:04:08 +000013#include "valid.h"
Daniel Veillard14fff061999-06-22 21:49:07 +000014#include "xmlIO.h"
Daniel Veillard4a53eca1999-12-12 13:03:50 +000015#include "entities.h"
16
Daniel Veillard260a68f1998-08-13 03:39:55 +000017
18#ifdef __cplusplus
19extern "C" {
20#endif
21
22/*
23 * Constants.
24 */
25#define XML_DEFAULT_VERSION "1.0"
26
Daniel Veillardb05deb71999-08-10 19:04:08 +000027/**
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 Veillarddd6b3671999-09-23 22:19:22 +000036typedef void (* xmlParserInputDeallocate)(xmlChar *);
Daniel Veillard71b656e2000-01-05 14:46:17 +000037typedef struct _xmlParserInput xmlParserInput;
38typedef xmlParserInput *xmlParserInputPtr;
39struct _xmlParserInput {
Daniel Veillard14fff061999-06-22 21:49:07 +000040 /* Input buffer */
41 xmlParserInputBufferPtr buf; /* UTF-8 encoded buffer */
42
Daniel Veillard260a68f1998-08-13 03:39:55 +000043 const char *filename; /* The file analyzed, if any */
Daniel Veillardb05deb71999-08-10 19:04:08 +000044 const char *directory; /* the directory/base of teh file */
Daniel Veillarddbfd6411999-12-28 16:35:14 +000045 const xmlChar *base; /* Base of the array to parse */
46 const xmlChar *cur; /* Current char being parsed */
47 int length; /* length if known */
Daniel Veillard260a68f1998-08-13 03:39:55 +000048 int line; /* Current line */
49 int col; /* Current column */
Daniel Veillarddbfd6411999-12-28 16:35:14 +000050 int consumed; /* How many xmlChars already consumed */
Daniel Veillardd692aa41999-02-28 21:54:31 +000051 xmlParserInputDeallocate free; /* function to deallocate the base */
Daniel Veillard71b656e2000-01-05 14:46:17 +000052};
Daniel Veillard260a68f1998-08-13 03:39:55 +000053
Daniel Veillardb05deb71999-08-10 19:04:08 +000054/**
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 Veillard71b656e2000-01-05 14:46:17 +000059typedef struct _xmlParserNodeInfo xmlParserNodeInfo;
60typedef xmlParserNodeInfo *xmlParserNodeInfoPtr;
61
62struct _xmlParserNodeInfo {
63 const struct _xmlNode* node;
Daniel Veillard260a68f1998-08-13 03:39:55 +000064 /* 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 Veillard71b656e2000-01-05 14:46:17 +000069};
Daniel Veillard260a68f1998-08-13 03:39:55 +000070
Daniel Veillard71b656e2000-01-05 14:46:17 +000071typedef struct _xmlParserNodeInfoSeq xmlParserNodeInfoSeq;
72typedef xmlParserNodeInfoSeq *xmlParserNodeInfoSeqPtr;
73struct _xmlParserNodeInfoSeq {
Daniel Veillard260a68f1998-08-13 03:39:55 +000074 unsigned long maximum;
75 unsigned long length;
76 xmlParserNodeInfo* buffer;
Daniel Veillard71b656e2000-01-05 14:46:17 +000077};
Daniel Veillard260a68f1998-08-13 03:39:55 +000078
Daniel Veillardb05deb71999-08-10 19:04:08 +000079/**
Daniel Veillard71b656e2000-01-05 14:46:17 +000080 * The parser is now working also as a state based parser
81 * The recursive one use the stagte info for entities processing
Daniel Veillardb05deb71999-08-10 19:04:08 +000082 */
Daniel Veillard00fdf371999-10-08 09:40:39 +000083typedef enum {
Daniel Veillarddbfd6411999-12-28 16:35:14 +000084 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 Veillardb05deb71999-08-10 19:04:08 +000099} 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 Veillard71b656e2000-01-05 14:46:17 +0000111typedef struct _xmlParserCtxt xmlParserCtxt;
112typedef xmlParserCtxt *xmlParserCtxtPtr;
113struct _xmlParserCtxt {
114 struct _xmlSAXHandler *sax; /* The SAX handler */
Daniel Veillard517752b1999-04-05 12:20:10 +0000115 void *userData; /* the document being built */
116 xmlDocPtr myDoc; /* the document being built */
Daniel Veillard7f7d1111999-09-22 09:46:25 +0000117 int wellFormed; /* is the document well formed */
Daniel Veillard011b63c1999-06-02 17:44:04 +0000118 int replaceEntities; /* shall we replace entities ? */
Daniel Veillarddd6b3671999-09-23 22:19:22 +0000119 const xmlChar *version; /* the XML version string */
120 const xmlChar *encoding; /* encoding, if any */
Daniel Veillardb05deb71999-08-10 19:04:08 +0000121 int standalone; /* standalone document */
Daniel Veillardb05deb71999-08-10 19:04:08 +0000122 int html; /* are we parsing an HTML document */
Daniel Veillard260a68f1998-08-13 03:39:55 +0000123
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 Veillardb05deb71999-08-10 19:04:08 +0000130 /* Node analysis stack only used for DOM building */
Daniel Veillard260a68f1998-08-13 03:39:55 +0000131 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 Veillard7f7d1111999-09-22 09:46:25 +0000138
Daniel Veillarddd6b3671999-09-23 22:19:22 +0000139 int errNo; /* error code */
Daniel Veillard7f7d1111999-09-22 09:46:25 +0000140
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 Veillard2673d3c1999-10-08 14:37:09 +0000153
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 Veillardaf78a0e1999-12-12 13:03:50 +0000160 long nbChars; /* number of xmlChar processed */
Daniel Veillarddbfd6411999-12-28 16:35:14 +0000161 long checkIndex; /* used by progressive parsing lookup */
Daniel Veillard71b656e2000-01-05 14:46:17 +0000162};
Daniel Veillard260a68f1998-08-13 03:39:55 +0000163
Daniel Veillardb05deb71999-08-10 19:04:08 +0000164/**
Daniel Veillard260a68f1998-08-13 03:39:55 +0000165 * a SAX Locator.
166 */
Daniel Veillard71b656e2000-01-05 14:46:17 +0000167typedef struct _xmlSAXLocator xmlSAXLocator;
168typedef xmlSAXLocator *xmlSAXLocatorPtr;
169struct _xmlSAXLocator {
Daniel Veillarddd6b3671999-09-23 22:19:22 +0000170 const xmlChar *(*getPublicId)(void *ctx);
171 const xmlChar *(*getSystemId)(void *ctx);
Daniel Veillard27d88741999-05-29 11:51:49 +0000172 int (*getLineNumber)(void *ctx);
173 int (*getColumnNumber)(void *ctx);
Daniel Veillard71b656e2000-01-05 14:46:17 +0000174};
Daniel Veillard260a68f1998-08-13 03:39:55 +0000175
Daniel Veillardb05deb71999-08-10 19:04:08 +0000176/**
177 * a SAX handler is bunch of callbacks called by the parser when processing
178 * of the input generate data or structure informations.
Daniel Veillard260a68f1998-08-13 03:39:55 +0000179 */
180
Daniel Veillard27d88741999-05-29 11:51:49 +0000181typedef xmlParserInputPtr (*resolveEntitySAXFunc) (void *ctx,
Daniel Veillarddd6b3671999-09-23 22:19:22 +0000182 const xmlChar *publicId, const xmlChar *systemId);
183typedef void (*internalSubsetSAXFunc) (void *ctx, const xmlChar *name,
184 const xmlChar *ExternalID, const xmlChar *SystemID);
Daniel Veillard27d88741999-05-29 11:51:49 +0000185typedef xmlEntityPtr (*getEntitySAXFunc) (void *ctx,
Daniel Veillarddd6b3671999-09-23 22:19:22 +0000186 const xmlChar *name);
Daniel Veillardb05deb71999-08-10 19:04:08 +0000187typedef xmlEntityPtr (*getParameterEntitySAXFunc) (void *ctx,
Daniel Veillarddd6b3671999-09-23 22:19:22 +0000188 const xmlChar *name);
Daniel Veillard27d88741999-05-29 11:51:49 +0000189typedef void (*entityDeclSAXFunc) (void *ctx,
Daniel Veillarddd6b3671999-09-23 22:19:22 +0000190 const xmlChar *name, int type, const xmlChar *publicId,
191 const xmlChar *systemId, xmlChar *content);
192typedef void (*notationDeclSAXFunc)(void *ctx, const xmlChar *name,
193 const xmlChar *publicId, const xmlChar *systemId);
194typedef void (*attributeDeclSAXFunc)(void *ctx, const xmlChar *elem,
195 const xmlChar *name, int type, int def,
196 const xmlChar *defaultValue, xmlEnumerationPtr tree);
197typedef void (*elementDeclSAXFunc)(void *ctx, const xmlChar *name,
Daniel Veillard517752b1999-04-05 12:20:10 +0000198 int type, xmlElementContentPtr content);
Daniel Veillard27d88741999-05-29 11:51:49 +0000199typedef void (*unparsedEntityDeclSAXFunc)(void *ctx,
Daniel Veillarddd6b3671999-09-23 22:19:22 +0000200 const xmlChar *name, const xmlChar *publicId,
201 const xmlChar *systemId, const xmlChar *notationName);
Daniel Veillard27d88741999-05-29 11:51:49 +0000202typedef void (*setDocumentLocatorSAXFunc) (void *ctx,
Daniel Veillard260a68f1998-08-13 03:39:55 +0000203 xmlSAXLocatorPtr loc);
Daniel Veillard27d88741999-05-29 11:51:49 +0000204typedef void (*startDocumentSAXFunc) (void *ctx);
205typedef void (*endDocumentSAXFunc) (void *ctx);
Daniel Veillarddd6b3671999-09-23 22:19:22 +0000206typedef void (*startElementSAXFunc) (void *ctx, const xmlChar *name,
207 const xmlChar **atts);
208typedef void (*endElementSAXFunc) (void *ctx, const xmlChar *name);
209typedef void (*attributeSAXFunc) (void *ctx, const xmlChar *name,
210 const xmlChar *value);
211typedef void (*referenceSAXFunc) (void *ctx, const xmlChar *name);
212typedef void (*charactersSAXFunc) (void *ctx, const xmlChar *ch,
Daniel Veillard517752b1999-04-05 12:20:10 +0000213 int len);
Daniel Veillard27d88741999-05-29 11:51:49 +0000214typedef void (*ignorableWhitespaceSAXFunc) (void *ctx,
Daniel Veillarddd6b3671999-09-23 22:19:22 +0000215 const xmlChar *ch, int len);
Daniel Veillard27d88741999-05-29 11:51:49 +0000216typedef void (*processingInstructionSAXFunc) (void *ctx,
Daniel Veillarddd6b3671999-09-23 22:19:22 +0000217 const xmlChar *target, const xmlChar *data);
218typedef void (*commentSAXFunc) (void *ctx, const xmlChar *value);
219typedef void (*cdataBlockSAXFunc) (void *ctx, const xmlChar *value, int len);
Daniel Veillard27d88741999-05-29 11:51:49 +0000220typedef void (*warningSAXFunc) (void *ctx, const char *msg, ...);
221typedef void (*errorSAXFunc) (void *ctx, const char *msg, ...);
222typedef void (*fatalErrorSAXFunc) (void *ctx, const char *msg, ...);
223typedef int (*isStandaloneSAXFunc) (void *ctx);
224typedef int (*hasInternalSubsetSAXFunc) (void *ctx);
225typedef int (*hasExternalSubsetSAXFunc) (void *ctx);
Daniel Veillard260a68f1998-08-13 03:39:55 +0000226
Daniel Veillard71b656e2000-01-05 14:46:17 +0000227typedef struct _xmlSAXHandler xmlSAXHandler;
228typedef xmlSAXHandler *xmlSAXHandlerPtr;
229struct _xmlSAXHandler {
Daniel Veillard517752b1999-04-05 12:20:10 +0000230 internalSubsetSAXFunc internalSubset;
231 isStandaloneSAXFunc isStandalone;
232 hasInternalSubsetSAXFunc hasInternalSubset;
233 hasExternalSubsetSAXFunc hasExternalSubset;
Daniel Veillard260a68f1998-08-13 03:39:55 +0000234 resolveEntitySAXFunc resolveEntity;
Daniel Veillard517752b1999-04-05 12:20:10 +0000235 getEntitySAXFunc getEntity;
236 entityDeclSAXFunc entityDecl;
Daniel Veillard260a68f1998-08-13 03:39:55 +0000237 notationDeclSAXFunc notationDecl;
Daniel Veillard517752b1999-04-05 12:20:10 +0000238 attributeDeclSAXFunc attributeDecl;
239 elementDeclSAXFunc elementDecl;
Daniel Veillard260a68f1998-08-13 03:39:55 +0000240 unparsedEntityDeclSAXFunc unparsedEntityDecl;
241 setDocumentLocatorSAXFunc setDocumentLocator;
242 startDocumentSAXFunc startDocument;
243 endDocumentSAXFunc endDocument;
244 startElementSAXFunc startElement;
245 endElementSAXFunc endElement;
Daniel Veillard517752b1999-04-05 12:20:10 +0000246 referenceSAXFunc reference;
Daniel Veillard260a68f1998-08-13 03:39:55 +0000247 charactersSAXFunc characters;
248 ignorableWhitespaceSAXFunc ignorableWhitespace;
249 processingInstructionSAXFunc processingInstruction;
Daniel Veillard517752b1999-04-05 12:20:10 +0000250 commentSAXFunc comment;
Daniel Veillard260a68f1998-08-13 03:39:55 +0000251 warningSAXFunc warning;
252 errorSAXFunc error;
253 fatalErrorSAXFunc fatalError;
Daniel Veillardb05deb71999-08-10 19:04:08 +0000254 getParameterEntitySAXFunc getParameterEntity;
255 cdataBlockSAXFunc cdataBlock;
Daniel Veillard71b656e2000-01-05 14:46:17 +0000256};
Daniel Veillard260a68f1998-08-13 03:39:55 +0000257
Daniel Veillardb05deb71999-08-10 19:04:08 +0000258/**
Daniel Veillard686d6b62000-01-03 11:08:02 +0000259 * External entity loaders types
260 */
261typedef xmlParserInputPtr (*xmlExternalEntityLoader)(const char *URL,
262 const char *ID,
263 xmlParserCtxtPtr context);
264
265/**
Daniel Veillard6454aec1999-09-02 22:04:43 +0000266 * Global variables: just the default SAX interface tables and XML
267 * version infos.
Daniel Veillard260a68f1998-08-13 03:39:55 +0000268 */
Daniel Veillard14fff061999-06-22 21:49:07 +0000269extern const char *xmlParserVersion;
270
Daniel Veillard151b1b01998-09-23 00:49:46 +0000271extern xmlSAXLocator xmlDefaultSAXLocator;
272extern xmlSAXHandler xmlDefaultSAXHandler;
Daniel Veillardbe70ff71999-07-05 16:50:46 +0000273extern xmlSAXHandler htmlDefaultSAXHandler;
Daniel Veillard260a68f1998-08-13 03:39:55 +0000274
Daniel Veillard6454aec1999-09-02 22:04:43 +0000275/**
276 * entity substitution default behaviour.
277 */
278
279extern int xmlSubstituteEntitiesDefaultValue;
280
281
Daniel Veillardccb09631998-10-27 06:21:04 +0000282
Daniel Veillardb05deb71999-08-10 19:04:08 +0000283/**
Daniel Veillarda819dac1999-11-24 18:04:22 +0000284 * Cleanup
285 */
286void xmlCleanupParser (void);
287
288/**
Daniel Veillarde2d034d1999-07-27 19:52:06 +0000289 * Input functions
290 */
Daniel Veillardb96e6431999-08-29 21:02:19 +0000291int xmlParserInputRead (xmlParserInputPtr in,
292 int len);
293int xmlParserInputGrow (xmlParserInputPtr in,
294 int len);
Daniel Veillarde2d034d1999-07-27 19:52:06 +0000295
Daniel Veillardb05deb71999-08-10 19:04:08 +0000296/**
Daniel Veillarddd6b3671999-09-23 22:19:22 +0000297 * xmlChar handling
Daniel Veillard260a68f1998-08-13 03:39:55 +0000298 */
Daniel Veillard7a66ee61999-09-26 11:31:02 +0000299xmlChar * xmlStrdup (const xmlChar *cur);
300xmlChar * xmlStrndup (const xmlChar *cur,
Daniel Veillardb96e6431999-08-29 21:02:19 +0000301 int len);
Daniel Veillard7a66ee61999-09-26 11:31:02 +0000302xmlChar * xmlStrsub (const xmlChar *str,
Daniel Veillardb96e6431999-08-29 21:02:19 +0000303 int start,
304 int len);
Daniel Veillarddd6b3671999-09-23 22:19:22 +0000305const xmlChar * xmlStrchr (const xmlChar *str,
306 xmlChar val);
307const xmlChar * xmlStrstr (const xmlChar *str,
308 xmlChar *val);
309int xmlStrcmp (const xmlChar *str1,
310 const xmlChar *str2);
311int xmlStrncmp (const xmlChar *str1,
312 const xmlChar *str2,
Daniel Veillardb96e6431999-08-29 21:02:19 +0000313 int len);
Daniel Veillarddd6b3671999-09-23 22:19:22 +0000314int xmlStrlen (const xmlChar *str);
Daniel Veillard7a66ee61999-09-26 11:31:02 +0000315xmlChar * xmlStrcat (xmlChar *cur,
Daniel Veillarddd6b3671999-09-23 22:19:22 +0000316 const xmlChar *add);
Daniel Veillard7a66ee61999-09-26 11:31:02 +0000317xmlChar * xmlStrncat (xmlChar *cur,
Daniel Veillarddd6b3671999-09-23 22:19:22 +0000318 const xmlChar *add,
Daniel Veillardb96e6431999-08-29 21:02:19 +0000319 int len);
Daniel Veillard260a68f1998-08-13 03:39:55 +0000320
Daniel Veillardb05deb71999-08-10 19:04:08 +0000321/**
322 * Basic parsing Interfaces
Daniel Veillard39a1f9a1999-01-17 19:11:59 +0000323 */
Daniel Veillarddd6b3671999-09-23 22:19:22 +0000324xmlDocPtr xmlParseDoc (xmlChar *cur);
Daniel Veillardb96e6431999-08-29 21:02:19 +0000325xmlDocPtr xmlParseMemory (char *buffer,
326 int size);
327xmlDocPtr xmlParseFile (const char *filename);
328int xmlSubstituteEntitiesDefault(int val);
Daniel Veillard39a1f9a1999-01-17 19:11:59 +0000329
Daniel Veillardb05deb71999-08-10 19:04:08 +0000330/**
Daniel Veillard39a1f9a1999-01-17 19:11:59 +0000331 * Recovery mode
332 */
Daniel Veillarddd6b3671999-09-23 22:19:22 +0000333xmlDocPtr xmlRecoverDoc (xmlChar *cur);
Daniel Veillardb96e6431999-08-29 21:02:19 +0000334xmlDocPtr xmlRecoverMemory (char *buffer,
335 int size);
336xmlDocPtr xmlRecoverFile (const char *filename);
Daniel Veillard39a1f9a1999-01-17 19:11:59 +0000337
Daniel Veillardb05deb71999-08-10 19:04:08 +0000338/**
339 * Less common routines and SAX interfaces
Daniel Veillard39a1f9a1999-01-17 19:11:59 +0000340 */
Daniel Veillardb96e6431999-08-29 21:02:19 +0000341int xmlParseDocument (xmlParserCtxtPtr ctxt);
342xmlDocPtr xmlSAXParseDoc (xmlSAXHandlerPtr sax,
Daniel Veillarddd6b3671999-09-23 22:19:22 +0000343 xmlChar *cur,
Daniel Veillardb96e6431999-08-29 21:02:19 +0000344 int recovery);
Daniel Veillard7a66ee61999-09-26 11:31:02 +0000345int xmlSAXUserParseFile (xmlSAXHandlerPtr sax,
346 void *user_data,
347 const char *filename);
348int xmlSAXUserParseMemory (xmlSAXHandlerPtr sax,
349 void *user_data,
350 char *buffer,
351 int size);
Daniel Veillardb96e6431999-08-29 21:02:19 +0000352xmlDocPtr xmlSAXParseMemory (xmlSAXHandlerPtr sax,
353 char *buffer,
354 int size,
355 int recovery);
356xmlDocPtr xmlSAXParseFile (xmlSAXHandlerPtr sax,
357 const char *filename,
358 int recovery);
Daniel Veillarddd6b3671999-09-23 22:19:22 +0000359xmlDtdPtr xmlParseDTD (const xmlChar *ExternalID,
360 const xmlChar *SystemID);
Daniel Veillardb96e6431999-08-29 21:02:19 +0000361xmlDtdPtr xmlSAXParseDTD (xmlSAXHandlerPtr sax,
Daniel Veillarddd6b3671999-09-23 22:19:22 +0000362 const xmlChar *ExternalID,
363 const xmlChar *SystemID);
Daniel Veillarddbfd6411999-12-28 16:35:14 +0000364/**
365 * SAX initialization routines
366 */
367void xmlDefaultSAXHandlerInit(void);
368void htmlDefaultSAXHandlerInit(void);
369
370/**
371 * Parser contexts handling.
372 */
Daniel Veillardb96e6431999-08-29 21:02:19 +0000373void xmlInitParserCtxt (xmlParserCtxtPtr ctxt);
374void xmlClearParserCtxt (xmlParserCtxtPtr ctxt);
Daniel Veillarddbfd6411999-12-28 16:35:14 +0000375void xmlFreeParserCtxt (xmlParserCtxtPtr ctxt);
Daniel Veillardb96e6431999-08-29 21:02:19 +0000376void xmlSetupParserForBuffer (xmlParserCtxtPtr ctxt,
Daniel Veillarddd6b3671999-09-23 22:19:22 +0000377 const xmlChar* buffer,
Daniel Veillardb96e6431999-08-29 21:02:19 +0000378 const char* filename);
Daniel Veillarddbfd6411999-12-28 16:35:14 +0000379xmlParserCtxtPtr xmlCreateDocParserCtxt (xmlChar *cur);
380
381/**
382 * Interfaces for the Push mode
383 */
384xmlParserCtxtPtr xmlCreatePushParserCtxt(xmlSAXHandlerPtr sax,
385 void *user_data,
386 const char *chunk,
387 int size,
388 const char *filename);
389int xmlParseChunk (xmlParserCtxtPtr ctxt,
390 const char *chunk,
391 int size,
392 int terminate);
Daniel Veillard260a68f1998-08-13 03:39:55 +0000393
Daniel Veillardb96e6431999-08-29 21:02:19 +0000394/**
395 * Node infos
396 */
397const xmlParserNodeInfo*
398 xmlParserFindNodeInfo (const xmlParserCtxt* ctxt,
Daniel Veillard1e346af1999-02-22 10:33:01 +0000399 const xmlNode* node);
Daniel Veillardb96e6431999-08-29 21:02:19 +0000400void xmlInitNodeInfoSeq (xmlParserNodeInfoSeqPtr seq);
401void xmlClearNodeInfoSeq (xmlParserNodeInfoSeqPtr seq);
Daniel Veillard260a68f1998-08-13 03:39:55 +0000402unsigned long xmlParserFindNodeInfoIndex(const xmlParserNodeInfoSeq* seq,
403 const xmlNode* node);
Daniel Veillardb96e6431999-08-29 21:02:19 +0000404void xmlParserAddNodeInfo (xmlParserCtxtPtr ctxt,
405 const xmlParserNodeInfo* info);
Daniel Veillard260a68f1998-08-13 03:39:55 +0000406
Daniel Veillardb96e6431999-08-29 21:02:19 +0000407/*
408 * External entities handling actually implemented in xmlIO
409 */
410
411void xmlSetExternalEntityLoader(xmlExternalEntityLoader f);
412xmlExternalEntityLoader
413 xmlGetExternalEntityLoader(void);
414xmlParserInputPtr
415 xmlLoadExternalEntity (const char *URL,
416 const char *ID,
Daniel Veillard686d6b62000-01-03 11:08:02 +0000417 xmlParserCtxtPtr context);
Daniel Veillard4a53eca1999-12-12 13:03:50 +0000418
Daniel Veillard260a68f1998-08-13 03:39:55 +0000419#ifdef __cplusplus
420}
421#endif
422
423#endif /* __XML_PARSER_H__ */
424