blob: 95e529d2149f522d6fb266d9261df051c0c87487 [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 Veillard71b656e2000-01-05 14:46:17 +0000188};
Daniel Veillard260a68f1998-08-13 03:39:55 +0000189
Daniel Veillardb05deb71999-08-10 19:04:08 +0000190/**
Daniel Veillard260a68f1998-08-13 03:39:55 +0000191 * a SAX Locator.
192 */
Daniel Veillard71b656e2000-01-05 14:46:17 +0000193typedef struct _xmlSAXLocator xmlSAXLocator;
194typedef xmlSAXLocator *xmlSAXLocatorPtr;
195struct _xmlSAXLocator {
Daniel Veillarddd6b3671999-09-23 22:19:22 +0000196 const xmlChar *(*getPublicId)(void *ctx);
197 const xmlChar *(*getSystemId)(void *ctx);
Daniel Veillard27d88741999-05-29 11:51:49 +0000198 int (*getLineNumber)(void *ctx);
199 int (*getColumnNumber)(void *ctx);
Daniel Veillard71b656e2000-01-05 14:46:17 +0000200};
Daniel Veillard260a68f1998-08-13 03:39:55 +0000201
Daniel Veillardb05deb71999-08-10 19:04:08 +0000202/**
203 * a SAX handler is bunch of callbacks called by the parser when processing
204 * of the input generate data or structure informations.
Daniel Veillard260a68f1998-08-13 03:39:55 +0000205 */
206
Daniel Veillard27d88741999-05-29 11:51:49 +0000207typedef xmlParserInputPtr (*resolveEntitySAXFunc) (void *ctx,
Daniel Veillarddd6b3671999-09-23 22:19:22 +0000208 const xmlChar *publicId, const xmlChar *systemId);
209typedef void (*internalSubsetSAXFunc) (void *ctx, const xmlChar *name,
210 const xmlChar *ExternalID, const xmlChar *SystemID);
Daniel Veillardcf461992000-03-14 18:30:20 +0000211typedef void (*externalSubsetSAXFunc) (void *ctx, const xmlChar *name,
212 const xmlChar *ExternalID, const xmlChar *SystemID);
Daniel Veillard27d88741999-05-29 11:51:49 +0000213typedef xmlEntityPtr (*getEntitySAXFunc) (void *ctx,
Daniel Veillarddd6b3671999-09-23 22:19:22 +0000214 const xmlChar *name);
Daniel Veillardb05deb71999-08-10 19:04:08 +0000215typedef xmlEntityPtr (*getParameterEntitySAXFunc) (void *ctx,
Daniel Veillarddd6b3671999-09-23 22:19:22 +0000216 const xmlChar *name);
Daniel Veillard27d88741999-05-29 11:51:49 +0000217typedef void (*entityDeclSAXFunc) (void *ctx,
Daniel Veillarddd6b3671999-09-23 22:19:22 +0000218 const xmlChar *name, int type, const xmlChar *publicId,
219 const xmlChar *systemId, xmlChar *content);
220typedef void (*notationDeclSAXFunc)(void *ctx, const xmlChar *name,
221 const xmlChar *publicId, const xmlChar *systemId);
222typedef void (*attributeDeclSAXFunc)(void *ctx, const xmlChar *elem,
223 const xmlChar *name, int type, int def,
224 const xmlChar *defaultValue, xmlEnumerationPtr tree);
225typedef void (*elementDeclSAXFunc)(void *ctx, const xmlChar *name,
Daniel Veillard517752b1999-04-05 12:20:10 +0000226 int type, xmlElementContentPtr content);
Daniel Veillard27d88741999-05-29 11:51:49 +0000227typedef void (*unparsedEntityDeclSAXFunc)(void *ctx,
Daniel Veillarddd6b3671999-09-23 22:19:22 +0000228 const xmlChar *name, const xmlChar *publicId,
229 const xmlChar *systemId, const xmlChar *notationName);
Daniel Veillard27d88741999-05-29 11:51:49 +0000230typedef void (*setDocumentLocatorSAXFunc) (void *ctx,
Daniel Veillard260a68f1998-08-13 03:39:55 +0000231 xmlSAXLocatorPtr loc);
Daniel Veillard27d88741999-05-29 11:51:49 +0000232typedef void (*startDocumentSAXFunc) (void *ctx);
233typedef void (*endDocumentSAXFunc) (void *ctx);
Daniel Veillarddd6b3671999-09-23 22:19:22 +0000234typedef void (*startElementSAXFunc) (void *ctx, const xmlChar *name,
235 const xmlChar **atts);
236typedef void (*endElementSAXFunc) (void *ctx, const xmlChar *name);
237typedef void (*attributeSAXFunc) (void *ctx, const xmlChar *name,
238 const xmlChar *value);
239typedef void (*referenceSAXFunc) (void *ctx, const xmlChar *name);
240typedef void (*charactersSAXFunc) (void *ctx, const xmlChar *ch,
Daniel Veillard517752b1999-04-05 12:20:10 +0000241 int len);
Daniel Veillard27d88741999-05-29 11:51:49 +0000242typedef void (*ignorableWhitespaceSAXFunc) (void *ctx,
Daniel Veillarddd6b3671999-09-23 22:19:22 +0000243 const xmlChar *ch, int len);
Daniel Veillard27d88741999-05-29 11:51:49 +0000244typedef void (*processingInstructionSAXFunc) (void *ctx,
Daniel Veillarddd6b3671999-09-23 22:19:22 +0000245 const xmlChar *target, const xmlChar *data);
246typedef void (*commentSAXFunc) (void *ctx, const xmlChar *value);
247typedef void (*cdataBlockSAXFunc) (void *ctx, const xmlChar *value, int len);
Daniel Veillard27d88741999-05-29 11:51:49 +0000248typedef void (*warningSAXFunc) (void *ctx, const char *msg, ...);
249typedef void (*errorSAXFunc) (void *ctx, const char *msg, ...);
250typedef void (*fatalErrorSAXFunc) (void *ctx, const char *msg, ...);
251typedef int (*isStandaloneSAXFunc) (void *ctx);
252typedef int (*hasInternalSubsetSAXFunc) (void *ctx);
253typedef int (*hasExternalSubsetSAXFunc) (void *ctx);
Daniel Veillard260a68f1998-08-13 03:39:55 +0000254
Daniel Veillard71b656e2000-01-05 14:46:17 +0000255typedef struct _xmlSAXHandler xmlSAXHandler;
256typedef xmlSAXHandler *xmlSAXHandlerPtr;
257struct _xmlSAXHandler {
Daniel Veillard517752b1999-04-05 12:20:10 +0000258 internalSubsetSAXFunc internalSubset;
259 isStandaloneSAXFunc isStandalone;
260 hasInternalSubsetSAXFunc hasInternalSubset;
261 hasExternalSubsetSAXFunc hasExternalSubset;
Daniel Veillard260a68f1998-08-13 03:39:55 +0000262 resolveEntitySAXFunc resolveEntity;
Daniel Veillard517752b1999-04-05 12:20:10 +0000263 getEntitySAXFunc getEntity;
264 entityDeclSAXFunc entityDecl;
Daniel Veillard260a68f1998-08-13 03:39:55 +0000265 notationDeclSAXFunc notationDecl;
Daniel Veillard517752b1999-04-05 12:20:10 +0000266 attributeDeclSAXFunc attributeDecl;
267 elementDeclSAXFunc elementDecl;
Daniel Veillard260a68f1998-08-13 03:39:55 +0000268 unparsedEntityDeclSAXFunc unparsedEntityDecl;
269 setDocumentLocatorSAXFunc setDocumentLocator;
270 startDocumentSAXFunc startDocument;
271 endDocumentSAXFunc endDocument;
272 startElementSAXFunc startElement;
273 endElementSAXFunc endElement;
Daniel Veillard517752b1999-04-05 12:20:10 +0000274 referenceSAXFunc reference;
Daniel Veillard260a68f1998-08-13 03:39:55 +0000275 charactersSAXFunc characters;
276 ignorableWhitespaceSAXFunc ignorableWhitespace;
277 processingInstructionSAXFunc processingInstruction;
Daniel Veillard517752b1999-04-05 12:20:10 +0000278 commentSAXFunc comment;
Daniel Veillard260a68f1998-08-13 03:39:55 +0000279 warningSAXFunc warning;
280 errorSAXFunc error;
281 fatalErrorSAXFunc fatalError;
Daniel Veillardb05deb71999-08-10 19:04:08 +0000282 getParameterEntitySAXFunc getParameterEntity;
283 cdataBlockSAXFunc cdataBlock;
Daniel Veillardcf461992000-03-14 18:30:20 +0000284 externalSubsetSAXFunc externalSubset;
Daniel Veillard71b656e2000-01-05 14:46:17 +0000285};
Daniel Veillard260a68f1998-08-13 03:39:55 +0000286
Daniel Veillardb05deb71999-08-10 19:04:08 +0000287/**
Daniel Veillard686d6b62000-01-03 11:08:02 +0000288 * External entity loaders types
289 */
290typedef xmlParserInputPtr (*xmlExternalEntityLoader)(const char *URL,
291 const char *ID,
292 xmlParserCtxtPtr context);
293
294/**
Daniel Veillard6454aec1999-09-02 22:04:43 +0000295 * Global variables: just the default SAX interface tables and XML
296 * version infos.
Daniel Veillard260a68f1998-08-13 03:39:55 +0000297 */
Daniel Veillardc2def842000-11-07 14:21:01 +0000298LIBXML_DLL_IMPORT extern const char *xmlParserVersion;
Daniel Veillard14fff061999-06-22 21:49:07 +0000299
Daniel Veillardc2def842000-11-07 14:21:01 +0000300LIBXML_DLL_IMPORT extern xmlSAXLocator xmlDefaultSAXLocator;
301LIBXML_DLL_IMPORT extern xmlSAXHandler xmlDefaultSAXHandler;
302LIBXML_DLL_IMPORT extern xmlSAXHandler htmlDefaultSAXHandler;
303LIBXML_DLL_IMPORT extern xmlSAXHandler sgmlDefaultSAXHandler;
Daniel Veillard260a68f1998-08-13 03:39:55 +0000304
Daniel Veillard6454aec1999-09-02 22:04:43 +0000305/**
306 * entity substitution default behaviour.
307 */
308
Daniel Veillardce6e98d2000-11-25 09:54:49 +0000309#ifdef VMS
310LIBXML_DLL_IMPORT extern int xmlSubstituteEntitiesDefaultVal;
311#define xmlSubstituteEntitiesDefaultValue xmlSubstituteEntitiesDefaultVal
312#else
Daniel Veillardc2def842000-11-07 14:21:01 +0000313LIBXML_DLL_IMPORT extern int xmlSubstituteEntitiesDefaultValue;
Daniel Veillardce6e98d2000-11-25 09:54:49 +0000314#endif
Daniel Veillardc2def842000-11-07 14:21:01 +0000315LIBXML_DLL_IMPORT extern int xmlGetWarningsDefaultValue;
Daniel Veillard6454aec1999-09-02 22:04:43 +0000316
Daniel Veillardccb09631998-10-27 06:21:04 +0000317
Daniel Veillardb05deb71999-08-10 19:04:08 +0000318/**
Daniel Veillardbc765302000-10-01 18:23:35 +0000319 * Init/Cleanup
Daniel Veillarda819dac1999-11-24 18:04:22 +0000320 */
Daniel Veillardbc765302000-10-01 18:23:35 +0000321void xmlInitParser (void);
Daniel Veillarda819dac1999-11-24 18:04:22 +0000322void xmlCleanupParser (void);
323
324/**
Daniel Veillarde2d034d1999-07-27 19:52:06 +0000325 * Input functions
326 */
Daniel Veillardb96e6431999-08-29 21:02:19 +0000327int xmlParserInputRead (xmlParserInputPtr in,
328 int len);
329int xmlParserInputGrow (xmlParserInputPtr in,
330 int len);
Daniel Veillarde2d034d1999-07-27 19:52:06 +0000331
Daniel Veillardb05deb71999-08-10 19:04:08 +0000332/**
Daniel Veillarddd6b3671999-09-23 22:19:22 +0000333 * xmlChar handling
Daniel Veillard260a68f1998-08-13 03:39:55 +0000334 */
Daniel Veillard7a66ee61999-09-26 11:31:02 +0000335xmlChar * xmlStrdup (const xmlChar *cur);
336xmlChar * xmlStrndup (const xmlChar *cur,
Daniel Veillardb96e6431999-08-29 21:02:19 +0000337 int len);
Daniel Veillard7a66ee61999-09-26 11:31:02 +0000338xmlChar * xmlStrsub (const xmlChar *str,
Daniel Veillardb96e6431999-08-29 21:02:19 +0000339 int start,
340 int len);
Daniel Veillarddd6b3671999-09-23 22:19:22 +0000341const xmlChar * xmlStrchr (const xmlChar *str,
342 xmlChar val);
343const xmlChar * xmlStrstr (const xmlChar *str,
344 xmlChar *val);
Daniel Veillardb656ebe2000-09-22 13:51:48 +0000345const xmlChar * xmlStrcasestr (const xmlChar *str,
346 xmlChar *val);
Daniel Veillarddd6b3671999-09-23 22:19:22 +0000347int xmlStrcmp (const xmlChar *str1,
348 const xmlChar *str2);
349int xmlStrncmp (const xmlChar *str1,
350 const xmlChar *str2,
Daniel Veillardb96e6431999-08-29 21:02:19 +0000351 int len);
Daniel Veillardb656ebe2000-09-22 13:51:48 +0000352int xmlStrcasecmp (const xmlChar *str1,
353 const xmlChar *str2);
354int xmlStrncasecmp (const xmlChar *str1,
355 const xmlChar *str2,
356 int len);
Daniel Veillard8b5dd832000-10-01 20:28:44 +0000357int xmlStrEqual (const xmlChar *str1,
358 const xmlChar *str2);
Daniel Veillarddd6b3671999-09-23 22:19:22 +0000359int xmlStrlen (const xmlChar *str);
Daniel Veillard7a66ee61999-09-26 11:31:02 +0000360xmlChar * xmlStrcat (xmlChar *cur,
Daniel Veillarddd6b3671999-09-23 22:19:22 +0000361 const xmlChar *add);
Daniel Veillard7a66ee61999-09-26 11:31:02 +0000362xmlChar * xmlStrncat (xmlChar *cur,
Daniel Veillarddd6b3671999-09-23 22:19:22 +0000363 const xmlChar *add,
Daniel Veillardb96e6431999-08-29 21:02:19 +0000364 int len);
Daniel Veillard260a68f1998-08-13 03:39:55 +0000365
Daniel Veillardb05deb71999-08-10 19:04:08 +0000366/**
367 * Basic parsing Interfaces
Daniel Veillard39a1f9a1999-01-17 19:11:59 +0000368 */
Daniel Veillarddd6b3671999-09-23 22:19:22 +0000369xmlDocPtr xmlParseDoc (xmlChar *cur);
Daniel Veillardb96e6431999-08-29 21:02:19 +0000370xmlDocPtr xmlParseMemory (char *buffer,
371 int size);
372xmlDocPtr xmlParseFile (const char *filename);
373int xmlSubstituteEntitiesDefault(int val);
Daniel Veillard3e6d2372000-03-04 11:39:43 +0000374int xmlKeepBlanksDefault (int val);
Daniel Veillard3f6f7f62000-06-30 17:58:25 +0000375void xmlStopParser (xmlParserCtxtPtr ctxt);
Daniel Veillardf0cc7cc2000-08-26 21:40:43 +0000376int xmlPedanticParserDefault(int val);
Daniel Veillard39a1f9a1999-01-17 19:11:59 +0000377
Daniel Veillardb05deb71999-08-10 19:04:08 +0000378/**
Daniel Veillard39a1f9a1999-01-17 19:11:59 +0000379 * Recovery mode
380 */
Daniel Veillarddd6b3671999-09-23 22:19:22 +0000381xmlDocPtr xmlRecoverDoc (xmlChar *cur);
Daniel Veillardb96e6431999-08-29 21:02:19 +0000382xmlDocPtr xmlRecoverMemory (char *buffer,
383 int size);
384xmlDocPtr xmlRecoverFile (const char *filename);
Daniel Veillard39a1f9a1999-01-17 19:11:59 +0000385
Daniel Veillardb05deb71999-08-10 19:04:08 +0000386/**
387 * Less common routines and SAX interfaces
Daniel Veillard39a1f9a1999-01-17 19:11:59 +0000388 */
Daniel Veillardb96e6431999-08-29 21:02:19 +0000389int xmlParseDocument (xmlParserCtxtPtr ctxt);
Daniel Veillardb1059e22000-09-16 14:02:43 +0000390int xmlParseExtParsedEnt (xmlParserCtxtPtr ctxt);
Daniel Veillardb96e6431999-08-29 21:02:19 +0000391xmlDocPtr xmlSAXParseDoc (xmlSAXHandlerPtr sax,
Daniel Veillarddd6b3671999-09-23 22:19:22 +0000392 xmlChar *cur,
Daniel Veillardb96e6431999-08-29 21:02:19 +0000393 int recovery);
Daniel Veillard7a66ee61999-09-26 11:31:02 +0000394int xmlSAXUserParseFile (xmlSAXHandlerPtr sax,
395 void *user_data,
396 const char *filename);
397int xmlSAXUserParseMemory (xmlSAXHandlerPtr sax,
398 void *user_data,
399 char *buffer,
400 int size);
Daniel Veillardb96e6431999-08-29 21:02:19 +0000401xmlDocPtr xmlSAXParseMemory (xmlSAXHandlerPtr sax,
402 char *buffer,
403 int size,
404 int recovery);
405xmlDocPtr xmlSAXParseFile (xmlSAXHandlerPtr sax,
406 const char *filename,
407 int recovery);
Daniel Veillardb1059e22000-09-16 14:02:43 +0000408xmlDocPtr xmlSAXParseEntity (xmlSAXHandlerPtr sax,
409 const char *filename);
410xmlDocPtr xmlParseEntity (const char *filename);
Daniel Veillarddd6b3671999-09-23 22:19:22 +0000411xmlDtdPtr xmlParseDTD (const xmlChar *ExternalID,
412 const xmlChar *SystemID);
Daniel Veillardb96e6431999-08-29 21:02:19 +0000413xmlDtdPtr xmlSAXParseDTD (xmlSAXHandlerPtr sax,
Daniel Veillarddd6b3671999-09-23 22:19:22 +0000414 const xmlChar *ExternalID,
415 const xmlChar *SystemID);
Daniel Veillard2ffc3592000-10-30 15:36:47 +0000416xmlDtdPtr xmlIOParseDTD (xmlSAXHandlerPtr sax,
417 xmlParserInputBufferPtr input,
418 xmlCharEncoding enc);
Daniel Veillardcf461992000-03-14 18:30:20 +0000419int xmlParseBalancedChunkMemory(xmlDocPtr doc,
420 xmlSAXHandlerPtr sax,
421 void *user_data,
422 int depth,
423 const xmlChar *string,
424 xmlNodePtr *list);
425int xmlParseExternalEntity (xmlDocPtr doc,
426 xmlSAXHandlerPtr sax,
427 void *user_data,
428 int depth,
429 const xmlChar *URL,
430 const xmlChar *ID,
431 xmlNodePtr *list);
Daniel Veillard87b95392000-08-12 21:12:04 +0000432int xmlParseCtxtExternalEntity(xmlParserCtxtPtr ctx,
433 const xmlChar *URL,
434 const xmlChar *ID,
435 xmlNodePtr *list);
Daniel Veillardcf461992000-03-14 18:30:20 +0000436
Daniel Veillarddbfd6411999-12-28 16:35:14 +0000437/**
438 * SAX initialization routines
439 */
440void xmlDefaultSAXHandlerInit(void);
441void htmlDefaultSAXHandlerInit(void);
442
443/**
444 * Parser contexts handling.
445 */
Daniel Veillardb96e6431999-08-29 21:02:19 +0000446void xmlInitParserCtxt (xmlParserCtxtPtr ctxt);
447void xmlClearParserCtxt (xmlParserCtxtPtr ctxt);
Daniel Veillarddbfd6411999-12-28 16:35:14 +0000448void xmlFreeParserCtxt (xmlParserCtxtPtr ctxt);
Daniel Veillardb96e6431999-08-29 21:02:19 +0000449void xmlSetupParserForBuffer (xmlParserCtxtPtr ctxt,
Daniel Veillarddd6b3671999-09-23 22:19:22 +0000450 const xmlChar* buffer,
Daniel Veillardb96e6431999-08-29 21:02:19 +0000451 const char* filename);
Daniel Veillarddbfd6411999-12-28 16:35:14 +0000452xmlParserCtxtPtr xmlCreateDocParserCtxt (xmlChar *cur);
453
454/**
Daniel Veillard87b95392000-08-12 21:12:04 +0000455 * Reading/setting optional parsing features.
456 */
457
458int xmlGetFeaturesList (int *len,
459 const char **result);
460int xmlGetFeature (xmlParserCtxtPtr ctxt,
461 const char *name,
462 void *result);
463int xmlSetFeature (xmlParserCtxtPtr ctxt,
464 const char *name,
465 void *value);
466
467/**
Daniel Veillarddbfd6411999-12-28 16:35:14 +0000468 * Interfaces for the Push mode
469 */
470xmlParserCtxtPtr xmlCreatePushParserCtxt(xmlSAXHandlerPtr sax,
471 void *user_data,
472 const char *chunk,
473 int size,
474 const char *filename);
475int xmlParseChunk (xmlParserCtxtPtr ctxt,
476 const char *chunk,
477 int size,
478 int terminate);
Daniel Veillard260a68f1998-08-13 03:39:55 +0000479
Daniel Veillardb96e6431999-08-29 21:02:19 +0000480/**
Daniel Veillard5e873c42000-04-12 13:27:38 +0000481 * Special I/O mode
482 */
483
484xmlParserCtxtPtr xmlCreateIOParserCtxt (xmlSAXHandlerPtr sax,
485 void *user_data,
486 xmlInputReadCallback ioread,
487 xmlInputCloseCallback ioclose,
488 void *ioctx,
489 xmlCharEncoding enc);
490
491xmlParserInputPtr xmlNewIOInputStream (xmlParserCtxtPtr ctxt,
492 xmlParserInputBufferPtr input,
493 xmlCharEncoding enc);
494
495/**
Daniel Veillardb96e6431999-08-29 21:02:19 +0000496 * Node infos
497 */
498const xmlParserNodeInfo*
499 xmlParserFindNodeInfo (const xmlParserCtxt* ctxt,
Daniel Veillard1e346af1999-02-22 10:33:01 +0000500 const xmlNode* node);
Daniel Veillardb96e6431999-08-29 21:02:19 +0000501void xmlInitNodeInfoSeq (xmlParserNodeInfoSeqPtr seq);
502void xmlClearNodeInfoSeq (xmlParserNodeInfoSeqPtr seq);
Daniel Veillard260a68f1998-08-13 03:39:55 +0000503unsigned long xmlParserFindNodeInfoIndex(const xmlParserNodeInfoSeq* seq,
504 const xmlNode* node);
Daniel Veillardb96e6431999-08-29 21:02:19 +0000505void xmlParserAddNodeInfo (xmlParserCtxtPtr ctxt,
506 const xmlParserNodeInfo* info);
Daniel Veillard260a68f1998-08-13 03:39:55 +0000507
Daniel Veillardb96e6431999-08-29 21:02:19 +0000508/*
509 * External entities handling actually implemented in xmlIO
510 */
511
512void xmlSetExternalEntityLoader(xmlExternalEntityLoader f);
513xmlExternalEntityLoader
514 xmlGetExternalEntityLoader(void);
515xmlParserInputPtr
516 xmlLoadExternalEntity (const char *URL,
517 const char *ID,
Daniel Veillard686d6b62000-01-03 11:08:02 +0000518 xmlParserCtxtPtr context);
Daniel Veillard4a53eca1999-12-12 13:03:50 +0000519
Daniel Veillard260a68f1998-08-13 03:39:55 +0000520#ifdef __cplusplus
521}
522#endif
523
524#endif /* __XML_PARSER_H__ */
525