blob: 9e232cacbf00b8948d9df08368dfcb08d6bf5328 [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 Veillard83a30e72000-03-02 03:33:32 +0000162 int keepBlanks; /* ugly but ... */
Daniel Veillard71b656e2000-01-05 14:46:17 +0000163};
Daniel Veillard260a68f1998-08-13 03:39:55 +0000164
Daniel Veillardb05deb71999-08-10 19:04:08 +0000165/**
Daniel Veillard260a68f1998-08-13 03:39:55 +0000166 * a SAX Locator.
167 */
Daniel Veillard71b656e2000-01-05 14:46:17 +0000168typedef struct _xmlSAXLocator xmlSAXLocator;
169typedef xmlSAXLocator *xmlSAXLocatorPtr;
170struct _xmlSAXLocator {
Daniel Veillarddd6b3671999-09-23 22:19:22 +0000171 const xmlChar *(*getPublicId)(void *ctx);
172 const xmlChar *(*getSystemId)(void *ctx);
Daniel Veillard27d88741999-05-29 11:51:49 +0000173 int (*getLineNumber)(void *ctx);
174 int (*getColumnNumber)(void *ctx);
Daniel Veillard71b656e2000-01-05 14:46:17 +0000175};
Daniel Veillard260a68f1998-08-13 03:39:55 +0000176
Daniel Veillardb05deb71999-08-10 19:04:08 +0000177/**
178 * a SAX handler is bunch of callbacks called by the parser when processing
179 * of the input generate data or structure informations.
Daniel Veillard260a68f1998-08-13 03:39:55 +0000180 */
181
Daniel Veillard27d88741999-05-29 11:51:49 +0000182typedef xmlParserInputPtr (*resolveEntitySAXFunc) (void *ctx,
Daniel Veillarddd6b3671999-09-23 22:19:22 +0000183 const xmlChar *publicId, const xmlChar *systemId);
184typedef void (*internalSubsetSAXFunc) (void *ctx, const xmlChar *name,
185 const xmlChar *ExternalID, const xmlChar *SystemID);
Daniel Veillard27d88741999-05-29 11:51:49 +0000186typedef xmlEntityPtr (*getEntitySAXFunc) (void *ctx,
Daniel Veillarddd6b3671999-09-23 22:19:22 +0000187 const xmlChar *name);
Daniel Veillardb05deb71999-08-10 19:04:08 +0000188typedef xmlEntityPtr (*getParameterEntitySAXFunc) (void *ctx,
Daniel Veillarddd6b3671999-09-23 22:19:22 +0000189 const xmlChar *name);
Daniel Veillard27d88741999-05-29 11:51:49 +0000190typedef void (*entityDeclSAXFunc) (void *ctx,
Daniel Veillarddd6b3671999-09-23 22:19:22 +0000191 const xmlChar *name, int type, const xmlChar *publicId,
192 const xmlChar *systemId, xmlChar *content);
193typedef void (*notationDeclSAXFunc)(void *ctx, const xmlChar *name,
194 const xmlChar *publicId, const xmlChar *systemId);
195typedef void (*attributeDeclSAXFunc)(void *ctx, const xmlChar *elem,
196 const xmlChar *name, int type, int def,
197 const xmlChar *defaultValue, xmlEnumerationPtr tree);
198typedef void (*elementDeclSAXFunc)(void *ctx, const xmlChar *name,
Daniel Veillard517752b1999-04-05 12:20:10 +0000199 int type, xmlElementContentPtr content);
Daniel Veillard27d88741999-05-29 11:51:49 +0000200typedef void (*unparsedEntityDeclSAXFunc)(void *ctx,
Daniel Veillarddd6b3671999-09-23 22:19:22 +0000201 const xmlChar *name, const xmlChar *publicId,
202 const xmlChar *systemId, const xmlChar *notationName);
Daniel Veillard27d88741999-05-29 11:51:49 +0000203typedef void (*setDocumentLocatorSAXFunc) (void *ctx,
Daniel Veillard260a68f1998-08-13 03:39:55 +0000204 xmlSAXLocatorPtr loc);
Daniel Veillard27d88741999-05-29 11:51:49 +0000205typedef void (*startDocumentSAXFunc) (void *ctx);
206typedef void (*endDocumentSAXFunc) (void *ctx);
Daniel Veillarddd6b3671999-09-23 22:19:22 +0000207typedef void (*startElementSAXFunc) (void *ctx, const xmlChar *name,
208 const xmlChar **atts);
209typedef void (*endElementSAXFunc) (void *ctx, const xmlChar *name);
210typedef void (*attributeSAXFunc) (void *ctx, const xmlChar *name,
211 const xmlChar *value);
212typedef void (*referenceSAXFunc) (void *ctx, const xmlChar *name);
213typedef void (*charactersSAXFunc) (void *ctx, const xmlChar *ch,
Daniel Veillard517752b1999-04-05 12:20:10 +0000214 int len);
Daniel Veillard27d88741999-05-29 11:51:49 +0000215typedef void (*ignorableWhitespaceSAXFunc) (void *ctx,
Daniel Veillarddd6b3671999-09-23 22:19:22 +0000216 const xmlChar *ch, int len);
Daniel Veillard27d88741999-05-29 11:51:49 +0000217typedef void (*processingInstructionSAXFunc) (void *ctx,
Daniel Veillarddd6b3671999-09-23 22:19:22 +0000218 const xmlChar *target, const xmlChar *data);
219typedef void (*commentSAXFunc) (void *ctx, const xmlChar *value);
220typedef void (*cdataBlockSAXFunc) (void *ctx, const xmlChar *value, int len);
Daniel Veillard27d88741999-05-29 11:51:49 +0000221typedef void (*warningSAXFunc) (void *ctx, const char *msg, ...);
222typedef void (*errorSAXFunc) (void *ctx, const char *msg, ...);
223typedef void (*fatalErrorSAXFunc) (void *ctx, const char *msg, ...);
224typedef int (*isStandaloneSAXFunc) (void *ctx);
225typedef int (*hasInternalSubsetSAXFunc) (void *ctx);
226typedef int (*hasExternalSubsetSAXFunc) (void *ctx);
Daniel Veillard260a68f1998-08-13 03:39:55 +0000227
Daniel Veillard71b656e2000-01-05 14:46:17 +0000228typedef struct _xmlSAXHandler xmlSAXHandler;
229typedef xmlSAXHandler *xmlSAXHandlerPtr;
230struct _xmlSAXHandler {
Daniel Veillard517752b1999-04-05 12:20:10 +0000231 internalSubsetSAXFunc internalSubset;
232 isStandaloneSAXFunc isStandalone;
233 hasInternalSubsetSAXFunc hasInternalSubset;
234 hasExternalSubsetSAXFunc hasExternalSubset;
Daniel Veillard260a68f1998-08-13 03:39:55 +0000235 resolveEntitySAXFunc resolveEntity;
Daniel Veillard517752b1999-04-05 12:20:10 +0000236 getEntitySAXFunc getEntity;
237 entityDeclSAXFunc entityDecl;
Daniel Veillard260a68f1998-08-13 03:39:55 +0000238 notationDeclSAXFunc notationDecl;
Daniel Veillard517752b1999-04-05 12:20:10 +0000239 attributeDeclSAXFunc attributeDecl;
240 elementDeclSAXFunc elementDecl;
Daniel Veillard260a68f1998-08-13 03:39:55 +0000241 unparsedEntityDeclSAXFunc unparsedEntityDecl;
242 setDocumentLocatorSAXFunc setDocumentLocator;
243 startDocumentSAXFunc startDocument;
244 endDocumentSAXFunc endDocument;
245 startElementSAXFunc startElement;
246 endElementSAXFunc endElement;
Daniel Veillard517752b1999-04-05 12:20:10 +0000247 referenceSAXFunc reference;
Daniel Veillard260a68f1998-08-13 03:39:55 +0000248 charactersSAXFunc characters;
249 ignorableWhitespaceSAXFunc ignorableWhitespace;
250 processingInstructionSAXFunc processingInstruction;
Daniel Veillard517752b1999-04-05 12:20:10 +0000251 commentSAXFunc comment;
Daniel Veillard260a68f1998-08-13 03:39:55 +0000252 warningSAXFunc warning;
253 errorSAXFunc error;
254 fatalErrorSAXFunc fatalError;
Daniel Veillardb05deb71999-08-10 19:04:08 +0000255 getParameterEntitySAXFunc getParameterEntity;
256 cdataBlockSAXFunc cdataBlock;
Daniel Veillard71b656e2000-01-05 14:46:17 +0000257};
Daniel Veillard260a68f1998-08-13 03:39:55 +0000258
Daniel Veillardb05deb71999-08-10 19:04:08 +0000259/**
Daniel Veillard686d6b62000-01-03 11:08:02 +0000260 * External entity loaders types
261 */
262typedef xmlParserInputPtr (*xmlExternalEntityLoader)(const char *URL,
263 const char *ID,
264 xmlParserCtxtPtr context);
265
266/**
Daniel Veillard6454aec1999-09-02 22:04:43 +0000267 * Global variables: just the default SAX interface tables and XML
268 * version infos.
Daniel Veillard260a68f1998-08-13 03:39:55 +0000269 */
Daniel Veillard14fff061999-06-22 21:49:07 +0000270extern const char *xmlParserVersion;
271
Daniel Veillard151b1b01998-09-23 00:49:46 +0000272extern xmlSAXLocator xmlDefaultSAXLocator;
273extern xmlSAXHandler xmlDefaultSAXHandler;
Daniel Veillardbe70ff71999-07-05 16:50:46 +0000274extern xmlSAXHandler htmlDefaultSAXHandler;
Daniel Veillard260a68f1998-08-13 03:39:55 +0000275
Daniel Veillard6454aec1999-09-02 22:04:43 +0000276/**
277 * entity substitution default behaviour.
278 */
279
280extern int xmlSubstituteEntitiesDefaultValue;
281
282
Daniel Veillardccb09631998-10-27 06:21:04 +0000283
Daniel Veillardb05deb71999-08-10 19:04:08 +0000284/**
Daniel Veillarda819dac1999-11-24 18:04:22 +0000285 * Cleanup
286 */
287void xmlCleanupParser (void);
288
289/**
Daniel Veillarde2d034d1999-07-27 19:52:06 +0000290 * Input functions
291 */
Daniel Veillardb96e6431999-08-29 21:02:19 +0000292int xmlParserInputRead (xmlParserInputPtr in,
293 int len);
294int xmlParserInputGrow (xmlParserInputPtr in,
295 int len);
Daniel Veillarde2d034d1999-07-27 19:52:06 +0000296
Daniel Veillardb05deb71999-08-10 19:04:08 +0000297/**
Daniel Veillarddd6b3671999-09-23 22:19:22 +0000298 * xmlChar handling
Daniel Veillard260a68f1998-08-13 03:39:55 +0000299 */
Daniel Veillard7a66ee61999-09-26 11:31:02 +0000300xmlChar * xmlStrdup (const xmlChar *cur);
301xmlChar * xmlStrndup (const xmlChar *cur,
Daniel Veillardb96e6431999-08-29 21:02:19 +0000302 int len);
Daniel Veillard7a66ee61999-09-26 11:31:02 +0000303xmlChar * xmlStrsub (const xmlChar *str,
Daniel Veillardb96e6431999-08-29 21:02:19 +0000304 int start,
305 int len);
Daniel Veillarddd6b3671999-09-23 22:19:22 +0000306const xmlChar * xmlStrchr (const xmlChar *str,
307 xmlChar val);
308const xmlChar * xmlStrstr (const xmlChar *str,
309 xmlChar *val);
310int xmlStrcmp (const xmlChar *str1,
311 const xmlChar *str2);
312int xmlStrncmp (const xmlChar *str1,
313 const xmlChar *str2,
Daniel Veillardb96e6431999-08-29 21:02:19 +0000314 int len);
Daniel Veillarddd6b3671999-09-23 22:19:22 +0000315int xmlStrlen (const xmlChar *str);
Daniel Veillard7a66ee61999-09-26 11:31:02 +0000316xmlChar * xmlStrcat (xmlChar *cur,
Daniel Veillarddd6b3671999-09-23 22:19:22 +0000317 const xmlChar *add);
Daniel Veillard7a66ee61999-09-26 11:31:02 +0000318xmlChar * xmlStrncat (xmlChar *cur,
Daniel Veillarddd6b3671999-09-23 22:19:22 +0000319 const xmlChar *add,
Daniel Veillardb96e6431999-08-29 21:02:19 +0000320 int len);
Daniel Veillard260a68f1998-08-13 03:39:55 +0000321
Daniel Veillardb05deb71999-08-10 19:04:08 +0000322/**
323 * Basic parsing Interfaces
Daniel Veillard39a1f9a1999-01-17 19:11:59 +0000324 */
Daniel Veillarddd6b3671999-09-23 22:19:22 +0000325xmlDocPtr xmlParseDoc (xmlChar *cur);
Daniel Veillardb96e6431999-08-29 21:02:19 +0000326xmlDocPtr xmlParseMemory (char *buffer,
327 int size);
328xmlDocPtr xmlParseFile (const char *filename);
329int xmlSubstituteEntitiesDefault(int val);
Daniel Veillard3e6d2372000-03-04 11:39:43 +0000330int xmlKeepBlanksDefault (int val);
Daniel Veillard39a1f9a1999-01-17 19:11:59 +0000331
Daniel Veillardb05deb71999-08-10 19:04:08 +0000332/**
Daniel Veillard39a1f9a1999-01-17 19:11:59 +0000333 * Recovery mode
334 */
Daniel Veillarddd6b3671999-09-23 22:19:22 +0000335xmlDocPtr xmlRecoverDoc (xmlChar *cur);
Daniel Veillardb96e6431999-08-29 21:02:19 +0000336xmlDocPtr xmlRecoverMemory (char *buffer,
337 int size);
338xmlDocPtr xmlRecoverFile (const char *filename);
Daniel Veillard39a1f9a1999-01-17 19:11:59 +0000339
Daniel Veillardb05deb71999-08-10 19:04:08 +0000340/**
341 * Less common routines and SAX interfaces
Daniel Veillard39a1f9a1999-01-17 19:11:59 +0000342 */
Daniel Veillardb96e6431999-08-29 21:02:19 +0000343int xmlParseDocument (xmlParserCtxtPtr ctxt);
344xmlDocPtr xmlSAXParseDoc (xmlSAXHandlerPtr sax,
Daniel Veillarddd6b3671999-09-23 22:19:22 +0000345 xmlChar *cur,
Daniel Veillardb96e6431999-08-29 21:02:19 +0000346 int recovery);
Daniel Veillard7a66ee61999-09-26 11:31:02 +0000347int xmlSAXUserParseFile (xmlSAXHandlerPtr sax,
348 void *user_data,
349 const char *filename);
350int xmlSAXUserParseMemory (xmlSAXHandlerPtr sax,
351 void *user_data,
352 char *buffer,
353 int size);
Daniel Veillardb96e6431999-08-29 21:02:19 +0000354xmlDocPtr xmlSAXParseMemory (xmlSAXHandlerPtr sax,
355 char *buffer,
356 int size,
357 int recovery);
358xmlDocPtr xmlSAXParseFile (xmlSAXHandlerPtr sax,
359 const char *filename,
360 int recovery);
Daniel Veillarddd6b3671999-09-23 22:19:22 +0000361xmlDtdPtr xmlParseDTD (const xmlChar *ExternalID,
362 const xmlChar *SystemID);
Daniel Veillardb96e6431999-08-29 21:02:19 +0000363xmlDtdPtr xmlSAXParseDTD (xmlSAXHandlerPtr sax,
Daniel Veillarddd6b3671999-09-23 22:19:22 +0000364 const xmlChar *ExternalID,
365 const xmlChar *SystemID);
Daniel Veillarddbfd6411999-12-28 16:35:14 +0000366/**
367 * SAX initialization routines
368 */
369void xmlDefaultSAXHandlerInit(void);
370void htmlDefaultSAXHandlerInit(void);
371
372/**
373 * Parser contexts handling.
374 */
Daniel Veillardb96e6431999-08-29 21:02:19 +0000375void xmlInitParserCtxt (xmlParserCtxtPtr ctxt);
376void xmlClearParserCtxt (xmlParserCtxtPtr ctxt);
Daniel Veillarddbfd6411999-12-28 16:35:14 +0000377void xmlFreeParserCtxt (xmlParserCtxtPtr ctxt);
Daniel Veillardb96e6431999-08-29 21:02:19 +0000378void xmlSetupParserForBuffer (xmlParserCtxtPtr ctxt,
Daniel Veillarddd6b3671999-09-23 22:19:22 +0000379 const xmlChar* buffer,
Daniel Veillardb96e6431999-08-29 21:02:19 +0000380 const char* filename);
Daniel Veillarddbfd6411999-12-28 16:35:14 +0000381xmlParserCtxtPtr xmlCreateDocParserCtxt (xmlChar *cur);
382
383/**
384 * Interfaces for the Push mode
385 */
386xmlParserCtxtPtr xmlCreatePushParserCtxt(xmlSAXHandlerPtr sax,
387 void *user_data,
388 const char *chunk,
389 int size,
390 const char *filename);
391int xmlParseChunk (xmlParserCtxtPtr ctxt,
392 const char *chunk,
393 int size,
394 int terminate);
Daniel Veillard260a68f1998-08-13 03:39:55 +0000395
Daniel Veillardb96e6431999-08-29 21:02:19 +0000396/**
397 * Node infos
398 */
399const xmlParserNodeInfo*
400 xmlParserFindNodeInfo (const xmlParserCtxt* ctxt,
Daniel Veillard1e346af1999-02-22 10:33:01 +0000401 const xmlNode* node);
Daniel Veillardb96e6431999-08-29 21:02:19 +0000402void xmlInitNodeInfoSeq (xmlParserNodeInfoSeqPtr seq);
403void xmlClearNodeInfoSeq (xmlParserNodeInfoSeqPtr seq);
Daniel Veillard260a68f1998-08-13 03:39:55 +0000404unsigned long xmlParserFindNodeInfoIndex(const xmlParserNodeInfoSeq* seq,
405 const xmlNode* node);
Daniel Veillardb96e6431999-08-29 21:02:19 +0000406void xmlParserAddNodeInfo (xmlParserCtxtPtr ctxt,
407 const xmlParserNodeInfo* info);
Daniel Veillard260a68f1998-08-13 03:39:55 +0000408
Daniel Veillardb96e6431999-08-29 21:02:19 +0000409/*
410 * External entities handling actually implemented in xmlIO
411 */
412
413void xmlSetExternalEntityLoader(xmlExternalEntityLoader f);
414xmlExternalEntityLoader
415 xmlGetExternalEntityLoader(void);
416xmlParserInputPtr
417 xmlLoadExternalEntity (const char *URL,
418 const char *ID,
Daniel Veillard686d6b62000-01-03 11:08:02 +0000419 xmlParserCtxtPtr context);
Daniel Veillard4a53eca1999-12-12 13:03:50 +0000420
Daniel Veillard260a68f1998-08-13 03:39:55 +0000421#ifdef __cplusplus
422}
423#endif
424
425#endif /* __XML_PARSER_H__ */
426