blob: 7e0a37abe5a7c0ad7c953c0e2e94276f75f7986f [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 Veillardb513f5a2000-09-10 14:01:12 +0000119 void *userData; /* For SAX interface only, used by DOM build */
Daniel Veillard517752b1999-04-05 12:20:10 +0000120 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 Veillardb513f5a2000-09-10 14:01:12 +0000126 int html; /* an HTML(1)/Docbook(2) 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 Veillardb513f5a2000-09-10 14:01:12 +0000186 void *_private; /* For user data, libxml won't touch it */
Daniel Veillard71b656e2000-01-05 14:46:17 +0000187};
Daniel Veillard260a68f1998-08-13 03:39:55 +0000188
Daniel Veillardb05deb71999-08-10 19:04:08 +0000189/**
Daniel Veillard260a68f1998-08-13 03:39:55 +0000190 * a SAX Locator.
191 */
Daniel Veillard71b656e2000-01-05 14:46:17 +0000192typedef struct _xmlSAXLocator xmlSAXLocator;
193typedef xmlSAXLocator *xmlSAXLocatorPtr;
194struct _xmlSAXLocator {
Daniel Veillarddd6b3671999-09-23 22:19:22 +0000195 const xmlChar *(*getPublicId)(void *ctx);
196 const xmlChar *(*getSystemId)(void *ctx);
Daniel Veillard27d88741999-05-29 11:51:49 +0000197 int (*getLineNumber)(void *ctx);
198 int (*getColumnNumber)(void *ctx);
Daniel Veillard71b656e2000-01-05 14:46:17 +0000199};
Daniel Veillard260a68f1998-08-13 03:39:55 +0000200
Daniel Veillardb05deb71999-08-10 19:04:08 +0000201/**
202 * a SAX handler is bunch of callbacks called by the parser when processing
203 * of the input generate data or structure informations.
Daniel Veillard260a68f1998-08-13 03:39:55 +0000204 */
205
Daniel Veillard27d88741999-05-29 11:51:49 +0000206typedef xmlParserInputPtr (*resolveEntitySAXFunc) (void *ctx,
Daniel Veillarddd6b3671999-09-23 22:19:22 +0000207 const xmlChar *publicId, const xmlChar *systemId);
208typedef void (*internalSubsetSAXFunc) (void *ctx, const xmlChar *name,
209 const xmlChar *ExternalID, const xmlChar *SystemID);
Daniel Veillardcf461992000-03-14 18:30:20 +0000210typedef void (*externalSubsetSAXFunc) (void *ctx, const xmlChar *name,
211 const xmlChar *ExternalID, const xmlChar *SystemID);
Daniel Veillard27d88741999-05-29 11:51:49 +0000212typedef xmlEntityPtr (*getEntitySAXFunc) (void *ctx,
Daniel Veillarddd6b3671999-09-23 22:19:22 +0000213 const xmlChar *name);
Daniel Veillardb05deb71999-08-10 19:04:08 +0000214typedef xmlEntityPtr (*getParameterEntitySAXFunc) (void *ctx,
Daniel Veillarddd6b3671999-09-23 22:19:22 +0000215 const xmlChar *name);
Daniel Veillard27d88741999-05-29 11:51:49 +0000216typedef void (*entityDeclSAXFunc) (void *ctx,
Daniel Veillarddd6b3671999-09-23 22:19:22 +0000217 const xmlChar *name, int type, const xmlChar *publicId,
218 const xmlChar *systemId, xmlChar *content);
219typedef void (*notationDeclSAXFunc)(void *ctx, const xmlChar *name,
220 const xmlChar *publicId, const xmlChar *systemId);
221typedef void (*attributeDeclSAXFunc)(void *ctx, const xmlChar *elem,
222 const xmlChar *name, int type, int def,
223 const xmlChar *defaultValue, xmlEnumerationPtr tree);
224typedef void (*elementDeclSAXFunc)(void *ctx, const xmlChar *name,
Daniel Veillard517752b1999-04-05 12:20:10 +0000225 int type, xmlElementContentPtr content);
Daniel Veillard27d88741999-05-29 11:51:49 +0000226typedef void (*unparsedEntityDeclSAXFunc)(void *ctx,
Daniel Veillarddd6b3671999-09-23 22:19:22 +0000227 const xmlChar *name, const xmlChar *publicId,
228 const xmlChar *systemId, const xmlChar *notationName);
Daniel Veillard27d88741999-05-29 11:51:49 +0000229typedef void (*setDocumentLocatorSAXFunc) (void *ctx,
Daniel Veillard260a68f1998-08-13 03:39:55 +0000230 xmlSAXLocatorPtr loc);
Daniel Veillard27d88741999-05-29 11:51:49 +0000231typedef void (*startDocumentSAXFunc) (void *ctx);
232typedef void (*endDocumentSAXFunc) (void *ctx);
Daniel Veillarddd6b3671999-09-23 22:19:22 +0000233typedef void (*startElementSAXFunc) (void *ctx, const xmlChar *name,
234 const xmlChar **atts);
235typedef void (*endElementSAXFunc) (void *ctx, const xmlChar *name);
236typedef void (*attributeSAXFunc) (void *ctx, const xmlChar *name,
237 const xmlChar *value);
238typedef void (*referenceSAXFunc) (void *ctx, const xmlChar *name);
239typedef void (*charactersSAXFunc) (void *ctx, const xmlChar *ch,
Daniel Veillard517752b1999-04-05 12:20:10 +0000240 int len);
Daniel Veillard27d88741999-05-29 11:51:49 +0000241typedef void (*ignorableWhitespaceSAXFunc) (void *ctx,
Daniel Veillarddd6b3671999-09-23 22:19:22 +0000242 const xmlChar *ch, int len);
Daniel Veillard27d88741999-05-29 11:51:49 +0000243typedef void (*processingInstructionSAXFunc) (void *ctx,
Daniel Veillarddd6b3671999-09-23 22:19:22 +0000244 const xmlChar *target, const xmlChar *data);
245typedef void (*commentSAXFunc) (void *ctx, const xmlChar *value);
246typedef void (*cdataBlockSAXFunc) (void *ctx, const xmlChar *value, int len);
Daniel Veillard27d88741999-05-29 11:51:49 +0000247typedef void (*warningSAXFunc) (void *ctx, const char *msg, ...);
248typedef void (*errorSAXFunc) (void *ctx, const char *msg, ...);
249typedef void (*fatalErrorSAXFunc) (void *ctx, const char *msg, ...);
250typedef int (*isStandaloneSAXFunc) (void *ctx);
251typedef int (*hasInternalSubsetSAXFunc) (void *ctx);
252typedef int (*hasExternalSubsetSAXFunc) (void *ctx);
Daniel Veillard260a68f1998-08-13 03:39:55 +0000253
Daniel Veillard71b656e2000-01-05 14:46:17 +0000254typedef struct _xmlSAXHandler xmlSAXHandler;
255typedef xmlSAXHandler *xmlSAXHandlerPtr;
256struct _xmlSAXHandler {
Daniel Veillard517752b1999-04-05 12:20:10 +0000257 internalSubsetSAXFunc internalSubset;
258 isStandaloneSAXFunc isStandalone;
259 hasInternalSubsetSAXFunc hasInternalSubset;
260 hasExternalSubsetSAXFunc hasExternalSubset;
Daniel Veillard260a68f1998-08-13 03:39:55 +0000261 resolveEntitySAXFunc resolveEntity;
Daniel Veillard517752b1999-04-05 12:20:10 +0000262 getEntitySAXFunc getEntity;
263 entityDeclSAXFunc entityDecl;
Daniel Veillard260a68f1998-08-13 03:39:55 +0000264 notationDeclSAXFunc notationDecl;
Daniel Veillard517752b1999-04-05 12:20:10 +0000265 attributeDeclSAXFunc attributeDecl;
266 elementDeclSAXFunc elementDecl;
Daniel Veillard260a68f1998-08-13 03:39:55 +0000267 unparsedEntityDeclSAXFunc unparsedEntityDecl;
268 setDocumentLocatorSAXFunc setDocumentLocator;
269 startDocumentSAXFunc startDocument;
270 endDocumentSAXFunc endDocument;
271 startElementSAXFunc startElement;
272 endElementSAXFunc endElement;
Daniel Veillard517752b1999-04-05 12:20:10 +0000273 referenceSAXFunc reference;
Daniel Veillard260a68f1998-08-13 03:39:55 +0000274 charactersSAXFunc characters;
275 ignorableWhitespaceSAXFunc ignorableWhitespace;
276 processingInstructionSAXFunc processingInstruction;
Daniel Veillard517752b1999-04-05 12:20:10 +0000277 commentSAXFunc comment;
Daniel Veillard260a68f1998-08-13 03:39:55 +0000278 warningSAXFunc warning;
279 errorSAXFunc error;
280 fatalErrorSAXFunc fatalError;
Daniel Veillardb05deb71999-08-10 19:04:08 +0000281 getParameterEntitySAXFunc getParameterEntity;
282 cdataBlockSAXFunc cdataBlock;
Daniel Veillardcf461992000-03-14 18:30:20 +0000283 externalSubsetSAXFunc externalSubset;
Daniel Veillard71b656e2000-01-05 14:46:17 +0000284};
Daniel Veillard260a68f1998-08-13 03:39:55 +0000285
Daniel Veillardb05deb71999-08-10 19:04:08 +0000286/**
Daniel Veillard686d6b62000-01-03 11:08:02 +0000287 * External entity loaders types
288 */
289typedef xmlParserInputPtr (*xmlExternalEntityLoader)(const char *URL,
290 const char *ID,
291 xmlParserCtxtPtr context);
292
293/**
Daniel Veillard6454aec1999-09-02 22:04:43 +0000294 * Global variables: just the default SAX interface tables and XML
295 * version infos.
Daniel Veillard260a68f1998-08-13 03:39:55 +0000296 */
Daniel Veillard14fff061999-06-22 21:49:07 +0000297extern const char *xmlParserVersion;
298
Daniel Veillard151b1b01998-09-23 00:49:46 +0000299extern xmlSAXLocator xmlDefaultSAXLocator;
300extern xmlSAXHandler xmlDefaultSAXHandler;
Daniel Veillardbe70ff71999-07-05 16:50:46 +0000301extern xmlSAXHandler htmlDefaultSAXHandler;
Daniel Veillardb513f5a2000-09-10 14:01:12 +0000302extern xmlSAXHandler sgmlDefaultSAXHandler;
Daniel Veillard260a68f1998-08-13 03:39:55 +0000303
Daniel Veillard6454aec1999-09-02 22:04:43 +0000304/**
305 * entity substitution default behaviour.
306 */
307
308extern int xmlSubstituteEntitiesDefaultValue;
Daniel Veillardcf461992000-03-14 18:30:20 +0000309extern int xmlGetWarningsDefaultValue;
Daniel Veillard6454aec1999-09-02 22:04:43 +0000310
Daniel Veillardccb09631998-10-27 06:21:04 +0000311
Daniel Veillardb05deb71999-08-10 19:04:08 +0000312/**
Daniel Veillarda819dac1999-11-24 18:04:22 +0000313 * Cleanup
314 */
315void xmlCleanupParser (void);
316
317/**
Daniel Veillarde2d034d1999-07-27 19:52:06 +0000318 * Input functions
319 */
Daniel Veillardb96e6431999-08-29 21:02:19 +0000320int xmlParserInputRead (xmlParserInputPtr in,
321 int len);
322int xmlParserInputGrow (xmlParserInputPtr in,
323 int len);
Daniel Veillarde2d034d1999-07-27 19:52:06 +0000324
Daniel Veillardb05deb71999-08-10 19:04:08 +0000325/**
Daniel Veillarddd6b3671999-09-23 22:19:22 +0000326 * xmlChar handling
Daniel Veillard260a68f1998-08-13 03:39:55 +0000327 */
Daniel Veillard7a66ee61999-09-26 11:31:02 +0000328xmlChar * xmlStrdup (const xmlChar *cur);
329xmlChar * xmlStrndup (const xmlChar *cur,
Daniel Veillardb96e6431999-08-29 21:02:19 +0000330 int len);
Daniel Veillard7a66ee61999-09-26 11:31:02 +0000331xmlChar * xmlStrsub (const xmlChar *str,
Daniel Veillardb96e6431999-08-29 21:02:19 +0000332 int start,
333 int len);
Daniel Veillarddd6b3671999-09-23 22:19:22 +0000334const xmlChar * xmlStrchr (const xmlChar *str,
335 xmlChar val);
336const xmlChar * xmlStrstr (const xmlChar *str,
337 xmlChar *val);
Daniel Veillardb656ebe2000-09-22 13:51:48 +0000338const xmlChar * xmlStrcasestr (const xmlChar *str,
339 xmlChar *val);
Daniel Veillarddd6b3671999-09-23 22:19:22 +0000340int xmlStrcmp (const xmlChar *str1,
341 const xmlChar *str2);
342int xmlStrncmp (const xmlChar *str1,
343 const xmlChar *str2,
Daniel Veillardb96e6431999-08-29 21:02:19 +0000344 int len);
Daniel Veillardb656ebe2000-09-22 13:51:48 +0000345int xmlStrcasecmp (const xmlChar *str1,
346 const xmlChar *str2);
347int xmlStrncasecmp (const xmlChar *str1,
348 const xmlChar *str2,
349 int len);
Daniel Veillarddd6b3671999-09-23 22:19:22 +0000350int xmlStrlen (const xmlChar *str);
Daniel Veillard7a66ee61999-09-26 11:31:02 +0000351xmlChar * xmlStrcat (xmlChar *cur,
Daniel Veillarddd6b3671999-09-23 22:19:22 +0000352 const xmlChar *add);
Daniel Veillard7a66ee61999-09-26 11:31:02 +0000353xmlChar * xmlStrncat (xmlChar *cur,
Daniel Veillarddd6b3671999-09-23 22:19:22 +0000354 const xmlChar *add,
Daniel Veillardb96e6431999-08-29 21:02:19 +0000355 int len);
Daniel Veillard260a68f1998-08-13 03:39:55 +0000356
Daniel Veillardb05deb71999-08-10 19:04:08 +0000357/**
358 * Basic parsing Interfaces
Daniel Veillard39a1f9a1999-01-17 19:11:59 +0000359 */
Daniel Veillarddd6b3671999-09-23 22:19:22 +0000360xmlDocPtr xmlParseDoc (xmlChar *cur);
Daniel Veillardb96e6431999-08-29 21:02:19 +0000361xmlDocPtr xmlParseMemory (char *buffer,
362 int size);
363xmlDocPtr xmlParseFile (const char *filename);
364int xmlSubstituteEntitiesDefault(int val);
Daniel Veillard3e6d2372000-03-04 11:39:43 +0000365int xmlKeepBlanksDefault (int val);
Daniel Veillard3f6f7f62000-06-30 17:58:25 +0000366void xmlStopParser (xmlParserCtxtPtr ctxt);
Daniel Veillardf0cc7cc2000-08-26 21:40:43 +0000367int xmlPedanticParserDefault(int val);
Daniel Veillard39a1f9a1999-01-17 19:11:59 +0000368
Daniel Veillardb05deb71999-08-10 19:04:08 +0000369/**
Daniel Veillard39a1f9a1999-01-17 19:11:59 +0000370 * Recovery mode
371 */
Daniel Veillarddd6b3671999-09-23 22:19:22 +0000372xmlDocPtr xmlRecoverDoc (xmlChar *cur);
Daniel Veillardb96e6431999-08-29 21:02:19 +0000373xmlDocPtr xmlRecoverMemory (char *buffer,
374 int size);
375xmlDocPtr xmlRecoverFile (const char *filename);
Daniel Veillard39a1f9a1999-01-17 19:11:59 +0000376
Daniel Veillardb05deb71999-08-10 19:04:08 +0000377/**
378 * Less common routines and SAX interfaces
Daniel Veillard39a1f9a1999-01-17 19:11:59 +0000379 */
Daniel Veillardb96e6431999-08-29 21:02:19 +0000380int xmlParseDocument (xmlParserCtxtPtr ctxt);
Daniel Veillardb1059e22000-09-16 14:02:43 +0000381int xmlParseExtParsedEnt (xmlParserCtxtPtr ctxt);
Daniel Veillardb96e6431999-08-29 21:02:19 +0000382xmlDocPtr xmlSAXParseDoc (xmlSAXHandlerPtr sax,
Daniel Veillarddd6b3671999-09-23 22:19:22 +0000383 xmlChar *cur,
Daniel Veillardb96e6431999-08-29 21:02:19 +0000384 int recovery);
Daniel Veillard7a66ee61999-09-26 11:31:02 +0000385int xmlSAXUserParseFile (xmlSAXHandlerPtr sax,
386 void *user_data,
387 const char *filename);
388int xmlSAXUserParseMemory (xmlSAXHandlerPtr sax,
389 void *user_data,
390 char *buffer,
391 int size);
Daniel Veillardb96e6431999-08-29 21:02:19 +0000392xmlDocPtr xmlSAXParseMemory (xmlSAXHandlerPtr sax,
393 char *buffer,
394 int size,
395 int recovery);
396xmlDocPtr xmlSAXParseFile (xmlSAXHandlerPtr sax,
397 const char *filename,
398 int recovery);
Daniel Veillardb1059e22000-09-16 14:02:43 +0000399xmlDocPtr xmlSAXParseEntity (xmlSAXHandlerPtr sax,
400 const char *filename);
401xmlDocPtr xmlParseEntity (const char *filename);
Daniel Veillarddd6b3671999-09-23 22:19:22 +0000402xmlDtdPtr xmlParseDTD (const xmlChar *ExternalID,
403 const xmlChar *SystemID);
Daniel Veillardb96e6431999-08-29 21:02:19 +0000404xmlDtdPtr xmlSAXParseDTD (xmlSAXHandlerPtr sax,
Daniel Veillarddd6b3671999-09-23 22:19:22 +0000405 const xmlChar *ExternalID,
406 const xmlChar *SystemID);
Daniel Veillardcf461992000-03-14 18:30:20 +0000407int xmlParseBalancedChunkMemory(xmlDocPtr doc,
408 xmlSAXHandlerPtr sax,
409 void *user_data,
410 int depth,
411 const xmlChar *string,
412 xmlNodePtr *list);
413int xmlParseExternalEntity (xmlDocPtr doc,
414 xmlSAXHandlerPtr sax,
415 void *user_data,
416 int depth,
417 const xmlChar *URL,
418 const xmlChar *ID,
419 xmlNodePtr *list);
Daniel Veillard87b95392000-08-12 21:12:04 +0000420int xmlParseCtxtExternalEntity(xmlParserCtxtPtr ctx,
421 const xmlChar *URL,
422 const xmlChar *ID,
423 xmlNodePtr *list);
Daniel Veillardcf461992000-03-14 18:30:20 +0000424
Daniel Veillarddbfd6411999-12-28 16:35:14 +0000425/**
426 * SAX initialization routines
427 */
428void xmlDefaultSAXHandlerInit(void);
429void htmlDefaultSAXHandlerInit(void);
430
431/**
432 * Parser contexts handling.
433 */
Daniel Veillardb96e6431999-08-29 21:02:19 +0000434void xmlInitParserCtxt (xmlParserCtxtPtr ctxt);
435void xmlClearParserCtxt (xmlParserCtxtPtr ctxt);
Daniel Veillarddbfd6411999-12-28 16:35:14 +0000436void xmlFreeParserCtxt (xmlParserCtxtPtr ctxt);
Daniel Veillardb96e6431999-08-29 21:02:19 +0000437void xmlSetupParserForBuffer (xmlParserCtxtPtr ctxt,
Daniel Veillarddd6b3671999-09-23 22:19:22 +0000438 const xmlChar* buffer,
Daniel Veillardb96e6431999-08-29 21:02:19 +0000439 const char* filename);
Daniel Veillarddbfd6411999-12-28 16:35:14 +0000440xmlParserCtxtPtr xmlCreateDocParserCtxt (xmlChar *cur);
441
442/**
Daniel Veillard87b95392000-08-12 21:12:04 +0000443 * Reading/setting optional parsing features.
444 */
445
446int xmlGetFeaturesList (int *len,
447 const char **result);
448int xmlGetFeature (xmlParserCtxtPtr ctxt,
449 const char *name,
450 void *result);
451int xmlSetFeature (xmlParserCtxtPtr ctxt,
452 const char *name,
453 void *value);
454
455/**
Daniel Veillarddbfd6411999-12-28 16:35:14 +0000456 * Interfaces for the Push mode
457 */
458xmlParserCtxtPtr xmlCreatePushParserCtxt(xmlSAXHandlerPtr sax,
459 void *user_data,
460 const char *chunk,
461 int size,
462 const char *filename);
463int xmlParseChunk (xmlParserCtxtPtr ctxt,
464 const char *chunk,
465 int size,
466 int terminate);
Daniel Veillard260a68f1998-08-13 03:39:55 +0000467
Daniel Veillardb96e6431999-08-29 21:02:19 +0000468/**
Daniel Veillard5e873c42000-04-12 13:27:38 +0000469 * Special I/O mode
470 */
471
472xmlParserCtxtPtr xmlCreateIOParserCtxt (xmlSAXHandlerPtr sax,
473 void *user_data,
474 xmlInputReadCallback ioread,
475 xmlInputCloseCallback ioclose,
476 void *ioctx,
477 xmlCharEncoding enc);
478
479xmlParserInputPtr xmlNewIOInputStream (xmlParserCtxtPtr ctxt,
480 xmlParserInputBufferPtr input,
481 xmlCharEncoding enc);
482
483/**
Daniel Veillardb96e6431999-08-29 21:02:19 +0000484 * Node infos
485 */
486const xmlParserNodeInfo*
487 xmlParserFindNodeInfo (const xmlParserCtxt* ctxt,
Daniel Veillard1e346af1999-02-22 10:33:01 +0000488 const xmlNode* node);
Daniel Veillardb96e6431999-08-29 21:02:19 +0000489void xmlInitNodeInfoSeq (xmlParserNodeInfoSeqPtr seq);
490void xmlClearNodeInfoSeq (xmlParserNodeInfoSeqPtr seq);
Daniel Veillard260a68f1998-08-13 03:39:55 +0000491unsigned long xmlParserFindNodeInfoIndex(const xmlParserNodeInfoSeq* seq,
492 const xmlNode* node);
Daniel Veillardb96e6431999-08-29 21:02:19 +0000493void xmlParserAddNodeInfo (xmlParserCtxtPtr ctxt,
494 const xmlParserNodeInfo* info);
Daniel Veillard260a68f1998-08-13 03:39:55 +0000495
Daniel Veillardb96e6431999-08-29 21:02:19 +0000496/*
497 * External entities handling actually implemented in xmlIO
498 */
499
500void xmlSetExternalEntityLoader(xmlExternalEntityLoader f);
501xmlExternalEntityLoader
502 xmlGetExternalEntityLoader(void);
503xmlParserInputPtr
504 xmlLoadExternalEntity (const char *URL,
505 const char *ID,
Daniel Veillard686d6b62000-01-03 11:08:02 +0000506 xmlParserCtxtPtr context);
Daniel Veillard4a53eca1999-12-12 13:03:50 +0000507
Daniel Veillard260a68f1998-08-13 03:39:55 +0000508#ifdef __cplusplus
509}
510#endif
511
512#endif /* __XML_PARSER_H__ */
513