blob: 911c634a0b5c590dce64af8d639e758d96672e33 [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
Igor Zlatkovic76874e42003-08-25 09:05:12 +000012#include <libxml/xmlversion.h>
Owen Taylor3473f882001-02-23 17:55:21 +000013#include <libxml/tree.h>
Daniel Veillard2fdbd322003-08-18 12:15:38 +000014#include <libxml/dict.h>
Daniel Veillard07cb8222003-09-10 10:51:05 +000015#include <libxml/hash.h>
Owen Taylor3473f882001-02-23 17:55:21 +000016#include <libxml/valid.h>
Owen Taylor3473f882001-02-23 17:55:21 +000017#include <libxml/entities.h>
Owen Taylor3473f882001-02-23 17:55:21 +000018
19#ifdef __cplusplus
20extern "C" {
21#endif
22
Daniel Veillard5e2dace2001-07-18 19:30:27 +000023/**
24 * XML_DEFAULT_VERSION:
25 *
26 * The default version of XML used: 1.0
Owen Taylor3473f882001-02-23 17:55:21 +000027 */
28#define XML_DEFAULT_VERSION "1.0"
29
30/**
Daniel Veillardf69bb4b2001-05-19 13:24:56 +000031 * xmlParserInput:
32 *
Daniel Veillard61f26172002-03-12 18:46:39 +000033 * An xmlParserInput is an input flow for the XML processor.
Owen Taylor3473f882001-02-23 17:55:21 +000034 * Each entity parsed is associated an xmlParserInput (except the
35 * few predefined ones). This is the case both for internal entities
36 * - in which case the flow is already completely in memory - or
37 * external entities - in which case we use the buf structure for
38 * progressive reading and I18N conversions to the internal UTF-8 format.
39 */
40
Daniel Veillard9d06d302002-01-22 18:15:52 +000041/**
42 * xmlParserInputDeallocate:
43 * @str: the string to deallocate
44 *
Daniel Veillard61f26172002-03-12 18:46:39 +000045 * Callback for freeing some parser input allocations.
Daniel Veillard9d06d302002-01-22 18:15:52 +000046 */
47typedef void (* xmlParserInputDeallocate)(xmlChar *str);
Daniel Veillard5e2dace2001-07-18 19:30:27 +000048
Owen Taylor3473f882001-02-23 17:55:21 +000049struct _xmlParserInput {
50 /* Input buffer */
51 xmlParserInputBufferPtr buf; /* UTF-8 encoded buffer */
52
53 const char *filename; /* The file analyzed, if any */
Daniel Veillard60087f32001-10-10 09:45:09 +000054 const char *directory; /* the directory/base of the file */
Owen Taylor3473f882001-02-23 17:55:21 +000055 const xmlChar *base; /* Base of the array to parse */
56 const xmlChar *cur; /* Current char being parsed */
Daniel Veillardcbaf3992001-12-31 16:16:02 +000057 const xmlChar *end; /* end of the array to parse */
Owen Taylor3473f882001-02-23 17:55:21 +000058 int length; /* length if known */
59 int line; /* Current line */
60 int col; /* Current column */
Daniel Veillard3e59fc52003-04-18 12:34:58 +000061 /*
62 * NOTE: consumed is only tested for equality in the parser code,
63 * so even if there is an overflow this should not give troubles
64 * for parsing very large instances.
65 */
66 unsigned long consumed; /* How many xmlChars already consumed */
Owen Taylor3473f882001-02-23 17:55:21 +000067 xmlParserInputDeallocate free; /* function to deallocate the base */
68 const xmlChar *encoding; /* the encoding string for entity */
69 const xmlChar *version; /* the version string for entity */
70 int standalone; /* Was that entity marked standalone */
Daniel Veillardbdbe0d42003-09-14 19:56:14 +000071 int id; /* an unique identifier for the entity */
Owen Taylor3473f882001-02-23 17:55:21 +000072};
73
74/**
Daniel Veillardf69bb4b2001-05-19 13:24:56 +000075 * xmlParserNodeInfo:
76 *
Daniel Veillard61f26172002-03-12 18:46:39 +000077 * The parser can be asked to collect Node informations, i.e. at what
Owen Taylor3473f882001-02-23 17:55:21 +000078 * place in the file they were detected.
79 * NOTE: This is off by default and not very well tested.
80 */
81typedef struct _xmlParserNodeInfo xmlParserNodeInfo;
82typedef xmlParserNodeInfo *xmlParserNodeInfoPtr;
83
84struct _xmlParserNodeInfo {
85 const struct _xmlNode* node;
86 /* Position & line # that text that created the node begins & ends on */
87 unsigned long begin_pos;
88 unsigned long begin_line;
89 unsigned long end_pos;
90 unsigned long end_line;
91};
92
93typedef struct _xmlParserNodeInfoSeq xmlParserNodeInfoSeq;
94typedef xmlParserNodeInfoSeq *xmlParserNodeInfoSeqPtr;
95struct _xmlParserNodeInfoSeq {
96 unsigned long maximum;
97 unsigned long length;
98 xmlParserNodeInfo* buffer;
99};
100
101/**
Daniel Veillardf69bb4b2001-05-19 13:24:56 +0000102 * xmlParserInputState:
103 *
Daniel Veillard61f26172002-03-12 18:46:39 +0000104 * The parser is now working also as a state based parser.
105 * The recursive one use the state info for entities processing.
Owen Taylor3473f882001-02-23 17:55:21 +0000106 */
107typedef enum {
108 XML_PARSER_EOF = -1, /* nothing is to be parsed */
109 XML_PARSER_START = 0, /* nothing has been parsed */
110 XML_PARSER_MISC, /* Misc* before int subset */
Daniel Veillardcbaf3992001-12-31 16:16:02 +0000111 XML_PARSER_PI, /* Within a processing instruction */
Owen Taylor3473f882001-02-23 17:55:21 +0000112 XML_PARSER_DTD, /* within some DTD content */
113 XML_PARSER_PROLOG, /* Misc* after internal subset */
114 XML_PARSER_COMMENT, /* within a comment */
115 XML_PARSER_START_TAG, /* within a start tag */
116 XML_PARSER_CONTENT, /* within the content */
117 XML_PARSER_CDATA_SECTION, /* within a CDATA section */
118 XML_PARSER_END_TAG, /* within a closing tag */
119 XML_PARSER_ENTITY_DECL, /* within an entity declaration */
120 XML_PARSER_ENTITY_VALUE, /* within an entity value in a decl */
121 XML_PARSER_ATTRIBUTE_VALUE, /* within an attribute value */
122 XML_PARSER_SYSTEM_LITERAL, /* within a SYSTEM value */
123 XML_PARSER_EPILOG, /* the Misc* after the last end tag */
Daniel Veillard4a7ae502002-02-18 19:18:17 +0000124 XML_PARSER_IGNORE, /* within an IGNORED section */
125 XML_PARSER_PUBLIC_LITERAL /* within a PUBLIC value */
Owen Taylor3473f882001-02-23 17:55:21 +0000126} xmlParserInputState;
127
128/**
Daniel Veillardd16df9f2001-05-23 13:44:21 +0000129 * XML_DETECT_IDS:
130 *
Daniel Veillard61f26172002-03-12 18:46:39 +0000131 * Bit in the loadsubset context field to tell to do ID/REFs lookups.
132 * Use it to initialize xmlLoadExtDtdDefaultValue.
Daniel Veillardd16df9f2001-05-23 13:44:21 +0000133 */
134#define XML_DETECT_IDS 2
135
136/**
137 * XML_COMPLETE_ATTRS:
138 *
139 * Bit in the loadsubset context field to tell to do complete the
Daniel Veillard61f26172002-03-12 18:46:39 +0000140 * elements attributes lists with the ones defaulted from the DTDs.
141 * Use it to initialize xmlLoadExtDtdDefaultValue.
Daniel Veillardd16df9f2001-05-23 13:44:21 +0000142 */
143#define XML_COMPLETE_ATTRS 4
144
145/**
Daniel Veillardef8dd7b2003-03-23 12:02:56 +0000146 * XML_SKIP_IDS:
147 *
148 * Bit in the loadsubset context field to tell to not do ID/REFs registration.
149 * Used to initialize xmlLoadExtDtdDefaultValue in some special cases.
150 */
151#define XML_SKIP_IDS 8
152
153/**
Daniel Veillardf69bb4b2001-05-19 13:24:56 +0000154 * xmlParserCtxt:
155 *
Owen Taylor3473f882001-02-23 17:55:21 +0000156 * The parser context.
Daniel Veillard61f26172002-03-12 18:46:39 +0000157 * NOTE This doesn't completely define the parser state, the (current ?)
Owen Taylor3473f882001-02-23 17:55:21 +0000158 * design of the parser uses recursive function calls since this allow
159 * and easy mapping from the production rules of the specification
160 * to the actual code. The drawback is that the actual function call
161 * also reflect the parser state. However most of the parsing routines
162 * takes as the only argument the parser context pointer, so migrating
163 * to a state based parser for progressive parsing shouldn't be too hard.
164 */
Owen Taylor3473f882001-02-23 17:55:21 +0000165struct _xmlParserCtxt {
166 struct _xmlSAXHandler *sax; /* The SAX handler */
167 void *userData; /* For SAX interface only, used by DOM build */
168 xmlDocPtr myDoc; /* the document being built */
169 int wellFormed; /* is the document well formed */
170 int replaceEntities; /* shall we replace entities ? */
171 const xmlChar *version; /* the XML version string */
172 const xmlChar *encoding; /* the declared encoding, if any */
173 int standalone; /* standalone document */
174 int html; /* an HTML(1)/Docbook(2) document */
175
176 /* Input stream stack */
177 xmlParserInputPtr input; /* Current input stream */
178 int inputNr; /* Number of current input streams */
179 int inputMax; /* Max number of input streams */
180 xmlParserInputPtr *inputTab; /* stack of inputs */
181
182 /* Node analysis stack only used for DOM building */
183 xmlNodePtr node; /* Current parsed Node */
184 int nodeNr; /* Depth of the parsing stack */
185 int nodeMax; /* Max depth of the parsing stack */
186 xmlNodePtr *nodeTab; /* array of nodes */
187
188 int record_info; /* Whether node info should be kept */
189 xmlParserNodeInfoSeq node_seq; /* info about each node parsed */
190
191 int errNo; /* error code */
192
193 int hasExternalSubset; /* reference and external subset */
194 int hasPErefs; /* the internal subset has PE refs */
195 int external; /* are we parsing an external entity */
196
197 int valid; /* is the document valid */
198 int validate; /* shall we try to validate ? */
199 xmlValidCtxt vctxt; /* The validity context */
200
201 xmlParserInputState instate; /* current type of input */
202 int token; /* next char look-ahead */
203
204 char *directory; /* the data directory */
205
206 /* Node name stack */
Daniel Veillard2fdbd322003-08-18 12:15:38 +0000207 const xmlChar *name; /* Current parsed Node */
Owen Taylor3473f882001-02-23 17:55:21 +0000208 int nameNr; /* Depth of the parsing stack */
209 int nameMax; /* Max depth of the parsing stack */
Daniel Veillard2fdbd322003-08-18 12:15:38 +0000210 const xmlChar * *nameTab; /* array of nodes */
Owen Taylor3473f882001-02-23 17:55:21 +0000211
212 long nbChars; /* number of xmlChar processed */
213 long checkIndex; /* used by progressive parsing lookup */
214 int keepBlanks; /* ugly but ... */
215 int disableSAX; /* SAX callbacks are disabled */
216 int inSubset; /* Parsing is in int 1/ext 2 subset */
Daniel Veillard2fdbd322003-08-18 12:15:38 +0000217 const xmlChar * intSubName; /* name of subset */
Owen Taylor3473f882001-02-23 17:55:21 +0000218 xmlChar * extSubURI; /* URI of external subset */
219 xmlChar * extSubSystem; /* SYSTEM ID of external subset */
220
221 /* xml:space values */
222 int * space; /* Should the parser preserve spaces */
223 int spaceNr; /* Depth of the parsing stack */
224 int spaceMax; /* Max depth of the parsing stack */
225 int * spaceTab; /* array of space infos */
226
227 int depth; /* to prevent entity substitution loops */
228 xmlParserInputPtr entity; /* used to check entities boundaries */
229 int charset; /* encoding of the in-memory content
230 actually an xmlCharEncoding */
231 int nodelen; /* Those two fields are there to */
232 int nodemem; /* Speed up large node parsing */
233 int pedantic; /* signal pedantic warnings */
234 void *_private; /* For user data, libxml won't touch it */
235
236 int loadsubset; /* should the external subset be loaded */
Daniel Veillardd9bad132001-07-23 19:39:43 +0000237 int linenumbers; /* set line number in element content */
Daniel Veillard5d90b6c2001-08-22 14:29:45 +0000238 void *catalogs; /* document's own catalog */
Daniel Veillarddad3f682002-11-17 16:47:27 +0000239 int recovery; /* run in recovery mode */
Daniel Veillarda880b122003-04-21 21:36:41 +0000240 int progressive; /* is this a progressive parsing */
Daniel Veillard2fdbd322003-08-18 12:15:38 +0000241 xmlDictPtr dict; /* dictionnary for the parser */
Daniel Veillard40412cd2003-09-03 13:28:32 +0000242 const xmlChar * *atts; /* array for the attributes callbacks */
Daniel Veillard6155d8a2003-08-19 15:01:28 +0000243 int maxatts; /* the size of the array */
Daniel Veillard40412cd2003-09-03 13:28:32 +0000244 int docdict; /* use strings from dict to build tree */
Daniel Veillard0fb18932003-09-07 09:14:37 +0000245
246 /*
247 * pre-interned strings
248 */
249 const xmlChar *str_xml;
250 const xmlChar *str_xmlns;
Daniel Veillard07cb8222003-09-10 10:51:05 +0000251 const xmlChar *str_xml_ns;
Daniel Veillard0fb18932003-09-07 09:14:37 +0000252
253 /*
Daniel Veillard07cb8222003-09-10 10:51:05 +0000254 * Everything below is used only by the new SAX mode
Daniel Veillard0fb18932003-09-07 09:14:37 +0000255 */
256 int sax2; /* operating in the new SAX mode */
257 int nsNr; /* the number of inherited namespaces */
258 int nsMax; /* the size of the arrays */
259 const xmlChar * *nsTab; /* the array of prefix/namespace name */
Daniel Veillard07cb8222003-09-10 10:51:05 +0000260 int *attallocs; /* which attribute were allocated */
261 void * *pushTab; /* array of data for push */
262 xmlHashTablePtr attsDefault; /* defaulted attributes if any */
263 xmlHashTablePtr attsSpecial; /* non-CDATA attributes if any */
Daniel Veillard3b7840c2003-09-11 23:42:01 +0000264 int nsWellFormed; /* is the document XML Nanespace okay */
Daniel Veillard9475a352003-09-26 12:47:50 +0000265 int options; /* Extra options */
Daniel Veillard8a44e592003-09-15 14:50:06 +0000266
267 /*
268 * Those fields are needed only for treaming parsing so far
269 */
Daniel Veillard9475a352003-09-26 12:47:50 +0000270 int dictNames; /* Use dictionary names for the tree */
271 int freeElemsNr; /* number of freed element nodes */
272 xmlNodePtr freeElems; /* List of freed element nodes */
273 int freeAttrsNr; /* number of freed attributes nodes */
274 xmlAttrPtr freeAttrs; /* List of freed attributes nodes */
Owen Taylor3473f882001-02-23 17:55:21 +0000275};
276
277/**
Daniel Veillardf69bb4b2001-05-19 13:24:56 +0000278 * xmlSAXLocator:
279 *
Daniel Veillard61f26172002-03-12 18:46:39 +0000280 * A SAX Locator.
Owen Taylor3473f882001-02-23 17:55:21 +0000281 */
Owen Taylor3473f882001-02-23 17:55:21 +0000282struct _xmlSAXLocator {
283 const xmlChar *(*getPublicId)(void *ctx);
284 const xmlChar *(*getSystemId)(void *ctx);
285 int (*getLineNumber)(void *ctx);
286 int (*getColumnNumber)(void *ctx);
287};
288
289/**
Daniel Veillardf69bb4b2001-05-19 13:24:56 +0000290 * xmlSAXHandler:
291 *
Daniel Veillard61f26172002-03-12 18:46:39 +0000292 * A SAX handler is bunch of callbacks called by the parser when processing
Owen Taylor3473f882001-02-23 17:55:21 +0000293 * of the input generate data or structure informations.
294 */
295
Daniel Veillard9d06d302002-01-22 18:15:52 +0000296/**
297 * resolveEntitySAXFunc:
298 * @ctx: the user data (XML parser context)
299 * @publicId: The public ID of the entity
300 * @systemId: The system ID of the entity
301 *
302 * Callback:
303 * The entity loader, to control the loading of external entities,
304 * the application can either:
305 * - override this resolveEntity() callback in the SAX block
306 * - or better use the xmlSetExternalEntityLoader() function to
307 * set up it's own entity resolution routine
308 *
309 * Returns the xmlParserInputPtr if inlined or NULL for DOM behaviour.
310 */
Owen Taylor3473f882001-02-23 17:55:21 +0000311typedef xmlParserInputPtr (*resolveEntitySAXFunc) (void *ctx,
Daniel Veillard9d06d302002-01-22 18:15:52 +0000312 const xmlChar *publicId,
313 const xmlChar *systemId);
314/**
315 * internalSubsetSAXFunc:
316 * @ctx: the user data (XML parser context)
317 * @name: the root element name
318 * @ExternalID: the external ID
319 * @SystemID: the SYSTEM ID (e.g. filename or URL)
320 *
321 * Callback on internal subset declaration.
322 */
323typedef void (*internalSubsetSAXFunc) (void *ctx,
324 const xmlChar *name,
325 const xmlChar *ExternalID,
326 const xmlChar *SystemID);
327/**
328 * externalSubsetSAXFunc:
329 * @ctx: the user data (XML parser context)
330 * @name: the root element name
331 * @ExternalID: the external ID
332 * @SystemID: the SYSTEM ID (e.g. filename or URL)
333 *
334 * Callback on external subset declaration.
335 */
336typedef void (*externalSubsetSAXFunc) (void *ctx,
337 const xmlChar *name,
338 const xmlChar *ExternalID,
339 const xmlChar *SystemID);
340/**
341 * getEntitySAXFunc:
342 * @ctx: the user data (XML parser context)
343 * @name: The entity name
344 *
Daniel Veillard61f26172002-03-12 18:46:39 +0000345 * Get an entity by name.
Daniel Veillard9d06d302002-01-22 18:15:52 +0000346 *
347 * Returns the xmlEntityPtr if found.
348 */
Owen Taylor3473f882001-02-23 17:55:21 +0000349typedef xmlEntityPtr (*getEntitySAXFunc) (void *ctx,
Daniel Veillard9d06d302002-01-22 18:15:52 +0000350 const xmlChar *name);
351/**
352 * getParameterEntitySAXFunc:
353 * @ctx: the user data (XML parser context)
354 * @name: The entity name
355 *
Daniel Veillard61f26172002-03-12 18:46:39 +0000356 * Get a parameter entity by name.
Daniel Veillard9d06d302002-01-22 18:15:52 +0000357 *
358 * Returns the xmlEntityPtr if found.
359 */
Owen Taylor3473f882001-02-23 17:55:21 +0000360typedef xmlEntityPtr (*getParameterEntitySAXFunc) (void *ctx,
Daniel Veillard9d06d302002-01-22 18:15:52 +0000361 const xmlChar *name);
362/**
363 * entityDeclSAXFunc:
364 * @ctx: the user data (XML parser context)
365 * @name: the entity name
366 * @type: the entity type
367 * @publicId: The public ID of the entity
368 * @systemId: The system ID of the entity
369 * @content: the entity value (without processing).
370 *
Daniel Veillard61f26172002-03-12 18:46:39 +0000371 * An entity definition has been parsed.
Daniel Veillard9d06d302002-01-22 18:15:52 +0000372 */
Owen Taylor3473f882001-02-23 17:55:21 +0000373typedef void (*entityDeclSAXFunc) (void *ctx,
Daniel Veillard9d06d302002-01-22 18:15:52 +0000374 const xmlChar *name,
375 int type,
376 const xmlChar *publicId,
377 const xmlChar *systemId,
378 xmlChar *content);
379/**
380 * notationDeclSAXFunc:
381 * @ctx: the user data (XML parser context)
382 * @name: The name of the notation
383 * @publicId: The public ID of the entity
384 * @systemId: The system ID of the entity
385 *
386 * What to do when a notation declaration has been parsed.
387 */
388typedef void (*notationDeclSAXFunc)(void *ctx,
389 const xmlChar *name,
390 const xmlChar *publicId,
391 const xmlChar *systemId);
392/**
393 * attributeDeclSAXFunc:
394 * @ctx: the user data (XML parser context)
395 * @elem: the name of the element
396 * @fullname: the attribute name
397 * @type: the attribute type
398 * @def: the type of default value
399 * @defaultValue: the attribute default value
400 * @tree: the tree of enumerated value set
401 *
Daniel Veillard61f26172002-03-12 18:46:39 +0000402 * An attribute definition has been parsed.
Daniel Veillard9d06d302002-01-22 18:15:52 +0000403 */
404typedef void (*attributeDeclSAXFunc)(void *ctx,
405 const xmlChar *elem,
406 const xmlChar *fullname,
407 int type,
408 int def,
409 const xmlChar *defaultValue,
410 xmlEnumerationPtr tree);
411/**
412 * elementDeclSAXFunc:
413 * @ctx: the user data (XML parser context)
414 * @name: the element name
415 * @type: the element type
416 * @content: the element value tree
417 *
Daniel Veillard61f26172002-03-12 18:46:39 +0000418 * An element definition has been parsed.
Daniel Veillard9d06d302002-01-22 18:15:52 +0000419 */
420typedef void (*elementDeclSAXFunc)(void *ctx,
421 const xmlChar *name,
422 int type,
423 xmlElementContentPtr content);
424/**
425 * unparsedEntityDeclSAXFunc:
426 * @ctx: the user data (XML parser context)
427 * @name: The name of the entity
428 * @publicId: The public ID of the entity
429 * @systemId: The system ID of the entity
430 * @notationName: the name of the notation
431 *
Daniel Veillard61f26172002-03-12 18:46:39 +0000432 * What to do when an unparsed entity declaration is parsed.
Daniel Veillard9d06d302002-01-22 18:15:52 +0000433 */
Owen Taylor3473f882001-02-23 17:55:21 +0000434typedef void (*unparsedEntityDeclSAXFunc)(void *ctx,
Daniel Veillard9d06d302002-01-22 18:15:52 +0000435 const xmlChar *name,
436 const xmlChar *publicId,
437 const xmlChar *systemId,
438 const xmlChar *notationName);
439/**
440 * setDocumentLocatorSAXFunc:
441 * @ctx: the user data (XML parser context)
442 * @loc: A SAX Locator
443 *
Daniel Veillard61f26172002-03-12 18:46:39 +0000444 * Receive the document locator at startup, actually xmlDefaultSAXLocator.
Daniel Veillard9d06d302002-01-22 18:15:52 +0000445 * Everything is available on the context, so this is useless in our case.
446 */
Owen Taylor3473f882001-02-23 17:55:21 +0000447typedef void (*setDocumentLocatorSAXFunc) (void *ctx,
Daniel Veillard9d06d302002-01-22 18:15:52 +0000448 xmlSAXLocatorPtr loc);
449/**
450 * startDocumentSAXFunc:
451 * @ctx: the user data (XML parser context)
452 *
Daniel Veillard61f26172002-03-12 18:46:39 +0000453 * Called when the document start being processed.
Daniel Veillard9d06d302002-01-22 18:15:52 +0000454 */
Owen Taylor3473f882001-02-23 17:55:21 +0000455typedef void (*startDocumentSAXFunc) (void *ctx);
Daniel Veillard9d06d302002-01-22 18:15:52 +0000456/**
457 * endDocumentSAXFunc:
458 * @ctx: the user data (XML parser context)
459 *
Daniel Veillard61f26172002-03-12 18:46:39 +0000460 * Called when the document end has been detected.
Daniel Veillard9d06d302002-01-22 18:15:52 +0000461 */
Owen Taylor3473f882001-02-23 17:55:21 +0000462typedef void (*endDocumentSAXFunc) (void *ctx);
Daniel Veillard9d06d302002-01-22 18:15:52 +0000463/**
464 * startElementSAXFunc:
465 * @ctx: the user data (XML parser context)
466 * @name: The element name, including namespace prefix
467 * @atts: An array of name/value attributes pairs, NULL terminated
468 *
Daniel Veillard61f26172002-03-12 18:46:39 +0000469 * Called when an opening tag has been processed.
Daniel Veillard9d06d302002-01-22 18:15:52 +0000470 */
471typedef void (*startElementSAXFunc) (void *ctx,
472 const xmlChar *name,
473 const xmlChar **atts);
474/**
475 * endElementSAXFunc:
476 * @ctx: the user data (XML parser context)
477 * @name: The element name
478 *
Daniel Veillard61f26172002-03-12 18:46:39 +0000479 * Called when the end of an element has been detected.
Daniel Veillard9d06d302002-01-22 18:15:52 +0000480 */
481typedef void (*endElementSAXFunc) (void *ctx,
482 const xmlChar *name);
483/**
484 * attributeSAXFunc:
485 * @ctx: the user data (XML parser context)
486 * @name: The attribute name, including namespace prefix
487 * @value: The attribute value
488 *
489 * Handle an attribute that has been read by the parser.
490 * The default handling is to convert the attribute into an
491 * DOM subtree and past it in a new xmlAttr element added to
492 * the element.
493 */
494typedef void (*attributeSAXFunc) (void *ctx,
495 const xmlChar *name,
496 const xmlChar *value);
497/**
498 * referenceSAXFunc:
499 * @ctx: the user data (XML parser context)
500 * @name: The entity name
501 *
Daniel Veillard61f26172002-03-12 18:46:39 +0000502 * Called when an entity reference is detected.
Daniel Veillard9d06d302002-01-22 18:15:52 +0000503 */
504typedef void (*referenceSAXFunc) (void *ctx,
505 const xmlChar *name);
506/**
507 * charactersSAXFunc:
508 * @ctx: the user data (XML parser context)
509 * @ch: a xmlChar string
510 * @len: the number of xmlChar
511 *
Daniel Veillard61f26172002-03-12 18:46:39 +0000512 * Receiving some chars from the parser.
Daniel Veillard9d06d302002-01-22 18:15:52 +0000513 */
514typedef void (*charactersSAXFunc) (void *ctx,
515 const xmlChar *ch,
516 int len);
517/**
518 * ignorableWhitespaceSAXFunc:
519 * @ctx: the user data (XML parser context)
520 * @ch: a xmlChar string
521 * @len: the number of xmlChar
522 *
Daniel Veillard61f26172002-03-12 18:46:39 +0000523 * Receiving some ignorable whitespaces from the parser.
524 * UNUSED: by default the DOM building will use characters.
Daniel Veillard9d06d302002-01-22 18:15:52 +0000525 */
Owen Taylor3473f882001-02-23 17:55:21 +0000526typedef void (*ignorableWhitespaceSAXFunc) (void *ctx,
Daniel Veillard9d06d302002-01-22 18:15:52 +0000527 const xmlChar *ch,
528 int len);
529/**
530 * processingInstructionSAXFunc:
531 * @ctx: the user data (XML parser context)
532 * @target: the target name
533 * @data: the PI data's
534 *
535 * A processing instruction has been parsed.
536 */
Owen Taylor3473f882001-02-23 17:55:21 +0000537typedef void (*processingInstructionSAXFunc) (void *ctx,
Daniel Veillard9d06d302002-01-22 18:15:52 +0000538 const xmlChar *target,
539 const xmlChar *data);
540/**
541 * commentSAXFunc:
542 * @ctx: the user data (XML parser context)
543 * @value: the comment content
544 *
545 * A comment has been parsed.
546 */
547typedef void (*commentSAXFunc) (void *ctx,
548 const xmlChar *value);
549/**
550 * cdataBlockSAXFunc:
551 * @ctx: the user data (XML parser context)
552 * @value: The pcdata content
553 * @len: the block length
554 *
Daniel Veillard61f26172002-03-12 18:46:39 +0000555 * Called when a pcdata block has been parsed.
Daniel Veillard9d06d302002-01-22 18:15:52 +0000556 */
557typedef void (*cdataBlockSAXFunc) (
558 void *ctx,
559 const xmlChar *value,
560 int len);
561/**
562 * warningSAXFunc:
563 * @ctx: an XML parser context
564 * @msg: the message to display/transmit
565 * @...: extra parameters for the message display
566 *
Daniel Veillard61f26172002-03-12 18:46:39 +0000567 * Display and format a warning messages, callback.
Daniel Veillard9d06d302002-01-22 18:15:52 +0000568 */
569typedef void (*warningSAXFunc) (void *ctx,
570 const char *msg, ...);
571/**
572 * errorSAXFunc:
573 * @ctx: an XML parser context
574 * @msg: the message to display/transmit
575 * @...: extra parameters for the message display
576 *
Daniel Veillard61f26172002-03-12 18:46:39 +0000577 * Display and format an error messages, callback.
Daniel Veillard9d06d302002-01-22 18:15:52 +0000578 */
579typedef void (*errorSAXFunc) (void *ctx,
580 const char *msg, ...);
581/**
582 * fatalErrorSAXFunc:
583 * @ctx: an XML parser context
584 * @msg: the message to display/transmit
585 * @...: extra parameters for the message display
586 *
Daniel Veillard61f26172002-03-12 18:46:39 +0000587 * Display and format fatal error messages, callback.
Daniel Veillard0821b152002-11-12 20:57:47 +0000588 * Note: so far fatalError() SAX callbacks are not used, error()
589 * get all the callbacks for errors.
Daniel Veillard9d06d302002-01-22 18:15:52 +0000590 */
591typedef void (*fatalErrorSAXFunc) (void *ctx,
592 const char *msg, ...);
593/**
594 * isStandaloneSAXFunc:
595 * @ctx: the user data (XML parser context)
596 *
Daniel Veillard61f26172002-03-12 18:46:39 +0000597 * Is this document tagged standalone?
Daniel Veillard9d06d302002-01-22 18:15:52 +0000598 *
599 * Returns 1 if true
600 */
Owen Taylor3473f882001-02-23 17:55:21 +0000601typedef int (*isStandaloneSAXFunc) (void *ctx);
Daniel Veillard9d06d302002-01-22 18:15:52 +0000602/**
603 * hasInternalSubsetSAXFunc:
604 * @ctx: the user data (XML parser context)
605 *
Daniel Veillard61f26172002-03-12 18:46:39 +0000606 * Does this document has an internal subset.
Daniel Veillard9d06d302002-01-22 18:15:52 +0000607 *
608 * Returns 1 if true
609 */
Owen Taylor3473f882001-02-23 17:55:21 +0000610typedef int (*hasInternalSubsetSAXFunc) (void *ctx);
Daniel Veillard1af9a412003-08-20 22:54:39 +0000611
Daniel Veillard9d06d302002-01-22 18:15:52 +0000612/**
613 * hasExternalSubsetSAXFunc:
614 * @ctx: the user data (XML parser context)
615 *
Daniel Veillard61f26172002-03-12 18:46:39 +0000616 * Does this document has an external subset?
Daniel Veillard9d06d302002-01-22 18:15:52 +0000617 *
618 * Returns 1 if true
619 */
Owen Taylor3473f882001-02-23 17:55:21 +0000620typedef int (*hasExternalSubsetSAXFunc) (void *ctx);
621
Daniel Veillard1af9a412003-08-20 22:54:39 +0000622/************************************************************************
623 * *
624 * The SAX version 2 API extensions *
625 * *
626 ************************************************************************/
627/**
628 * XML_SAX2_MAGIC:
629 *
630 * Special constant found in SAX2 blocks initialized fields
631 */
632#define XML_SAX2_MAGIC 0xDEEDBEAF
633
634/**
635 * startElementNsSAX2Func:
636 * @ctx: the user data (XML parser context)
637 * @localname: the local name of the element
638 * @prefix: the element namespace prefix if available
639 * @URI: the element namespace name if available
640 * @nb_namespaces: number of namespace definitions on that node
641 * @namespaces: pointer to the array of prefix/URI pairs namespace definitions
642 * @nb_attributes: the number of attributes on that node
Daniel Veillard07cb8222003-09-10 10:51:05 +0000643 * @nb_defaulted: the number of defaulted attributes. The defaulted
644 * ones are at the end of the array
645 * @attributes: pointer to the array of (localname/prefix/URI/value/end)
646 * attribute values.
Daniel Veillard1af9a412003-08-20 22:54:39 +0000647 *
648 * SAX2 callback when an element start has been detected by the parser.
649 * It provides the namespace informations for the element, as well as
650 * the new namespace declarations on the element.
Daniel Veillard1af9a412003-08-20 22:54:39 +0000651 */
652
653typedef void (*startElementNsSAX2Func) (void *ctx,
654 const xmlChar *localname,
655 const xmlChar *prefix,
656 const xmlChar *URI,
657 int nb_namespaces,
658 const xmlChar **namespaces,
Daniel Veillard07cb8222003-09-10 10:51:05 +0000659 int nb_attributes,
660 int nb_defaulted,
661 const xmlChar **attributes);
Daniel Veillard1af9a412003-08-20 22:54:39 +0000662
663/**
664 * endElementNsSAX2Func:
665 * @ctx: the user data (XML parser context)
666 * @localname: the local name of the element
667 * @prefix: the element namespace prefix if available
668 * @URI: the element namespace name if available
669 *
670 * SAX2 callback when an element end has been detected by the parser.
671 * It provides the namespace informations for the element.
672 */
673
674typedef void (*endElementNsSAX2Func) (void *ctx,
675 const xmlChar *localname,
676 const xmlChar *prefix,
677 const xmlChar *URI);
678
Daniel Veillard1af9a412003-08-20 22:54:39 +0000679
Owen Taylor3473f882001-02-23 17:55:21 +0000680struct _xmlSAXHandler {
681 internalSubsetSAXFunc internalSubset;
682 isStandaloneSAXFunc isStandalone;
683 hasInternalSubsetSAXFunc hasInternalSubset;
684 hasExternalSubsetSAXFunc hasExternalSubset;
685 resolveEntitySAXFunc resolveEntity;
686 getEntitySAXFunc getEntity;
687 entityDeclSAXFunc entityDecl;
688 notationDeclSAXFunc notationDecl;
689 attributeDeclSAXFunc attributeDecl;
690 elementDeclSAXFunc elementDecl;
691 unparsedEntityDeclSAXFunc unparsedEntityDecl;
692 setDocumentLocatorSAXFunc setDocumentLocator;
693 startDocumentSAXFunc startDocument;
694 endDocumentSAXFunc endDocument;
695 startElementSAXFunc startElement;
696 endElementSAXFunc endElement;
697 referenceSAXFunc reference;
698 charactersSAXFunc characters;
699 ignorableWhitespaceSAXFunc ignorableWhitespace;
700 processingInstructionSAXFunc processingInstruction;
701 commentSAXFunc comment;
702 warningSAXFunc warning;
703 errorSAXFunc error;
Daniel Veillard0821b152002-11-12 20:57:47 +0000704 fatalErrorSAXFunc fatalError; /* unused error() get all the errors */
Owen Taylor3473f882001-02-23 17:55:21 +0000705 getParameterEntitySAXFunc getParameterEntity;
706 cdataBlockSAXFunc cdataBlock;
707 externalSubsetSAXFunc externalSubset;
Daniel Veillard07cb8222003-09-10 10:51:05 +0000708 unsigned int initialized;
Daniel Veillard1af9a412003-08-20 22:54:39 +0000709 /* The following fields are extensions available only on version 2 */
710 void *_private;
711 startElementNsSAX2Func startElementNs;
712 endElementNsSAX2Func endElementNs;
Owen Taylor3473f882001-02-23 17:55:21 +0000713};
714
Daniel Veillard9ee35f32003-09-28 00:19:54 +0000715/*
716 * SAX Version 1
717 */
718typedef struct _xmlSAXHandlerV1 xmlSAXHandlerV1;
719typedef xmlSAXHandlerV1 *xmlSAXHandlerV1Ptr;
720struct _xmlSAXHandlerV1 {
721 internalSubsetSAXFunc internalSubset;
722 isStandaloneSAXFunc isStandalone;
723 hasInternalSubsetSAXFunc hasInternalSubset;
724 hasExternalSubsetSAXFunc hasExternalSubset;
725 resolveEntitySAXFunc resolveEntity;
726 getEntitySAXFunc getEntity;
727 entityDeclSAXFunc entityDecl;
728 notationDeclSAXFunc notationDecl;
729 attributeDeclSAXFunc attributeDecl;
730 elementDeclSAXFunc elementDecl;
731 unparsedEntityDeclSAXFunc unparsedEntityDecl;
732 setDocumentLocatorSAXFunc setDocumentLocator;
733 startDocumentSAXFunc startDocument;
734 endDocumentSAXFunc endDocument;
735 startElementSAXFunc startElement;
736 endElementSAXFunc endElement;
737 referenceSAXFunc reference;
738 charactersSAXFunc characters;
739 ignorableWhitespaceSAXFunc ignorableWhitespace;
740 processingInstructionSAXFunc processingInstruction;
741 commentSAXFunc comment;
742 warningSAXFunc warning;
743 errorSAXFunc error;
744 fatalErrorSAXFunc fatalError; /* unused error() get all the errors */
745 getParameterEntitySAXFunc getParameterEntity;
746 cdataBlockSAXFunc cdataBlock;
747 externalSubsetSAXFunc externalSubset;
748 unsigned int initialized;
749};
750
751
Owen Taylor3473f882001-02-23 17:55:21 +0000752/**
Daniel Veillardf69bb4b2001-05-19 13:24:56 +0000753 * xmlExternalEntityLoader:
754 * @URL: The System ID of the resource requested
755 * @ID: The Public ID of the resource requested
Daniel Veillardcbaf3992001-12-31 16:16:02 +0000756 * @context: the XML parser context
Daniel Veillardf69bb4b2001-05-19 13:24:56 +0000757 *
Daniel Veillard61f26172002-03-12 18:46:39 +0000758 * External entity loaders types.
Daniel Veillardcbaf3992001-12-31 16:16:02 +0000759 *
Daniel Veillard61f26172002-03-12 18:46:39 +0000760 * Returns the entity input parser.
Owen Taylor3473f882001-02-23 17:55:21 +0000761 */
Daniel Veillard9d06d302002-01-22 18:15:52 +0000762typedef xmlParserInputPtr (*xmlExternalEntityLoader) (const char *URL,
763 const char *ID,
764 xmlParserCtxtPtr context);
Owen Taylor3473f882001-02-23 17:55:21 +0000765
Daniel Veillard6c4ffaf2002-02-11 08:54:05 +0000766#ifdef __cplusplus
767}
768#endif
Igor Zlatkovic76874e42003-08-25 09:05:12 +0000769
Daniel Veillard6c4ffaf2002-02-11 08:54:05 +0000770#include <libxml/encoding.h>
771#include <libxml/xmlIO.h>
772#include <libxml/globals.h>
Igor Zlatkovic76874e42003-08-25 09:05:12 +0000773
Daniel Veillard6c4ffaf2002-02-11 08:54:05 +0000774#ifdef __cplusplus
775extern "C" {
776#endif
777
Owen Taylor3473f882001-02-23 17:55:21 +0000778
Daniel Veillardf69bb4b2001-05-19 13:24:56 +0000779/*
Owen Taylor3473f882001-02-23 17:55:21 +0000780 * Init/Cleanup
781 */
Igor Zlatkovic76874e42003-08-25 09:05:12 +0000782XMLPUBFUN void XMLCALL
783 xmlInitParser (void);
784XMLPUBFUN void XMLCALL
785 xmlCleanupParser (void);
Owen Taylor3473f882001-02-23 17:55:21 +0000786
Daniel Veillardf69bb4b2001-05-19 13:24:56 +0000787/*
Owen Taylor3473f882001-02-23 17:55:21 +0000788 * Input functions
789 */
Igor Zlatkovic76874e42003-08-25 09:05:12 +0000790XMLPUBFUN int XMLCALL
791 xmlParserInputRead (xmlParserInputPtr in,
Owen Taylor3473f882001-02-23 17:55:21 +0000792 int len);
Igor Zlatkovic76874e42003-08-25 09:05:12 +0000793XMLPUBFUN int XMLCALL
794 xmlParserInputGrow (xmlParserInputPtr in,
Owen Taylor3473f882001-02-23 17:55:21 +0000795 int len);
796
Daniel Veillardf69bb4b2001-05-19 13:24:56 +0000797/*
Owen Taylor3473f882001-02-23 17:55:21 +0000798 * xmlChar handling
799 */
Igor Zlatkovic76874e42003-08-25 09:05:12 +0000800XMLPUBFUN xmlChar * XMLCALL
801 xmlStrdup (const xmlChar *cur);
802XMLPUBFUN xmlChar * XMLCALL
803 xmlStrndup (const xmlChar *cur,
Owen Taylor3473f882001-02-23 17:55:21 +0000804 int len);
Igor Zlatkovic76874e42003-08-25 09:05:12 +0000805XMLPUBFUN xmlChar * XMLCALL
806 xmlCharStrndup (const char *cur,
Daniel Veillard56a4cb82001-03-24 17:00:36 +0000807 int len);
Igor Zlatkovic76874e42003-08-25 09:05:12 +0000808XMLPUBFUN xmlChar * XMLCALL
809 xmlCharStrdup (const char *cur);
810XMLPUBFUN xmlChar * XMLCALL
811 xmlStrsub (const xmlChar *str,
Owen Taylor3473f882001-02-23 17:55:21 +0000812 int start,
813 int len);
Igor Zlatkovic76874e42003-08-25 09:05:12 +0000814XMLPUBFUN const xmlChar * XMLCALL
815 xmlStrchr (const xmlChar *str,
Owen Taylor3473f882001-02-23 17:55:21 +0000816 xmlChar val);
Igor Zlatkovic76874e42003-08-25 09:05:12 +0000817XMLPUBFUN const xmlChar * XMLCALL
818 xmlStrstr (const xmlChar *str,
Daniel Veillard77044732001-06-29 21:31:07 +0000819 const xmlChar *val);
Igor Zlatkovic76874e42003-08-25 09:05:12 +0000820XMLPUBFUN const xmlChar * XMLCALL
821 xmlStrcasestr (const xmlChar *str,
Owen Taylor3473f882001-02-23 17:55:21 +0000822 xmlChar *val);
Igor Zlatkovic76874e42003-08-25 09:05:12 +0000823XMLPUBFUN int XMLCALL
824 xmlStrcmp (const xmlChar *str1,
Owen Taylor3473f882001-02-23 17:55:21 +0000825 const xmlChar *str2);
Igor Zlatkovic76874e42003-08-25 09:05:12 +0000826XMLPUBFUN int XMLCALL
827 xmlStrncmp (const xmlChar *str1,
Owen Taylor3473f882001-02-23 17:55:21 +0000828 const xmlChar *str2,
829 int len);
Igor Zlatkovic76874e42003-08-25 09:05:12 +0000830XMLPUBFUN int XMLCALL
831 xmlStrcasecmp (const xmlChar *str1,
Owen Taylor3473f882001-02-23 17:55:21 +0000832 const xmlChar *str2);
Igor Zlatkovic76874e42003-08-25 09:05:12 +0000833XMLPUBFUN int XMLCALL
834 xmlStrncasecmp (const xmlChar *str1,
Owen Taylor3473f882001-02-23 17:55:21 +0000835 const xmlChar *str2,
836 int len);
Igor Zlatkovic76874e42003-08-25 09:05:12 +0000837XMLPUBFUN int XMLCALL
838 xmlStrEqual (const xmlChar *str1,
Owen Taylor3473f882001-02-23 17:55:21 +0000839 const xmlChar *str2);
Daniel Veillard07cb8222003-09-10 10:51:05 +0000840XMLPUBFUN int XMLCALL
841 xmlStrQEqual (const xmlChar *pref,
842 const xmlChar *name,
843 const xmlChar *str);
Igor Zlatkovic76874e42003-08-25 09:05:12 +0000844XMLPUBFUN int XMLCALL
845 xmlStrlen (const xmlChar *str);
846XMLPUBFUN xmlChar * XMLCALL
847 xmlStrcat (xmlChar *cur,
Owen Taylor3473f882001-02-23 17:55:21 +0000848 const xmlChar *add);
Igor Zlatkovic76874e42003-08-25 09:05:12 +0000849XMLPUBFUN xmlChar * XMLCALL
850 xmlStrncat (xmlChar *cur,
Owen Taylor3473f882001-02-23 17:55:21 +0000851 const xmlChar *add,
852 int len);
853
Aleksey Sanine7acf432003-10-02 20:05:27 +0000854XMLPUBFUN int XMLCALL
855 xmlStrPrintf (xmlChar *buf,
856 int len,
857 const xmlChar *msg,
858 ...);
859
Daniel Veillardf69bb4b2001-05-19 13:24:56 +0000860/*
Owen Taylor3473f882001-02-23 17:55:21 +0000861 * Basic parsing Interfaces
862 */
Igor Zlatkovic76874e42003-08-25 09:05:12 +0000863XMLPUBFUN xmlDocPtr XMLCALL
864 xmlParseDoc (xmlChar *cur);
865XMLPUBFUN xmlDocPtr XMLCALL
866 xmlParseMemory (const char *buffer,
Owen Taylor3473f882001-02-23 17:55:21 +0000867 int size);
Igor Zlatkovic76874e42003-08-25 09:05:12 +0000868XMLPUBFUN xmlDocPtr XMLCALL
869 xmlParseFile (const char *filename);
870XMLPUBFUN int XMLCALL
871 xmlSubstituteEntitiesDefault(int val);
872XMLPUBFUN int XMLCALL
873 xmlKeepBlanksDefault (int val);
874XMLPUBFUN void XMLCALL
875 xmlStopParser (xmlParserCtxtPtr ctxt);
876XMLPUBFUN int XMLCALL
877 xmlPedanticParserDefault(int val);
878XMLPUBFUN int XMLCALL
879 xmlLineNumbersDefault (int val);
Owen Taylor3473f882001-02-23 17:55:21 +0000880
Daniel Veillardf69bb4b2001-05-19 13:24:56 +0000881/*
Owen Taylor3473f882001-02-23 17:55:21 +0000882 * Recovery mode
883 */
Igor Zlatkovic76874e42003-08-25 09:05:12 +0000884XMLPUBFUN xmlDocPtr XMLCALL
885 xmlRecoverDoc (xmlChar *cur);
886XMLPUBFUN xmlDocPtr XMLCALL
887 xmlRecoverMemory (const char *buffer,
Owen Taylor3473f882001-02-23 17:55:21 +0000888 int size);
Igor Zlatkovic76874e42003-08-25 09:05:12 +0000889XMLPUBFUN xmlDocPtr XMLCALL
890 xmlRecoverFile (const char *filename);
Owen Taylor3473f882001-02-23 17:55:21 +0000891
Daniel Veillardf69bb4b2001-05-19 13:24:56 +0000892/*
Owen Taylor3473f882001-02-23 17:55:21 +0000893 * Less common routines and SAX interfaces
894 */
Igor Zlatkovic76874e42003-08-25 09:05:12 +0000895XMLPUBFUN int XMLCALL
896 xmlParseDocument (xmlParserCtxtPtr ctxt);
897XMLPUBFUN int XMLCALL
898 xmlParseExtParsedEnt (xmlParserCtxtPtr ctxt);
899XMLPUBFUN xmlDocPtr XMLCALL
900 xmlSAXParseDoc (xmlSAXHandlerPtr sax,
Owen Taylor3473f882001-02-23 17:55:21 +0000901 xmlChar *cur,
902 int recovery);
Igor Zlatkovic76874e42003-08-25 09:05:12 +0000903XMLPUBFUN int XMLCALL
904 xmlSAXUserParseFile (xmlSAXHandlerPtr sax,
Owen Taylor3473f882001-02-23 17:55:21 +0000905 void *user_data,
906 const char *filename);
Igor Zlatkovic76874e42003-08-25 09:05:12 +0000907XMLPUBFUN int XMLCALL
908 xmlSAXUserParseMemory (xmlSAXHandlerPtr sax,
Owen Taylor3473f882001-02-23 17:55:21 +0000909 void *user_data,
Daniel Veillardfd7ddca2001-05-16 10:57:35 +0000910 const char *buffer,
Owen Taylor3473f882001-02-23 17:55:21 +0000911 int size);
Igor Zlatkovic76874e42003-08-25 09:05:12 +0000912XMLPUBFUN xmlDocPtr XMLCALL
913 xmlSAXParseMemory (xmlSAXHandlerPtr sax,
Daniel Veillard50822cb2001-07-26 20:05:51 +0000914 const char *buffer,
Owen Taylor3473f882001-02-23 17:55:21 +0000915 int size,
916 int recovery);
Igor Zlatkovic76874e42003-08-25 09:05:12 +0000917XMLPUBFUN xmlDocPtr XMLCALL
918 xmlSAXParseMemoryWithData (xmlSAXHandlerPtr sax,
Daniel Veillard8606bbb2002-11-12 12:36:52 +0000919 const char *buffer,
920 int size,
921 int recovery,
922 void *data);
Igor Zlatkovic76874e42003-08-25 09:05:12 +0000923XMLPUBFUN xmlDocPtr XMLCALL
924 xmlSAXParseFile (xmlSAXHandlerPtr sax,
Owen Taylor3473f882001-02-23 17:55:21 +0000925 const char *filename,
926 int recovery);
Igor Zlatkovic76874e42003-08-25 09:05:12 +0000927XMLPUBFUN xmlDocPtr XMLCALL
928 xmlSAXParseFileWithData (xmlSAXHandlerPtr sax,
Daniel Veillarda293c322001-10-02 13:54:14 +0000929 const char *filename,
930 int recovery,
931 void *data);
Igor Zlatkovic76874e42003-08-25 09:05:12 +0000932XMLPUBFUN xmlDocPtr XMLCALL
933 xmlSAXParseEntity (xmlSAXHandlerPtr sax,
Owen Taylor3473f882001-02-23 17:55:21 +0000934 const char *filename);
Igor Zlatkovic76874e42003-08-25 09:05:12 +0000935XMLPUBFUN xmlDocPtr XMLCALL
936 xmlParseEntity (const char *filename);
937XMLPUBFUN xmlDtdPtr XMLCALL
938 xmlParseDTD (const xmlChar *ExternalID,
Owen Taylor3473f882001-02-23 17:55:21 +0000939 const xmlChar *SystemID);
Igor Zlatkovic76874e42003-08-25 09:05:12 +0000940XMLPUBFUN xmlDtdPtr XMLCALL
941 xmlSAXParseDTD (xmlSAXHandlerPtr sax,
Owen Taylor3473f882001-02-23 17:55:21 +0000942 const xmlChar *ExternalID,
943 const xmlChar *SystemID);
Igor Zlatkovic76874e42003-08-25 09:05:12 +0000944XMLPUBFUN xmlDtdPtr XMLCALL
945 xmlIOParseDTD (xmlSAXHandlerPtr sax,
Owen Taylor3473f882001-02-23 17:55:21 +0000946 xmlParserInputBufferPtr input,
947 xmlCharEncoding enc);
Igor Zlatkovic76874e42003-08-25 09:05:12 +0000948XMLPUBFUN int XMLCALL
949 xmlParseBalancedChunkMemory(xmlDocPtr doc,
Owen Taylor3473f882001-02-23 17:55:21 +0000950 xmlSAXHandlerPtr sax,
951 void *user_data,
952 int depth,
953 const xmlChar *string,
Daniel Veillardcda96922001-08-21 10:56:31 +0000954 xmlNodePtr *lst);
Igor Zlatkovic76874e42003-08-25 09:05:12 +0000955XMLPUBFUN int XMLCALL
956 xmlParseBalancedChunkMemoryRecover(xmlDocPtr doc,
Daniel Veillard58e44c92002-08-02 22:19:49 +0000957 xmlSAXHandlerPtr sax,
958 void *user_data,
959 int depth,
960 const xmlChar *string,
961 xmlNodePtr *lst,
962 int recover);
Igor Zlatkovic76874e42003-08-25 09:05:12 +0000963XMLPUBFUN int XMLCALL
964 xmlParseExternalEntity (xmlDocPtr doc,
Owen Taylor3473f882001-02-23 17:55:21 +0000965 xmlSAXHandlerPtr sax,
966 void *user_data,
967 int depth,
968 const xmlChar *URL,
969 const xmlChar *ID,
Daniel Veillardcda96922001-08-21 10:56:31 +0000970 xmlNodePtr *lst);
Igor Zlatkovic76874e42003-08-25 09:05:12 +0000971XMLPUBFUN int XMLCALL
972 xmlParseCtxtExternalEntity(xmlParserCtxtPtr ctx,
Owen Taylor3473f882001-02-23 17:55:21 +0000973 const xmlChar *URL,
974 const xmlChar *ID,
Daniel Veillardcda96922001-08-21 10:56:31 +0000975 xmlNodePtr *lst);
Owen Taylor3473f882001-02-23 17:55:21 +0000976
Daniel Veillardf69bb4b2001-05-19 13:24:56 +0000977/*
Owen Taylor3473f882001-02-23 17:55:21 +0000978 * Parser contexts handling.
979 */
Igor Zlatkovic76874e42003-08-25 09:05:12 +0000980XMLPUBFUN int XMLCALL
981 xmlInitParserCtxt (xmlParserCtxtPtr ctxt);
982XMLPUBFUN void XMLCALL
983 xmlClearParserCtxt (xmlParserCtxtPtr ctxt);
984XMLPUBFUN void XMLCALL
985 xmlFreeParserCtxt (xmlParserCtxtPtr ctxt);
986XMLPUBFUN void XMLCALL
987 xmlSetupParserForBuffer (xmlParserCtxtPtr ctxt,
Owen Taylor3473f882001-02-23 17:55:21 +0000988 const xmlChar* buffer,
Daniel Veillard963d2ae2002-01-20 22:08:18 +0000989 const char *filename);
Igor Zlatkovic76874e42003-08-25 09:05:12 +0000990XMLPUBFUN xmlParserCtxtPtr XMLCALL
Daniel Veillard16fa96c2003-09-23 21:50:54 +0000991 xmlCreateDocParserCtxt (const xmlChar *cur);
Owen Taylor3473f882001-02-23 17:55:21 +0000992
Daniel Veillardf69bb4b2001-05-19 13:24:56 +0000993/*
Owen Taylor3473f882001-02-23 17:55:21 +0000994 * Reading/setting optional parsing features.
995 */
996
Igor Zlatkovic76874e42003-08-25 09:05:12 +0000997XMLPUBFUN int XMLCALL
998 xmlGetFeaturesList (int *len,
Owen Taylor3473f882001-02-23 17:55:21 +0000999 const char **result);
Igor Zlatkovic76874e42003-08-25 09:05:12 +00001000XMLPUBFUN int XMLCALL
1001 xmlGetFeature (xmlParserCtxtPtr ctxt,
Owen Taylor3473f882001-02-23 17:55:21 +00001002 const char *name,
1003 void *result);
Igor Zlatkovic76874e42003-08-25 09:05:12 +00001004XMLPUBFUN int XMLCALL
1005 xmlSetFeature (xmlParserCtxtPtr ctxt,
Owen Taylor3473f882001-02-23 17:55:21 +00001006 const char *name,
1007 void *value);
1008
Daniel Veillard73b013f2003-09-30 12:36:01 +00001009#ifdef LIBXML_PUSH_ENABLED
Daniel Veillardf69bb4b2001-05-19 13:24:56 +00001010/*
Daniel Veillard61f26172002-03-12 18:46:39 +00001011 * Interfaces for the Push mode.
Owen Taylor3473f882001-02-23 17:55:21 +00001012 */
Igor Zlatkovic76874e42003-08-25 09:05:12 +00001013XMLPUBFUN xmlParserCtxtPtr XMLCALL
1014 xmlCreatePushParserCtxt(xmlSAXHandlerPtr sax,
Owen Taylor3473f882001-02-23 17:55:21 +00001015 void *user_data,
1016 const char *chunk,
1017 int size,
1018 const char *filename);
Igor Zlatkovic76874e42003-08-25 09:05:12 +00001019XMLPUBFUN int XMLCALL
1020 xmlParseChunk (xmlParserCtxtPtr ctxt,
Owen Taylor3473f882001-02-23 17:55:21 +00001021 const char *chunk,
1022 int size,
1023 int terminate);
Daniel Veillard73b013f2003-09-30 12:36:01 +00001024#endif /* LIBXML_PUSH_ENABLED */
Owen Taylor3473f882001-02-23 17:55:21 +00001025
Daniel Veillardf69bb4b2001-05-19 13:24:56 +00001026/*
Daniel Veillard61f26172002-03-12 18:46:39 +00001027 * Special I/O mode.
Owen Taylor3473f882001-02-23 17:55:21 +00001028 */
1029
Igor Zlatkovic76874e42003-08-25 09:05:12 +00001030XMLPUBFUN xmlParserCtxtPtr XMLCALL
1031 xmlCreateIOParserCtxt (xmlSAXHandlerPtr sax,
Owen Taylor3473f882001-02-23 17:55:21 +00001032 void *user_data,
1033 xmlInputReadCallback ioread,
1034 xmlInputCloseCallback ioclose,
1035 void *ioctx,
1036 xmlCharEncoding enc);
1037
Igor Zlatkovic76874e42003-08-25 09:05:12 +00001038XMLPUBFUN xmlParserInputPtr XMLCALL
1039 xmlNewIOInputStream (xmlParserCtxtPtr ctxt,
Owen Taylor3473f882001-02-23 17:55:21 +00001040 xmlParserInputBufferPtr input,
1041 xmlCharEncoding enc);
1042
Daniel Veillardf69bb4b2001-05-19 13:24:56 +00001043/*
Daniel Veillard61f26172002-03-12 18:46:39 +00001044 * Node infos.
Owen Taylor3473f882001-02-23 17:55:21 +00001045 */
Igor Zlatkovic76874e42003-08-25 09:05:12 +00001046XMLPUBFUN const xmlParserNodeInfo* XMLCALL
Daniel Veillard963d2ae2002-01-20 22:08:18 +00001047 xmlParserFindNodeInfo (const xmlParserCtxtPtr ctxt,
1048 const xmlNodePtr node);
Igor Zlatkovic76874e42003-08-25 09:05:12 +00001049XMLPUBFUN void XMLCALL
1050 xmlInitNodeInfoSeq (xmlParserNodeInfoSeqPtr seq);
1051XMLPUBFUN void XMLCALL
1052 xmlClearNodeInfoSeq (xmlParserNodeInfoSeqPtr seq);
1053XMLPUBFUN unsigned long XMLCALL
1054 xmlParserFindNodeInfoIndex(const xmlParserNodeInfoSeqPtr seq,
Daniel Veillard963d2ae2002-01-20 22:08:18 +00001055 const xmlNodePtr node);
Igor Zlatkovic76874e42003-08-25 09:05:12 +00001056XMLPUBFUN void XMLCALL
1057 xmlParserAddNodeInfo (xmlParserCtxtPtr ctxt,
Daniel Veillard963d2ae2002-01-20 22:08:18 +00001058 const xmlParserNodeInfoPtr info);
Owen Taylor3473f882001-02-23 17:55:21 +00001059
1060/*
Daniel Veillard61f26172002-03-12 18:46:39 +00001061 * External entities handling actually implemented in xmlIO.
Owen Taylor3473f882001-02-23 17:55:21 +00001062 */
1063
Igor Zlatkovic76874e42003-08-25 09:05:12 +00001064XMLPUBFUN void XMLCALL
1065 xmlSetExternalEntityLoader(xmlExternalEntityLoader f);
1066XMLPUBFUN xmlExternalEntityLoader XMLCALL
Owen Taylor3473f882001-02-23 17:55:21 +00001067 xmlGetExternalEntityLoader(void);
Igor Zlatkovic76874e42003-08-25 09:05:12 +00001068XMLPUBFUN xmlParserInputPtr XMLCALL
Owen Taylor3473f882001-02-23 17:55:21 +00001069 xmlLoadExternalEntity (const char *URL,
1070 const char *ID,
Daniel Veillard9d06d302002-01-22 18:15:52 +00001071 xmlParserCtxtPtr ctxt);
Daniel Veillard16fa96c2003-09-23 21:50:54 +00001072/*
1073 * New set of simpler/more flexible APIs
1074 */
1075/**
1076 * xmlParserOption:
1077 *
1078 * This is the set of XML parser options that can be passed down
1079 * to the xmlReadDoc() and similar calls.
1080 */
1081typedef enum {
1082 XML_PARSE_RECOVER = 1<<0, /* recover on errors */
1083 XML_PARSE_NOENT = 1<<1, /* substitute entities */
1084 XML_PARSE_DTDLOAD = 1<<2, /* load the external subset */
1085 XML_PARSE_DTDATTR = 1<<3, /* default DTD attributes */
1086 XML_PARSE_DTDVALID = 1<<4, /* validate with the DTD */
1087 XML_PARSE_NOERROR = 1<<5, /* suppress error reports */
1088 XML_PARSE_NOWARNING = 1<<6, /* suppress warning reports */
1089 XML_PARSE_PEDANTIC = 1<<7, /* pedantic error reporting */
1090 XML_PARSE_NOBLANKS = 1<<8, /* remove blank nodes */
1091 XML_PARSE_SAX1 = 1<<9, /* use the SAX1 interface internally */
1092 XML_PARSE_XINCLUDE = 1<<10,/* Implement XInclude substitition */
Daniel Veillarde96a2a42003-09-24 21:23:56 +00001093 XML_PARSE_NONET = 1<<11,/* Forbid network access */
Daniel Veillard9475a352003-09-26 12:47:50 +00001094 XML_PARSE_NODICT = 1<<12,/* Do not reuse the context dictionnary */
1095 XML_PARSE_NSCLEAN = 1<<13,/* remove redundant namespaces declarations */
1096 XML_PARSE_NOCDATA = 1<<14 /* merge CDATA as text nodes */
Daniel Veillard16fa96c2003-09-23 21:50:54 +00001097} xmlParserOption;
1098
1099XMLPUBFUN void XMLCALL
1100 xmlCtxtReset (xmlParserCtxtPtr ctxt);
1101XMLPUBFUN int XMLCALL
1102 xmlCtxtUseOptions (xmlParserCtxtPtr ctxt,
1103 int options);
1104XMLPUBFUN xmlDocPtr XMLCALL
1105 xmlReadDoc (const xmlChar *cur,
Daniel Veillard60942de2003-09-25 21:05:58 +00001106 const char *URL,
Daniel Veillard16fa96c2003-09-23 21:50:54 +00001107 const char *encoding,
1108 int options);
1109XMLPUBFUN xmlDocPtr XMLCALL
Daniel Veillard60942de2003-09-25 21:05:58 +00001110 xmlReadFile (const char *URL,
Daniel Veillard16fa96c2003-09-23 21:50:54 +00001111 const char *encoding,
1112 int options);
1113XMLPUBFUN xmlDocPtr XMLCALL
1114 xmlReadMemory (const char *buffer,
1115 int size,
Daniel Veillard60942de2003-09-25 21:05:58 +00001116 const char *URL,
Daniel Veillard16fa96c2003-09-23 21:50:54 +00001117 const char *encoding,
1118 int options);
1119XMLPUBFUN xmlDocPtr XMLCALL
1120 xmlReadFd (int fd,
Daniel Veillard60942de2003-09-25 21:05:58 +00001121 const char *URL,
Daniel Veillard16fa96c2003-09-23 21:50:54 +00001122 const char *encoding,
1123 int options);
1124XMLPUBFUN xmlDocPtr XMLCALL
1125 xmlReadIO (xmlInputReadCallback ioread,
1126 xmlInputCloseCallback ioclose,
1127 void *ioctx,
Daniel Veillard60942de2003-09-25 21:05:58 +00001128 const char *URL,
Daniel Veillard16fa96c2003-09-23 21:50:54 +00001129 const char *encoding,
1130 int options);
1131XMLPUBFUN xmlDocPtr XMLCALL
1132 xmlCtxtReadDoc (xmlParserCtxtPtr ctxt,
1133 const xmlChar *cur,
Daniel Veillard60942de2003-09-25 21:05:58 +00001134 const char *URL,
Daniel Veillard16fa96c2003-09-23 21:50:54 +00001135 const char *encoding,
1136 int options);
1137XMLPUBFUN xmlDocPtr XMLCALL
1138 xmlCtxtReadFile (xmlParserCtxtPtr ctxt,
1139 const char *filename,
1140 const char *encoding,
1141 int options);
1142XMLPUBFUN xmlDocPtr XMLCALL
1143 xmlCtxtReadMemory (xmlParserCtxtPtr ctxt,
1144 const char *buffer,
1145 int size,
Daniel Veillard60942de2003-09-25 21:05:58 +00001146 const char *URL,
Daniel Veillard16fa96c2003-09-23 21:50:54 +00001147 const char *encoding,
1148 int options);
1149XMLPUBFUN xmlDocPtr XMLCALL
1150 xmlCtxtReadFd (xmlParserCtxtPtr ctxt,
1151 int fd,
Daniel Veillard60942de2003-09-25 21:05:58 +00001152 const char *URL,
Daniel Veillard16fa96c2003-09-23 21:50:54 +00001153 const char *encoding,
1154 int options);
1155XMLPUBFUN xmlDocPtr XMLCALL
1156 xmlCtxtReadIO (xmlParserCtxtPtr ctxt,
1157 xmlInputReadCallback ioread,
1158 xmlInputCloseCallback ioclose,
1159 void *ioctx,
Daniel Veillard60942de2003-09-25 21:05:58 +00001160 const char *URL,
Daniel Veillard16fa96c2003-09-23 21:50:54 +00001161 const char *encoding,
1162 int options);
Owen Taylor3473f882001-02-23 17:55:21 +00001163
1164#ifdef __cplusplus
1165}
1166#endif
Owen Taylor3473f882001-02-23 17:55:21 +00001167#endif /* __XML_PARSER_H__ */
1168