blob: b98f2a33e259bdcd87b0e6b7e62ec6e2f5ad7f70 [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 Veillard41e06512000-11-13 11:47:47 +0000102 XML_PARSER_EPILOG, /* the Misc* after the last end tag */
103 XML_PARSER_IGNORE /* within an IGNORED section */
Daniel Veillardb05deb71999-08-10 19:04:08 +0000104} xmlParserInputState;
105
106/**
107 * The parser context.
108 * NOTE This doesn't completely defines the parser state, the (current ?)
109 * design of the parser uses recursive function calls since this allow
110 * and easy mapping from the production rules of the specification
111 * to the actual code. The drawback is that the actual function call
112 * also reflect the parser state. However most of the parsing routines
113 * takes as the only argument the parser context pointer, so migrating
114 * to a state based parser for progressive parsing shouldn't be too hard.
115 */
Daniel Veillard71b656e2000-01-05 14:46:17 +0000116typedef struct _xmlParserCtxt xmlParserCtxt;
117typedef xmlParserCtxt *xmlParserCtxtPtr;
118struct _xmlParserCtxt {
119 struct _xmlSAXHandler *sax; /* The SAX handler */
Daniel Veillardb513f5a2000-09-10 14:01:12 +0000120 void *userData; /* For SAX interface only, used by DOM build */
Daniel Veillard517752b1999-04-05 12:20:10 +0000121 xmlDocPtr myDoc; /* the document being built */
Daniel Veillard7f7d1111999-09-22 09:46:25 +0000122 int wellFormed; /* is the document well formed */
Daniel Veillard011b63c1999-06-02 17:44:04 +0000123 int replaceEntities; /* shall we replace entities ? */
Daniel Veillardbe803962000-06-28 23:40:59 +0000124 const xmlChar *version; /* the XML version string */
125 const xmlChar *encoding; /* the declared encoding, if any */
Daniel Veillardb05deb71999-08-10 19:04:08 +0000126 int standalone; /* standalone document */
Daniel Veillardb513f5a2000-09-10 14:01:12 +0000127 int html; /* an HTML(1)/Docbook(2) document */
Daniel Veillard260a68f1998-08-13 03:39:55 +0000128
129 /* Input stream stack */
130 xmlParserInputPtr input; /* Current input stream */
131 int inputNr; /* Number of current input streams */
132 int inputMax; /* Max number of input streams */
133 xmlParserInputPtr *inputTab; /* stack of inputs */
134
Daniel Veillardb05deb71999-08-10 19:04:08 +0000135 /* Node analysis stack only used for DOM building */
Daniel Veillard260a68f1998-08-13 03:39:55 +0000136 xmlNodePtr node; /* Current parsed Node */
137 int nodeNr; /* Depth of the parsing stack */
138 int nodeMax; /* Max depth of the parsing stack */
139 xmlNodePtr *nodeTab; /* array of nodes */
140
141 int record_info; /* Whether node info should be kept */
142 xmlParserNodeInfoSeq node_seq; /* info about each node parsed */
Daniel Veillard7f7d1111999-09-22 09:46:25 +0000143
Daniel Veillarddd6b3671999-09-23 22:19:22 +0000144 int errNo; /* error code */
Daniel Veillard7f7d1111999-09-22 09:46:25 +0000145
146 int hasExternalSubset; /* reference and external subset */
147 int hasPErefs; /* the internal subset has PE refs */
148 int external; /* are we parsing an external entity */
149
150 int valid; /* is the document valid */
151 int validate; /* shall we try to validate ? */
152 xmlValidCtxt vctxt; /* The validity context */
153
154 xmlParserInputState instate; /* current type of input */
155 int token; /* next char look-ahead */
156
157 char *directory; /* the data directory */
Daniel Veillard2673d3c1999-10-08 14:37:09 +0000158
Daniel Veillardcf461992000-03-14 18:30:20 +0000159 /* Node name stack */
Daniel Veillard2673d3c1999-10-08 14:37:09 +0000160 xmlChar *name; /* Current parsed Node */
161 int nameNr; /* Depth of the parsing stack */
162 int nameMax; /* Max depth of the parsing stack */
163 xmlChar * *nameTab; /* array of nodes */
164
Daniel Veillardaf78a0e1999-12-12 13:03:50 +0000165 long nbChars; /* number of xmlChar processed */
Daniel Veillarddbfd6411999-12-28 16:35:14 +0000166 long checkIndex; /* used by progressive parsing lookup */
Daniel Veillard83a30e72000-03-02 03:33:32 +0000167 int keepBlanks; /* ugly but ... */
Daniel Veillardcf461992000-03-14 18:30:20 +0000168 int disableSAX; /* SAX callbacks are disabled */
169 int inSubset; /* Parsing is in int 1/ext 2 subset */
170 xmlChar * intSubName; /* name of subset */
171 xmlChar * extSubURI; /* URI of external subset */
172 xmlChar * extSubSystem; /* SYSTEM ID of external subset */
173
174 /* xml:space values */
175 int * space; /* Should the parser preserve spaces */
176 int spaceNr; /* Depth of the parsing stack */
177 int spaceMax; /* Max depth of the parsing stack */
178 int * spaceTab; /* array of space infos */
179
180 int depth; /* to prevent entity substitution loops */
Daniel Veillardbe803962000-06-28 23:40:59 +0000181 xmlParserInputPtr entity; /* used to check entities boundaries */
182 int charset; /* encoding of the in-memory content
183 actually an xmlCharEncoding */
184 int nodelen; /* Those two fields are there to */
185 int nodemem; /* Speed up large node parsing */
Daniel Veillardf0cc7cc2000-08-26 21:40:43 +0000186 int pedantic; /* signal pedantic warnings */
Daniel Veillardb513f5a2000-09-10 14:01:12 +0000187 void *_private; /* For user data, libxml won't touch it */
Daniel Veillard0f2a53c2001-02-05 17:57:33 +0000188
189 int loadsubset; /* should the external subset be loaded */
Daniel Veillard71b656e2000-01-05 14:46:17 +0000190};
Daniel Veillard260a68f1998-08-13 03:39:55 +0000191
Daniel Veillardb05deb71999-08-10 19:04:08 +0000192/**
Daniel Veillard260a68f1998-08-13 03:39:55 +0000193 * a SAX Locator.
194 */
Daniel Veillard71b656e2000-01-05 14:46:17 +0000195typedef struct _xmlSAXLocator xmlSAXLocator;
196typedef xmlSAXLocator *xmlSAXLocatorPtr;
197struct _xmlSAXLocator {
Daniel Veillarddd6b3671999-09-23 22:19:22 +0000198 const xmlChar *(*getPublicId)(void *ctx);
199 const xmlChar *(*getSystemId)(void *ctx);
Daniel Veillard27d88741999-05-29 11:51:49 +0000200 int (*getLineNumber)(void *ctx);
201 int (*getColumnNumber)(void *ctx);
Daniel Veillard71b656e2000-01-05 14:46:17 +0000202};
Daniel Veillard260a68f1998-08-13 03:39:55 +0000203
Daniel Veillardb05deb71999-08-10 19:04:08 +0000204/**
205 * a SAX handler is bunch of callbacks called by the parser when processing
206 * of the input generate data or structure informations.
Daniel Veillard260a68f1998-08-13 03:39:55 +0000207 */
208
Daniel Veillard27d88741999-05-29 11:51:49 +0000209typedef xmlParserInputPtr (*resolveEntitySAXFunc) (void *ctx,
Daniel Veillarddd6b3671999-09-23 22:19:22 +0000210 const xmlChar *publicId, const xmlChar *systemId);
211typedef void (*internalSubsetSAXFunc) (void *ctx, const xmlChar *name,
212 const xmlChar *ExternalID, const xmlChar *SystemID);
Daniel Veillardcf461992000-03-14 18:30:20 +0000213typedef void (*externalSubsetSAXFunc) (void *ctx, const xmlChar *name,
214 const xmlChar *ExternalID, const xmlChar *SystemID);
Daniel Veillard27d88741999-05-29 11:51:49 +0000215typedef xmlEntityPtr (*getEntitySAXFunc) (void *ctx,
Daniel Veillarddd6b3671999-09-23 22:19:22 +0000216 const xmlChar *name);
Daniel Veillardb05deb71999-08-10 19:04:08 +0000217typedef xmlEntityPtr (*getParameterEntitySAXFunc) (void *ctx,
Daniel Veillarddd6b3671999-09-23 22:19:22 +0000218 const xmlChar *name);
Daniel Veillard27d88741999-05-29 11:51:49 +0000219typedef void (*entityDeclSAXFunc) (void *ctx,
Daniel Veillarddd6b3671999-09-23 22:19:22 +0000220 const xmlChar *name, int type, const xmlChar *publicId,
221 const xmlChar *systemId, xmlChar *content);
222typedef void (*notationDeclSAXFunc)(void *ctx, const xmlChar *name,
223 const xmlChar *publicId, const xmlChar *systemId);
224typedef void (*attributeDeclSAXFunc)(void *ctx, const xmlChar *elem,
225 const xmlChar *name, int type, int def,
226 const xmlChar *defaultValue, xmlEnumerationPtr tree);
227typedef void (*elementDeclSAXFunc)(void *ctx, const xmlChar *name,
Daniel Veillard517752b1999-04-05 12:20:10 +0000228 int type, xmlElementContentPtr content);
Daniel Veillard27d88741999-05-29 11:51:49 +0000229typedef void (*unparsedEntityDeclSAXFunc)(void *ctx,
Daniel Veillarddd6b3671999-09-23 22:19:22 +0000230 const xmlChar *name, const xmlChar *publicId,
231 const xmlChar *systemId, const xmlChar *notationName);
Daniel Veillard27d88741999-05-29 11:51:49 +0000232typedef void (*setDocumentLocatorSAXFunc) (void *ctx,
Daniel Veillard260a68f1998-08-13 03:39:55 +0000233 xmlSAXLocatorPtr loc);
Daniel Veillard27d88741999-05-29 11:51:49 +0000234typedef void (*startDocumentSAXFunc) (void *ctx);
235typedef void (*endDocumentSAXFunc) (void *ctx);
Daniel Veillarddd6b3671999-09-23 22:19:22 +0000236typedef void (*startElementSAXFunc) (void *ctx, const xmlChar *name,
237 const xmlChar **atts);
238typedef void (*endElementSAXFunc) (void *ctx, const xmlChar *name);
239typedef void (*attributeSAXFunc) (void *ctx, const xmlChar *name,
240 const xmlChar *value);
241typedef void (*referenceSAXFunc) (void *ctx, const xmlChar *name);
242typedef void (*charactersSAXFunc) (void *ctx, const xmlChar *ch,
Daniel Veillard517752b1999-04-05 12:20:10 +0000243 int len);
Daniel Veillard27d88741999-05-29 11:51:49 +0000244typedef void (*ignorableWhitespaceSAXFunc) (void *ctx,
Daniel Veillarddd6b3671999-09-23 22:19:22 +0000245 const xmlChar *ch, int len);
Daniel Veillard27d88741999-05-29 11:51:49 +0000246typedef void (*processingInstructionSAXFunc) (void *ctx,
Daniel Veillarddd6b3671999-09-23 22:19:22 +0000247 const xmlChar *target, const xmlChar *data);
248typedef void (*commentSAXFunc) (void *ctx, const xmlChar *value);
249typedef void (*cdataBlockSAXFunc) (void *ctx, const xmlChar *value, int len);
Daniel Veillard27d88741999-05-29 11:51:49 +0000250typedef void (*warningSAXFunc) (void *ctx, const char *msg, ...);
251typedef void (*errorSAXFunc) (void *ctx, const char *msg, ...);
252typedef void (*fatalErrorSAXFunc) (void *ctx, const char *msg, ...);
253typedef int (*isStandaloneSAXFunc) (void *ctx);
254typedef int (*hasInternalSubsetSAXFunc) (void *ctx);
255typedef int (*hasExternalSubsetSAXFunc) (void *ctx);
Daniel Veillard260a68f1998-08-13 03:39:55 +0000256
Daniel Veillard71b656e2000-01-05 14:46:17 +0000257typedef struct _xmlSAXHandler xmlSAXHandler;
258typedef xmlSAXHandler *xmlSAXHandlerPtr;
259struct _xmlSAXHandler {
Daniel Veillard517752b1999-04-05 12:20:10 +0000260 internalSubsetSAXFunc internalSubset;
261 isStandaloneSAXFunc isStandalone;
262 hasInternalSubsetSAXFunc hasInternalSubset;
263 hasExternalSubsetSAXFunc hasExternalSubset;
Daniel Veillard260a68f1998-08-13 03:39:55 +0000264 resolveEntitySAXFunc resolveEntity;
Daniel Veillard517752b1999-04-05 12:20:10 +0000265 getEntitySAXFunc getEntity;
266 entityDeclSAXFunc entityDecl;
Daniel Veillard260a68f1998-08-13 03:39:55 +0000267 notationDeclSAXFunc notationDecl;
Daniel Veillard517752b1999-04-05 12:20:10 +0000268 attributeDeclSAXFunc attributeDecl;
269 elementDeclSAXFunc elementDecl;
Daniel Veillard260a68f1998-08-13 03:39:55 +0000270 unparsedEntityDeclSAXFunc unparsedEntityDecl;
271 setDocumentLocatorSAXFunc setDocumentLocator;
272 startDocumentSAXFunc startDocument;
273 endDocumentSAXFunc endDocument;
274 startElementSAXFunc startElement;
275 endElementSAXFunc endElement;
Daniel Veillard517752b1999-04-05 12:20:10 +0000276 referenceSAXFunc reference;
Daniel Veillard260a68f1998-08-13 03:39:55 +0000277 charactersSAXFunc characters;
278 ignorableWhitespaceSAXFunc ignorableWhitespace;
279 processingInstructionSAXFunc processingInstruction;
Daniel Veillard517752b1999-04-05 12:20:10 +0000280 commentSAXFunc comment;
Daniel Veillard260a68f1998-08-13 03:39:55 +0000281 warningSAXFunc warning;
282 errorSAXFunc error;
283 fatalErrorSAXFunc fatalError;
Daniel Veillardb05deb71999-08-10 19:04:08 +0000284 getParameterEntitySAXFunc getParameterEntity;
285 cdataBlockSAXFunc cdataBlock;
Daniel Veillardcf461992000-03-14 18:30:20 +0000286 externalSubsetSAXFunc externalSubset;
Daniel Veillard71b656e2000-01-05 14:46:17 +0000287};
Daniel Veillard260a68f1998-08-13 03:39:55 +0000288
Daniel Veillardb05deb71999-08-10 19:04:08 +0000289/**
Daniel Veillard686d6b62000-01-03 11:08:02 +0000290 * External entity loaders types
291 */
292typedef xmlParserInputPtr (*xmlExternalEntityLoader)(const char *URL,
293 const char *ID,
294 xmlParserCtxtPtr context);
295
296/**
Daniel Veillard6454aec1999-09-02 22:04:43 +0000297 * Global variables: just the default SAX interface tables and XML
298 * version infos.
Daniel Veillard260a68f1998-08-13 03:39:55 +0000299 */
Daniel Veillardc2def842000-11-07 14:21:01 +0000300LIBXML_DLL_IMPORT extern const char *xmlParserVersion;
Daniel Veillard14fff061999-06-22 21:49:07 +0000301
Daniel Veillardc2def842000-11-07 14:21:01 +0000302LIBXML_DLL_IMPORT extern xmlSAXLocator xmlDefaultSAXLocator;
303LIBXML_DLL_IMPORT extern xmlSAXHandler xmlDefaultSAXHandler;
304LIBXML_DLL_IMPORT extern xmlSAXHandler htmlDefaultSAXHandler;
305LIBXML_DLL_IMPORT extern xmlSAXHandler sgmlDefaultSAXHandler;
Daniel Veillard260a68f1998-08-13 03:39:55 +0000306
Daniel Veillard6454aec1999-09-02 22:04:43 +0000307/**
308 * entity substitution default behaviour.
309 */
310
Daniel Veillardce6e98d2000-11-25 09:54:49 +0000311#ifdef VMS
312LIBXML_DLL_IMPORT extern int xmlSubstituteEntitiesDefaultVal;
313#define xmlSubstituteEntitiesDefaultValue xmlSubstituteEntitiesDefaultVal
314#else
Daniel Veillardc2def842000-11-07 14:21:01 +0000315LIBXML_DLL_IMPORT extern int xmlSubstituteEntitiesDefaultValue;
Daniel Veillardce6e98d2000-11-25 09:54:49 +0000316#endif
Daniel Veillardc2def842000-11-07 14:21:01 +0000317LIBXML_DLL_IMPORT extern int xmlGetWarningsDefaultValue;
Daniel Veillard6454aec1999-09-02 22:04:43 +0000318
Daniel Veillardccb09631998-10-27 06:21:04 +0000319
Daniel Veillardb05deb71999-08-10 19:04:08 +0000320/**
Daniel Veillardbc765302000-10-01 18:23:35 +0000321 * Init/Cleanup
Daniel Veillarda819dac1999-11-24 18:04:22 +0000322 */
Daniel Veillardbc765302000-10-01 18:23:35 +0000323void xmlInitParser (void);
Daniel Veillarda819dac1999-11-24 18:04:22 +0000324void xmlCleanupParser (void);
325
326/**
Daniel Veillarde2d034d1999-07-27 19:52:06 +0000327 * Input functions
328 */
Daniel Veillardb96e6431999-08-29 21:02:19 +0000329int xmlParserInputRead (xmlParserInputPtr in,
330 int len);
331int xmlParserInputGrow (xmlParserInputPtr in,
332 int len);
Daniel Veillarde2d034d1999-07-27 19:52:06 +0000333
Daniel Veillardb05deb71999-08-10 19:04:08 +0000334/**
Daniel Veillarddd6b3671999-09-23 22:19:22 +0000335 * xmlChar handling
Daniel Veillard260a68f1998-08-13 03:39:55 +0000336 */
Daniel Veillard7a66ee61999-09-26 11:31:02 +0000337xmlChar * xmlStrdup (const xmlChar *cur);
338xmlChar * xmlStrndup (const xmlChar *cur,
Daniel Veillardb96e6431999-08-29 21:02:19 +0000339 int len);
Daniel Veillard7a66ee61999-09-26 11:31:02 +0000340xmlChar * xmlStrsub (const xmlChar *str,
Daniel Veillardb96e6431999-08-29 21:02:19 +0000341 int start,
342 int len);
Daniel Veillarddd6b3671999-09-23 22:19:22 +0000343const xmlChar * xmlStrchr (const xmlChar *str,
344 xmlChar val);
345const xmlChar * xmlStrstr (const xmlChar *str,
346 xmlChar *val);
Daniel Veillardb656ebe2000-09-22 13:51:48 +0000347const xmlChar * xmlStrcasestr (const xmlChar *str,
348 xmlChar *val);
Daniel Veillarddd6b3671999-09-23 22:19:22 +0000349int xmlStrcmp (const xmlChar *str1,
350 const xmlChar *str2);
351int xmlStrncmp (const xmlChar *str1,
352 const xmlChar *str2,
Daniel Veillardb96e6431999-08-29 21:02:19 +0000353 int len);
Daniel Veillardb656ebe2000-09-22 13:51:48 +0000354int xmlStrcasecmp (const xmlChar *str1,
355 const xmlChar *str2);
356int xmlStrncasecmp (const xmlChar *str1,
357 const xmlChar *str2,
358 int len);
Daniel Veillard8b5dd832000-10-01 20:28:44 +0000359int xmlStrEqual (const xmlChar *str1,
360 const xmlChar *str2);
Daniel Veillarddd6b3671999-09-23 22:19:22 +0000361int xmlStrlen (const xmlChar *str);
Daniel Veillard7a66ee61999-09-26 11:31:02 +0000362xmlChar * xmlStrcat (xmlChar *cur,
Daniel Veillarddd6b3671999-09-23 22:19:22 +0000363 const xmlChar *add);
Daniel Veillard7a66ee61999-09-26 11:31:02 +0000364xmlChar * xmlStrncat (xmlChar *cur,
Daniel Veillarddd6b3671999-09-23 22:19:22 +0000365 const xmlChar *add,
Daniel Veillardb96e6431999-08-29 21:02:19 +0000366 int len);
Daniel Veillard260a68f1998-08-13 03:39:55 +0000367
Daniel Veillardb05deb71999-08-10 19:04:08 +0000368/**
369 * Basic parsing Interfaces
Daniel Veillard39a1f9a1999-01-17 19:11:59 +0000370 */
Daniel Veillarddd6b3671999-09-23 22:19:22 +0000371xmlDocPtr xmlParseDoc (xmlChar *cur);
Daniel Veillardb96e6431999-08-29 21:02:19 +0000372xmlDocPtr xmlParseMemory (char *buffer,
373 int size);
374xmlDocPtr xmlParseFile (const char *filename);
375int xmlSubstituteEntitiesDefault(int val);
Daniel Veillard3e6d2372000-03-04 11:39:43 +0000376int xmlKeepBlanksDefault (int val);
Daniel Veillard3f6f7f62000-06-30 17:58:25 +0000377void xmlStopParser (xmlParserCtxtPtr ctxt);
Daniel Veillardf0cc7cc2000-08-26 21:40:43 +0000378int xmlPedanticParserDefault(int val);
Daniel Veillard39a1f9a1999-01-17 19:11:59 +0000379
Daniel Veillardb05deb71999-08-10 19:04:08 +0000380/**
Daniel Veillard39a1f9a1999-01-17 19:11:59 +0000381 * Recovery mode
382 */
Daniel Veillarddd6b3671999-09-23 22:19:22 +0000383xmlDocPtr xmlRecoverDoc (xmlChar *cur);
Daniel Veillardb96e6431999-08-29 21:02:19 +0000384xmlDocPtr xmlRecoverMemory (char *buffer,
385 int size);
386xmlDocPtr xmlRecoverFile (const char *filename);
Daniel Veillard39a1f9a1999-01-17 19:11:59 +0000387
Daniel Veillardb05deb71999-08-10 19:04:08 +0000388/**
389 * Less common routines and SAX interfaces
Daniel Veillard39a1f9a1999-01-17 19:11:59 +0000390 */
Daniel Veillardb96e6431999-08-29 21:02:19 +0000391int xmlParseDocument (xmlParserCtxtPtr ctxt);
Daniel Veillardb1059e22000-09-16 14:02:43 +0000392int xmlParseExtParsedEnt (xmlParserCtxtPtr ctxt);
Daniel Veillardb96e6431999-08-29 21:02:19 +0000393xmlDocPtr xmlSAXParseDoc (xmlSAXHandlerPtr sax,
Daniel Veillarddd6b3671999-09-23 22:19:22 +0000394 xmlChar *cur,
Daniel Veillardb96e6431999-08-29 21:02:19 +0000395 int recovery);
Daniel Veillard7a66ee61999-09-26 11:31:02 +0000396int xmlSAXUserParseFile (xmlSAXHandlerPtr sax,
397 void *user_data,
398 const char *filename);
399int xmlSAXUserParseMemory (xmlSAXHandlerPtr sax,
400 void *user_data,
401 char *buffer,
402 int size);
Daniel Veillardb96e6431999-08-29 21:02:19 +0000403xmlDocPtr xmlSAXParseMemory (xmlSAXHandlerPtr sax,
404 char *buffer,
405 int size,
406 int recovery);
407xmlDocPtr xmlSAXParseFile (xmlSAXHandlerPtr sax,
408 const char *filename,
409 int recovery);
Daniel Veillardb1059e22000-09-16 14:02:43 +0000410xmlDocPtr xmlSAXParseEntity (xmlSAXHandlerPtr sax,
411 const char *filename);
412xmlDocPtr xmlParseEntity (const char *filename);
Daniel Veillarddd6b3671999-09-23 22:19:22 +0000413xmlDtdPtr xmlParseDTD (const xmlChar *ExternalID,
414 const xmlChar *SystemID);
Daniel Veillardb96e6431999-08-29 21:02:19 +0000415xmlDtdPtr xmlSAXParseDTD (xmlSAXHandlerPtr sax,
Daniel Veillarddd6b3671999-09-23 22:19:22 +0000416 const xmlChar *ExternalID,
417 const xmlChar *SystemID);
Daniel Veillard2ffc3592000-10-30 15:36:47 +0000418xmlDtdPtr xmlIOParseDTD (xmlSAXHandlerPtr sax,
419 xmlParserInputBufferPtr input,
420 xmlCharEncoding enc);
Daniel Veillardcf461992000-03-14 18:30:20 +0000421int xmlParseBalancedChunkMemory(xmlDocPtr doc,
422 xmlSAXHandlerPtr sax,
423 void *user_data,
424 int depth,
425 const xmlChar *string,
426 xmlNodePtr *list);
427int xmlParseExternalEntity (xmlDocPtr doc,
428 xmlSAXHandlerPtr sax,
429 void *user_data,
430 int depth,
431 const xmlChar *URL,
432 const xmlChar *ID,
433 xmlNodePtr *list);
Daniel Veillard87b95392000-08-12 21:12:04 +0000434int xmlParseCtxtExternalEntity(xmlParserCtxtPtr ctx,
435 const xmlChar *URL,
436 const xmlChar *ID,
437 xmlNodePtr *list);
Daniel Veillardcf461992000-03-14 18:30:20 +0000438
Daniel Veillarddbfd6411999-12-28 16:35:14 +0000439/**
440 * SAX initialization routines
441 */
442void xmlDefaultSAXHandlerInit(void);
443void htmlDefaultSAXHandlerInit(void);
444
445/**
446 * Parser contexts handling.
447 */
Daniel Veillardb96e6431999-08-29 21:02:19 +0000448void xmlInitParserCtxt (xmlParserCtxtPtr ctxt);
449void xmlClearParserCtxt (xmlParserCtxtPtr ctxt);
Daniel Veillarddbfd6411999-12-28 16:35:14 +0000450void xmlFreeParserCtxt (xmlParserCtxtPtr ctxt);
Daniel Veillardb96e6431999-08-29 21:02:19 +0000451void xmlSetupParserForBuffer (xmlParserCtxtPtr ctxt,
Daniel Veillarddd6b3671999-09-23 22:19:22 +0000452 const xmlChar* buffer,
Daniel Veillardb96e6431999-08-29 21:02:19 +0000453 const char* filename);
Daniel Veillarddbfd6411999-12-28 16:35:14 +0000454xmlParserCtxtPtr xmlCreateDocParserCtxt (xmlChar *cur);
455
456/**
Daniel Veillard87b95392000-08-12 21:12:04 +0000457 * Reading/setting optional parsing features.
458 */
459
460int xmlGetFeaturesList (int *len,
461 const char **result);
462int xmlGetFeature (xmlParserCtxtPtr ctxt,
463 const char *name,
464 void *result);
465int xmlSetFeature (xmlParserCtxtPtr ctxt,
466 const char *name,
467 void *value);
468
469/**
Daniel Veillarddbfd6411999-12-28 16:35:14 +0000470 * Interfaces for the Push mode
471 */
472xmlParserCtxtPtr xmlCreatePushParserCtxt(xmlSAXHandlerPtr sax,
473 void *user_data,
474 const char *chunk,
475 int size,
476 const char *filename);
477int xmlParseChunk (xmlParserCtxtPtr ctxt,
478 const char *chunk,
479 int size,
480 int terminate);
Daniel Veillard260a68f1998-08-13 03:39:55 +0000481
Daniel Veillardb96e6431999-08-29 21:02:19 +0000482/**
Daniel Veillard5e873c42000-04-12 13:27:38 +0000483 * Special I/O mode
484 */
485
486xmlParserCtxtPtr xmlCreateIOParserCtxt (xmlSAXHandlerPtr sax,
487 void *user_data,
488 xmlInputReadCallback ioread,
489 xmlInputCloseCallback ioclose,
490 void *ioctx,
491 xmlCharEncoding enc);
492
493xmlParserInputPtr xmlNewIOInputStream (xmlParserCtxtPtr ctxt,
494 xmlParserInputBufferPtr input,
495 xmlCharEncoding enc);
496
497/**
Daniel Veillardb96e6431999-08-29 21:02:19 +0000498 * Node infos
499 */
500const xmlParserNodeInfo*
501 xmlParserFindNodeInfo (const xmlParserCtxt* ctxt,
Daniel Veillard1e346af1999-02-22 10:33:01 +0000502 const xmlNode* node);
Daniel Veillardb96e6431999-08-29 21:02:19 +0000503void xmlInitNodeInfoSeq (xmlParserNodeInfoSeqPtr seq);
504void xmlClearNodeInfoSeq (xmlParserNodeInfoSeqPtr seq);
Daniel Veillard260a68f1998-08-13 03:39:55 +0000505unsigned long xmlParserFindNodeInfoIndex(const xmlParserNodeInfoSeq* seq,
506 const xmlNode* node);
Daniel Veillardb96e6431999-08-29 21:02:19 +0000507void xmlParserAddNodeInfo (xmlParserCtxtPtr ctxt,
508 const xmlParserNodeInfo* info);
Daniel Veillard260a68f1998-08-13 03:39:55 +0000509
Daniel Veillardb96e6431999-08-29 21:02:19 +0000510/*
511 * External entities handling actually implemented in xmlIO
512 */
513
514void xmlSetExternalEntityLoader(xmlExternalEntityLoader f);
515xmlExternalEntityLoader
516 xmlGetExternalEntityLoader(void);
517xmlParserInputPtr
518 xmlLoadExternalEntity (const char *URL,
519 const char *ID,
Daniel Veillard686d6b62000-01-03 11:08:02 +0000520 xmlParserCtxtPtr context);
Daniel Veillard4a53eca1999-12-12 13:03:50 +0000521
Daniel Veillard260a68f1998-08-13 03:39:55 +0000522#ifdef __cplusplus
523}
524#endif
525
526#endif /* __XML_PARSER_H__ */
527