blob: 6d257c5691a7c85aa69fa63313e5f462445761c2 [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
Daniel Veillard361d8452000-04-03 19:48:13 +000012#include <libxml/tree.h>
13#include <libxml/valid.h>
14#include <libxml/xmlIO.h>
15#include <libxml/entities.h>
Daniel Veillard4a53eca1999-12-12 13:03:50 +000016
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 Veillardcf461992000-03-14 18:30:20 +000052 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 Veillard71b656e2000-01-05 14:46:17 +000055};
Daniel Veillard260a68f1998-08-13 03:39:55 +000056
Daniel Veillardb05deb71999-08-10 19:04:08 +000057/**
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 Veillard71b656e2000-01-05 14:46:17 +000062typedef struct _xmlParserNodeInfo xmlParserNodeInfo;
63typedef xmlParserNodeInfo *xmlParserNodeInfoPtr;
64
65struct _xmlParserNodeInfo {
66 const struct _xmlNode* node;
Daniel Veillard260a68f1998-08-13 03:39:55 +000067 /* 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 Veillard71b656e2000-01-05 14:46:17 +000072};
Daniel Veillard260a68f1998-08-13 03:39:55 +000073
Daniel Veillard71b656e2000-01-05 14:46:17 +000074typedef struct _xmlParserNodeInfoSeq xmlParserNodeInfoSeq;
75typedef xmlParserNodeInfoSeq *xmlParserNodeInfoSeqPtr;
76struct _xmlParserNodeInfoSeq {
Daniel Veillard260a68f1998-08-13 03:39:55 +000077 unsigned long maximum;
78 unsigned long length;
79 xmlParserNodeInfo* buffer;
Daniel Veillard71b656e2000-01-05 14:46:17 +000080};
Daniel Veillard260a68f1998-08-13 03:39:55 +000081
Daniel Veillardb05deb71999-08-10 19:04:08 +000082/**
Daniel Veillard71b656e2000-01-05 14:46:17 +000083 * The parser is now working also as a state based parser
84 * The recursive one use the stagte info for entities processing
Daniel Veillardb05deb71999-08-10 19:04:08 +000085 */
Daniel Veillard00fdf371999-10-08 09:40:39 +000086typedef enum {
Daniel Veillarddbfd6411999-12-28 16:35:14 +000087 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 Veillardcf461992000-03-14 18:30:20 +0000101 XML_PARSER_SYSTEM_LITERAL, /* within a SYSTEM value */
Daniel Veillarddbfd6411999-12-28 16:35:14 +0000102 XML_PARSER_EPILOG /* the Misc* after the last end tag */
Daniel Veillardb05deb71999-08-10 19:04:08 +0000103} 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 Veillard71b656e2000-01-05 14:46:17 +0000115typedef struct _xmlParserCtxt xmlParserCtxt;
116typedef xmlParserCtxt *xmlParserCtxtPtr;
117struct _xmlParserCtxt {
118 struct _xmlSAXHandler *sax; /* The SAX handler */
Daniel Veillard517752b1999-04-05 12:20:10 +0000119 void *userData; /* the document being built */
120 xmlDocPtr myDoc; /* the document being built */
Daniel Veillard7f7d1111999-09-22 09:46:25 +0000121 int wellFormed; /* is the document well formed */
Daniel Veillard011b63c1999-06-02 17:44:04 +0000122 int replaceEntities; /* shall we replace entities ? */
Daniel Veillardbe803962000-06-28 23:40:59 +0000123 const xmlChar *version; /* the XML version string */
124 const xmlChar *encoding; /* the declared encoding, if any */
Daniel Veillardb05deb71999-08-10 19:04:08 +0000125 int standalone; /* standalone document */
Daniel Veillardb05deb71999-08-10 19:04:08 +0000126 int html; /* are we parsing an HTML document */
Daniel Veillard260a68f1998-08-13 03:39:55 +0000127
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 Veillardb05deb71999-08-10 19:04:08 +0000134 /* Node analysis stack only used for DOM building */
Daniel Veillard260a68f1998-08-13 03:39:55 +0000135 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 Veillard7f7d1111999-09-22 09:46:25 +0000142
Daniel Veillarddd6b3671999-09-23 22:19:22 +0000143 int errNo; /* error code */
Daniel Veillard7f7d1111999-09-22 09:46:25 +0000144
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 Veillard2673d3c1999-10-08 14:37:09 +0000157
Daniel Veillardcf461992000-03-14 18:30:20 +0000158 /* Node name stack */
Daniel Veillard2673d3c1999-10-08 14:37:09 +0000159 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 Veillardaf78a0e1999-12-12 13:03:50 +0000164 long nbChars; /* number of xmlChar processed */
Daniel Veillarddbfd6411999-12-28 16:35:14 +0000165 long checkIndex; /* used by progressive parsing lookup */
Daniel Veillard83a30e72000-03-02 03:33:32 +0000166 int keepBlanks; /* ugly but ... */
Daniel Veillardcf461992000-03-14 18:30:20 +0000167 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 Veillardbe803962000-06-28 23:40:59 +0000180 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 Veillard71b656e2000-01-05 14:46:17 +0000185};
Daniel Veillard260a68f1998-08-13 03:39:55 +0000186
Daniel Veillardb05deb71999-08-10 19:04:08 +0000187/**
Daniel Veillard260a68f1998-08-13 03:39:55 +0000188 * a SAX Locator.
189 */
Daniel Veillard71b656e2000-01-05 14:46:17 +0000190typedef struct _xmlSAXLocator xmlSAXLocator;
191typedef xmlSAXLocator *xmlSAXLocatorPtr;
192struct _xmlSAXLocator {
Daniel Veillarddd6b3671999-09-23 22:19:22 +0000193 const xmlChar *(*getPublicId)(void *ctx);
194 const xmlChar *(*getSystemId)(void *ctx);
Daniel Veillard27d88741999-05-29 11:51:49 +0000195 int (*getLineNumber)(void *ctx);
196 int (*getColumnNumber)(void *ctx);
Daniel Veillard71b656e2000-01-05 14:46:17 +0000197};
Daniel Veillard260a68f1998-08-13 03:39:55 +0000198
Daniel Veillardb05deb71999-08-10 19:04:08 +0000199/**
200 * a SAX handler is bunch of callbacks called by the parser when processing
201 * of the input generate data or structure informations.
Daniel Veillard260a68f1998-08-13 03:39:55 +0000202 */
203
Daniel Veillard27d88741999-05-29 11:51:49 +0000204typedef xmlParserInputPtr (*resolveEntitySAXFunc) (void *ctx,
Daniel Veillarddd6b3671999-09-23 22:19:22 +0000205 const xmlChar *publicId, const xmlChar *systemId);
206typedef void (*internalSubsetSAXFunc) (void *ctx, const xmlChar *name,
207 const xmlChar *ExternalID, const xmlChar *SystemID);
Daniel Veillardcf461992000-03-14 18:30:20 +0000208typedef void (*externalSubsetSAXFunc) (void *ctx, const xmlChar *name,
209 const xmlChar *ExternalID, const xmlChar *SystemID);
Daniel Veillard27d88741999-05-29 11:51:49 +0000210typedef xmlEntityPtr (*getEntitySAXFunc) (void *ctx,
Daniel Veillarddd6b3671999-09-23 22:19:22 +0000211 const xmlChar *name);
Daniel Veillardb05deb71999-08-10 19:04:08 +0000212typedef xmlEntityPtr (*getParameterEntitySAXFunc) (void *ctx,
Daniel Veillarddd6b3671999-09-23 22:19:22 +0000213 const xmlChar *name);
Daniel Veillard27d88741999-05-29 11:51:49 +0000214typedef void (*entityDeclSAXFunc) (void *ctx,
Daniel Veillarddd6b3671999-09-23 22:19:22 +0000215 const xmlChar *name, int type, const xmlChar *publicId,
216 const xmlChar *systemId, xmlChar *content);
217typedef void (*notationDeclSAXFunc)(void *ctx, const xmlChar *name,
218 const xmlChar *publicId, const xmlChar *systemId);
219typedef void (*attributeDeclSAXFunc)(void *ctx, const xmlChar *elem,
220 const xmlChar *name, int type, int def,
221 const xmlChar *defaultValue, xmlEnumerationPtr tree);
222typedef void (*elementDeclSAXFunc)(void *ctx, const xmlChar *name,
Daniel Veillard517752b1999-04-05 12:20:10 +0000223 int type, xmlElementContentPtr content);
Daniel Veillard27d88741999-05-29 11:51:49 +0000224typedef void (*unparsedEntityDeclSAXFunc)(void *ctx,
Daniel Veillarddd6b3671999-09-23 22:19:22 +0000225 const xmlChar *name, const xmlChar *publicId,
226 const xmlChar *systemId, const xmlChar *notationName);
Daniel Veillard27d88741999-05-29 11:51:49 +0000227typedef void (*setDocumentLocatorSAXFunc) (void *ctx,
Daniel Veillard260a68f1998-08-13 03:39:55 +0000228 xmlSAXLocatorPtr loc);
Daniel Veillard27d88741999-05-29 11:51:49 +0000229typedef void (*startDocumentSAXFunc) (void *ctx);
230typedef void (*endDocumentSAXFunc) (void *ctx);
Daniel Veillarddd6b3671999-09-23 22:19:22 +0000231typedef void (*startElementSAXFunc) (void *ctx, const xmlChar *name,
232 const xmlChar **atts);
233typedef void (*endElementSAXFunc) (void *ctx, const xmlChar *name);
234typedef void (*attributeSAXFunc) (void *ctx, const xmlChar *name,
235 const xmlChar *value);
236typedef void (*referenceSAXFunc) (void *ctx, const xmlChar *name);
237typedef void (*charactersSAXFunc) (void *ctx, const xmlChar *ch,
Daniel Veillard517752b1999-04-05 12:20:10 +0000238 int len);
Daniel Veillard27d88741999-05-29 11:51:49 +0000239typedef void (*ignorableWhitespaceSAXFunc) (void *ctx,
Daniel Veillarddd6b3671999-09-23 22:19:22 +0000240 const xmlChar *ch, int len);
Daniel Veillard27d88741999-05-29 11:51:49 +0000241typedef void (*processingInstructionSAXFunc) (void *ctx,
Daniel Veillarddd6b3671999-09-23 22:19:22 +0000242 const xmlChar *target, const xmlChar *data);
243typedef void (*commentSAXFunc) (void *ctx, const xmlChar *value);
244typedef void (*cdataBlockSAXFunc) (void *ctx, const xmlChar *value, int len);
Daniel Veillard27d88741999-05-29 11:51:49 +0000245typedef void (*warningSAXFunc) (void *ctx, const char *msg, ...);
246typedef void (*errorSAXFunc) (void *ctx, const char *msg, ...);
247typedef void (*fatalErrorSAXFunc) (void *ctx, const char *msg, ...);
248typedef int (*isStandaloneSAXFunc) (void *ctx);
249typedef int (*hasInternalSubsetSAXFunc) (void *ctx);
250typedef int (*hasExternalSubsetSAXFunc) (void *ctx);
Daniel Veillard260a68f1998-08-13 03:39:55 +0000251
Daniel Veillard71b656e2000-01-05 14:46:17 +0000252typedef struct _xmlSAXHandler xmlSAXHandler;
253typedef xmlSAXHandler *xmlSAXHandlerPtr;
254struct _xmlSAXHandler {
Daniel Veillard517752b1999-04-05 12:20:10 +0000255 internalSubsetSAXFunc internalSubset;
256 isStandaloneSAXFunc isStandalone;
257 hasInternalSubsetSAXFunc hasInternalSubset;
258 hasExternalSubsetSAXFunc hasExternalSubset;
Daniel Veillard260a68f1998-08-13 03:39:55 +0000259 resolveEntitySAXFunc resolveEntity;
Daniel Veillard517752b1999-04-05 12:20:10 +0000260 getEntitySAXFunc getEntity;
261 entityDeclSAXFunc entityDecl;
Daniel Veillard260a68f1998-08-13 03:39:55 +0000262 notationDeclSAXFunc notationDecl;
Daniel Veillard517752b1999-04-05 12:20:10 +0000263 attributeDeclSAXFunc attributeDecl;
264 elementDeclSAXFunc elementDecl;
Daniel Veillard260a68f1998-08-13 03:39:55 +0000265 unparsedEntityDeclSAXFunc unparsedEntityDecl;
266 setDocumentLocatorSAXFunc setDocumentLocator;
267 startDocumentSAXFunc startDocument;
268 endDocumentSAXFunc endDocument;
269 startElementSAXFunc startElement;
270 endElementSAXFunc endElement;
Daniel Veillard517752b1999-04-05 12:20:10 +0000271 referenceSAXFunc reference;
Daniel Veillard260a68f1998-08-13 03:39:55 +0000272 charactersSAXFunc characters;
273 ignorableWhitespaceSAXFunc ignorableWhitespace;
274 processingInstructionSAXFunc processingInstruction;
Daniel Veillard517752b1999-04-05 12:20:10 +0000275 commentSAXFunc comment;
Daniel Veillard260a68f1998-08-13 03:39:55 +0000276 warningSAXFunc warning;
277 errorSAXFunc error;
278 fatalErrorSAXFunc fatalError;
Daniel Veillardb05deb71999-08-10 19:04:08 +0000279 getParameterEntitySAXFunc getParameterEntity;
280 cdataBlockSAXFunc cdataBlock;
Daniel Veillardcf461992000-03-14 18:30:20 +0000281 externalSubsetSAXFunc externalSubset;
Daniel Veillard71b656e2000-01-05 14:46:17 +0000282};
Daniel Veillard260a68f1998-08-13 03:39:55 +0000283
Daniel Veillardb05deb71999-08-10 19:04:08 +0000284/**
Daniel Veillard686d6b62000-01-03 11:08:02 +0000285 * External entity loaders types
286 */
287typedef xmlParserInputPtr (*xmlExternalEntityLoader)(const char *URL,
288 const char *ID,
289 xmlParserCtxtPtr context);
290
291/**
Daniel Veillard6454aec1999-09-02 22:04:43 +0000292 * Global variables: just the default SAX interface tables and XML
293 * version infos.
Daniel Veillard260a68f1998-08-13 03:39:55 +0000294 */
Daniel Veillard14fff061999-06-22 21:49:07 +0000295extern const char *xmlParserVersion;
296
Daniel Veillard151b1b01998-09-23 00:49:46 +0000297extern xmlSAXLocator xmlDefaultSAXLocator;
298extern xmlSAXHandler xmlDefaultSAXHandler;
Daniel Veillardbe70ff71999-07-05 16:50:46 +0000299extern xmlSAXHandler htmlDefaultSAXHandler;
Daniel Veillard260a68f1998-08-13 03:39:55 +0000300
Daniel Veillard6454aec1999-09-02 22:04:43 +0000301/**
302 * entity substitution default behaviour.
303 */
304
305extern int xmlSubstituteEntitiesDefaultValue;
Daniel Veillardcf461992000-03-14 18:30:20 +0000306extern int xmlGetWarningsDefaultValue;
Daniel Veillard6454aec1999-09-02 22:04:43 +0000307
Daniel Veillardccb09631998-10-27 06:21:04 +0000308
Daniel Veillardb05deb71999-08-10 19:04:08 +0000309/**
Daniel Veillarda819dac1999-11-24 18:04:22 +0000310 * Cleanup
311 */
312void xmlCleanupParser (void);
313
314/**
Daniel Veillarde2d034d1999-07-27 19:52:06 +0000315 * Input functions
316 */
Daniel Veillardb96e6431999-08-29 21:02:19 +0000317int xmlParserInputRead (xmlParserInputPtr in,
318 int len);
319int xmlParserInputGrow (xmlParserInputPtr in,
320 int len);
Daniel Veillarde2d034d1999-07-27 19:52:06 +0000321
Daniel Veillardb05deb71999-08-10 19:04:08 +0000322/**
Daniel Veillarddd6b3671999-09-23 22:19:22 +0000323 * xmlChar handling
Daniel Veillard260a68f1998-08-13 03:39:55 +0000324 */
Daniel Veillard7a66ee61999-09-26 11:31:02 +0000325xmlChar * xmlStrdup (const xmlChar *cur);
326xmlChar * xmlStrndup (const xmlChar *cur,
Daniel Veillardb96e6431999-08-29 21:02:19 +0000327 int len);
Daniel Veillard7a66ee61999-09-26 11:31:02 +0000328xmlChar * xmlStrsub (const xmlChar *str,
Daniel Veillardb96e6431999-08-29 21:02:19 +0000329 int start,
330 int len);
Daniel Veillarddd6b3671999-09-23 22:19:22 +0000331const xmlChar * xmlStrchr (const xmlChar *str,
332 xmlChar val);
333const xmlChar * xmlStrstr (const xmlChar *str,
334 xmlChar *val);
335int xmlStrcmp (const xmlChar *str1,
336 const xmlChar *str2);
337int xmlStrncmp (const xmlChar *str1,
338 const xmlChar *str2,
Daniel Veillardb96e6431999-08-29 21:02:19 +0000339 int len);
Daniel Veillarddd6b3671999-09-23 22:19:22 +0000340int xmlStrlen (const xmlChar *str);
Daniel Veillard7a66ee61999-09-26 11:31:02 +0000341xmlChar * xmlStrcat (xmlChar *cur,
Daniel Veillarddd6b3671999-09-23 22:19:22 +0000342 const xmlChar *add);
Daniel Veillard7a66ee61999-09-26 11:31:02 +0000343xmlChar * xmlStrncat (xmlChar *cur,
Daniel Veillarddd6b3671999-09-23 22:19:22 +0000344 const xmlChar *add,
Daniel Veillardb96e6431999-08-29 21:02:19 +0000345 int len);
Daniel Veillard260a68f1998-08-13 03:39:55 +0000346
Daniel Veillardb05deb71999-08-10 19:04:08 +0000347/**
348 * Basic parsing Interfaces
Daniel Veillard39a1f9a1999-01-17 19:11:59 +0000349 */
Daniel Veillarddd6b3671999-09-23 22:19:22 +0000350xmlDocPtr xmlParseDoc (xmlChar *cur);
Daniel Veillardb96e6431999-08-29 21:02:19 +0000351xmlDocPtr xmlParseMemory (char *buffer,
352 int size);
353xmlDocPtr xmlParseFile (const char *filename);
354int xmlSubstituteEntitiesDefault(int val);
Daniel Veillard3e6d2372000-03-04 11:39:43 +0000355int xmlKeepBlanksDefault (int val);
Daniel Veillard3f6f7f62000-06-30 17:58:25 +0000356void xmlStopParser (xmlParserCtxtPtr ctxt);
Daniel Veillard39a1f9a1999-01-17 19:11:59 +0000357
Daniel Veillardb05deb71999-08-10 19:04:08 +0000358/**
Daniel Veillard39a1f9a1999-01-17 19:11:59 +0000359 * Recovery mode
360 */
Daniel Veillarddd6b3671999-09-23 22:19:22 +0000361xmlDocPtr xmlRecoverDoc (xmlChar *cur);
Daniel Veillardb96e6431999-08-29 21:02:19 +0000362xmlDocPtr xmlRecoverMemory (char *buffer,
363 int size);
364xmlDocPtr xmlRecoverFile (const char *filename);
Daniel Veillard39a1f9a1999-01-17 19:11:59 +0000365
Daniel Veillardb05deb71999-08-10 19:04:08 +0000366/**
367 * Less common routines and SAX interfaces
Daniel Veillard39a1f9a1999-01-17 19:11:59 +0000368 */
Daniel Veillardb96e6431999-08-29 21:02:19 +0000369int xmlParseDocument (xmlParserCtxtPtr ctxt);
370xmlDocPtr xmlSAXParseDoc (xmlSAXHandlerPtr sax,
Daniel Veillarddd6b3671999-09-23 22:19:22 +0000371 xmlChar *cur,
Daniel Veillardb96e6431999-08-29 21:02:19 +0000372 int recovery);
Daniel Veillard7a66ee61999-09-26 11:31:02 +0000373int xmlSAXUserParseFile (xmlSAXHandlerPtr sax,
374 void *user_data,
375 const char *filename);
376int xmlSAXUserParseMemory (xmlSAXHandlerPtr sax,
377 void *user_data,
378 char *buffer,
379 int size);
Daniel Veillardb96e6431999-08-29 21:02:19 +0000380xmlDocPtr xmlSAXParseMemory (xmlSAXHandlerPtr sax,
381 char *buffer,
382 int size,
383 int recovery);
384xmlDocPtr xmlSAXParseFile (xmlSAXHandlerPtr sax,
385 const char *filename,
386 int recovery);
Daniel Veillarddd6b3671999-09-23 22:19:22 +0000387xmlDtdPtr xmlParseDTD (const xmlChar *ExternalID,
388 const xmlChar *SystemID);
Daniel Veillardb96e6431999-08-29 21:02:19 +0000389xmlDtdPtr xmlSAXParseDTD (xmlSAXHandlerPtr sax,
Daniel Veillarddd6b3671999-09-23 22:19:22 +0000390 const xmlChar *ExternalID,
391 const xmlChar *SystemID);
Daniel Veillardcf461992000-03-14 18:30:20 +0000392int xmlParseBalancedChunkMemory(xmlDocPtr doc,
393 xmlSAXHandlerPtr sax,
394 void *user_data,
395 int depth,
396 const xmlChar *string,
397 xmlNodePtr *list);
398int xmlParseExternalEntity (xmlDocPtr doc,
399 xmlSAXHandlerPtr sax,
400 void *user_data,
401 int depth,
402 const xmlChar *URL,
403 const xmlChar *ID,
404 xmlNodePtr *list);
Daniel Veillard87b95392000-08-12 21:12:04 +0000405int xmlParseCtxtExternalEntity(xmlParserCtxtPtr ctx,
406 const xmlChar *URL,
407 const xmlChar *ID,
408 xmlNodePtr *list);
Daniel Veillardcf461992000-03-14 18:30:20 +0000409
Daniel Veillarddbfd6411999-12-28 16:35:14 +0000410/**
411 * SAX initialization routines
412 */
413void xmlDefaultSAXHandlerInit(void);
414void htmlDefaultSAXHandlerInit(void);
415
416/**
417 * Parser contexts handling.
418 */
Daniel Veillardb96e6431999-08-29 21:02:19 +0000419void xmlInitParserCtxt (xmlParserCtxtPtr ctxt);
420void xmlClearParserCtxt (xmlParserCtxtPtr ctxt);
Daniel Veillarddbfd6411999-12-28 16:35:14 +0000421void xmlFreeParserCtxt (xmlParserCtxtPtr ctxt);
Daniel Veillardb96e6431999-08-29 21:02:19 +0000422void xmlSetupParserForBuffer (xmlParserCtxtPtr ctxt,
Daniel Veillarddd6b3671999-09-23 22:19:22 +0000423 const xmlChar* buffer,
Daniel Veillardb96e6431999-08-29 21:02:19 +0000424 const char* filename);
Daniel Veillarddbfd6411999-12-28 16:35:14 +0000425xmlParserCtxtPtr xmlCreateDocParserCtxt (xmlChar *cur);
426
427/**
Daniel Veillard87b95392000-08-12 21:12:04 +0000428 * Reading/setting optional parsing features.
429 */
430
431int xmlGetFeaturesList (int *len,
432 const char **result);
433int xmlGetFeature (xmlParserCtxtPtr ctxt,
434 const char *name,
435 void *result);
436int xmlSetFeature (xmlParserCtxtPtr ctxt,
437 const char *name,
438 void *value);
439
440/**
Daniel Veillarddbfd6411999-12-28 16:35:14 +0000441 * Interfaces for the Push mode
442 */
443xmlParserCtxtPtr xmlCreatePushParserCtxt(xmlSAXHandlerPtr sax,
444 void *user_data,
445 const char *chunk,
446 int size,
447 const char *filename);
448int xmlParseChunk (xmlParserCtxtPtr ctxt,
449 const char *chunk,
450 int size,
451 int terminate);
Daniel Veillard260a68f1998-08-13 03:39:55 +0000452
Daniel Veillardb96e6431999-08-29 21:02:19 +0000453/**
Daniel Veillard5e873c42000-04-12 13:27:38 +0000454 * Special I/O mode
455 */
456
457xmlParserCtxtPtr xmlCreateIOParserCtxt (xmlSAXHandlerPtr sax,
458 void *user_data,
459 xmlInputReadCallback ioread,
460 xmlInputCloseCallback ioclose,
461 void *ioctx,
462 xmlCharEncoding enc);
463
464xmlParserInputPtr xmlNewIOInputStream (xmlParserCtxtPtr ctxt,
465 xmlParserInputBufferPtr input,
466 xmlCharEncoding enc);
467
468/**
Daniel Veillardb96e6431999-08-29 21:02:19 +0000469 * Node infos
470 */
471const xmlParserNodeInfo*
472 xmlParserFindNodeInfo (const xmlParserCtxt* ctxt,
Daniel Veillard1e346af1999-02-22 10:33:01 +0000473 const xmlNode* node);
Daniel Veillardb96e6431999-08-29 21:02:19 +0000474void xmlInitNodeInfoSeq (xmlParserNodeInfoSeqPtr seq);
475void xmlClearNodeInfoSeq (xmlParserNodeInfoSeqPtr seq);
Daniel Veillard260a68f1998-08-13 03:39:55 +0000476unsigned long xmlParserFindNodeInfoIndex(const xmlParserNodeInfoSeq* seq,
477 const xmlNode* node);
Daniel Veillardb96e6431999-08-29 21:02:19 +0000478void xmlParserAddNodeInfo (xmlParserCtxtPtr ctxt,
479 const xmlParserNodeInfo* info);
Daniel Veillard260a68f1998-08-13 03:39:55 +0000480
Daniel Veillardb96e6431999-08-29 21:02:19 +0000481/*
482 * External entities handling actually implemented in xmlIO
483 */
484
485void xmlSetExternalEntityLoader(xmlExternalEntityLoader f);
486xmlExternalEntityLoader
487 xmlGetExternalEntityLoader(void);
488xmlParserInputPtr
489 xmlLoadExternalEntity (const char *URL,
490 const char *ID,
Daniel Veillard686d6b62000-01-03 11:08:02 +0000491 xmlParserCtxtPtr context);
Daniel Veillard4a53eca1999-12-12 13:03:50 +0000492
Daniel Veillard260a68f1998-08-13 03:39:55 +0000493#ifdef __cplusplus
494}
495#endif
496
497#endif /* __XML_PARSER_H__ */
498