blob: d7f8ce740a9021302e378e9d94abaa076a82c92b [file] [log] [blame]
Owen Taylor3473f882001-02-23 17:55:21 +00001/*
2 * parser.h : Interfaces, constants and types related to the XML parser.
3 *
4 * See Copyright for the status of this software.
5 *
Daniel Veillardc5d64342001-06-24 12:13:24 +00006 * daniel@veillard.com
Owen Taylor3473f882001-02-23 17:55:21 +00007 */
8
9#ifndef __XML_PARSER_H__
10#define __XML_PARSER_H__
11
Aleksey Saninb5a46da2003-10-29 15:51:17 +000012#include <stdarg.h>
13
Igor Zlatkovic76874e42003-08-25 09:05:12 +000014#include <libxml/xmlversion.h>
Owen Taylor3473f882001-02-23 17:55:21 +000015#include <libxml/tree.h>
Daniel Veillard2fdbd322003-08-18 12:15:38 +000016#include <libxml/dict.h>
Daniel Veillard07cb8222003-09-10 10:51:05 +000017#include <libxml/hash.h>
Owen Taylor3473f882001-02-23 17:55:21 +000018#include <libxml/valid.h>
Owen Taylor3473f882001-02-23 17:55:21 +000019#include <libxml/entities.h>
Daniel Veillard2b8c4a12003-10-02 22:28:19 +000020#include <libxml/xmlerror.h>
Owen Taylor3473f882001-02-23 17:55:21 +000021
22#ifdef __cplusplus
23extern "C" {
24#endif
25
Daniel Veillard5e2dace2001-07-18 19:30:27 +000026/**
27 * XML_DEFAULT_VERSION:
28 *
29 * The default version of XML used: 1.0
Owen Taylor3473f882001-02-23 17:55:21 +000030 */
31#define XML_DEFAULT_VERSION "1.0"
32
33/**
Daniel Veillardf69bb4b2001-05-19 13:24:56 +000034 * xmlParserInput:
35 *
Daniel Veillard61f26172002-03-12 18:46:39 +000036 * An xmlParserInput is an input flow for the XML processor.
Owen Taylor3473f882001-02-23 17:55:21 +000037 * Each entity parsed is associated an xmlParserInput (except the
38 * few predefined ones). This is the case both for internal entities
39 * - in which case the flow is already completely in memory - or
40 * external entities - in which case we use the buf structure for
41 * progressive reading and I18N conversions to the internal UTF-8 format.
42 */
43
Daniel Veillard9d06d302002-01-22 18:15:52 +000044/**
45 * xmlParserInputDeallocate:
46 * @str: the string to deallocate
47 *
Daniel Veillard61f26172002-03-12 18:46:39 +000048 * Callback for freeing some parser input allocations.
Daniel Veillard9d06d302002-01-22 18:15:52 +000049 */
50typedef void (* xmlParserInputDeallocate)(xmlChar *str);
Daniel Veillard5e2dace2001-07-18 19:30:27 +000051
Owen Taylor3473f882001-02-23 17:55:21 +000052struct _xmlParserInput {
53 /* Input buffer */
54 xmlParserInputBufferPtr buf; /* UTF-8 encoded buffer */
55
56 const char *filename; /* The file analyzed, if any */
Daniel Veillard60087f32001-10-10 09:45:09 +000057 const char *directory; /* the directory/base of the file */
Owen Taylor3473f882001-02-23 17:55:21 +000058 const xmlChar *base; /* Base of the array to parse */
59 const xmlChar *cur; /* Current char being parsed */
Daniel Veillardcbaf3992001-12-31 16:16:02 +000060 const xmlChar *end; /* end of the array to parse */
Owen Taylor3473f882001-02-23 17:55:21 +000061 int length; /* length if known */
62 int line; /* Current line */
63 int col; /* Current column */
Daniel Veillard3e59fc52003-04-18 12:34:58 +000064 /*
65 * NOTE: consumed is only tested for equality in the parser code,
66 * so even if there is an overflow this should not give troubles
67 * for parsing very large instances.
68 */
69 unsigned long consumed; /* How many xmlChars already consumed */
Owen Taylor3473f882001-02-23 17:55:21 +000070 xmlParserInputDeallocate free; /* function to deallocate the base */
71 const xmlChar *encoding; /* the encoding string for entity */
72 const xmlChar *version; /* the version string for entity */
73 int standalone; /* Was that entity marked standalone */
Daniel Veillardbdbe0d42003-09-14 19:56:14 +000074 int id; /* an unique identifier for the entity */
Owen Taylor3473f882001-02-23 17:55:21 +000075};
76
77/**
Daniel Veillardf69bb4b2001-05-19 13:24:56 +000078 * xmlParserNodeInfo:
79 *
Daniel Veillard61f26172002-03-12 18:46:39 +000080 * The parser can be asked to collect Node informations, i.e. at what
Owen Taylor3473f882001-02-23 17:55:21 +000081 * place in the file they were detected.
82 * NOTE: This is off by default and not very well tested.
83 */
84typedef struct _xmlParserNodeInfo xmlParserNodeInfo;
85typedef xmlParserNodeInfo *xmlParserNodeInfoPtr;
86
87struct _xmlParserNodeInfo {
88 const struct _xmlNode* node;
89 /* Position & line # that text that created the node begins & ends on */
90 unsigned long begin_pos;
91 unsigned long begin_line;
92 unsigned long end_pos;
93 unsigned long end_line;
94};
95
96typedef struct _xmlParserNodeInfoSeq xmlParserNodeInfoSeq;
97typedef xmlParserNodeInfoSeq *xmlParserNodeInfoSeqPtr;
98struct _xmlParserNodeInfoSeq {
99 unsigned long maximum;
100 unsigned long length;
101 xmlParserNodeInfo* buffer;
102};
103
104/**
Daniel Veillardf69bb4b2001-05-19 13:24:56 +0000105 * xmlParserInputState:
106 *
Daniel Veillard61f26172002-03-12 18:46:39 +0000107 * The parser is now working also as a state based parser.
108 * The recursive one use the state info for entities processing.
Owen Taylor3473f882001-02-23 17:55:21 +0000109 */
110typedef enum {
111 XML_PARSER_EOF = -1, /* nothing is to be parsed */
112 XML_PARSER_START = 0, /* nothing has been parsed */
113 XML_PARSER_MISC, /* Misc* before int subset */
Daniel Veillardcbaf3992001-12-31 16:16:02 +0000114 XML_PARSER_PI, /* Within a processing instruction */
Owen Taylor3473f882001-02-23 17:55:21 +0000115 XML_PARSER_DTD, /* within some DTD content */
116 XML_PARSER_PROLOG, /* Misc* after internal subset */
117 XML_PARSER_COMMENT, /* within a comment */
118 XML_PARSER_START_TAG, /* within a start tag */
119 XML_PARSER_CONTENT, /* within the content */
120 XML_PARSER_CDATA_SECTION, /* within a CDATA section */
121 XML_PARSER_END_TAG, /* within a closing tag */
122 XML_PARSER_ENTITY_DECL, /* within an entity declaration */
123 XML_PARSER_ENTITY_VALUE, /* within an entity value in a decl */
124 XML_PARSER_ATTRIBUTE_VALUE, /* within an attribute value */
125 XML_PARSER_SYSTEM_LITERAL, /* within a SYSTEM value */
126 XML_PARSER_EPILOG, /* the Misc* after the last end tag */
Daniel Veillard4a7ae502002-02-18 19:18:17 +0000127 XML_PARSER_IGNORE, /* within an IGNORED section */
128 XML_PARSER_PUBLIC_LITERAL /* within a PUBLIC value */
Owen Taylor3473f882001-02-23 17:55:21 +0000129} xmlParserInputState;
130
131/**
Daniel Veillardd16df9f2001-05-23 13:44:21 +0000132 * XML_DETECT_IDS:
133 *
Daniel Veillard61f26172002-03-12 18:46:39 +0000134 * Bit in the loadsubset context field to tell to do ID/REFs lookups.
135 * Use it to initialize xmlLoadExtDtdDefaultValue.
Daniel Veillardd16df9f2001-05-23 13:44:21 +0000136 */
137#define XML_DETECT_IDS 2
138
139/**
140 * XML_COMPLETE_ATTRS:
141 *
142 * Bit in the loadsubset context field to tell to do complete the
Daniel Veillard61f26172002-03-12 18:46:39 +0000143 * elements attributes lists with the ones defaulted from the DTDs.
144 * Use it to initialize xmlLoadExtDtdDefaultValue.
Daniel Veillardd16df9f2001-05-23 13:44:21 +0000145 */
146#define XML_COMPLETE_ATTRS 4
147
148/**
Daniel Veillardef8dd7b2003-03-23 12:02:56 +0000149 * XML_SKIP_IDS:
150 *
151 * Bit in the loadsubset context field to tell to not do ID/REFs registration.
152 * Used to initialize xmlLoadExtDtdDefaultValue in some special cases.
153 */
154#define XML_SKIP_IDS 8
155
156/**
Daniel Veillardf69bb4b2001-05-19 13:24:56 +0000157 * xmlParserCtxt:
158 *
Owen Taylor3473f882001-02-23 17:55:21 +0000159 * The parser context.
Daniel Veillard61f26172002-03-12 18:46:39 +0000160 * NOTE This doesn't completely define the parser state, the (current ?)
Owen Taylor3473f882001-02-23 17:55:21 +0000161 * design of the parser uses recursive function calls since this allow
162 * and easy mapping from the production rules of the specification
163 * to the actual code. The drawback is that the actual function call
164 * also reflect the parser state. However most of the parsing routines
165 * takes as the only argument the parser context pointer, so migrating
166 * to a state based parser for progressive parsing shouldn't be too hard.
167 */
Owen Taylor3473f882001-02-23 17:55:21 +0000168struct _xmlParserCtxt {
169 struct _xmlSAXHandler *sax; /* The SAX handler */
170 void *userData; /* For SAX interface only, used by DOM build */
171 xmlDocPtr myDoc; /* the document being built */
172 int wellFormed; /* is the document well formed */
173 int replaceEntities; /* shall we replace entities ? */
174 const xmlChar *version; /* the XML version string */
175 const xmlChar *encoding; /* the declared encoding, if any */
176 int standalone; /* standalone document */
177 int html; /* an HTML(1)/Docbook(2) document */
178
179 /* Input stream stack */
180 xmlParserInputPtr input; /* Current input stream */
181 int inputNr; /* Number of current input streams */
182 int inputMax; /* Max number of input streams */
183 xmlParserInputPtr *inputTab; /* stack of inputs */
184
185 /* Node analysis stack only used for DOM building */
186 xmlNodePtr node; /* Current parsed Node */
187 int nodeNr; /* Depth of the parsing stack */
188 int nodeMax; /* Max depth of the parsing stack */
189 xmlNodePtr *nodeTab; /* array of nodes */
190
191 int record_info; /* Whether node info should be kept */
192 xmlParserNodeInfoSeq node_seq; /* info about each node parsed */
193
194 int errNo; /* error code */
195
196 int hasExternalSubset; /* reference and external subset */
197 int hasPErefs; /* the internal subset has PE refs */
198 int external; /* are we parsing an external entity */
199
200 int valid; /* is the document valid */
201 int validate; /* shall we try to validate ? */
202 xmlValidCtxt vctxt; /* The validity context */
203
204 xmlParserInputState instate; /* current type of input */
205 int token; /* next char look-ahead */
206
207 char *directory; /* the data directory */
208
209 /* Node name stack */
Daniel Veillard2fdbd322003-08-18 12:15:38 +0000210 const xmlChar *name; /* Current parsed Node */
Owen Taylor3473f882001-02-23 17:55:21 +0000211 int nameNr; /* Depth of the parsing stack */
212 int nameMax; /* Max depth of the parsing stack */
Daniel Veillard2fdbd322003-08-18 12:15:38 +0000213 const xmlChar * *nameTab; /* array of nodes */
Owen Taylor3473f882001-02-23 17:55:21 +0000214
215 long nbChars; /* number of xmlChar processed */
216 long checkIndex; /* used by progressive parsing lookup */
217 int keepBlanks; /* ugly but ... */
218 int disableSAX; /* SAX callbacks are disabled */
219 int inSubset; /* Parsing is in int 1/ext 2 subset */
Daniel Veillard2fdbd322003-08-18 12:15:38 +0000220 const xmlChar * intSubName; /* name of subset */
Owen Taylor3473f882001-02-23 17:55:21 +0000221 xmlChar * extSubURI; /* URI of external subset */
222 xmlChar * extSubSystem; /* SYSTEM ID of external subset */
223
224 /* xml:space values */
225 int * space; /* Should the parser preserve spaces */
226 int spaceNr; /* Depth of the parsing stack */
227 int spaceMax; /* Max depth of the parsing stack */
228 int * spaceTab; /* array of space infos */
229
230 int depth; /* to prevent entity substitution loops */
231 xmlParserInputPtr entity; /* used to check entities boundaries */
232 int charset; /* encoding of the in-memory content
233 actually an xmlCharEncoding */
234 int nodelen; /* Those two fields are there to */
235 int nodemem; /* Speed up large node parsing */
236 int pedantic; /* signal pedantic warnings */
237 void *_private; /* For user data, libxml won't touch it */
238
239 int loadsubset; /* should the external subset be loaded */
Daniel Veillardd9bad132001-07-23 19:39:43 +0000240 int linenumbers; /* set line number in element content */
Daniel Veillard5d90b6c2001-08-22 14:29:45 +0000241 void *catalogs; /* document's own catalog */
Daniel Veillarddad3f682002-11-17 16:47:27 +0000242 int recovery; /* run in recovery mode */
Daniel Veillarda880b122003-04-21 21:36:41 +0000243 int progressive; /* is this a progressive parsing */
Daniel Veillard2fdbd322003-08-18 12:15:38 +0000244 xmlDictPtr dict; /* dictionnary for the parser */
Daniel Veillard40412cd2003-09-03 13:28:32 +0000245 const xmlChar * *atts; /* array for the attributes callbacks */
Daniel Veillard6155d8a2003-08-19 15:01:28 +0000246 int maxatts; /* the size of the array */
Daniel Veillard40412cd2003-09-03 13:28:32 +0000247 int docdict; /* use strings from dict to build tree */
Daniel Veillard0fb18932003-09-07 09:14:37 +0000248
249 /*
250 * pre-interned strings
251 */
252 const xmlChar *str_xml;
253 const xmlChar *str_xmlns;
Daniel Veillard07cb8222003-09-10 10:51:05 +0000254 const xmlChar *str_xml_ns;
Daniel Veillard0fb18932003-09-07 09:14:37 +0000255
256 /*
Daniel Veillard07cb8222003-09-10 10:51:05 +0000257 * Everything below is used only by the new SAX mode
Daniel Veillard0fb18932003-09-07 09:14:37 +0000258 */
259 int sax2; /* operating in the new SAX mode */
260 int nsNr; /* the number of inherited namespaces */
261 int nsMax; /* the size of the arrays */
262 const xmlChar * *nsTab; /* the array of prefix/namespace name */
Daniel Veillard07cb8222003-09-10 10:51:05 +0000263 int *attallocs; /* which attribute were allocated */
264 void * *pushTab; /* array of data for push */
265 xmlHashTablePtr attsDefault; /* defaulted attributes if any */
266 xmlHashTablePtr attsSpecial; /* non-CDATA attributes if any */
Daniel Veillard3b7840c2003-09-11 23:42:01 +0000267 int nsWellFormed; /* is the document XML Nanespace okay */
Daniel Veillard9475a352003-09-26 12:47:50 +0000268 int options; /* Extra options */
Daniel Veillard8a44e592003-09-15 14:50:06 +0000269
270 /*
271 * Those fields are needed only for treaming parsing so far
272 */
Daniel Veillard9475a352003-09-26 12:47:50 +0000273 int dictNames; /* Use dictionary names for the tree */
274 int freeElemsNr; /* number of freed element nodes */
275 xmlNodePtr freeElems; /* List of freed element nodes */
276 int freeAttrsNr; /* number of freed attributes nodes */
277 xmlAttrPtr freeAttrs; /* List of freed attributes nodes */
Daniel Veillard2b8c4a12003-10-02 22:28:19 +0000278
279 /*
280 * the complete error informations for the last error.
281 */
282 xmlError lastError;
Owen Taylor3473f882001-02-23 17:55:21 +0000283};
284
285/**
Daniel Veillardf69bb4b2001-05-19 13:24:56 +0000286 * xmlSAXLocator:
287 *
Daniel Veillard61f26172002-03-12 18:46:39 +0000288 * A SAX Locator.
Owen Taylor3473f882001-02-23 17:55:21 +0000289 */
Owen Taylor3473f882001-02-23 17:55:21 +0000290struct _xmlSAXLocator {
291 const xmlChar *(*getPublicId)(void *ctx);
292 const xmlChar *(*getSystemId)(void *ctx);
293 int (*getLineNumber)(void *ctx);
294 int (*getColumnNumber)(void *ctx);
295};
296
297/**
Daniel Veillardf69bb4b2001-05-19 13:24:56 +0000298 * xmlSAXHandler:
299 *
Daniel Veillard61f26172002-03-12 18:46:39 +0000300 * A SAX handler is bunch of callbacks called by the parser when processing
Owen Taylor3473f882001-02-23 17:55:21 +0000301 * of the input generate data or structure informations.
302 */
303
Daniel Veillard9d06d302002-01-22 18:15:52 +0000304/**
305 * resolveEntitySAXFunc:
306 * @ctx: the user data (XML parser context)
307 * @publicId: The public ID of the entity
308 * @systemId: The system ID of the entity
309 *
310 * Callback:
311 * The entity loader, to control the loading of external entities,
312 * the application can either:
313 * - override this resolveEntity() callback in the SAX block
314 * - or better use the xmlSetExternalEntityLoader() function to
315 * set up it's own entity resolution routine
316 *
317 * Returns the xmlParserInputPtr if inlined or NULL for DOM behaviour.
318 */
Owen Taylor3473f882001-02-23 17:55:21 +0000319typedef xmlParserInputPtr (*resolveEntitySAXFunc) (void *ctx,
Daniel Veillard9d06d302002-01-22 18:15:52 +0000320 const xmlChar *publicId,
321 const xmlChar *systemId);
322/**
323 * internalSubsetSAXFunc:
324 * @ctx: the user data (XML parser context)
325 * @name: the root element name
326 * @ExternalID: the external ID
327 * @SystemID: the SYSTEM ID (e.g. filename or URL)
328 *
329 * Callback on internal subset declaration.
330 */
331typedef void (*internalSubsetSAXFunc) (void *ctx,
332 const xmlChar *name,
333 const xmlChar *ExternalID,
334 const xmlChar *SystemID);
335/**
336 * externalSubsetSAXFunc:
337 * @ctx: the user data (XML parser context)
338 * @name: the root element name
339 * @ExternalID: the external ID
340 * @SystemID: the SYSTEM ID (e.g. filename or URL)
341 *
342 * Callback on external subset declaration.
343 */
344typedef void (*externalSubsetSAXFunc) (void *ctx,
345 const xmlChar *name,
346 const xmlChar *ExternalID,
347 const xmlChar *SystemID);
348/**
349 * getEntitySAXFunc:
350 * @ctx: the user data (XML parser context)
351 * @name: The entity name
352 *
Daniel Veillard61f26172002-03-12 18:46:39 +0000353 * Get an entity by name.
Daniel Veillard9d06d302002-01-22 18:15:52 +0000354 *
355 * Returns the xmlEntityPtr if found.
356 */
Owen Taylor3473f882001-02-23 17:55:21 +0000357typedef xmlEntityPtr (*getEntitySAXFunc) (void *ctx,
Daniel Veillard9d06d302002-01-22 18:15:52 +0000358 const xmlChar *name);
359/**
360 * getParameterEntitySAXFunc:
361 * @ctx: the user data (XML parser context)
362 * @name: The entity name
363 *
Daniel Veillard61f26172002-03-12 18:46:39 +0000364 * Get a parameter entity by name.
Daniel Veillard9d06d302002-01-22 18:15:52 +0000365 *
366 * Returns the xmlEntityPtr if found.
367 */
Owen Taylor3473f882001-02-23 17:55:21 +0000368typedef xmlEntityPtr (*getParameterEntitySAXFunc) (void *ctx,
Daniel Veillard9d06d302002-01-22 18:15:52 +0000369 const xmlChar *name);
370/**
371 * entityDeclSAXFunc:
372 * @ctx: the user data (XML parser context)
373 * @name: the entity name
374 * @type: the entity type
375 * @publicId: The public ID of the entity
376 * @systemId: The system ID of the entity
377 * @content: the entity value (without processing).
378 *
Daniel Veillard61f26172002-03-12 18:46:39 +0000379 * An entity definition has been parsed.
Daniel Veillard9d06d302002-01-22 18:15:52 +0000380 */
Owen Taylor3473f882001-02-23 17:55:21 +0000381typedef void (*entityDeclSAXFunc) (void *ctx,
Daniel Veillard9d06d302002-01-22 18:15:52 +0000382 const xmlChar *name,
383 int type,
384 const xmlChar *publicId,
385 const xmlChar *systemId,
386 xmlChar *content);
387/**
388 * notationDeclSAXFunc:
389 * @ctx: the user data (XML parser context)
390 * @name: The name of the notation
391 * @publicId: The public ID of the entity
392 * @systemId: The system ID of the entity
393 *
394 * What to do when a notation declaration has been parsed.
395 */
396typedef void (*notationDeclSAXFunc)(void *ctx,
397 const xmlChar *name,
398 const xmlChar *publicId,
399 const xmlChar *systemId);
400/**
401 * attributeDeclSAXFunc:
402 * @ctx: the user data (XML parser context)
403 * @elem: the name of the element
404 * @fullname: the attribute name
405 * @type: the attribute type
406 * @def: the type of default value
407 * @defaultValue: the attribute default value
408 * @tree: the tree of enumerated value set
409 *
Daniel Veillard61f26172002-03-12 18:46:39 +0000410 * An attribute definition has been parsed.
Daniel Veillard9d06d302002-01-22 18:15:52 +0000411 */
412typedef void (*attributeDeclSAXFunc)(void *ctx,
413 const xmlChar *elem,
414 const xmlChar *fullname,
415 int type,
416 int def,
417 const xmlChar *defaultValue,
418 xmlEnumerationPtr tree);
419/**
420 * elementDeclSAXFunc:
421 * @ctx: the user data (XML parser context)
422 * @name: the element name
423 * @type: the element type
424 * @content: the element value tree
425 *
Daniel Veillard61f26172002-03-12 18:46:39 +0000426 * An element definition has been parsed.
Daniel Veillard9d06d302002-01-22 18:15:52 +0000427 */
428typedef void (*elementDeclSAXFunc)(void *ctx,
429 const xmlChar *name,
430 int type,
431 xmlElementContentPtr content);
432/**
433 * unparsedEntityDeclSAXFunc:
434 * @ctx: the user data (XML parser context)
435 * @name: The name of the entity
436 * @publicId: The public ID of the entity
437 * @systemId: The system ID of the entity
438 * @notationName: the name of the notation
439 *
Daniel Veillard61f26172002-03-12 18:46:39 +0000440 * What to do when an unparsed entity declaration is parsed.
Daniel Veillard9d06d302002-01-22 18:15:52 +0000441 */
Owen Taylor3473f882001-02-23 17:55:21 +0000442typedef void (*unparsedEntityDeclSAXFunc)(void *ctx,
Daniel Veillard9d06d302002-01-22 18:15:52 +0000443 const xmlChar *name,
444 const xmlChar *publicId,
445 const xmlChar *systemId,
446 const xmlChar *notationName);
447/**
448 * setDocumentLocatorSAXFunc:
449 * @ctx: the user data (XML parser context)
450 * @loc: A SAX Locator
451 *
Daniel Veillard61f26172002-03-12 18:46:39 +0000452 * Receive the document locator at startup, actually xmlDefaultSAXLocator.
Daniel Veillard9d06d302002-01-22 18:15:52 +0000453 * Everything is available on the context, so this is useless in our case.
454 */
Owen Taylor3473f882001-02-23 17:55:21 +0000455typedef void (*setDocumentLocatorSAXFunc) (void *ctx,
Daniel Veillard9d06d302002-01-22 18:15:52 +0000456 xmlSAXLocatorPtr loc);
457/**
458 * startDocumentSAXFunc:
459 * @ctx: the user data (XML parser context)
460 *
Daniel Veillard61f26172002-03-12 18:46:39 +0000461 * Called when the document start being processed.
Daniel Veillard9d06d302002-01-22 18:15:52 +0000462 */
Owen Taylor3473f882001-02-23 17:55:21 +0000463typedef void (*startDocumentSAXFunc) (void *ctx);
Daniel Veillard9d06d302002-01-22 18:15:52 +0000464/**
465 * endDocumentSAXFunc:
466 * @ctx: the user data (XML parser context)
467 *
Daniel Veillard61f26172002-03-12 18:46:39 +0000468 * Called when the document end has been detected.
Daniel Veillard9d06d302002-01-22 18:15:52 +0000469 */
Owen Taylor3473f882001-02-23 17:55:21 +0000470typedef void (*endDocumentSAXFunc) (void *ctx);
Daniel Veillard9d06d302002-01-22 18:15:52 +0000471/**
472 * startElementSAXFunc:
473 * @ctx: the user data (XML parser context)
474 * @name: The element name, including namespace prefix
475 * @atts: An array of name/value attributes pairs, NULL terminated
476 *
Daniel Veillard61f26172002-03-12 18:46:39 +0000477 * Called when an opening tag has been processed.
Daniel Veillard9d06d302002-01-22 18:15:52 +0000478 */
479typedef void (*startElementSAXFunc) (void *ctx,
480 const xmlChar *name,
481 const xmlChar **atts);
482/**
483 * endElementSAXFunc:
484 * @ctx: the user data (XML parser context)
485 * @name: The element name
486 *
Daniel Veillard61f26172002-03-12 18:46:39 +0000487 * Called when the end of an element has been detected.
Daniel Veillard9d06d302002-01-22 18:15:52 +0000488 */
489typedef void (*endElementSAXFunc) (void *ctx,
490 const xmlChar *name);
491/**
492 * attributeSAXFunc:
493 * @ctx: the user data (XML parser context)
494 * @name: The attribute name, including namespace prefix
495 * @value: The attribute value
496 *
497 * Handle an attribute that has been read by the parser.
498 * The default handling is to convert the attribute into an
499 * DOM subtree and past it in a new xmlAttr element added to
500 * the element.
501 */
502typedef void (*attributeSAXFunc) (void *ctx,
503 const xmlChar *name,
504 const xmlChar *value);
505/**
506 * referenceSAXFunc:
507 * @ctx: the user data (XML parser context)
508 * @name: The entity name
509 *
Daniel Veillard61f26172002-03-12 18:46:39 +0000510 * Called when an entity reference is detected.
Daniel Veillard9d06d302002-01-22 18:15:52 +0000511 */
512typedef void (*referenceSAXFunc) (void *ctx,
513 const xmlChar *name);
514/**
515 * charactersSAXFunc:
516 * @ctx: the user data (XML parser context)
517 * @ch: a xmlChar string
518 * @len: the number of xmlChar
519 *
Daniel Veillard61f26172002-03-12 18:46:39 +0000520 * Receiving some chars from the parser.
Daniel Veillard9d06d302002-01-22 18:15:52 +0000521 */
522typedef void (*charactersSAXFunc) (void *ctx,
523 const xmlChar *ch,
524 int len);
525/**
526 * ignorableWhitespaceSAXFunc:
527 * @ctx: the user data (XML parser context)
528 * @ch: a xmlChar string
529 * @len: the number of xmlChar
530 *
Daniel Veillard61f26172002-03-12 18:46:39 +0000531 * Receiving some ignorable whitespaces from the parser.
532 * UNUSED: by default the DOM building will use characters.
Daniel Veillard9d06d302002-01-22 18:15:52 +0000533 */
Owen Taylor3473f882001-02-23 17:55:21 +0000534typedef void (*ignorableWhitespaceSAXFunc) (void *ctx,
Daniel Veillard9d06d302002-01-22 18:15:52 +0000535 const xmlChar *ch,
536 int len);
537/**
538 * processingInstructionSAXFunc:
539 * @ctx: the user data (XML parser context)
540 * @target: the target name
541 * @data: the PI data's
542 *
543 * A processing instruction has been parsed.
544 */
Owen Taylor3473f882001-02-23 17:55:21 +0000545typedef void (*processingInstructionSAXFunc) (void *ctx,
Daniel Veillard9d06d302002-01-22 18:15:52 +0000546 const xmlChar *target,
547 const xmlChar *data);
548/**
549 * commentSAXFunc:
550 * @ctx: the user data (XML parser context)
551 * @value: the comment content
552 *
553 * A comment has been parsed.
554 */
555typedef void (*commentSAXFunc) (void *ctx,
556 const xmlChar *value);
557/**
558 * cdataBlockSAXFunc:
559 * @ctx: the user data (XML parser context)
560 * @value: The pcdata content
561 * @len: the block length
562 *
Daniel Veillard61f26172002-03-12 18:46:39 +0000563 * Called when a pcdata block has been parsed.
Daniel Veillard9d06d302002-01-22 18:15:52 +0000564 */
565typedef void (*cdataBlockSAXFunc) (
566 void *ctx,
567 const xmlChar *value,
568 int len);
569/**
570 * warningSAXFunc:
571 * @ctx: an XML parser context
572 * @msg: the message to display/transmit
573 * @...: extra parameters for the message display
574 *
Daniel Veillard61f26172002-03-12 18:46:39 +0000575 * Display and format a warning messages, callback.
Daniel Veillard9d06d302002-01-22 18:15:52 +0000576 */
577typedef void (*warningSAXFunc) (void *ctx,
578 const char *msg, ...);
579/**
580 * errorSAXFunc:
581 * @ctx: an XML parser context
582 * @msg: the message to display/transmit
583 * @...: extra parameters for the message display
584 *
Daniel Veillard61f26172002-03-12 18:46:39 +0000585 * Display and format an error messages, callback.
Daniel Veillard9d06d302002-01-22 18:15:52 +0000586 */
587typedef void (*errorSAXFunc) (void *ctx,
588 const char *msg, ...);
589/**
590 * fatalErrorSAXFunc:
591 * @ctx: an XML parser context
592 * @msg: the message to display/transmit
593 * @...: extra parameters for the message display
594 *
Daniel Veillard61f26172002-03-12 18:46:39 +0000595 * Display and format fatal error messages, callback.
Daniel Veillard0821b152002-11-12 20:57:47 +0000596 * Note: so far fatalError() SAX callbacks are not used, error()
597 * get all the callbacks for errors.
Daniel Veillard9d06d302002-01-22 18:15:52 +0000598 */
599typedef void (*fatalErrorSAXFunc) (void *ctx,
600 const char *msg, ...);
601/**
602 * isStandaloneSAXFunc:
603 * @ctx: the user data (XML parser context)
604 *
Daniel Veillard61f26172002-03-12 18:46:39 +0000605 * Is this document tagged standalone?
Daniel Veillard9d06d302002-01-22 18:15:52 +0000606 *
607 * Returns 1 if true
608 */
Owen Taylor3473f882001-02-23 17:55:21 +0000609typedef int (*isStandaloneSAXFunc) (void *ctx);
Daniel Veillard9d06d302002-01-22 18:15:52 +0000610/**
611 * hasInternalSubsetSAXFunc:
612 * @ctx: the user data (XML parser context)
613 *
Daniel Veillard61f26172002-03-12 18:46:39 +0000614 * Does this document has an internal subset.
Daniel Veillard9d06d302002-01-22 18:15:52 +0000615 *
616 * Returns 1 if true
617 */
Owen Taylor3473f882001-02-23 17:55:21 +0000618typedef int (*hasInternalSubsetSAXFunc) (void *ctx);
Daniel Veillard1af9a412003-08-20 22:54:39 +0000619
Daniel Veillard9d06d302002-01-22 18:15:52 +0000620/**
621 * hasExternalSubsetSAXFunc:
622 * @ctx: the user data (XML parser context)
623 *
Daniel Veillard61f26172002-03-12 18:46:39 +0000624 * Does this document has an external subset?
Daniel Veillard9d06d302002-01-22 18:15:52 +0000625 *
626 * Returns 1 if true
627 */
Owen Taylor3473f882001-02-23 17:55:21 +0000628typedef int (*hasExternalSubsetSAXFunc) (void *ctx);
629
Daniel Veillard1af9a412003-08-20 22:54:39 +0000630/************************************************************************
631 * *
632 * The SAX version 2 API extensions *
633 * *
634 ************************************************************************/
635/**
636 * XML_SAX2_MAGIC:
637 *
638 * Special constant found in SAX2 blocks initialized fields
639 */
640#define XML_SAX2_MAGIC 0xDEEDBEAF
641
642/**
643 * startElementNsSAX2Func:
644 * @ctx: the user data (XML parser context)
645 * @localname: the local name of the element
646 * @prefix: the element namespace prefix if available
647 * @URI: the element namespace name if available
648 * @nb_namespaces: number of namespace definitions on that node
649 * @namespaces: pointer to the array of prefix/URI pairs namespace definitions
650 * @nb_attributes: the number of attributes on that node
Daniel Veillard07cb8222003-09-10 10:51:05 +0000651 * @nb_defaulted: the number of defaulted attributes. The defaulted
652 * ones are at the end of the array
653 * @attributes: pointer to the array of (localname/prefix/URI/value/end)
654 * attribute values.
Daniel Veillard1af9a412003-08-20 22:54:39 +0000655 *
656 * SAX2 callback when an element start has been detected by the parser.
657 * It provides the namespace informations for the element, as well as
658 * the new namespace declarations on the element.
Daniel Veillard1af9a412003-08-20 22:54:39 +0000659 */
660
661typedef void (*startElementNsSAX2Func) (void *ctx,
662 const xmlChar *localname,
663 const xmlChar *prefix,
664 const xmlChar *URI,
665 int nb_namespaces,
666 const xmlChar **namespaces,
Daniel Veillard07cb8222003-09-10 10:51:05 +0000667 int nb_attributes,
668 int nb_defaulted,
669 const xmlChar **attributes);
Daniel Veillard1af9a412003-08-20 22:54:39 +0000670
671/**
672 * endElementNsSAX2Func:
673 * @ctx: the user data (XML parser context)
674 * @localname: the local name of the element
675 * @prefix: the element namespace prefix if available
676 * @URI: the element namespace name if available
677 *
678 * SAX2 callback when an element end has been detected by the parser.
679 * It provides the namespace informations for the element.
680 */
681
682typedef void (*endElementNsSAX2Func) (void *ctx,
683 const xmlChar *localname,
684 const xmlChar *prefix,
685 const xmlChar *URI);
686
Daniel Veillard1af9a412003-08-20 22:54:39 +0000687
Owen Taylor3473f882001-02-23 17:55:21 +0000688struct _xmlSAXHandler {
689 internalSubsetSAXFunc internalSubset;
690 isStandaloneSAXFunc isStandalone;
691 hasInternalSubsetSAXFunc hasInternalSubset;
692 hasExternalSubsetSAXFunc hasExternalSubset;
693 resolveEntitySAXFunc resolveEntity;
694 getEntitySAXFunc getEntity;
695 entityDeclSAXFunc entityDecl;
696 notationDeclSAXFunc notationDecl;
697 attributeDeclSAXFunc attributeDecl;
698 elementDeclSAXFunc elementDecl;
699 unparsedEntityDeclSAXFunc unparsedEntityDecl;
700 setDocumentLocatorSAXFunc setDocumentLocator;
701 startDocumentSAXFunc startDocument;
702 endDocumentSAXFunc endDocument;
703 startElementSAXFunc startElement;
704 endElementSAXFunc endElement;
705 referenceSAXFunc reference;
706 charactersSAXFunc characters;
707 ignorableWhitespaceSAXFunc ignorableWhitespace;
708 processingInstructionSAXFunc processingInstruction;
709 commentSAXFunc comment;
710 warningSAXFunc warning;
711 errorSAXFunc error;
Daniel Veillard0821b152002-11-12 20:57:47 +0000712 fatalErrorSAXFunc fatalError; /* unused error() get all the errors */
Owen Taylor3473f882001-02-23 17:55:21 +0000713 getParameterEntitySAXFunc getParameterEntity;
714 cdataBlockSAXFunc cdataBlock;
715 externalSubsetSAXFunc externalSubset;
Daniel Veillard07cb8222003-09-10 10:51:05 +0000716 unsigned int initialized;
Daniel Veillard1af9a412003-08-20 22:54:39 +0000717 /* The following fields are extensions available only on version 2 */
718 void *_private;
719 startElementNsSAX2Func startElementNs;
720 endElementNsSAX2Func endElementNs;
Daniel Veillard659e71e2003-10-10 14:10:40 +0000721 xmlStructuredErrorFunc serror;
Owen Taylor3473f882001-02-23 17:55:21 +0000722};
723
Daniel Veillard9ee35f32003-09-28 00:19:54 +0000724/*
725 * SAX Version 1
726 */
727typedef struct _xmlSAXHandlerV1 xmlSAXHandlerV1;
728typedef xmlSAXHandlerV1 *xmlSAXHandlerV1Ptr;
729struct _xmlSAXHandlerV1 {
730 internalSubsetSAXFunc internalSubset;
731 isStandaloneSAXFunc isStandalone;
732 hasInternalSubsetSAXFunc hasInternalSubset;
733 hasExternalSubsetSAXFunc hasExternalSubset;
734 resolveEntitySAXFunc resolveEntity;
735 getEntitySAXFunc getEntity;
736 entityDeclSAXFunc entityDecl;
737 notationDeclSAXFunc notationDecl;
738 attributeDeclSAXFunc attributeDecl;
739 elementDeclSAXFunc elementDecl;
740 unparsedEntityDeclSAXFunc unparsedEntityDecl;
741 setDocumentLocatorSAXFunc setDocumentLocator;
742 startDocumentSAXFunc startDocument;
743 endDocumentSAXFunc endDocument;
744 startElementSAXFunc startElement;
745 endElementSAXFunc endElement;
746 referenceSAXFunc reference;
747 charactersSAXFunc characters;
748 ignorableWhitespaceSAXFunc ignorableWhitespace;
749 processingInstructionSAXFunc processingInstruction;
750 commentSAXFunc comment;
751 warningSAXFunc warning;
752 errorSAXFunc error;
753 fatalErrorSAXFunc fatalError; /* unused error() get all the errors */
754 getParameterEntitySAXFunc getParameterEntity;
755 cdataBlockSAXFunc cdataBlock;
756 externalSubsetSAXFunc externalSubset;
757 unsigned int initialized;
758};
759
760
Owen Taylor3473f882001-02-23 17:55:21 +0000761/**
Daniel Veillardf69bb4b2001-05-19 13:24:56 +0000762 * xmlExternalEntityLoader:
763 * @URL: The System ID of the resource requested
764 * @ID: The Public ID of the resource requested
Daniel Veillardcbaf3992001-12-31 16:16:02 +0000765 * @context: the XML parser context
Daniel Veillardf69bb4b2001-05-19 13:24:56 +0000766 *
Daniel Veillard61f26172002-03-12 18:46:39 +0000767 * External entity loaders types.
Daniel Veillardcbaf3992001-12-31 16:16:02 +0000768 *
Daniel Veillard61f26172002-03-12 18:46:39 +0000769 * Returns the entity input parser.
Owen Taylor3473f882001-02-23 17:55:21 +0000770 */
Daniel Veillard9d06d302002-01-22 18:15:52 +0000771typedef xmlParserInputPtr (*xmlExternalEntityLoader) (const char *URL,
772 const char *ID,
773 xmlParserCtxtPtr context);
Owen Taylor3473f882001-02-23 17:55:21 +0000774
Daniel Veillard6c4ffaf2002-02-11 08:54:05 +0000775#ifdef __cplusplus
776}
777#endif
Igor Zlatkovic76874e42003-08-25 09:05:12 +0000778
Daniel Veillard6c4ffaf2002-02-11 08:54:05 +0000779#include <libxml/encoding.h>
780#include <libxml/xmlIO.h>
781#include <libxml/globals.h>
Igor Zlatkovic76874e42003-08-25 09:05:12 +0000782
Daniel Veillard6c4ffaf2002-02-11 08:54:05 +0000783#ifdef __cplusplus
784extern "C" {
785#endif
786
Owen Taylor3473f882001-02-23 17:55:21 +0000787
Daniel Veillardf69bb4b2001-05-19 13:24:56 +0000788/*
Owen Taylor3473f882001-02-23 17:55:21 +0000789 * Init/Cleanup
790 */
Igor Zlatkovic76874e42003-08-25 09:05:12 +0000791XMLPUBFUN void XMLCALL
792 xmlInitParser (void);
793XMLPUBFUN void XMLCALL
794 xmlCleanupParser (void);
Owen Taylor3473f882001-02-23 17:55:21 +0000795
Daniel Veillardf69bb4b2001-05-19 13:24:56 +0000796/*
Owen Taylor3473f882001-02-23 17:55:21 +0000797 * Input functions
798 */
Igor Zlatkovic76874e42003-08-25 09:05:12 +0000799XMLPUBFUN int XMLCALL
800 xmlParserInputRead (xmlParserInputPtr in,
Owen Taylor3473f882001-02-23 17:55:21 +0000801 int len);
Igor Zlatkovic76874e42003-08-25 09:05:12 +0000802XMLPUBFUN int XMLCALL
803 xmlParserInputGrow (xmlParserInputPtr in,
Owen Taylor3473f882001-02-23 17:55:21 +0000804 int len);
805
Daniel Veillardf69bb4b2001-05-19 13:24:56 +0000806/*
Owen Taylor3473f882001-02-23 17:55:21 +0000807 * xmlChar handling
808 */
Igor Zlatkovic76874e42003-08-25 09:05:12 +0000809XMLPUBFUN xmlChar * XMLCALL
810 xmlStrdup (const xmlChar *cur);
811XMLPUBFUN xmlChar * XMLCALL
812 xmlStrndup (const xmlChar *cur,
Owen Taylor3473f882001-02-23 17:55:21 +0000813 int len);
Igor Zlatkovic76874e42003-08-25 09:05:12 +0000814XMLPUBFUN xmlChar * XMLCALL
815 xmlCharStrndup (const char *cur,
Daniel Veillard56a4cb82001-03-24 17:00:36 +0000816 int len);
Igor Zlatkovic76874e42003-08-25 09:05:12 +0000817XMLPUBFUN xmlChar * XMLCALL
818 xmlCharStrdup (const char *cur);
819XMLPUBFUN xmlChar * XMLCALL
820 xmlStrsub (const xmlChar *str,
Owen Taylor3473f882001-02-23 17:55:21 +0000821 int start,
822 int len);
Igor Zlatkovic76874e42003-08-25 09:05:12 +0000823XMLPUBFUN const xmlChar * XMLCALL
824 xmlStrchr (const xmlChar *str,
Owen Taylor3473f882001-02-23 17:55:21 +0000825 xmlChar val);
Igor Zlatkovic76874e42003-08-25 09:05:12 +0000826XMLPUBFUN const xmlChar * XMLCALL
827 xmlStrstr (const xmlChar *str,
Daniel Veillard77044732001-06-29 21:31:07 +0000828 const xmlChar *val);
Igor Zlatkovic76874e42003-08-25 09:05:12 +0000829XMLPUBFUN const xmlChar * XMLCALL
830 xmlStrcasestr (const xmlChar *str,
Owen Taylor3473f882001-02-23 17:55:21 +0000831 xmlChar *val);
Igor Zlatkovic76874e42003-08-25 09:05:12 +0000832XMLPUBFUN int XMLCALL
833 xmlStrcmp (const xmlChar *str1,
Owen Taylor3473f882001-02-23 17:55:21 +0000834 const xmlChar *str2);
Igor Zlatkovic76874e42003-08-25 09:05:12 +0000835XMLPUBFUN int XMLCALL
836 xmlStrncmp (const xmlChar *str1,
Owen Taylor3473f882001-02-23 17:55:21 +0000837 const xmlChar *str2,
838 int len);
Igor Zlatkovic76874e42003-08-25 09:05:12 +0000839XMLPUBFUN int XMLCALL
840 xmlStrcasecmp (const xmlChar *str1,
Owen Taylor3473f882001-02-23 17:55:21 +0000841 const xmlChar *str2);
Igor Zlatkovic76874e42003-08-25 09:05:12 +0000842XMLPUBFUN int XMLCALL
843 xmlStrncasecmp (const xmlChar *str1,
Owen Taylor3473f882001-02-23 17:55:21 +0000844 const xmlChar *str2,
845 int len);
Igor Zlatkovic76874e42003-08-25 09:05:12 +0000846XMLPUBFUN int XMLCALL
847 xmlStrEqual (const xmlChar *str1,
Owen Taylor3473f882001-02-23 17:55:21 +0000848 const xmlChar *str2);
Daniel Veillard07cb8222003-09-10 10:51:05 +0000849XMLPUBFUN int XMLCALL
850 xmlStrQEqual (const xmlChar *pref,
851 const xmlChar *name,
852 const xmlChar *str);
Igor Zlatkovic76874e42003-08-25 09:05:12 +0000853XMLPUBFUN int XMLCALL
854 xmlStrlen (const xmlChar *str);
855XMLPUBFUN xmlChar * XMLCALL
856 xmlStrcat (xmlChar *cur,
Owen Taylor3473f882001-02-23 17:55:21 +0000857 const xmlChar *add);
Igor Zlatkovic76874e42003-08-25 09:05:12 +0000858XMLPUBFUN xmlChar * XMLCALL
859 xmlStrncat (xmlChar *cur,
Owen Taylor3473f882001-02-23 17:55:21 +0000860 const xmlChar *add,
861 int len);
862
Aleksey Sanine7acf432003-10-02 20:05:27 +0000863XMLPUBFUN int XMLCALL
864 xmlStrPrintf (xmlChar *buf,
865 int len,
866 const xmlChar *msg,
867 ...);
868
Aleksey Saninb5a46da2003-10-29 15:51:17 +0000869XMLPUBFUN int XMLCALL
870 xmlStrVPrintf (xmlChar *buf,
871 int len,
872 const xmlChar *msg,
873 va_list ap);
874
Daniel Veillardf69bb4b2001-05-19 13:24:56 +0000875/*
Owen Taylor3473f882001-02-23 17:55:21 +0000876 * Basic parsing Interfaces
877 */
Igor Zlatkovic76874e42003-08-25 09:05:12 +0000878XMLPUBFUN xmlDocPtr XMLCALL
879 xmlParseDoc (xmlChar *cur);
880XMLPUBFUN xmlDocPtr XMLCALL
881 xmlParseMemory (const char *buffer,
Owen Taylor3473f882001-02-23 17:55:21 +0000882 int size);
Igor Zlatkovic76874e42003-08-25 09:05:12 +0000883XMLPUBFUN xmlDocPtr XMLCALL
884 xmlParseFile (const char *filename);
885XMLPUBFUN int XMLCALL
886 xmlSubstituteEntitiesDefault(int val);
887XMLPUBFUN int XMLCALL
888 xmlKeepBlanksDefault (int val);
889XMLPUBFUN void XMLCALL
890 xmlStopParser (xmlParserCtxtPtr ctxt);
891XMLPUBFUN int XMLCALL
892 xmlPedanticParserDefault(int val);
893XMLPUBFUN int XMLCALL
894 xmlLineNumbersDefault (int val);
Owen Taylor3473f882001-02-23 17:55:21 +0000895
Daniel Veillardf69bb4b2001-05-19 13:24:56 +0000896/*
Owen Taylor3473f882001-02-23 17:55:21 +0000897 * Recovery mode
898 */
Igor Zlatkovic76874e42003-08-25 09:05:12 +0000899XMLPUBFUN xmlDocPtr XMLCALL
900 xmlRecoverDoc (xmlChar *cur);
901XMLPUBFUN xmlDocPtr XMLCALL
902 xmlRecoverMemory (const char *buffer,
Owen Taylor3473f882001-02-23 17:55:21 +0000903 int size);
Igor Zlatkovic76874e42003-08-25 09:05:12 +0000904XMLPUBFUN xmlDocPtr XMLCALL
905 xmlRecoverFile (const char *filename);
Owen Taylor3473f882001-02-23 17:55:21 +0000906
Daniel Veillardf69bb4b2001-05-19 13:24:56 +0000907/*
Owen Taylor3473f882001-02-23 17:55:21 +0000908 * Less common routines and SAX interfaces
909 */
Igor Zlatkovic76874e42003-08-25 09:05:12 +0000910XMLPUBFUN int XMLCALL
911 xmlParseDocument (xmlParserCtxtPtr ctxt);
912XMLPUBFUN int XMLCALL
913 xmlParseExtParsedEnt (xmlParserCtxtPtr ctxt);
914XMLPUBFUN xmlDocPtr XMLCALL
915 xmlSAXParseDoc (xmlSAXHandlerPtr sax,
Owen Taylor3473f882001-02-23 17:55:21 +0000916 xmlChar *cur,
917 int recovery);
Igor Zlatkovic76874e42003-08-25 09:05:12 +0000918XMLPUBFUN int XMLCALL
919 xmlSAXUserParseFile (xmlSAXHandlerPtr sax,
Owen Taylor3473f882001-02-23 17:55:21 +0000920 void *user_data,
921 const char *filename);
Igor Zlatkovic76874e42003-08-25 09:05:12 +0000922XMLPUBFUN int XMLCALL
923 xmlSAXUserParseMemory (xmlSAXHandlerPtr sax,
Owen Taylor3473f882001-02-23 17:55:21 +0000924 void *user_data,
Daniel Veillardfd7ddca2001-05-16 10:57:35 +0000925 const char *buffer,
Owen Taylor3473f882001-02-23 17:55:21 +0000926 int size);
Igor Zlatkovic76874e42003-08-25 09:05:12 +0000927XMLPUBFUN xmlDocPtr XMLCALL
928 xmlSAXParseMemory (xmlSAXHandlerPtr sax,
Daniel Veillard50822cb2001-07-26 20:05:51 +0000929 const char *buffer,
Owen Taylor3473f882001-02-23 17:55:21 +0000930 int size,
931 int recovery);
Igor Zlatkovic76874e42003-08-25 09:05:12 +0000932XMLPUBFUN xmlDocPtr XMLCALL
933 xmlSAXParseMemoryWithData (xmlSAXHandlerPtr sax,
Daniel Veillard8606bbb2002-11-12 12:36:52 +0000934 const char *buffer,
935 int size,
936 int recovery,
937 void *data);
Igor Zlatkovic76874e42003-08-25 09:05:12 +0000938XMLPUBFUN xmlDocPtr XMLCALL
939 xmlSAXParseFile (xmlSAXHandlerPtr sax,
Owen Taylor3473f882001-02-23 17:55:21 +0000940 const char *filename,
941 int recovery);
Igor Zlatkovic76874e42003-08-25 09:05:12 +0000942XMLPUBFUN xmlDocPtr XMLCALL
943 xmlSAXParseFileWithData (xmlSAXHandlerPtr sax,
Daniel Veillarda293c322001-10-02 13:54:14 +0000944 const char *filename,
945 int recovery,
946 void *data);
Igor Zlatkovic76874e42003-08-25 09:05:12 +0000947XMLPUBFUN xmlDocPtr XMLCALL
948 xmlSAXParseEntity (xmlSAXHandlerPtr sax,
Owen Taylor3473f882001-02-23 17:55:21 +0000949 const char *filename);
Igor Zlatkovic76874e42003-08-25 09:05:12 +0000950XMLPUBFUN xmlDocPtr XMLCALL
951 xmlParseEntity (const char *filename);
952XMLPUBFUN xmlDtdPtr XMLCALL
953 xmlParseDTD (const xmlChar *ExternalID,
Owen Taylor3473f882001-02-23 17:55:21 +0000954 const xmlChar *SystemID);
Igor Zlatkovic76874e42003-08-25 09:05:12 +0000955XMLPUBFUN xmlDtdPtr XMLCALL
956 xmlSAXParseDTD (xmlSAXHandlerPtr sax,
Owen Taylor3473f882001-02-23 17:55:21 +0000957 const xmlChar *ExternalID,
958 const xmlChar *SystemID);
Igor Zlatkovic76874e42003-08-25 09:05:12 +0000959XMLPUBFUN xmlDtdPtr XMLCALL
960 xmlIOParseDTD (xmlSAXHandlerPtr sax,
Owen Taylor3473f882001-02-23 17:55:21 +0000961 xmlParserInputBufferPtr input,
962 xmlCharEncoding enc);
Igor Zlatkovic76874e42003-08-25 09:05:12 +0000963XMLPUBFUN int XMLCALL
964 xmlParseBalancedChunkMemory(xmlDocPtr doc,
Owen Taylor3473f882001-02-23 17:55:21 +0000965 xmlSAXHandlerPtr sax,
966 void *user_data,
967 int depth,
968 const xmlChar *string,
Daniel Veillardcda96922001-08-21 10:56:31 +0000969 xmlNodePtr *lst);
Igor Zlatkovic76874e42003-08-25 09:05:12 +0000970XMLPUBFUN int XMLCALL
971 xmlParseBalancedChunkMemoryRecover(xmlDocPtr doc,
Daniel Veillard58e44c92002-08-02 22:19:49 +0000972 xmlSAXHandlerPtr sax,
973 void *user_data,
974 int depth,
975 const xmlChar *string,
976 xmlNodePtr *lst,
977 int recover);
Igor Zlatkovic76874e42003-08-25 09:05:12 +0000978XMLPUBFUN int XMLCALL
979 xmlParseExternalEntity (xmlDocPtr doc,
Owen Taylor3473f882001-02-23 17:55:21 +0000980 xmlSAXHandlerPtr sax,
981 void *user_data,
982 int depth,
983 const xmlChar *URL,
984 const xmlChar *ID,
Daniel Veillardcda96922001-08-21 10:56:31 +0000985 xmlNodePtr *lst);
Igor Zlatkovic76874e42003-08-25 09:05:12 +0000986XMLPUBFUN int XMLCALL
987 xmlParseCtxtExternalEntity(xmlParserCtxtPtr ctx,
Owen Taylor3473f882001-02-23 17:55:21 +0000988 const xmlChar *URL,
989 const xmlChar *ID,
Daniel Veillardcda96922001-08-21 10:56:31 +0000990 xmlNodePtr *lst);
Owen Taylor3473f882001-02-23 17:55:21 +0000991
Daniel Veillardf69bb4b2001-05-19 13:24:56 +0000992/*
Owen Taylor3473f882001-02-23 17:55:21 +0000993 * Parser contexts handling.
994 */
Daniel Veillard2b8c4a12003-10-02 22:28:19 +0000995XMLPUBFUN xmlParserCtxtPtr XMLCALL
996 xmlNewParserCtxt (void);
Igor Zlatkovic76874e42003-08-25 09:05:12 +0000997XMLPUBFUN int XMLCALL
998 xmlInitParserCtxt (xmlParserCtxtPtr ctxt);
999XMLPUBFUN void XMLCALL
1000 xmlClearParserCtxt (xmlParserCtxtPtr ctxt);
1001XMLPUBFUN void XMLCALL
1002 xmlFreeParserCtxt (xmlParserCtxtPtr ctxt);
1003XMLPUBFUN void XMLCALL
1004 xmlSetupParserForBuffer (xmlParserCtxtPtr ctxt,
Owen Taylor3473f882001-02-23 17:55:21 +00001005 const xmlChar* buffer,
Daniel Veillard963d2ae2002-01-20 22:08:18 +00001006 const char *filename);
Igor Zlatkovic76874e42003-08-25 09:05:12 +00001007XMLPUBFUN xmlParserCtxtPtr XMLCALL
Daniel Veillard16fa96c2003-09-23 21:50:54 +00001008 xmlCreateDocParserCtxt (const xmlChar *cur);
Owen Taylor3473f882001-02-23 17:55:21 +00001009
Daniel Veillardf69bb4b2001-05-19 13:24:56 +00001010/*
Owen Taylor3473f882001-02-23 17:55:21 +00001011 * Reading/setting optional parsing features.
1012 */
1013
Igor Zlatkovic76874e42003-08-25 09:05:12 +00001014XMLPUBFUN int XMLCALL
1015 xmlGetFeaturesList (int *len,
Owen Taylor3473f882001-02-23 17:55:21 +00001016 const char **result);
Igor Zlatkovic76874e42003-08-25 09:05:12 +00001017XMLPUBFUN int XMLCALL
1018 xmlGetFeature (xmlParserCtxtPtr ctxt,
Owen Taylor3473f882001-02-23 17:55:21 +00001019 const char *name,
1020 void *result);
Igor Zlatkovic76874e42003-08-25 09:05:12 +00001021XMLPUBFUN int XMLCALL
1022 xmlSetFeature (xmlParserCtxtPtr ctxt,
Owen Taylor3473f882001-02-23 17:55:21 +00001023 const char *name,
1024 void *value);
1025
Daniel Veillard73b013f2003-09-30 12:36:01 +00001026#ifdef LIBXML_PUSH_ENABLED
Daniel Veillardf69bb4b2001-05-19 13:24:56 +00001027/*
Daniel Veillard61f26172002-03-12 18:46:39 +00001028 * Interfaces for the Push mode.
Owen Taylor3473f882001-02-23 17:55:21 +00001029 */
Igor Zlatkovic76874e42003-08-25 09:05:12 +00001030XMLPUBFUN xmlParserCtxtPtr XMLCALL
1031 xmlCreatePushParserCtxt(xmlSAXHandlerPtr sax,
Owen Taylor3473f882001-02-23 17:55:21 +00001032 void *user_data,
1033 const char *chunk,
1034 int size,
1035 const char *filename);
Igor Zlatkovic76874e42003-08-25 09:05:12 +00001036XMLPUBFUN int XMLCALL
1037 xmlParseChunk (xmlParserCtxtPtr ctxt,
Owen Taylor3473f882001-02-23 17:55:21 +00001038 const char *chunk,
1039 int size,
1040 int terminate);
Daniel Veillard73b013f2003-09-30 12:36:01 +00001041#endif /* LIBXML_PUSH_ENABLED */
Owen Taylor3473f882001-02-23 17:55:21 +00001042
Daniel Veillardf69bb4b2001-05-19 13:24:56 +00001043/*
Daniel Veillard61f26172002-03-12 18:46:39 +00001044 * Special I/O mode.
Owen Taylor3473f882001-02-23 17:55:21 +00001045 */
1046
Igor Zlatkovic76874e42003-08-25 09:05:12 +00001047XMLPUBFUN xmlParserCtxtPtr XMLCALL
1048 xmlCreateIOParserCtxt (xmlSAXHandlerPtr sax,
Owen Taylor3473f882001-02-23 17:55:21 +00001049 void *user_data,
1050 xmlInputReadCallback ioread,
1051 xmlInputCloseCallback ioclose,
1052 void *ioctx,
1053 xmlCharEncoding enc);
1054
Igor Zlatkovic76874e42003-08-25 09:05:12 +00001055XMLPUBFUN xmlParserInputPtr XMLCALL
1056 xmlNewIOInputStream (xmlParserCtxtPtr ctxt,
Owen Taylor3473f882001-02-23 17:55:21 +00001057 xmlParserInputBufferPtr input,
1058 xmlCharEncoding enc);
1059
Daniel Veillardf69bb4b2001-05-19 13:24:56 +00001060/*
Daniel Veillard61f26172002-03-12 18:46:39 +00001061 * Node infos.
Owen Taylor3473f882001-02-23 17:55:21 +00001062 */
Igor Zlatkovic76874e42003-08-25 09:05:12 +00001063XMLPUBFUN const xmlParserNodeInfo* XMLCALL
Daniel Veillard963d2ae2002-01-20 22:08:18 +00001064 xmlParserFindNodeInfo (const xmlParserCtxtPtr ctxt,
1065 const xmlNodePtr node);
Igor Zlatkovic76874e42003-08-25 09:05:12 +00001066XMLPUBFUN void XMLCALL
1067 xmlInitNodeInfoSeq (xmlParserNodeInfoSeqPtr seq);
1068XMLPUBFUN void XMLCALL
1069 xmlClearNodeInfoSeq (xmlParserNodeInfoSeqPtr seq);
1070XMLPUBFUN unsigned long XMLCALL
1071 xmlParserFindNodeInfoIndex(const xmlParserNodeInfoSeqPtr seq,
Daniel Veillard963d2ae2002-01-20 22:08:18 +00001072 const xmlNodePtr node);
Igor Zlatkovic76874e42003-08-25 09:05:12 +00001073XMLPUBFUN void XMLCALL
1074 xmlParserAddNodeInfo (xmlParserCtxtPtr ctxt,
Daniel Veillard963d2ae2002-01-20 22:08:18 +00001075 const xmlParserNodeInfoPtr info);
Owen Taylor3473f882001-02-23 17:55:21 +00001076
1077/*
Daniel Veillard61f26172002-03-12 18:46:39 +00001078 * External entities handling actually implemented in xmlIO.
Owen Taylor3473f882001-02-23 17:55:21 +00001079 */
1080
Igor Zlatkovic76874e42003-08-25 09:05:12 +00001081XMLPUBFUN void XMLCALL
1082 xmlSetExternalEntityLoader(xmlExternalEntityLoader f);
1083XMLPUBFUN xmlExternalEntityLoader XMLCALL
Owen Taylor3473f882001-02-23 17:55:21 +00001084 xmlGetExternalEntityLoader(void);
Igor Zlatkovic76874e42003-08-25 09:05:12 +00001085XMLPUBFUN xmlParserInputPtr XMLCALL
Owen Taylor3473f882001-02-23 17:55:21 +00001086 xmlLoadExternalEntity (const char *URL,
1087 const char *ID,
Daniel Veillard9d06d302002-01-22 18:15:52 +00001088 xmlParserCtxtPtr ctxt);
Daniel Veillard16fa96c2003-09-23 21:50:54 +00001089/*
1090 * New set of simpler/more flexible APIs
1091 */
1092/**
1093 * xmlParserOption:
1094 *
1095 * This is the set of XML parser options that can be passed down
1096 * to the xmlReadDoc() and similar calls.
1097 */
1098typedef enum {
1099 XML_PARSE_RECOVER = 1<<0, /* recover on errors */
1100 XML_PARSE_NOENT = 1<<1, /* substitute entities */
1101 XML_PARSE_DTDLOAD = 1<<2, /* load the external subset */
1102 XML_PARSE_DTDATTR = 1<<3, /* default DTD attributes */
1103 XML_PARSE_DTDVALID = 1<<4, /* validate with the DTD */
1104 XML_PARSE_NOERROR = 1<<5, /* suppress error reports */
1105 XML_PARSE_NOWARNING = 1<<6, /* suppress warning reports */
1106 XML_PARSE_PEDANTIC = 1<<7, /* pedantic error reporting */
1107 XML_PARSE_NOBLANKS = 1<<8, /* remove blank nodes */
1108 XML_PARSE_SAX1 = 1<<9, /* use the SAX1 interface internally */
1109 XML_PARSE_XINCLUDE = 1<<10,/* Implement XInclude substitition */
Daniel Veillarde96a2a42003-09-24 21:23:56 +00001110 XML_PARSE_NONET = 1<<11,/* Forbid network access */
Daniel Veillard9475a352003-09-26 12:47:50 +00001111 XML_PARSE_NODICT = 1<<12,/* Do not reuse the context dictionnary */
1112 XML_PARSE_NSCLEAN = 1<<13,/* remove redundant namespaces declarations */
1113 XML_PARSE_NOCDATA = 1<<14 /* merge CDATA as text nodes */
Daniel Veillard16fa96c2003-09-23 21:50:54 +00001114} xmlParserOption;
1115
1116XMLPUBFUN void XMLCALL
1117 xmlCtxtReset (xmlParserCtxtPtr ctxt);
1118XMLPUBFUN int XMLCALL
Daniel Veillard9ba8e382003-10-28 21:31:45 +00001119 xmlCtxtResetPush (xmlParserCtxtPtr ctxt,
1120 const char *chunk,
1121 int size,
1122 const char *filename,
1123 const char *encoding);
1124XMLPUBFUN int XMLCALL
Daniel Veillard16fa96c2003-09-23 21:50:54 +00001125 xmlCtxtUseOptions (xmlParserCtxtPtr ctxt,
1126 int options);
1127XMLPUBFUN xmlDocPtr XMLCALL
1128 xmlReadDoc (const xmlChar *cur,
Daniel Veillard60942de2003-09-25 21:05:58 +00001129 const char *URL,
Daniel Veillard16fa96c2003-09-23 21:50:54 +00001130 const char *encoding,
1131 int options);
1132XMLPUBFUN xmlDocPtr XMLCALL
Daniel Veillard60942de2003-09-25 21:05:58 +00001133 xmlReadFile (const char *URL,
Daniel Veillard16fa96c2003-09-23 21:50:54 +00001134 const char *encoding,
1135 int options);
1136XMLPUBFUN xmlDocPtr XMLCALL
1137 xmlReadMemory (const char *buffer,
1138 int size,
Daniel Veillard60942de2003-09-25 21:05:58 +00001139 const char *URL,
Daniel Veillard16fa96c2003-09-23 21:50:54 +00001140 const char *encoding,
1141 int options);
1142XMLPUBFUN xmlDocPtr XMLCALL
1143 xmlReadFd (int fd,
Daniel Veillard60942de2003-09-25 21:05:58 +00001144 const char *URL,
Daniel Veillard16fa96c2003-09-23 21:50:54 +00001145 const char *encoding,
1146 int options);
1147XMLPUBFUN xmlDocPtr XMLCALL
1148 xmlReadIO (xmlInputReadCallback ioread,
1149 xmlInputCloseCallback ioclose,
1150 void *ioctx,
Daniel Veillard60942de2003-09-25 21:05:58 +00001151 const char *URL,
Daniel Veillard16fa96c2003-09-23 21:50:54 +00001152 const char *encoding,
1153 int options);
1154XMLPUBFUN xmlDocPtr XMLCALL
1155 xmlCtxtReadDoc (xmlParserCtxtPtr ctxt,
1156 const xmlChar *cur,
Daniel Veillard60942de2003-09-25 21:05:58 +00001157 const char *URL,
Daniel Veillard16fa96c2003-09-23 21:50:54 +00001158 const char *encoding,
1159 int options);
1160XMLPUBFUN xmlDocPtr XMLCALL
1161 xmlCtxtReadFile (xmlParserCtxtPtr ctxt,
1162 const char *filename,
1163 const char *encoding,
1164 int options);
1165XMLPUBFUN xmlDocPtr XMLCALL
1166 xmlCtxtReadMemory (xmlParserCtxtPtr ctxt,
1167 const char *buffer,
1168 int size,
Daniel Veillard60942de2003-09-25 21:05:58 +00001169 const char *URL,
Daniel Veillard16fa96c2003-09-23 21:50:54 +00001170 const char *encoding,
1171 int options);
1172XMLPUBFUN xmlDocPtr XMLCALL
1173 xmlCtxtReadFd (xmlParserCtxtPtr ctxt,
1174 int fd,
Daniel Veillard60942de2003-09-25 21:05:58 +00001175 const char *URL,
Daniel Veillard16fa96c2003-09-23 21:50:54 +00001176 const char *encoding,
1177 int options);
1178XMLPUBFUN xmlDocPtr XMLCALL
1179 xmlCtxtReadIO (xmlParserCtxtPtr ctxt,
1180 xmlInputReadCallback ioread,
1181 xmlInputCloseCallback ioclose,
1182 void *ioctx,
Daniel Veillard60942de2003-09-25 21:05:58 +00001183 const char *URL,
Daniel Veillard16fa96c2003-09-23 21:50:54 +00001184 const char *encoding,
1185 int options);
Owen Taylor3473f882001-02-23 17:55:21 +00001186
1187#ifdef __cplusplus
1188}
1189#endif
Owen Taylor3473f882001-02-23 17:55:21 +00001190#endif /* __XML_PARSER_H__ */
1191