blob: 73dd71f9146ca03eee0ad78446f16e1b204d369e [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
715/**
Daniel Veillardf69bb4b2001-05-19 13:24:56 +0000716 * xmlExternalEntityLoader:
717 * @URL: The System ID of the resource requested
718 * @ID: The Public ID of the resource requested
Daniel Veillardcbaf3992001-12-31 16:16:02 +0000719 * @context: the XML parser context
Daniel Veillardf69bb4b2001-05-19 13:24:56 +0000720 *
Daniel Veillard61f26172002-03-12 18:46:39 +0000721 * External entity loaders types.
Daniel Veillardcbaf3992001-12-31 16:16:02 +0000722 *
Daniel Veillard61f26172002-03-12 18:46:39 +0000723 * Returns the entity input parser.
Owen Taylor3473f882001-02-23 17:55:21 +0000724 */
Daniel Veillard9d06d302002-01-22 18:15:52 +0000725typedef xmlParserInputPtr (*xmlExternalEntityLoader) (const char *URL,
726 const char *ID,
727 xmlParserCtxtPtr context);
Owen Taylor3473f882001-02-23 17:55:21 +0000728
Daniel Veillard6c4ffaf2002-02-11 08:54:05 +0000729#ifdef __cplusplus
730}
731#endif
Igor Zlatkovic76874e42003-08-25 09:05:12 +0000732
Daniel Veillard6c4ffaf2002-02-11 08:54:05 +0000733#include <libxml/encoding.h>
734#include <libxml/xmlIO.h>
735#include <libxml/globals.h>
Igor Zlatkovic76874e42003-08-25 09:05:12 +0000736
Daniel Veillard6c4ffaf2002-02-11 08:54:05 +0000737#ifdef __cplusplus
738extern "C" {
739#endif
740
Owen Taylor3473f882001-02-23 17:55:21 +0000741
Daniel Veillardf69bb4b2001-05-19 13:24:56 +0000742/*
Owen Taylor3473f882001-02-23 17:55:21 +0000743 * Init/Cleanup
744 */
Igor Zlatkovic76874e42003-08-25 09:05:12 +0000745XMLPUBFUN void XMLCALL
746 xmlInitParser (void);
747XMLPUBFUN void XMLCALL
748 xmlCleanupParser (void);
Owen Taylor3473f882001-02-23 17:55:21 +0000749
Daniel Veillardf69bb4b2001-05-19 13:24:56 +0000750/*
Owen Taylor3473f882001-02-23 17:55:21 +0000751 * Input functions
752 */
Igor Zlatkovic76874e42003-08-25 09:05:12 +0000753XMLPUBFUN int XMLCALL
754 xmlParserInputRead (xmlParserInputPtr in,
Owen Taylor3473f882001-02-23 17:55:21 +0000755 int len);
Igor Zlatkovic76874e42003-08-25 09:05:12 +0000756XMLPUBFUN int XMLCALL
757 xmlParserInputGrow (xmlParserInputPtr in,
Owen Taylor3473f882001-02-23 17:55:21 +0000758 int len);
759
Daniel Veillardf69bb4b2001-05-19 13:24:56 +0000760/*
Owen Taylor3473f882001-02-23 17:55:21 +0000761 * xmlChar handling
762 */
Igor Zlatkovic76874e42003-08-25 09:05:12 +0000763XMLPUBFUN xmlChar * XMLCALL
764 xmlStrdup (const xmlChar *cur);
765XMLPUBFUN xmlChar * XMLCALL
766 xmlStrndup (const xmlChar *cur,
Owen Taylor3473f882001-02-23 17:55:21 +0000767 int len);
Igor Zlatkovic76874e42003-08-25 09:05:12 +0000768XMLPUBFUN xmlChar * XMLCALL
769 xmlCharStrndup (const char *cur,
Daniel Veillard56a4cb82001-03-24 17:00:36 +0000770 int len);
Igor Zlatkovic76874e42003-08-25 09:05:12 +0000771XMLPUBFUN xmlChar * XMLCALL
772 xmlCharStrdup (const char *cur);
773XMLPUBFUN xmlChar * XMLCALL
774 xmlStrsub (const xmlChar *str,
Owen Taylor3473f882001-02-23 17:55:21 +0000775 int start,
776 int len);
Igor Zlatkovic76874e42003-08-25 09:05:12 +0000777XMLPUBFUN const xmlChar * XMLCALL
778 xmlStrchr (const xmlChar *str,
Owen Taylor3473f882001-02-23 17:55:21 +0000779 xmlChar val);
Igor Zlatkovic76874e42003-08-25 09:05:12 +0000780XMLPUBFUN const xmlChar * XMLCALL
781 xmlStrstr (const xmlChar *str,
Daniel Veillard77044732001-06-29 21:31:07 +0000782 const xmlChar *val);
Igor Zlatkovic76874e42003-08-25 09:05:12 +0000783XMLPUBFUN const xmlChar * XMLCALL
784 xmlStrcasestr (const xmlChar *str,
Owen Taylor3473f882001-02-23 17:55:21 +0000785 xmlChar *val);
Igor Zlatkovic76874e42003-08-25 09:05:12 +0000786XMLPUBFUN int XMLCALL
787 xmlStrcmp (const xmlChar *str1,
Owen Taylor3473f882001-02-23 17:55:21 +0000788 const xmlChar *str2);
Igor Zlatkovic76874e42003-08-25 09:05:12 +0000789XMLPUBFUN int XMLCALL
790 xmlStrncmp (const xmlChar *str1,
Owen Taylor3473f882001-02-23 17:55:21 +0000791 const xmlChar *str2,
792 int len);
Igor Zlatkovic76874e42003-08-25 09:05:12 +0000793XMLPUBFUN int XMLCALL
794 xmlStrcasecmp (const xmlChar *str1,
Owen Taylor3473f882001-02-23 17:55:21 +0000795 const xmlChar *str2);
Igor Zlatkovic76874e42003-08-25 09:05:12 +0000796XMLPUBFUN int XMLCALL
797 xmlStrncasecmp (const xmlChar *str1,
Owen Taylor3473f882001-02-23 17:55:21 +0000798 const xmlChar *str2,
799 int len);
Igor Zlatkovic76874e42003-08-25 09:05:12 +0000800XMLPUBFUN int XMLCALL
801 xmlStrEqual (const xmlChar *str1,
Owen Taylor3473f882001-02-23 17:55:21 +0000802 const xmlChar *str2);
Daniel Veillard07cb8222003-09-10 10:51:05 +0000803XMLPUBFUN int XMLCALL
804 xmlStrQEqual (const xmlChar *pref,
805 const xmlChar *name,
806 const xmlChar *str);
Igor Zlatkovic76874e42003-08-25 09:05:12 +0000807XMLPUBFUN int XMLCALL
808 xmlStrlen (const xmlChar *str);
809XMLPUBFUN xmlChar * XMLCALL
810 xmlStrcat (xmlChar *cur,
Owen Taylor3473f882001-02-23 17:55:21 +0000811 const xmlChar *add);
Igor Zlatkovic76874e42003-08-25 09:05:12 +0000812XMLPUBFUN xmlChar * XMLCALL
813 xmlStrncat (xmlChar *cur,
Owen Taylor3473f882001-02-23 17:55:21 +0000814 const xmlChar *add,
815 int len);
816
Daniel Veillardf69bb4b2001-05-19 13:24:56 +0000817/*
Owen Taylor3473f882001-02-23 17:55:21 +0000818 * Basic parsing Interfaces
819 */
Igor Zlatkovic76874e42003-08-25 09:05:12 +0000820XMLPUBFUN xmlDocPtr XMLCALL
821 xmlParseDoc (xmlChar *cur);
822XMLPUBFUN xmlDocPtr XMLCALL
823 xmlParseMemory (const char *buffer,
Owen Taylor3473f882001-02-23 17:55:21 +0000824 int size);
Igor Zlatkovic76874e42003-08-25 09:05:12 +0000825XMLPUBFUN xmlDocPtr XMLCALL
826 xmlParseFile (const char *filename);
827XMLPUBFUN int XMLCALL
828 xmlSubstituteEntitiesDefault(int val);
829XMLPUBFUN int XMLCALL
830 xmlKeepBlanksDefault (int val);
831XMLPUBFUN void XMLCALL
832 xmlStopParser (xmlParserCtxtPtr ctxt);
833XMLPUBFUN int XMLCALL
834 xmlPedanticParserDefault(int val);
835XMLPUBFUN int XMLCALL
836 xmlLineNumbersDefault (int val);
Owen Taylor3473f882001-02-23 17:55:21 +0000837
Daniel Veillardf69bb4b2001-05-19 13:24:56 +0000838/*
Owen Taylor3473f882001-02-23 17:55:21 +0000839 * Recovery mode
840 */
Igor Zlatkovic76874e42003-08-25 09:05:12 +0000841XMLPUBFUN xmlDocPtr XMLCALL
842 xmlRecoverDoc (xmlChar *cur);
843XMLPUBFUN xmlDocPtr XMLCALL
844 xmlRecoverMemory (const char *buffer,
Owen Taylor3473f882001-02-23 17:55:21 +0000845 int size);
Igor Zlatkovic76874e42003-08-25 09:05:12 +0000846XMLPUBFUN xmlDocPtr XMLCALL
847 xmlRecoverFile (const char *filename);
Owen Taylor3473f882001-02-23 17:55:21 +0000848
Daniel Veillardf69bb4b2001-05-19 13:24:56 +0000849/*
Owen Taylor3473f882001-02-23 17:55:21 +0000850 * Less common routines and SAX interfaces
851 */
Igor Zlatkovic76874e42003-08-25 09:05:12 +0000852XMLPUBFUN int XMLCALL
853 xmlParseDocument (xmlParserCtxtPtr ctxt);
854XMLPUBFUN int XMLCALL
855 xmlParseExtParsedEnt (xmlParserCtxtPtr ctxt);
856XMLPUBFUN xmlDocPtr XMLCALL
857 xmlSAXParseDoc (xmlSAXHandlerPtr sax,
Owen Taylor3473f882001-02-23 17:55:21 +0000858 xmlChar *cur,
859 int recovery);
Igor Zlatkovic76874e42003-08-25 09:05:12 +0000860XMLPUBFUN int XMLCALL
861 xmlSAXUserParseFile (xmlSAXHandlerPtr sax,
Owen Taylor3473f882001-02-23 17:55:21 +0000862 void *user_data,
863 const char *filename);
Igor Zlatkovic76874e42003-08-25 09:05:12 +0000864XMLPUBFUN int XMLCALL
865 xmlSAXUserParseMemory (xmlSAXHandlerPtr sax,
Owen Taylor3473f882001-02-23 17:55:21 +0000866 void *user_data,
Daniel Veillardfd7ddca2001-05-16 10:57:35 +0000867 const char *buffer,
Owen Taylor3473f882001-02-23 17:55:21 +0000868 int size);
Igor Zlatkovic76874e42003-08-25 09:05:12 +0000869XMLPUBFUN xmlDocPtr XMLCALL
870 xmlSAXParseMemory (xmlSAXHandlerPtr sax,
Daniel Veillard50822cb2001-07-26 20:05:51 +0000871 const char *buffer,
Owen Taylor3473f882001-02-23 17:55:21 +0000872 int size,
873 int recovery);
Igor Zlatkovic76874e42003-08-25 09:05:12 +0000874XMLPUBFUN xmlDocPtr XMLCALL
875 xmlSAXParseMemoryWithData (xmlSAXHandlerPtr sax,
Daniel Veillard8606bbb2002-11-12 12:36:52 +0000876 const char *buffer,
877 int size,
878 int recovery,
879 void *data);
Igor Zlatkovic76874e42003-08-25 09:05:12 +0000880XMLPUBFUN xmlDocPtr XMLCALL
881 xmlSAXParseFile (xmlSAXHandlerPtr sax,
Owen Taylor3473f882001-02-23 17:55:21 +0000882 const char *filename,
883 int recovery);
Igor Zlatkovic76874e42003-08-25 09:05:12 +0000884XMLPUBFUN xmlDocPtr XMLCALL
885 xmlSAXParseFileWithData (xmlSAXHandlerPtr sax,
Daniel Veillarda293c322001-10-02 13:54:14 +0000886 const char *filename,
887 int recovery,
888 void *data);
Igor Zlatkovic76874e42003-08-25 09:05:12 +0000889XMLPUBFUN xmlDocPtr XMLCALL
890 xmlSAXParseEntity (xmlSAXHandlerPtr sax,
Owen Taylor3473f882001-02-23 17:55:21 +0000891 const char *filename);
Igor Zlatkovic76874e42003-08-25 09:05:12 +0000892XMLPUBFUN xmlDocPtr XMLCALL
893 xmlParseEntity (const char *filename);
894XMLPUBFUN xmlDtdPtr XMLCALL
895 xmlParseDTD (const xmlChar *ExternalID,
Owen Taylor3473f882001-02-23 17:55:21 +0000896 const xmlChar *SystemID);
Igor Zlatkovic76874e42003-08-25 09:05:12 +0000897XMLPUBFUN xmlDtdPtr XMLCALL
898 xmlSAXParseDTD (xmlSAXHandlerPtr sax,
Owen Taylor3473f882001-02-23 17:55:21 +0000899 const xmlChar *ExternalID,
900 const xmlChar *SystemID);
Igor Zlatkovic76874e42003-08-25 09:05:12 +0000901XMLPUBFUN xmlDtdPtr XMLCALL
902 xmlIOParseDTD (xmlSAXHandlerPtr sax,
Owen Taylor3473f882001-02-23 17:55:21 +0000903 xmlParserInputBufferPtr input,
904 xmlCharEncoding enc);
Igor Zlatkovic76874e42003-08-25 09:05:12 +0000905XMLPUBFUN int XMLCALL
906 xmlParseBalancedChunkMemory(xmlDocPtr doc,
Owen Taylor3473f882001-02-23 17:55:21 +0000907 xmlSAXHandlerPtr sax,
908 void *user_data,
909 int depth,
910 const xmlChar *string,
Daniel Veillardcda96922001-08-21 10:56:31 +0000911 xmlNodePtr *lst);
Igor Zlatkovic76874e42003-08-25 09:05:12 +0000912XMLPUBFUN int XMLCALL
913 xmlParseBalancedChunkMemoryRecover(xmlDocPtr doc,
Daniel Veillard58e44c92002-08-02 22:19:49 +0000914 xmlSAXHandlerPtr sax,
915 void *user_data,
916 int depth,
917 const xmlChar *string,
918 xmlNodePtr *lst,
919 int recover);
Igor Zlatkovic76874e42003-08-25 09:05:12 +0000920XMLPUBFUN int XMLCALL
921 xmlParseExternalEntity (xmlDocPtr doc,
Owen Taylor3473f882001-02-23 17:55:21 +0000922 xmlSAXHandlerPtr sax,
923 void *user_data,
924 int depth,
925 const xmlChar *URL,
926 const xmlChar *ID,
Daniel Veillardcda96922001-08-21 10:56:31 +0000927 xmlNodePtr *lst);
Igor Zlatkovic76874e42003-08-25 09:05:12 +0000928XMLPUBFUN int XMLCALL
929 xmlParseCtxtExternalEntity(xmlParserCtxtPtr ctx,
Owen Taylor3473f882001-02-23 17:55:21 +0000930 const xmlChar *URL,
931 const xmlChar *ID,
Daniel Veillardcda96922001-08-21 10:56:31 +0000932 xmlNodePtr *lst);
Owen Taylor3473f882001-02-23 17:55:21 +0000933
Daniel Veillardf69bb4b2001-05-19 13:24:56 +0000934/*
Owen Taylor3473f882001-02-23 17:55:21 +0000935 * Parser contexts handling.
936 */
Igor Zlatkovic76874e42003-08-25 09:05:12 +0000937XMLPUBFUN int XMLCALL
938 xmlInitParserCtxt (xmlParserCtxtPtr ctxt);
939XMLPUBFUN void XMLCALL
940 xmlClearParserCtxt (xmlParserCtxtPtr ctxt);
941XMLPUBFUN void XMLCALL
942 xmlFreeParserCtxt (xmlParserCtxtPtr ctxt);
943XMLPUBFUN void XMLCALL
944 xmlSetupParserForBuffer (xmlParserCtxtPtr ctxt,
Owen Taylor3473f882001-02-23 17:55:21 +0000945 const xmlChar* buffer,
Daniel Veillard963d2ae2002-01-20 22:08:18 +0000946 const char *filename);
Igor Zlatkovic76874e42003-08-25 09:05:12 +0000947XMLPUBFUN xmlParserCtxtPtr XMLCALL
Daniel Veillard16fa96c2003-09-23 21:50:54 +0000948 xmlCreateDocParserCtxt (const xmlChar *cur);
Owen Taylor3473f882001-02-23 17:55:21 +0000949
Daniel Veillardf69bb4b2001-05-19 13:24:56 +0000950/*
Owen Taylor3473f882001-02-23 17:55:21 +0000951 * Reading/setting optional parsing features.
952 */
953
Igor Zlatkovic76874e42003-08-25 09:05:12 +0000954XMLPUBFUN int XMLCALL
955 xmlGetFeaturesList (int *len,
Owen Taylor3473f882001-02-23 17:55:21 +0000956 const char **result);
Igor Zlatkovic76874e42003-08-25 09:05:12 +0000957XMLPUBFUN int XMLCALL
958 xmlGetFeature (xmlParserCtxtPtr ctxt,
Owen Taylor3473f882001-02-23 17:55:21 +0000959 const char *name,
960 void *result);
Igor Zlatkovic76874e42003-08-25 09:05:12 +0000961XMLPUBFUN int XMLCALL
962 xmlSetFeature (xmlParserCtxtPtr ctxt,
Owen Taylor3473f882001-02-23 17:55:21 +0000963 const char *name,
964 void *value);
965
Daniel Veillardf69bb4b2001-05-19 13:24:56 +0000966/*
Daniel Veillard61f26172002-03-12 18:46:39 +0000967 * Interfaces for the Push mode.
Owen Taylor3473f882001-02-23 17:55:21 +0000968 */
Igor Zlatkovic76874e42003-08-25 09:05:12 +0000969XMLPUBFUN xmlParserCtxtPtr XMLCALL
970 xmlCreatePushParserCtxt(xmlSAXHandlerPtr sax,
Owen Taylor3473f882001-02-23 17:55:21 +0000971 void *user_data,
972 const char *chunk,
973 int size,
974 const char *filename);
Igor Zlatkovic76874e42003-08-25 09:05:12 +0000975XMLPUBFUN int XMLCALL
976 xmlParseChunk (xmlParserCtxtPtr ctxt,
Owen Taylor3473f882001-02-23 17:55:21 +0000977 const char *chunk,
978 int size,
979 int terminate);
980
Daniel Veillardf69bb4b2001-05-19 13:24:56 +0000981/*
Daniel Veillard61f26172002-03-12 18:46:39 +0000982 * Special I/O mode.
Owen Taylor3473f882001-02-23 17:55:21 +0000983 */
984
Igor Zlatkovic76874e42003-08-25 09:05:12 +0000985XMLPUBFUN xmlParserCtxtPtr XMLCALL
986 xmlCreateIOParserCtxt (xmlSAXHandlerPtr sax,
Owen Taylor3473f882001-02-23 17:55:21 +0000987 void *user_data,
988 xmlInputReadCallback ioread,
989 xmlInputCloseCallback ioclose,
990 void *ioctx,
991 xmlCharEncoding enc);
992
Igor Zlatkovic76874e42003-08-25 09:05:12 +0000993XMLPUBFUN xmlParserInputPtr XMLCALL
994 xmlNewIOInputStream (xmlParserCtxtPtr ctxt,
Owen Taylor3473f882001-02-23 17:55:21 +0000995 xmlParserInputBufferPtr input,
996 xmlCharEncoding enc);
997
Daniel Veillardf69bb4b2001-05-19 13:24:56 +0000998/*
Daniel Veillard61f26172002-03-12 18:46:39 +0000999 * Node infos.
Owen Taylor3473f882001-02-23 17:55:21 +00001000 */
Igor Zlatkovic76874e42003-08-25 09:05:12 +00001001XMLPUBFUN const xmlParserNodeInfo* XMLCALL
Daniel Veillard963d2ae2002-01-20 22:08:18 +00001002 xmlParserFindNodeInfo (const xmlParserCtxtPtr ctxt,
1003 const xmlNodePtr node);
Igor Zlatkovic76874e42003-08-25 09:05:12 +00001004XMLPUBFUN void XMLCALL
1005 xmlInitNodeInfoSeq (xmlParserNodeInfoSeqPtr seq);
1006XMLPUBFUN void XMLCALL
1007 xmlClearNodeInfoSeq (xmlParserNodeInfoSeqPtr seq);
1008XMLPUBFUN unsigned long XMLCALL
1009 xmlParserFindNodeInfoIndex(const xmlParserNodeInfoSeqPtr seq,
Daniel Veillard963d2ae2002-01-20 22:08:18 +00001010 const xmlNodePtr node);
Igor Zlatkovic76874e42003-08-25 09:05:12 +00001011XMLPUBFUN void XMLCALL
1012 xmlParserAddNodeInfo (xmlParserCtxtPtr ctxt,
Daniel Veillard963d2ae2002-01-20 22:08:18 +00001013 const xmlParserNodeInfoPtr info);
Owen Taylor3473f882001-02-23 17:55:21 +00001014
1015/*
Daniel Veillard61f26172002-03-12 18:46:39 +00001016 * External entities handling actually implemented in xmlIO.
Owen Taylor3473f882001-02-23 17:55:21 +00001017 */
1018
Igor Zlatkovic76874e42003-08-25 09:05:12 +00001019XMLPUBFUN void XMLCALL
1020 xmlSetExternalEntityLoader(xmlExternalEntityLoader f);
1021XMLPUBFUN xmlExternalEntityLoader XMLCALL
Owen Taylor3473f882001-02-23 17:55:21 +00001022 xmlGetExternalEntityLoader(void);
Igor Zlatkovic76874e42003-08-25 09:05:12 +00001023XMLPUBFUN xmlParserInputPtr XMLCALL
Owen Taylor3473f882001-02-23 17:55:21 +00001024 xmlLoadExternalEntity (const char *URL,
1025 const char *ID,
Daniel Veillard9d06d302002-01-22 18:15:52 +00001026 xmlParserCtxtPtr ctxt);
Daniel Veillard16fa96c2003-09-23 21:50:54 +00001027/*
1028 * New set of simpler/more flexible APIs
1029 */
1030/**
1031 * xmlParserOption:
1032 *
1033 * This is the set of XML parser options that can be passed down
1034 * to the xmlReadDoc() and similar calls.
1035 */
1036typedef enum {
1037 XML_PARSE_RECOVER = 1<<0, /* recover on errors */
1038 XML_PARSE_NOENT = 1<<1, /* substitute entities */
1039 XML_PARSE_DTDLOAD = 1<<2, /* load the external subset */
1040 XML_PARSE_DTDATTR = 1<<3, /* default DTD attributes */
1041 XML_PARSE_DTDVALID = 1<<4, /* validate with the DTD */
1042 XML_PARSE_NOERROR = 1<<5, /* suppress error reports */
1043 XML_PARSE_NOWARNING = 1<<6, /* suppress warning reports */
1044 XML_PARSE_PEDANTIC = 1<<7, /* pedantic error reporting */
1045 XML_PARSE_NOBLANKS = 1<<8, /* remove blank nodes */
1046 XML_PARSE_SAX1 = 1<<9, /* use the SAX1 interface internally */
1047 XML_PARSE_XINCLUDE = 1<<10,/* Implement XInclude substitition */
Daniel Veillarde96a2a42003-09-24 21:23:56 +00001048 XML_PARSE_NONET = 1<<11,/* Forbid network access */
Daniel Veillard9475a352003-09-26 12:47:50 +00001049 XML_PARSE_NODICT = 1<<12,/* Do not reuse the context dictionnary */
1050 XML_PARSE_NSCLEAN = 1<<13,/* remove redundant namespaces declarations */
1051 XML_PARSE_NOCDATA = 1<<14 /* merge CDATA as text nodes */
Daniel Veillard16fa96c2003-09-23 21:50:54 +00001052} xmlParserOption;
1053
1054XMLPUBFUN void XMLCALL
1055 xmlCtxtReset (xmlParserCtxtPtr ctxt);
1056XMLPUBFUN int XMLCALL
1057 xmlCtxtUseOptions (xmlParserCtxtPtr ctxt,
1058 int options);
1059XMLPUBFUN xmlDocPtr XMLCALL
1060 xmlReadDoc (const xmlChar *cur,
Daniel Veillard60942de2003-09-25 21:05:58 +00001061 const char *URL,
Daniel Veillard16fa96c2003-09-23 21:50:54 +00001062 const char *encoding,
1063 int options);
1064XMLPUBFUN xmlDocPtr XMLCALL
Daniel Veillard60942de2003-09-25 21:05:58 +00001065 xmlReadFile (const char *URL,
Daniel Veillard16fa96c2003-09-23 21:50:54 +00001066 const char *encoding,
1067 int options);
1068XMLPUBFUN xmlDocPtr XMLCALL
1069 xmlReadMemory (const char *buffer,
1070 int size,
Daniel Veillard60942de2003-09-25 21:05:58 +00001071 const char *URL,
Daniel Veillard16fa96c2003-09-23 21:50:54 +00001072 const char *encoding,
1073 int options);
1074XMLPUBFUN xmlDocPtr XMLCALL
1075 xmlReadFd (int fd,
Daniel Veillard60942de2003-09-25 21:05:58 +00001076 const char *URL,
Daniel Veillard16fa96c2003-09-23 21:50:54 +00001077 const char *encoding,
1078 int options);
1079XMLPUBFUN xmlDocPtr XMLCALL
1080 xmlReadIO (xmlInputReadCallback ioread,
1081 xmlInputCloseCallback ioclose,
1082 void *ioctx,
Daniel Veillard60942de2003-09-25 21:05:58 +00001083 const char *URL,
Daniel Veillard16fa96c2003-09-23 21:50:54 +00001084 const char *encoding,
1085 int options);
1086XMLPUBFUN xmlDocPtr XMLCALL
1087 xmlCtxtReadDoc (xmlParserCtxtPtr ctxt,
1088 const xmlChar *cur,
Daniel Veillard60942de2003-09-25 21:05:58 +00001089 const char *URL,
Daniel Veillard16fa96c2003-09-23 21:50:54 +00001090 const char *encoding,
1091 int options);
1092XMLPUBFUN xmlDocPtr XMLCALL
1093 xmlCtxtReadFile (xmlParserCtxtPtr ctxt,
1094 const char *filename,
1095 const char *encoding,
1096 int options);
1097XMLPUBFUN xmlDocPtr XMLCALL
1098 xmlCtxtReadMemory (xmlParserCtxtPtr ctxt,
1099 const char *buffer,
1100 int size,
Daniel Veillard60942de2003-09-25 21:05:58 +00001101 const char *URL,
Daniel Veillard16fa96c2003-09-23 21:50:54 +00001102 const char *encoding,
1103 int options);
1104XMLPUBFUN xmlDocPtr XMLCALL
1105 xmlCtxtReadFd (xmlParserCtxtPtr ctxt,
1106 int fd,
Daniel Veillard60942de2003-09-25 21:05:58 +00001107 const char *URL,
Daniel Veillard16fa96c2003-09-23 21:50:54 +00001108 const char *encoding,
1109 int options);
1110XMLPUBFUN xmlDocPtr XMLCALL
1111 xmlCtxtReadIO (xmlParserCtxtPtr ctxt,
1112 xmlInputReadCallback ioread,
1113 xmlInputCloseCallback ioclose,
1114 void *ioctx,
Daniel Veillard60942de2003-09-25 21:05:58 +00001115 const char *URL,
Daniel Veillard16fa96c2003-09-23 21:50:54 +00001116 const char *encoding,
1117 int options);
Owen Taylor3473f882001-02-23 17:55:21 +00001118
1119#ifdef __cplusplus
1120}
1121#endif
Owen Taylor3473f882001-02-23 17:55:21 +00001122#endif /* __XML_PARSER_H__ */
1123