blob: 5c49eb4d933fb35a826935d924448b762b010423 [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 Veillardf0cc7cc2000-08-26 21:40:43 +0000185 int pedantic; /* signal pedantic warnings */
Daniel Veillard71b656e2000-01-05 14:46:17 +0000186};
Daniel Veillard260a68f1998-08-13 03:39:55 +0000187
Daniel Veillardb05deb71999-08-10 19:04:08 +0000188/**
Daniel Veillard260a68f1998-08-13 03:39:55 +0000189 * a SAX Locator.
190 */
Daniel Veillard71b656e2000-01-05 14:46:17 +0000191typedef struct _xmlSAXLocator xmlSAXLocator;
192typedef xmlSAXLocator *xmlSAXLocatorPtr;
193struct _xmlSAXLocator {
Daniel Veillarddd6b3671999-09-23 22:19:22 +0000194 const xmlChar *(*getPublicId)(void *ctx);
195 const xmlChar *(*getSystemId)(void *ctx);
Daniel Veillard27d88741999-05-29 11:51:49 +0000196 int (*getLineNumber)(void *ctx);
197 int (*getColumnNumber)(void *ctx);
Daniel Veillard71b656e2000-01-05 14:46:17 +0000198};
Daniel Veillard260a68f1998-08-13 03:39:55 +0000199
Daniel Veillardb05deb71999-08-10 19:04:08 +0000200/**
201 * a SAX handler is bunch of callbacks called by the parser when processing
202 * of the input generate data or structure informations.
Daniel Veillard260a68f1998-08-13 03:39:55 +0000203 */
204
Daniel Veillard27d88741999-05-29 11:51:49 +0000205typedef xmlParserInputPtr (*resolveEntitySAXFunc) (void *ctx,
Daniel Veillarddd6b3671999-09-23 22:19:22 +0000206 const xmlChar *publicId, const xmlChar *systemId);
207typedef void (*internalSubsetSAXFunc) (void *ctx, const xmlChar *name,
208 const xmlChar *ExternalID, const xmlChar *SystemID);
Daniel Veillardcf461992000-03-14 18:30:20 +0000209typedef void (*externalSubsetSAXFunc) (void *ctx, const xmlChar *name,
210 const xmlChar *ExternalID, const xmlChar *SystemID);
Daniel Veillard27d88741999-05-29 11:51:49 +0000211typedef xmlEntityPtr (*getEntitySAXFunc) (void *ctx,
Daniel Veillarddd6b3671999-09-23 22:19:22 +0000212 const xmlChar *name);
Daniel Veillardb05deb71999-08-10 19:04:08 +0000213typedef xmlEntityPtr (*getParameterEntitySAXFunc) (void *ctx,
Daniel Veillarddd6b3671999-09-23 22:19:22 +0000214 const xmlChar *name);
Daniel Veillard27d88741999-05-29 11:51:49 +0000215typedef void (*entityDeclSAXFunc) (void *ctx,
Daniel Veillarddd6b3671999-09-23 22:19:22 +0000216 const xmlChar *name, int type, const xmlChar *publicId,
217 const xmlChar *systemId, xmlChar *content);
218typedef void (*notationDeclSAXFunc)(void *ctx, const xmlChar *name,
219 const xmlChar *publicId, const xmlChar *systemId);
220typedef void (*attributeDeclSAXFunc)(void *ctx, const xmlChar *elem,
221 const xmlChar *name, int type, int def,
222 const xmlChar *defaultValue, xmlEnumerationPtr tree);
223typedef void (*elementDeclSAXFunc)(void *ctx, const xmlChar *name,
Daniel Veillard517752b1999-04-05 12:20:10 +0000224 int type, xmlElementContentPtr content);
Daniel Veillard27d88741999-05-29 11:51:49 +0000225typedef void (*unparsedEntityDeclSAXFunc)(void *ctx,
Daniel Veillarddd6b3671999-09-23 22:19:22 +0000226 const xmlChar *name, const xmlChar *publicId,
227 const xmlChar *systemId, const xmlChar *notationName);
Daniel Veillard27d88741999-05-29 11:51:49 +0000228typedef void (*setDocumentLocatorSAXFunc) (void *ctx,
Daniel Veillard260a68f1998-08-13 03:39:55 +0000229 xmlSAXLocatorPtr loc);
Daniel Veillard27d88741999-05-29 11:51:49 +0000230typedef void (*startDocumentSAXFunc) (void *ctx);
231typedef void (*endDocumentSAXFunc) (void *ctx);
Daniel Veillarddd6b3671999-09-23 22:19:22 +0000232typedef void (*startElementSAXFunc) (void *ctx, const xmlChar *name,
233 const xmlChar **atts);
234typedef void (*endElementSAXFunc) (void *ctx, const xmlChar *name);
235typedef void (*attributeSAXFunc) (void *ctx, const xmlChar *name,
236 const xmlChar *value);
237typedef void (*referenceSAXFunc) (void *ctx, const xmlChar *name);
238typedef void (*charactersSAXFunc) (void *ctx, const xmlChar *ch,
Daniel Veillard517752b1999-04-05 12:20:10 +0000239 int len);
Daniel Veillard27d88741999-05-29 11:51:49 +0000240typedef void (*ignorableWhitespaceSAXFunc) (void *ctx,
Daniel Veillarddd6b3671999-09-23 22:19:22 +0000241 const xmlChar *ch, int len);
Daniel Veillard27d88741999-05-29 11:51:49 +0000242typedef void (*processingInstructionSAXFunc) (void *ctx,
Daniel Veillarddd6b3671999-09-23 22:19:22 +0000243 const xmlChar *target, const xmlChar *data);
244typedef void (*commentSAXFunc) (void *ctx, const xmlChar *value);
245typedef void (*cdataBlockSAXFunc) (void *ctx, const xmlChar *value, int len);
Daniel Veillard27d88741999-05-29 11:51:49 +0000246typedef void (*warningSAXFunc) (void *ctx, const char *msg, ...);
247typedef void (*errorSAXFunc) (void *ctx, const char *msg, ...);
248typedef void (*fatalErrorSAXFunc) (void *ctx, const char *msg, ...);
249typedef int (*isStandaloneSAXFunc) (void *ctx);
250typedef int (*hasInternalSubsetSAXFunc) (void *ctx);
251typedef int (*hasExternalSubsetSAXFunc) (void *ctx);
Daniel Veillard260a68f1998-08-13 03:39:55 +0000252
Daniel Veillard71b656e2000-01-05 14:46:17 +0000253typedef struct _xmlSAXHandler xmlSAXHandler;
254typedef xmlSAXHandler *xmlSAXHandlerPtr;
255struct _xmlSAXHandler {
Daniel Veillard517752b1999-04-05 12:20:10 +0000256 internalSubsetSAXFunc internalSubset;
257 isStandaloneSAXFunc isStandalone;
258 hasInternalSubsetSAXFunc hasInternalSubset;
259 hasExternalSubsetSAXFunc hasExternalSubset;
Daniel Veillard260a68f1998-08-13 03:39:55 +0000260 resolveEntitySAXFunc resolveEntity;
Daniel Veillard517752b1999-04-05 12:20:10 +0000261 getEntitySAXFunc getEntity;
262 entityDeclSAXFunc entityDecl;
Daniel Veillard260a68f1998-08-13 03:39:55 +0000263 notationDeclSAXFunc notationDecl;
Daniel Veillard517752b1999-04-05 12:20:10 +0000264 attributeDeclSAXFunc attributeDecl;
265 elementDeclSAXFunc elementDecl;
Daniel Veillard260a68f1998-08-13 03:39:55 +0000266 unparsedEntityDeclSAXFunc unparsedEntityDecl;
267 setDocumentLocatorSAXFunc setDocumentLocator;
268 startDocumentSAXFunc startDocument;
269 endDocumentSAXFunc endDocument;
270 startElementSAXFunc startElement;
271 endElementSAXFunc endElement;
Daniel Veillard517752b1999-04-05 12:20:10 +0000272 referenceSAXFunc reference;
Daniel Veillard260a68f1998-08-13 03:39:55 +0000273 charactersSAXFunc characters;
274 ignorableWhitespaceSAXFunc ignorableWhitespace;
275 processingInstructionSAXFunc processingInstruction;
Daniel Veillard517752b1999-04-05 12:20:10 +0000276 commentSAXFunc comment;
Daniel Veillard260a68f1998-08-13 03:39:55 +0000277 warningSAXFunc warning;
278 errorSAXFunc error;
279 fatalErrorSAXFunc fatalError;
Daniel Veillardb05deb71999-08-10 19:04:08 +0000280 getParameterEntitySAXFunc getParameterEntity;
281 cdataBlockSAXFunc cdataBlock;
Daniel Veillardcf461992000-03-14 18:30:20 +0000282 externalSubsetSAXFunc externalSubset;
Daniel Veillard71b656e2000-01-05 14:46:17 +0000283};
Daniel Veillard260a68f1998-08-13 03:39:55 +0000284
Daniel Veillardb05deb71999-08-10 19:04:08 +0000285/**
Daniel Veillard686d6b62000-01-03 11:08:02 +0000286 * External entity loaders types
287 */
288typedef xmlParserInputPtr (*xmlExternalEntityLoader)(const char *URL,
289 const char *ID,
290 xmlParserCtxtPtr context);
291
292/**
Daniel Veillard6454aec1999-09-02 22:04:43 +0000293 * Global variables: just the default SAX interface tables and XML
294 * version infos.
Daniel Veillard260a68f1998-08-13 03:39:55 +0000295 */
Daniel Veillard14fff061999-06-22 21:49:07 +0000296extern const char *xmlParserVersion;
297
Daniel Veillard151b1b01998-09-23 00:49:46 +0000298extern xmlSAXLocator xmlDefaultSAXLocator;
299extern xmlSAXHandler xmlDefaultSAXHandler;
Daniel Veillardbe70ff71999-07-05 16:50:46 +0000300extern xmlSAXHandler htmlDefaultSAXHandler;
Daniel Veillard260a68f1998-08-13 03:39:55 +0000301
Daniel Veillard6454aec1999-09-02 22:04:43 +0000302/**
303 * entity substitution default behaviour.
304 */
305
306extern int xmlSubstituteEntitiesDefaultValue;
Daniel Veillardcf461992000-03-14 18:30:20 +0000307extern int xmlGetWarningsDefaultValue;
Daniel Veillard6454aec1999-09-02 22:04:43 +0000308
Daniel Veillardccb09631998-10-27 06:21:04 +0000309
Daniel Veillardb05deb71999-08-10 19:04:08 +0000310/**
Daniel Veillarda819dac1999-11-24 18:04:22 +0000311 * Cleanup
312 */
313void xmlCleanupParser (void);
314
315/**
Daniel Veillarde2d034d1999-07-27 19:52:06 +0000316 * Input functions
317 */
Daniel Veillardb96e6431999-08-29 21:02:19 +0000318int xmlParserInputRead (xmlParserInputPtr in,
319 int len);
320int xmlParserInputGrow (xmlParserInputPtr in,
321 int len);
Daniel Veillarde2d034d1999-07-27 19:52:06 +0000322
Daniel Veillardb05deb71999-08-10 19:04:08 +0000323/**
Daniel Veillarddd6b3671999-09-23 22:19:22 +0000324 * xmlChar handling
Daniel Veillard260a68f1998-08-13 03:39:55 +0000325 */
Daniel Veillard7a66ee61999-09-26 11:31:02 +0000326xmlChar * xmlStrdup (const xmlChar *cur);
327xmlChar * xmlStrndup (const xmlChar *cur,
Daniel Veillardb96e6431999-08-29 21:02:19 +0000328 int len);
Daniel Veillard7a66ee61999-09-26 11:31:02 +0000329xmlChar * xmlStrsub (const xmlChar *str,
Daniel Veillardb96e6431999-08-29 21:02:19 +0000330 int start,
331 int len);
Daniel Veillarddd6b3671999-09-23 22:19:22 +0000332const xmlChar * xmlStrchr (const xmlChar *str,
333 xmlChar val);
334const xmlChar * xmlStrstr (const xmlChar *str,
335 xmlChar *val);
336int xmlStrcmp (const xmlChar *str1,
337 const xmlChar *str2);
338int xmlStrncmp (const xmlChar *str1,
339 const xmlChar *str2,
Daniel Veillardb96e6431999-08-29 21:02:19 +0000340 int len);
Daniel Veillarddd6b3671999-09-23 22:19:22 +0000341int xmlStrlen (const xmlChar *str);
Daniel Veillard7a66ee61999-09-26 11:31:02 +0000342xmlChar * xmlStrcat (xmlChar *cur,
Daniel Veillarddd6b3671999-09-23 22:19:22 +0000343 const xmlChar *add);
Daniel Veillard7a66ee61999-09-26 11:31:02 +0000344xmlChar * xmlStrncat (xmlChar *cur,
Daniel Veillarddd6b3671999-09-23 22:19:22 +0000345 const xmlChar *add,
Daniel Veillardb96e6431999-08-29 21:02:19 +0000346 int len);
Daniel Veillard260a68f1998-08-13 03:39:55 +0000347
Daniel Veillardb05deb71999-08-10 19:04:08 +0000348/**
349 * Basic parsing Interfaces
Daniel Veillard39a1f9a1999-01-17 19:11:59 +0000350 */
Daniel Veillarddd6b3671999-09-23 22:19:22 +0000351xmlDocPtr xmlParseDoc (xmlChar *cur);
Daniel Veillardb96e6431999-08-29 21:02:19 +0000352xmlDocPtr xmlParseMemory (char *buffer,
353 int size);
354xmlDocPtr xmlParseFile (const char *filename);
355int xmlSubstituteEntitiesDefault(int val);
Daniel Veillard3e6d2372000-03-04 11:39:43 +0000356int xmlKeepBlanksDefault (int val);
Daniel Veillard3f6f7f62000-06-30 17:58:25 +0000357void xmlStopParser (xmlParserCtxtPtr ctxt);
Daniel Veillardf0cc7cc2000-08-26 21:40:43 +0000358int xmlPedanticParserDefault(int val);
Daniel Veillard39a1f9a1999-01-17 19:11:59 +0000359
Daniel Veillardb05deb71999-08-10 19:04:08 +0000360/**
Daniel Veillard39a1f9a1999-01-17 19:11:59 +0000361 * Recovery mode
362 */
Daniel Veillarddd6b3671999-09-23 22:19:22 +0000363xmlDocPtr xmlRecoverDoc (xmlChar *cur);
Daniel Veillardb96e6431999-08-29 21:02:19 +0000364xmlDocPtr xmlRecoverMemory (char *buffer,
365 int size);
366xmlDocPtr xmlRecoverFile (const char *filename);
Daniel Veillard39a1f9a1999-01-17 19:11:59 +0000367
Daniel Veillardb05deb71999-08-10 19:04:08 +0000368/**
369 * Less common routines and SAX interfaces
Daniel Veillard39a1f9a1999-01-17 19:11:59 +0000370 */
Daniel Veillardb96e6431999-08-29 21:02:19 +0000371int xmlParseDocument (xmlParserCtxtPtr ctxt);
372xmlDocPtr xmlSAXParseDoc (xmlSAXHandlerPtr sax,
Daniel Veillarddd6b3671999-09-23 22:19:22 +0000373 xmlChar *cur,
Daniel Veillardb96e6431999-08-29 21:02:19 +0000374 int recovery);
Daniel Veillard7a66ee61999-09-26 11:31:02 +0000375int xmlSAXUserParseFile (xmlSAXHandlerPtr sax,
376 void *user_data,
377 const char *filename);
378int xmlSAXUserParseMemory (xmlSAXHandlerPtr sax,
379 void *user_data,
380 char *buffer,
381 int size);
Daniel Veillardb96e6431999-08-29 21:02:19 +0000382xmlDocPtr xmlSAXParseMemory (xmlSAXHandlerPtr sax,
383 char *buffer,
384 int size,
385 int recovery);
386xmlDocPtr xmlSAXParseFile (xmlSAXHandlerPtr sax,
387 const char *filename,
388 int recovery);
Daniel Veillarddd6b3671999-09-23 22:19:22 +0000389xmlDtdPtr xmlParseDTD (const xmlChar *ExternalID,
390 const xmlChar *SystemID);
Daniel Veillardb96e6431999-08-29 21:02:19 +0000391xmlDtdPtr xmlSAXParseDTD (xmlSAXHandlerPtr sax,
Daniel Veillarddd6b3671999-09-23 22:19:22 +0000392 const xmlChar *ExternalID,
393 const xmlChar *SystemID);
Daniel Veillardcf461992000-03-14 18:30:20 +0000394int xmlParseBalancedChunkMemory(xmlDocPtr doc,
395 xmlSAXHandlerPtr sax,
396 void *user_data,
397 int depth,
398 const xmlChar *string,
399 xmlNodePtr *list);
400int xmlParseExternalEntity (xmlDocPtr doc,
401 xmlSAXHandlerPtr sax,
402 void *user_data,
403 int depth,
404 const xmlChar *URL,
405 const xmlChar *ID,
406 xmlNodePtr *list);
Daniel Veillard87b95392000-08-12 21:12:04 +0000407int xmlParseCtxtExternalEntity(xmlParserCtxtPtr ctx,
408 const xmlChar *URL,
409 const xmlChar *ID,
410 xmlNodePtr *list);
Daniel Veillardcf461992000-03-14 18:30:20 +0000411
Daniel Veillarddbfd6411999-12-28 16:35:14 +0000412/**
413 * SAX initialization routines
414 */
415void xmlDefaultSAXHandlerInit(void);
416void htmlDefaultSAXHandlerInit(void);
417
418/**
419 * Parser contexts handling.
420 */
Daniel Veillardb96e6431999-08-29 21:02:19 +0000421void xmlInitParserCtxt (xmlParserCtxtPtr ctxt);
422void xmlClearParserCtxt (xmlParserCtxtPtr ctxt);
Daniel Veillarddbfd6411999-12-28 16:35:14 +0000423void xmlFreeParserCtxt (xmlParserCtxtPtr ctxt);
Daniel Veillardb96e6431999-08-29 21:02:19 +0000424void xmlSetupParserForBuffer (xmlParserCtxtPtr ctxt,
Daniel Veillarddd6b3671999-09-23 22:19:22 +0000425 const xmlChar* buffer,
Daniel Veillardb96e6431999-08-29 21:02:19 +0000426 const char* filename);
Daniel Veillarddbfd6411999-12-28 16:35:14 +0000427xmlParserCtxtPtr xmlCreateDocParserCtxt (xmlChar *cur);
428
429/**
Daniel Veillard87b95392000-08-12 21:12:04 +0000430 * Reading/setting optional parsing features.
431 */
432
433int xmlGetFeaturesList (int *len,
434 const char **result);
435int xmlGetFeature (xmlParserCtxtPtr ctxt,
436 const char *name,
437 void *result);
438int xmlSetFeature (xmlParserCtxtPtr ctxt,
439 const char *name,
440 void *value);
441
442/**
Daniel Veillarddbfd6411999-12-28 16:35:14 +0000443 * Interfaces for the Push mode
444 */
445xmlParserCtxtPtr xmlCreatePushParserCtxt(xmlSAXHandlerPtr sax,
446 void *user_data,
447 const char *chunk,
448 int size,
449 const char *filename);
450int xmlParseChunk (xmlParserCtxtPtr ctxt,
451 const char *chunk,
452 int size,
453 int terminate);
Daniel Veillard260a68f1998-08-13 03:39:55 +0000454
Daniel Veillardb96e6431999-08-29 21:02:19 +0000455/**
Daniel Veillard5e873c42000-04-12 13:27:38 +0000456 * Special I/O mode
457 */
458
459xmlParserCtxtPtr xmlCreateIOParserCtxt (xmlSAXHandlerPtr sax,
460 void *user_data,
461 xmlInputReadCallback ioread,
462 xmlInputCloseCallback ioclose,
463 void *ioctx,
464 xmlCharEncoding enc);
465
466xmlParserInputPtr xmlNewIOInputStream (xmlParserCtxtPtr ctxt,
467 xmlParserInputBufferPtr input,
468 xmlCharEncoding enc);
469
470/**
Daniel Veillardb96e6431999-08-29 21:02:19 +0000471 * Node infos
472 */
473const xmlParserNodeInfo*
474 xmlParserFindNodeInfo (const xmlParserCtxt* ctxt,
Daniel Veillard1e346af1999-02-22 10:33:01 +0000475 const xmlNode* node);
Daniel Veillardb96e6431999-08-29 21:02:19 +0000476void xmlInitNodeInfoSeq (xmlParserNodeInfoSeqPtr seq);
477void xmlClearNodeInfoSeq (xmlParserNodeInfoSeqPtr seq);
Daniel Veillard260a68f1998-08-13 03:39:55 +0000478unsigned long xmlParserFindNodeInfoIndex(const xmlParserNodeInfoSeq* seq,
479 const xmlNode* node);
Daniel Veillardb96e6431999-08-29 21:02:19 +0000480void xmlParserAddNodeInfo (xmlParserCtxtPtr ctxt,
481 const xmlParserNodeInfo* info);
Daniel Veillard260a68f1998-08-13 03:39:55 +0000482
Daniel Veillardb96e6431999-08-29 21:02:19 +0000483/*
484 * External entities handling actually implemented in xmlIO
485 */
486
487void xmlSetExternalEntityLoader(xmlExternalEntityLoader f);
488xmlExternalEntityLoader
489 xmlGetExternalEntityLoader(void);
490xmlParserInputPtr
491 xmlLoadExternalEntity (const char *URL,
492 const char *ID,
Daniel Veillard686d6b62000-01-03 11:08:02 +0000493 xmlParserCtxtPtr context);
Daniel Veillard4a53eca1999-12-12 13:03:50 +0000494
Daniel Veillard260a68f1998-08-13 03:39:55 +0000495#ifdef __cplusplus
496}
497#endif
498
499#endif /* __XML_PARSER_H__ */
500