blob: 17051d79f1c69d43513a2f432799382ebb88d5cf [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 Veillardbc765302000-10-01 18:23:35 +0000313 * Init/Cleanup
Daniel Veillarda819dac1999-11-24 18:04:22 +0000314 */
Daniel Veillardbc765302000-10-01 18:23:35 +0000315void xmlInitParser (void);
Daniel Veillarda819dac1999-11-24 18:04:22 +0000316void xmlCleanupParser (void);
317
318/**
Daniel Veillarde2d034d1999-07-27 19:52:06 +0000319 * Input functions
320 */
Daniel Veillardb96e6431999-08-29 21:02:19 +0000321int xmlParserInputRead (xmlParserInputPtr in,
322 int len);
323int xmlParserInputGrow (xmlParserInputPtr in,
324 int len);
Daniel Veillarde2d034d1999-07-27 19:52:06 +0000325
Daniel Veillardb05deb71999-08-10 19:04:08 +0000326/**
Daniel Veillarddd6b3671999-09-23 22:19:22 +0000327 * xmlChar handling
Daniel Veillard260a68f1998-08-13 03:39:55 +0000328 */
Daniel Veillard7a66ee61999-09-26 11:31:02 +0000329xmlChar * xmlStrdup (const xmlChar *cur);
330xmlChar * xmlStrndup (const xmlChar *cur,
Daniel Veillardb96e6431999-08-29 21:02:19 +0000331 int len);
Daniel Veillard7a66ee61999-09-26 11:31:02 +0000332xmlChar * xmlStrsub (const xmlChar *str,
Daniel Veillardb96e6431999-08-29 21:02:19 +0000333 int start,
334 int len);
Daniel Veillarddd6b3671999-09-23 22:19:22 +0000335const xmlChar * xmlStrchr (const xmlChar *str,
336 xmlChar val);
337const xmlChar * xmlStrstr (const xmlChar *str,
338 xmlChar *val);
Daniel Veillardb656ebe2000-09-22 13:51:48 +0000339const xmlChar * xmlStrcasestr (const xmlChar *str,
340 xmlChar *val);
Daniel Veillarddd6b3671999-09-23 22:19:22 +0000341int xmlStrcmp (const xmlChar *str1,
342 const xmlChar *str2);
343int xmlStrncmp (const xmlChar *str1,
344 const xmlChar *str2,
Daniel Veillardb96e6431999-08-29 21:02:19 +0000345 int len);
Daniel Veillardb656ebe2000-09-22 13:51:48 +0000346int xmlStrcasecmp (const xmlChar *str1,
347 const xmlChar *str2);
348int xmlStrncasecmp (const xmlChar *str1,
349 const xmlChar *str2,
350 int len);
Daniel Veillard8b5dd832000-10-01 20:28:44 +0000351int xmlStrEqual (const xmlChar *str1,
352 const xmlChar *str2);
Daniel Veillarddd6b3671999-09-23 22:19:22 +0000353int xmlStrlen (const xmlChar *str);
Daniel Veillard7a66ee61999-09-26 11:31:02 +0000354xmlChar * xmlStrcat (xmlChar *cur,
Daniel Veillarddd6b3671999-09-23 22:19:22 +0000355 const xmlChar *add);
Daniel Veillard7a66ee61999-09-26 11:31:02 +0000356xmlChar * xmlStrncat (xmlChar *cur,
Daniel Veillarddd6b3671999-09-23 22:19:22 +0000357 const xmlChar *add,
Daniel Veillardb96e6431999-08-29 21:02:19 +0000358 int len);
Daniel Veillard260a68f1998-08-13 03:39:55 +0000359
Daniel Veillardb05deb71999-08-10 19:04:08 +0000360/**
361 * Basic parsing Interfaces
Daniel Veillard39a1f9a1999-01-17 19:11:59 +0000362 */
Daniel Veillarddd6b3671999-09-23 22:19:22 +0000363xmlDocPtr xmlParseDoc (xmlChar *cur);
Daniel Veillardb96e6431999-08-29 21:02:19 +0000364xmlDocPtr xmlParseMemory (char *buffer,
365 int size);
366xmlDocPtr xmlParseFile (const char *filename);
367int xmlSubstituteEntitiesDefault(int val);
Daniel Veillard3e6d2372000-03-04 11:39:43 +0000368int xmlKeepBlanksDefault (int val);
Daniel Veillard3f6f7f62000-06-30 17:58:25 +0000369void xmlStopParser (xmlParserCtxtPtr ctxt);
Daniel Veillardf0cc7cc2000-08-26 21:40:43 +0000370int xmlPedanticParserDefault(int val);
Daniel Veillard39a1f9a1999-01-17 19:11:59 +0000371
Daniel Veillardb05deb71999-08-10 19:04:08 +0000372/**
Daniel Veillard39a1f9a1999-01-17 19:11:59 +0000373 * Recovery mode
374 */
Daniel Veillarddd6b3671999-09-23 22:19:22 +0000375xmlDocPtr xmlRecoverDoc (xmlChar *cur);
Daniel Veillardb96e6431999-08-29 21:02:19 +0000376xmlDocPtr xmlRecoverMemory (char *buffer,
377 int size);
378xmlDocPtr xmlRecoverFile (const char *filename);
Daniel Veillard39a1f9a1999-01-17 19:11:59 +0000379
Daniel Veillardb05deb71999-08-10 19:04:08 +0000380/**
381 * Less common routines and SAX interfaces
Daniel Veillard39a1f9a1999-01-17 19:11:59 +0000382 */
Daniel Veillardb96e6431999-08-29 21:02:19 +0000383int xmlParseDocument (xmlParserCtxtPtr ctxt);
Daniel Veillardb1059e22000-09-16 14:02:43 +0000384int xmlParseExtParsedEnt (xmlParserCtxtPtr ctxt);
Daniel Veillardb96e6431999-08-29 21:02:19 +0000385xmlDocPtr xmlSAXParseDoc (xmlSAXHandlerPtr sax,
Daniel Veillarddd6b3671999-09-23 22:19:22 +0000386 xmlChar *cur,
Daniel Veillardb96e6431999-08-29 21:02:19 +0000387 int recovery);
Daniel Veillard7a66ee61999-09-26 11:31:02 +0000388int xmlSAXUserParseFile (xmlSAXHandlerPtr sax,
389 void *user_data,
390 const char *filename);
391int xmlSAXUserParseMemory (xmlSAXHandlerPtr sax,
392 void *user_data,
393 char *buffer,
394 int size);
Daniel Veillardb96e6431999-08-29 21:02:19 +0000395xmlDocPtr xmlSAXParseMemory (xmlSAXHandlerPtr sax,
396 char *buffer,
397 int size,
398 int recovery);
399xmlDocPtr xmlSAXParseFile (xmlSAXHandlerPtr sax,
400 const char *filename,
401 int recovery);
Daniel Veillardb1059e22000-09-16 14:02:43 +0000402xmlDocPtr xmlSAXParseEntity (xmlSAXHandlerPtr sax,
403 const char *filename);
404xmlDocPtr xmlParseEntity (const char *filename);
Daniel Veillarddd6b3671999-09-23 22:19:22 +0000405xmlDtdPtr xmlParseDTD (const xmlChar *ExternalID,
406 const xmlChar *SystemID);
Daniel Veillardb96e6431999-08-29 21:02:19 +0000407xmlDtdPtr xmlSAXParseDTD (xmlSAXHandlerPtr sax,
Daniel Veillarddd6b3671999-09-23 22:19:22 +0000408 const xmlChar *ExternalID,
409 const xmlChar *SystemID);
Daniel Veillardcf461992000-03-14 18:30:20 +0000410int xmlParseBalancedChunkMemory(xmlDocPtr doc,
411 xmlSAXHandlerPtr sax,
412 void *user_data,
413 int depth,
414 const xmlChar *string,
415 xmlNodePtr *list);
416int xmlParseExternalEntity (xmlDocPtr doc,
417 xmlSAXHandlerPtr sax,
418 void *user_data,
419 int depth,
420 const xmlChar *URL,
421 const xmlChar *ID,
422 xmlNodePtr *list);
Daniel Veillard87b95392000-08-12 21:12:04 +0000423int xmlParseCtxtExternalEntity(xmlParserCtxtPtr ctx,
424 const xmlChar *URL,
425 const xmlChar *ID,
426 xmlNodePtr *list);
Daniel Veillardcf461992000-03-14 18:30:20 +0000427
Daniel Veillarddbfd6411999-12-28 16:35:14 +0000428/**
429 * SAX initialization routines
430 */
431void xmlDefaultSAXHandlerInit(void);
432void htmlDefaultSAXHandlerInit(void);
433
434/**
435 * Parser contexts handling.
436 */
Daniel Veillardb96e6431999-08-29 21:02:19 +0000437void xmlInitParserCtxt (xmlParserCtxtPtr ctxt);
438void xmlClearParserCtxt (xmlParserCtxtPtr ctxt);
Daniel Veillarddbfd6411999-12-28 16:35:14 +0000439void xmlFreeParserCtxt (xmlParserCtxtPtr ctxt);
Daniel Veillardb96e6431999-08-29 21:02:19 +0000440void xmlSetupParserForBuffer (xmlParserCtxtPtr ctxt,
Daniel Veillarddd6b3671999-09-23 22:19:22 +0000441 const xmlChar* buffer,
Daniel Veillardb96e6431999-08-29 21:02:19 +0000442 const char* filename);
Daniel Veillarddbfd6411999-12-28 16:35:14 +0000443xmlParserCtxtPtr xmlCreateDocParserCtxt (xmlChar *cur);
444
445/**
Daniel Veillard87b95392000-08-12 21:12:04 +0000446 * Reading/setting optional parsing features.
447 */
448
449int xmlGetFeaturesList (int *len,
450 const char **result);
451int xmlGetFeature (xmlParserCtxtPtr ctxt,
452 const char *name,
453 void *result);
454int xmlSetFeature (xmlParserCtxtPtr ctxt,
455 const char *name,
456 void *value);
457
458/**
Daniel Veillarddbfd6411999-12-28 16:35:14 +0000459 * Interfaces for the Push mode
460 */
461xmlParserCtxtPtr xmlCreatePushParserCtxt(xmlSAXHandlerPtr sax,
462 void *user_data,
463 const char *chunk,
464 int size,
465 const char *filename);
466int xmlParseChunk (xmlParserCtxtPtr ctxt,
467 const char *chunk,
468 int size,
469 int terminate);
Daniel Veillard260a68f1998-08-13 03:39:55 +0000470
Daniel Veillardb96e6431999-08-29 21:02:19 +0000471/**
Daniel Veillard5e873c42000-04-12 13:27:38 +0000472 * Special I/O mode
473 */
474
475xmlParserCtxtPtr xmlCreateIOParserCtxt (xmlSAXHandlerPtr sax,
476 void *user_data,
477 xmlInputReadCallback ioread,
478 xmlInputCloseCallback ioclose,
479 void *ioctx,
480 xmlCharEncoding enc);
481
482xmlParserInputPtr xmlNewIOInputStream (xmlParserCtxtPtr ctxt,
483 xmlParserInputBufferPtr input,
484 xmlCharEncoding enc);
485
486/**
Daniel Veillardb96e6431999-08-29 21:02:19 +0000487 * Node infos
488 */
489const xmlParserNodeInfo*
490 xmlParserFindNodeInfo (const xmlParserCtxt* ctxt,
Daniel Veillard1e346af1999-02-22 10:33:01 +0000491 const xmlNode* node);
Daniel Veillardb96e6431999-08-29 21:02:19 +0000492void xmlInitNodeInfoSeq (xmlParserNodeInfoSeqPtr seq);
493void xmlClearNodeInfoSeq (xmlParserNodeInfoSeqPtr seq);
Daniel Veillard260a68f1998-08-13 03:39:55 +0000494unsigned long xmlParserFindNodeInfoIndex(const xmlParserNodeInfoSeq* seq,
495 const xmlNode* node);
Daniel Veillardb96e6431999-08-29 21:02:19 +0000496void xmlParserAddNodeInfo (xmlParserCtxtPtr ctxt,
497 const xmlParserNodeInfo* info);
Daniel Veillard260a68f1998-08-13 03:39:55 +0000498
Daniel Veillardb96e6431999-08-29 21:02:19 +0000499/*
500 * External entities handling actually implemented in xmlIO
501 */
502
503void xmlSetExternalEntityLoader(xmlExternalEntityLoader f);
504xmlExternalEntityLoader
505 xmlGetExternalEntityLoader(void);
506xmlParserInputPtr
507 xmlLoadExternalEntity (const char *URL,
508 const char *ID,
Daniel Veillard686d6b62000-01-03 11:08:02 +0000509 xmlParserCtxtPtr context);
Daniel Veillard4a53eca1999-12-12 13:03:50 +0000510
Daniel Veillard260a68f1998-08-13 03:39:55 +0000511#ifdef __cplusplus
512}
513#endif
514
515#endif /* __XML_PARSER_H__ */
516