blob: 965fbc47dfde0e7243e4c716469893a6704c3933 [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 Veillard8a44e592003-09-15 14:50:06 +0000265
266 /*
267 * Those fields are needed only for treaming parsing so far
268 */
269 int dictNames; /* Use dictionary names for the tree */
Daniel Veillard19895052003-09-17 13:59:32 +0000270 int freeElemsNr; /* number of freed element nodes */
Daniel Veillard8a44e592003-09-15 14:50:06 +0000271 xmlNodePtr freeElems; /* List of freed element nodes */
Daniel Veillard19895052003-09-17 13:59:32 +0000272 int freeAttrsNr; /* number of freed attributes nodes */
Daniel Veillard8a44e592003-09-15 14:50:06 +0000273 xmlAttrPtr freeAttrs; /* List of freed attributes nodes */
Owen Taylor3473f882001-02-23 17:55:21 +0000274};
275
276/**
Daniel Veillardf69bb4b2001-05-19 13:24:56 +0000277 * xmlSAXLocator:
278 *
Daniel Veillard61f26172002-03-12 18:46:39 +0000279 * A SAX Locator.
Owen Taylor3473f882001-02-23 17:55:21 +0000280 */
Owen Taylor3473f882001-02-23 17:55:21 +0000281struct _xmlSAXLocator {
282 const xmlChar *(*getPublicId)(void *ctx);
283 const xmlChar *(*getSystemId)(void *ctx);
284 int (*getLineNumber)(void *ctx);
285 int (*getColumnNumber)(void *ctx);
286};
287
288/**
Daniel Veillardf69bb4b2001-05-19 13:24:56 +0000289 * xmlSAXHandler:
290 *
Daniel Veillard61f26172002-03-12 18:46:39 +0000291 * A SAX handler is bunch of callbacks called by the parser when processing
Owen Taylor3473f882001-02-23 17:55:21 +0000292 * of the input generate data or structure informations.
293 */
294
Daniel Veillard9d06d302002-01-22 18:15:52 +0000295/**
296 * resolveEntitySAXFunc:
297 * @ctx: the user data (XML parser context)
298 * @publicId: The public ID of the entity
299 * @systemId: The system ID of the entity
300 *
301 * Callback:
302 * The entity loader, to control the loading of external entities,
303 * the application can either:
304 * - override this resolveEntity() callback in the SAX block
305 * - or better use the xmlSetExternalEntityLoader() function to
306 * set up it's own entity resolution routine
307 *
308 * Returns the xmlParserInputPtr if inlined or NULL for DOM behaviour.
309 */
Owen Taylor3473f882001-02-23 17:55:21 +0000310typedef xmlParserInputPtr (*resolveEntitySAXFunc) (void *ctx,
Daniel Veillard9d06d302002-01-22 18:15:52 +0000311 const xmlChar *publicId,
312 const xmlChar *systemId);
313/**
314 * internalSubsetSAXFunc:
315 * @ctx: the user data (XML parser context)
316 * @name: the root element name
317 * @ExternalID: the external ID
318 * @SystemID: the SYSTEM ID (e.g. filename or URL)
319 *
320 * Callback on internal subset declaration.
321 */
322typedef void (*internalSubsetSAXFunc) (void *ctx,
323 const xmlChar *name,
324 const xmlChar *ExternalID,
325 const xmlChar *SystemID);
326/**
327 * externalSubsetSAXFunc:
328 * @ctx: the user data (XML parser context)
329 * @name: the root element name
330 * @ExternalID: the external ID
331 * @SystemID: the SYSTEM ID (e.g. filename or URL)
332 *
333 * Callback on external subset declaration.
334 */
335typedef void (*externalSubsetSAXFunc) (void *ctx,
336 const xmlChar *name,
337 const xmlChar *ExternalID,
338 const xmlChar *SystemID);
339/**
340 * getEntitySAXFunc:
341 * @ctx: the user data (XML parser context)
342 * @name: The entity name
343 *
Daniel Veillard61f26172002-03-12 18:46:39 +0000344 * Get an entity by name.
Daniel Veillard9d06d302002-01-22 18:15:52 +0000345 *
346 * Returns the xmlEntityPtr if found.
347 */
Owen Taylor3473f882001-02-23 17:55:21 +0000348typedef xmlEntityPtr (*getEntitySAXFunc) (void *ctx,
Daniel Veillard9d06d302002-01-22 18:15:52 +0000349 const xmlChar *name);
350/**
351 * getParameterEntitySAXFunc:
352 * @ctx: the user data (XML parser context)
353 * @name: The entity name
354 *
Daniel Veillard61f26172002-03-12 18:46:39 +0000355 * Get a parameter entity by name.
Daniel Veillard9d06d302002-01-22 18:15:52 +0000356 *
357 * Returns the xmlEntityPtr if found.
358 */
Owen Taylor3473f882001-02-23 17:55:21 +0000359typedef xmlEntityPtr (*getParameterEntitySAXFunc) (void *ctx,
Daniel Veillard9d06d302002-01-22 18:15:52 +0000360 const xmlChar *name);
361/**
362 * entityDeclSAXFunc:
363 * @ctx: the user data (XML parser context)
364 * @name: the entity name
365 * @type: the entity type
366 * @publicId: The public ID of the entity
367 * @systemId: The system ID of the entity
368 * @content: the entity value (without processing).
369 *
Daniel Veillard61f26172002-03-12 18:46:39 +0000370 * An entity definition has been parsed.
Daniel Veillard9d06d302002-01-22 18:15:52 +0000371 */
Owen Taylor3473f882001-02-23 17:55:21 +0000372typedef void (*entityDeclSAXFunc) (void *ctx,
Daniel Veillard9d06d302002-01-22 18:15:52 +0000373 const xmlChar *name,
374 int type,
375 const xmlChar *publicId,
376 const xmlChar *systemId,
377 xmlChar *content);
378/**
379 * notationDeclSAXFunc:
380 * @ctx: the user data (XML parser context)
381 * @name: The name of the notation
382 * @publicId: The public ID of the entity
383 * @systemId: The system ID of the entity
384 *
385 * What to do when a notation declaration has been parsed.
386 */
387typedef void (*notationDeclSAXFunc)(void *ctx,
388 const xmlChar *name,
389 const xmlChar *publicId,
390 const xmlChar *systemId);
391/**
392 * attributeDeclSAXFunc:
393 * @ctx: the user data (XML parser context)
394 * @elem: the name of the element
395 * @fullname: the attribute name
396 * @type: the attribute type
397 * @def: the type of default value
398 * @defaultValue: the attribute default value
399 * @tree: the tree of enumerated value set
400 *
Daniel Veillard61f26172002-03-12 18:46:39 +0000401 * An attribute definition has been parsed.
Daniel Veillard9d06d302002-01-22 18:15:52 +0000402 */
403typedef void (*attributeDeclSAXFunc)(void *ctx,
404 const xmlChar *elem,
405 const xmlChar *fullname,
406 int type,
407 int def,
408 const xmlChar *defaultValue,
409 xmlEnumerationPtr tree);
410/**
411 * elementDeclSAXFunc:
412 * @ctx: the user data (XML parser context)
413 * @name: the element name
414 * @type: the element type
415 * @content: the element value tree
416 *
Daniel Veillard61f26172002-03-12 18:46:39 +0000417 * An element definition has been parsed.
Daniel Veillard9d06d302002-01-22 18:15:52 +0000418 */
419typedef void (*elementDeclSAXFunc)(void *ctx,
420 const xmlChar *name,
421 int type,
422 xmlElementContentPtr content);
423/**
424 * unparsedEntityDeclSAXFunc:
425 * @ctx: the user data (XML parser context)
426 * @name: The name of the entity
427 * @publicId: The public ID of the entity
428 * @systemId: The system ID of the entity
429 * @notationName: the name of the notation
430 *
Daniel Veillard61f26172002-03-12 18:46:39 +0000431 * What to do when an unparsed entity declaration is parsed.
Daniel Veillard9d06d302002-01-22 18:15:52 +0000432 */
Owen Taylor3473f882001-02-23 17:55:21 +0000433typedef void (*unparsedEntityDeclSAXFunc)(void *ctx,
Daniel Veillard9d06d302002-01-22 18:15:52 +0000434 const xmlChar *name,
435 const xmlChar *publicId,
436 const xmlChar *systemId,
437 const xmlChar *notationName);
438/**
439 * setDocumentLocatorSAXFunc:
440 * @ctx: the user data (XML parser context)
441 * @loc: A SAX Locator
442 *
Daniel Veillard61f26172002-03-12 18:46:39 +0000443 * Receive the document locator at startup, actually xmlDefaultSAXLocator.
Daniel Veillard9d06d302002-01-22 18:15:52 +0000444 * Everything is available on the context, so this is useless in our case.
445 */
Owen Taylor3473f882001-02-23 17:55:21 +0000446typedef void (*setDocumentLocatorSAXFunc) (void *ctx,
Daniel Veillard9d06d302002-01-22 18:15:52 +0000447 xmlSAXLocatorPtr loc);
448/**
449 * startDocumentSAXFunc:
450 * @ctx: the user data (XML parser context)
451 *
Daniel Veillard61f26172002-03-12 18:46:39 +0000452 * Called when the document start being processed.
Daniel Veillard9d06d302002-01-22 18:15:52 +0000453 */
Owen Taylor3473f882001-02-23 17:55:21 +0000454typedef void (*startDocumentSAXFunc) (void *ctx);
Daniel Veillard9d06d302002-01-22 18:15:52 +0000455/**
456 * endDocumentSAXFunc:
457 * @ctx: the user data (XML parser context)
458 *
Daniel Veillard61f26172002-03-12 18:46:39 +0000459 * Called when the document end has been detected.
Daniel Veillard9d06d302002-01-22 18:15:52 +0000460 */
Owen Taylor3473f882001-02-23 17:55:21 +0000461typedef void (*endDocumentSAXFunc) (void *ctx);
Daniel Veillard9d06d302002-01-22 18:15:52 +0000462/**
463 * startElementSAXFunc:
464 * @ctx: the user data (XML parser context)
465 * @name: The element name, including namespace prefix
466 * @atts: An array of name/value attributes pairs, NULL terminated
467 *
Daniel Veillard61f26172002-03-12 18:46:39 +0000468 * Called when an opening tag has been processed.
Daniel Veillard9d06d302002-01-22 18:15:52 +0000469 */
470typedef void (*startElementSAXFunc) (void *ctx,
471 const xmlChar *name,
472 const xmlChar **atts);
473/**
474 * endElementSAXFunc:
475 * @ctx: the user data (XML parser context)
476 * @name: The element name
477 *
Daniel Veillard61f26172002-03-12 18:46:39 +0000478 * Called when the end of an element has been detected.
Daniel Veillard9d06d302002-01-22 18:15:52 +0000479 */
480typedef void (*endElementSAXFunc) (void *ctx,
481 const xmlChar *name);
482/**
483 * attributeSAXFunc:
484 * @ctx: the user data (XML parser context)
485 * @name: The attribute name, including namespace prefix
486 * @value: The attribute value
487 *
488 * Handle an attribute that has been read by the parser.
489 * The default handling is to convert the attribute into an
490 * DOM subtree and past it in a new xmlAttr element added to
491 * the element.
492 */
493typedef void (*attributeSAXFunc) (void *ctx,
494 const xmlChar *name,
495 const xmlChar *value);
496/**
497 * referenceSAXFunc:
498 * @ctx: the user data (XML parser context)
499 * @name: The entity name
500 *
Daniel Veillard61f26172002-03-12 18:46:39 +0000501 * Called when an entity reference is detected.
Daniel Veillard9d06d302002-01-22 18:15:52 +0000502 */
503typedef void (*referenceSAXFunc) (void *ctx,
504 const xmlChar *name);
505/**
506 * charactersSAXFunc:
507 * @ctx: the user data (XML parser context)
508 * @ch: a xmlChar string
509 * @len: the number of xmlChar
510 *
Daniel Veillard61f26172002-03-12 18:46:39 +0000511 * Receiving some chars from the parser.
Daniel Veillard9d06d302002-01-22 18:15:52 +0000512 */
513typedef void (*charactersSAXFunc) (void *ctx,
514 const xmlChar *ch,
515 int len);
516/**
517 * ignorableWhitespaceSAXFunc:
518 * @ctx: the user data (XML parser context)
519 * @ch: a xmlChar string
520 * @len: the number of xmlChar
521 *
Daniel Veillard61f26172002-03-12 18:46:39 +0000522 * Receiving some ignorable whitespaces from the parser.
523 * UNUSED: by default the DOM building will use characters.
Daniel Veillard9d06d302002-01-22 18:15:52 +0000524 */
Owen Taylor3473f882001-02-23 17:55:21 +0000525typedef void (*ignorableWhitespaceSAXFunc) (void *ctx,
Daniel Veillard9d06d302002-01-22 18:15:52 +0000526 const xmlChar *ch,
527 int len);
528/**
529 * processingInstructionSAXFunc:
530 * @ctx: the user data (XML parser context)
531 * @target: the target name
532 * @data: the PI data's
533 *
534 * A processing instruction has been parsed.
535 */
Owen Taylor3473f882001-02-23 17:55:21 +0000536typedef void (*processingInstructionSAXFunc) (void *ctx,
Daniel Veillard9d06d302002-01-22 18:15:52 +0000537 const xmlChar *target,
538 const xmlChar *data);
539/**
540 * commentSAXFunc:
541 * @ctx: the user data (XML parser context)
542 * @value: the comment content
543 *
544 * A comment has been parsed.
545 */
546typedef void (*commentSAXFunc) (void *ctx,
547 const xmlChar *value);
548/**
549 * cdataBlockSAXFunc:
550 * @ctx: the user data (XML parser context)
551 * @value: The pcdata content
552 * @len: the block length
553 *
Daniel Veillard61f26172002-03-12 18:46:39 +0000554 * Called when a pcdata block has been parsed.
Daniel Veillard9d06d302002-01-22 18:15:52 +0000555 */
556typedef void (*cdataBlockSAXFunc) (
557 void *ctx,
558 const xmlChar *value,
559 int len);
560/**
561 * warningSAXFunc:
562 * @ctx: an XML parser context
563 * @msg: the message to display/transmit
564 * @...: extra parameters for the message display
565 *
Daniel Veillard61f26172002-03-12 18:46:39 +0000566 * Display and format a warning messages, callback.
Daniel Veillard9d06d302002-01-22 18:15:52 +0000567 */
568typedef void (*warningSAXFunc) (void *ctx,
569 const char *msg, ...);
570/**
571 * errorSAXFunc:
572 * @ctx: an XML parser context
573 * @msg: the message to display/transmit
574 * @...: extra parameters for the message display
575 *
Daniel Veillard61f26172002-03-12 18:46:39 +0000576 * Display and format an error messages, callback.
Daniel Veillard9d06d302002-01-22 18:15:52 +0000577 */
578typedef void (*errorSAXFunc) (void *ctx,
579 const char *msg, ...);
580/**
581 * fatalErrorSAXFunc:
582 * @ctx: an XML parser context
583 * @msg: the message to display/transmit
584 * @...: extra parameters for the message display
585 *
Daniel Veillard61f26172002-03-12 18:46:39 +0000586 * Display and format fatal error messages, callback.
Daniel Veillard0821b152002-11-12 20:57:47 +0000587 * Note: so far fatalError() SAX callbacks are not used, error()
588 * get all the callbacks for errors.
Daniel Veillard9d06d302002-01-22 18:15:52 +0000589 */
590typedef void (*fatalErrorSAXFunc) (void *ctx,
591 const char *msg, ...);
592/**
593 * isStandaloneSAXFunc:
594 * @ctx: the user data (XML parser context)
595 *
Daniel Veillard61f26172002-03-12 18:46:39 +0000596 * Is this document tagged standalone?
Daniel Veillard9d06d302002-01-22 18:15:52 +0000597 *
598 * Returns 1 if true
599 */
Owen Taylor3473f882001-02-23 17:55:21 +0000600typedef int (*isStandaloneSAXFunc) (void *ctx);
Daniel Veillard9d06d302002-01-22 18:15:52 +0000601/**
602 * hasInternalSubsetSAXFunc:
603 * @ctx: the user data (XML parser context)
604 *
Daniel Veillard61f26172002-03-12 18:46:39 +0000605 * Does this document has an internal subset.
Daniel Veillard9d06d302002-01-22 18:15:52 +0000606 *
607 * Returns 1 if true
608 */
Owen Taylor3473f882001-02-23 17:55:21 +0000609typedef int (*hasInternalSubsetSAXFunc) (void *ctx);
Daniel Veillard1af9a412003-08-20 22:54:39 +0000610
Daniel Veillard9d06d302002-01-22 18:15:52 +0000611/**
612 * hasExternalSubsetSAXFunc:
613 * @ctx: the user data (XML parser context)
614 *
Daniel Veillard61f26172002-03-12 18:46:39 +0000615 * Does this document has an external subset?
Daniel Veillard9d06d302002-01-22 18:15:52 +0000616 *
617 * Returns 1 if true
618 */
Owen Taylor3473f882001-02-23 17:55:21 +0000619typedef int (*hasExternalSubsetSAXFunc) (void *ctx);
620
Daniel Veillard1af9a412003-08-20 22:54:39 +0000621/************************************************************************
622 * *
623 * The SAX version 2 API extensions *
624 * *
625 ************************************************************************/
626/**
627 * XML_SAX2_MAGIC:
628 *
629 * Special constant found in SAX2 blocks initialized fields
630 */
631#define XML_SAX2_MAGIC 0xDEEDBEAF
632
633/**
634 * startElementNsSAX2Func:
635 * @ctx: the user data (XML parser context)
636 * @localname: the local name of the element
637 * @prefix: the element namespace prefix if available
638 * @URI: the element namespace name if available
639 * @nb_namespaces: number of namespace definitions on that node
640 * @namespaces: pointer to the array of prefix/URI pairs namespace definitions
641 * @nb_attributes: the number of attributes on that node
Daniel Veillard07cb8222003-09-10 10:51:05 +0000642 * @nb_defaulted: the number of defaulted attributes. The defaulted
643 * ones are at the end of the array
644 * @attributes: pointer to the array of (localname/prefix/URI/value/end)
645 * attribute values.
Daniel Veillard1af9a412003-08-20 22:54:39 +0000646 *
647 * SAX2 callback when an element start has been detected by the parser.
648 * It provides the namespace informations for the element, as well as
649 * the new namespace declarations on the element.
Daniel Veillard1af9a412003-08-20 22:54:39 +0000650 */
651
652typedef void (*startElementNsSAX2Func) (void *ctx,
653 const xmlChar *localname,
654 const xmlChar *prefix,
655 const xmlChar *URI,
656 int nb_namespaces,
657 const xmlChar **namespaces,
Daniel Veillard07cb8222003-09-10 10:51:05 +0000658 int nb_attributes,
659 int nb_defaulted,
660 const xmlChar **attributes);
Daniel Veillard1af9a412003-08-20 22:54:39 +0000661
662/**
663 * endElementNsSAX2Func:
664 * @ctx: the user data (XML parser context)
665 * @localname: the local name of the element
666 * @prefix: the element namespace prefix if available
667 * @URI: the element namespace name if available
668 *
669 * SAX2 callback when an element end has been detected by the parser.
670 * It provides the namespace informations for the element.
671 */
672
673typedef void (*endElementNsSAX2Func) (void *ctx,
674 const xmlChar *localname,
675 const xmlChar *prefix,
676 const xmlChar *URI);
677
Daniel Veillard1af9a412003-08-20 22:54:39 +0000678
Owen Taylor3473f882001-02-23 17:55:21 +0000679struct _xmlSAXHandler {
680 internalSubsetSAXFunc internalSubset;
681 isStandaloneSAXFunc isStandalone;
682 hasInternalSubsetSAXFunc hasInternalSubset;
683 hasExternalSubsetSAXFunc hasExternalSubset;
684 resolveEntitySAXFunc resolveEntity;
685 getEntitySAXFunc getEntity;
686 entityDeclSAXFunc entityDecl;
687 notationDeclSAXFunc notationDecl;
688 attributeDeclSAXFunc attributeDecl;
689 elementDeclSAXFunc elementDecl;
690 unparsedEntityDeclSAXFunc unparsedEntityDecl;
691 setDocumentLocatorSAXFunc setDocumentLocator;
692 startDocumentSAXFunc startDocument;
693 endDocumentSAXFunc endDocument;
694 startElementSAXFunc startElement;
695 endElementSAXFunc endElement;
696 referenceSAXFunc reference;
697 charactersSAXFunc characters;
698 ignorableWhitespaceSAXFunc ignorableWhitespace;
699 processingInstructionSAXFunc processingInstruction;
700 commentSAXFunc comment;
701 warningSAXFunc warning;
702 errorSAXFunc error;
Daniel Veillard0821b152002-11-12 20:57:47 +0000703 fatalErrorSAXFunc fatalError; /* unused error() get all the errors */
Owen Taylor3473f882001-02-23 17:55:21 +0000704 getParameterEntitySAXFunc getParameterEntity;
705 cdataBlockSAXFunc cdataBlock;
706 externalSubsetSAXFunc externalSubset;
Daniel Veillard07cb8222003-09-10 10:51:05 +0000707 unsigned int initialized;
Daniel Veillard1af9a412003-08-20 22:54:39 +0000708 /* The following fields are extensions available only on version 2 */
709 void *_private;
710 startElementNsSAX2Func startElementNs;
711 endElementNsSAX2Func endElementNs;
Owen Taylor3473f882001-02-23 17:55:21 +0000712};
713
714/**
Daniel Veillardf69bb4b2001-05-19 13:24:56 +0000715 * xmlExternalEntityLoader:
716 * @URL: The System ID of the resource requested
717 * @ID: The Public ID of the resource requested
Daniel Veillardcbaf3992001-12-31 16:16:02 +0000718 * @context: the XML parser context
Daniel Veillardf69bb4b2001-05-19 13:24:56 +0000719 *
Daniel Veillard61f26172002-03-12 18:46:39 +0000720 * External entity loaders types.
Daniel Veillardcbaf3992001-12-31 16:16:02 +0000721 *
Daniel Veillard61f26172002-03-12 18:46:39 +0000722 * Returns the entity input parser.
Owen Taylor3473f882001-02-23 17:55:21 +0000723 */
Daniel Veillard9d06d302002-01-22 18:15:52 +0000724typedef xmlParserInputPtr (*xmlExternalEntityLoader) (const char *URL,
725 const char *ID,
726 xmlParserCtxtPtr context);
Owen Taylor3473f882001-02-23 17:55:21 +0000727
Daniel Veillard6c4ffaf2002-02-11 08:54:05 +0000728#ifdef __cplusplus
729}
730#endif
Igor Zlatkovic76874e42003-08-25 09:05:12 +0000731
Daniel Veillard6c4ffaf2002-02-11 08:54:05 +0000732#include <libxml/encoding.h>
733#include <libxml/xmlIO.h>
734#include <libxml/globals.h>
Igor Zlatkovic76874e42003-08-25 09:05:12 +0000735
Daniel Veillard6c4ffaf2002-02-11 08:54:05 +0000736#ifdef __cplusplus
737extern "C" {
738#endif
739
Owen Taylor3473f882001-02-23 17:55:21 +0000740
Daniel Veillardf69bb4b2001-05-19 13:24:56 +0000741/*
Owen Taylor3473f882001-02-23 17:55:21 +0000742 * Init/Cleanup
743 */
Igor Zlatkovic76874e42003-08-25 09:05:12 +0000744XMLPUBFUN void XMLCALL
745 xmlInitParser (void);
746XMLPUBFUN void XMLCALL
747 xmlCleanupParser (void);
Owen Taylor3473f882001-02-23 17:55:21 +0000748
Daniel Veillardf69bb4b2001-05-19 13:24:56 +0000749/*
Owen Taylor3473f882001-02-23 17:55:21 +0000750 * Input functions
751 */
Igor Zlatkovic76874e42003-08-25 09:05:12 +0000752XMLPUBFUN int XMLCALL
753 xmlParserInputRead (xmlParserInputPtr in,
Owen Taylor3473f882001-02-23 17:55:21 +0000754 int len);
Igor Zlatkovic76874e42003-08-25 09:05:12 +0000755XMLPUBFUN int XMLCALL
756 xmlParserInputGrow (xmlParserInputPtr in,
Owen Taylor3473f882001-02-23 17:55:21 +0000757 int len);
758
Daniel Veillardf69bb4b2001-05-19 13:24:56 +0000759/*
Owen Taylor3473f882001-02-23 17:55:21 +0000760 * xmlChar handling
761 */
Igor Zlatkovic76874e42003-08-25 09:05:12 +0000762XMLPUBFUN xmlChar * XMLCALL
763 xmlStrdup (const xmlChar *cur);
764XMLPUBFUN xmlChar * XMLCALL
765 xmlStrndup (const xmlChar *cur,
Owen Taylor3473f882001-02-23 17:55:21 +0000766 int len);
Igor Zlatkovic76874e42003-08-25 09:05:12 +0000767XMLPUBFUN xmlChar * XMLCALL
768 xmlCharStrndup (const char *cur,
Daniel Veillard56a4cb82001-03-24 17:00:36 +0000769 int len);
Igor Zlatkovic76874e42003-08-25 09:05:12 +0000770XMLPUBFUN xmlChar * XMLCALL
771 xmlCharStrdup (const char *cur);
772XMLPUBFUN xmlChar * XMLCALL
773 xmlStrsub (const xmlChar *str,
Owen Taylor3473f882001-02-23 17:55:21 +0000774 int start,
775 int len);
Igor Zlatkovic76874e42003-08-25 09:05:12 +0000776XMLPUBFUN const xmlChar * XMLCALL
777 xmlStrchr (const xmlChar *str,
Owen Taylor3473f882001-02-23 17:55:21 +0000778 xmlChar val);
Igor Zlatkovic76874e42003-08-25 09:05:12 +0000779XMLPUBFUN const xmlChar * XMLCALL
780 xmlStrstr (const xmlChar *str,
Daniel Veillard77044732001-06-29 21:31:07 +0000781 const xmlChar *val);
Igor Zlatkovic76874e42003-08-25 09:05:12 +0000782XMLPUBFUN const xmlChar * XMLCALL
783 xmlStrcasestr (const xmlChar *str,
Owen Taylor3473f882001-02-23 17:55:21 +0000784 xmlChar *val);
Igor Zlatkovic76874e42003-08-25 09:05:12 +0000785XMLPUBFUN int XMLCALL
786 xmlStrcmp (const xmlChar *str1,
Owen Taylor3473f882001-02-23 17:55:21 +0000787 const xmlChar *str2);
Igor Zlatkovic76874e42003-08-25 09:05:12 +0000788XMLPUBFUN int XMLCALL
789 xmlStrncmp (const xmlChar *str1,
Owen Taylor3473f882001-02-23 17:55:21 +0000790 const xmlChar *str2,
791 int len);
Igor Zlatkovic76874e42003-08-25 09:05:12 +0000792XMLPUBFUN int XMLCALL
793 xmlStrcasecmp (const xmlChar *str1,
Owen Taylor3473f882001-02-23 17:55:21 +0000794 const xmlChar *str2);
Igor Zlatkovic76874e42003-08-25 09:05:12 +0000795XMLPUBFUN int XMLCALL
796 xmlStrncasecmp (const xmlChar *str1,
Owen Taylor3473f882001-02-23 17:55:21 +0000797 const xmlChar *str2,
798 int len);
Igor Zlatkovic76874e42003-08-25 09:05:12 +0000799XMLPUBFUN int XMLCALL
800 xmlStrEqual (const xmlChar *str1,
Owen Taylor3473f882001-02-23 17:55:21 +0000801 const xmlChar *str2);
Daniel Veillard07cb8222003-09-10 10:51:05 +0000802XMLPUBFUN int XMLCALL
803 xmlStrQEqual (const xmlChar *pref,
804 const xmlChar *name,
805 const xmlChar *str);
Igor Zlatkovic76874e42003-08-25 09:05:12 +0000806XMLPUBFUN int XMLCALL
807 xmlStrlen (const xmlChar *str);
808XMLPUBFUN xmlChar * XMLCALL
809 xmlStrcat (xmlChar *cur,
Owen Taylor3473f882001-02-23 17:55:21 +0000810 const xmlChar *add);
Igor Zlatkovic76874e42003-08-25 09:05:12 +0000811XMLPUBFUN xmlChar * XMLCALL
812 xmlStrncat (xmlChar *cur,
Owen Taylor3473f882001-02-23 17:55:21 +0000813 const xmlChar *add,
814 int len);
815
Daniel Veillardf69bb4b2001-05-19 13:24:56 +0000816/*
Owen Taylor3473f882001-02-23 17:55:21 +0000817 * Basic parsing Interfaces
818 */
Igor Zlatkovic76874e42003-08-25 09:05:12 +0000819XMLPUBFUN xmlDocPtr XMLCALL
820 xmlParseDoc (xmlChar *cur);
821XMLPUBFUN xmlDocPtr XMLCALL
822 xmlParseMemory (const char *buffer,
Owen Taylor3473f882001-02-23 17:55:21 +0000823 int size);
Igor Zlatkovic76874e42003-08-25 09:05:12 +0000824XMLPUBFUN xmlDocPtr XMLCALL
825 xmlParseFile (const char *filename);
826XMLPUBFUN int XMLCALL
827 xmlSubstituteEntitiesDefault(int val);
828XMLPUBFUN int XMLCALL
829 xmlKeepBlanksDefault (int val);
830XMLPUBFUN void XMLCALL
831 xmlStopParser (xmlParserCtxtPtr ctxt);
832XMLPUBFUN int XMLCALL
833 xmlPedanticParserDefault(int val);
834XMLPUBFUN int XMLCALL
835 xmlLineNumbersDefault (int val);
Owen Taylor3473f882001-02-23 17:55:21 +0000836
Daniel Veillardf69bb4b2001-05-19 13:24:56 +0000837/*
Owen Taylor3473f882001-02-23 17:55:21 +0000838 * Recovery mode
839 */
Igor Zlatkovic76874e42003-08-25 09:05:12 +0000840XMLPUBFUN xmlDocPtr XMLCALL
841 xmlRecoverDoc (xmlChar *cur);
842XMLPUBFUN xmlDocPtr XMLCALL
843 xmlRecoverMemory (const char *buffer,
Owen Taylor3473f882001-02-23 17:55:21 +0000844 int size);
Igor Zlatkovic76874e42003-08-25 09:05:12 +0000845XMLPUBFUN xmlDocPtr XMLCALL
846 xmlRecoverFile (const char *filename);
Owen Taylor3473f882001-02-23 17:55:21 +0000847
Daniel Veillardf69bb4b2001-05-19 13:24:56 +0000848/*
Owen Taylor3473f882001-02-23 17:55:21 +0000849 * Less common routines and SAX interfaces
850 */
Igor Zlatkovic76874e42003-08-25 09:05:12 +0000851XMLPUBFUN int XMLCALL
852 xmlParseDocument (xmlParserCtxtPtr ctxt);
853XMLPUBFUN int XMLCALL
854 xmlParseExtParsedEnt (xmlParserCtxtPtr ctxt);
855XMLPUBFUN xmlDocPtr XMLCALL
856 xmlSAXParseDoc (xmlSAXHandlerPtr sax,
Owen Taylor3473f882001-02-23 17:55:21 +0000857 xmlChar *cur,
858 int recovery);
Igor Zlatkovic76874e42003-08-25 09:05:12 +0000859XMLPUBFUN int XMLCALL
860 xmlSAXUserParseFile (xmlSAXHandlerPtr sax,
Owen Taylor3473f882001-02-23 17:55:21 +0000861 void *user_data,
862 const char *filename);
Igor Zlatkovic76874e42003-08-25 09:05:12 +0000863XMLPUBFUN int XMLCALL
864 xmlSAXUserParseMemory (xmlSAXHandlerPtr sax,
Owen Taylor3473f882001-02-23 17:55:21 +0000865 void *user_data,
Daniel Veillardfd7ddca2001-05-16 10:57:35 +0000866 const char *buffer,
Owen Taylor3473f882001-02-23 17:55:21 +0000867 int size);
Igor Zlatkovic76874e42003-08-25 09:05:12 +0000868XMLPUBFUN xmlDocPtr XMLCALL
869 xmlSAXParseMemory (xmlSAXHandlerPtr sax,
Daniel Veillard50822cb2001-07-26 20:05:51 +0000870 const char *buffer,
Owen Taylor3473f882001-02-23 17:55:21 +0000871 int size,
872 int recovery);
Igor Zlatkovic76874e42003-08-25 09:05:12 +0000873XMLPUBFUN xmlDocPtr XMLCALL
874 xmlSAXParseMemoryWithData (xmlSAXHandlerPtr sax,
Daniel Veillard8606bbb2002-11-12 12:36:52 +0000875 const char *buffer,
876 int size,
877 int recovery,
878 void *data);
Igor Zlatkovic76874e42003-08-25 09:05:12 +0000879XMLPUBFUN xmlDocPtr XMLCALL
880 xmlSAXParseFile (xmlSAXHandlerPtr sax,
Owen Taylor3473f882001-02-23 17:55:21 +0000881 const char *filename,
882 int recovery);
Igor Zlatkovic76874e42003-08-25 09:05:12 +0000883XMLPUBFUN xmlDocPtr XMLCALL
884 xmlSAXParseFileWithData (xmlSAXHandlerPtr sax,
Daniel Veillarda293c322001-10-02 13:54:14 +0000885 const char *filename,
886 int recovery,
887 void *data);
Igor Zlatkovic76874e42003-08-25 09:05:12 +0000888XMLPUBFUN xmlDocPtr XMLCALL
889 xmlSAXParseEntity (xmlSAXHandlerPtr sax,
Owen Taylor3473f882001-02-23 17:55:21 +0000890 const char *filename);
Igor Zlatkovic76874e42003-08-25 09:05:12 +0000891XMLPUBFUN xmlDocPtr XMLCALL
892 xmlParseEntity (const char *filename);
893XMLPUBFUN xmlDtdPtr XMLCALL
894 xmlParseDTD (const xmlChar *ExternalID,
Owen Taylor3473f882001-02-23 17:55:21 +0000895 const xmlChar *SystemID);
Igor Zlatkovic76874e42003-08-25 09:05:12 +0000896XMLPUBFUN xmlDtdPtr XMLCALL
897 xmlSAXParseDTD (xmlSAXHandlerPtr sax,
Owen Taylor3473f882001-02-23 17:55:21 +0000898 const xmlChar *ExternalID,
899 const xmlChar *SystemID);
Igor Zlatkovic76874e42003-08-25 09:05:12 +0000900XMLPUBFUN xmlDtdPtr XMLCALL
901 xmlIOParseDTD (xmlSAXHandlerPtr sax,
Owen Taylor3473f882001-02-23 17:55:21 +0000902 xmlParserInputBufferPtr input,
903 xmlCharEncoding enc);
Igor Zlatkovic76874e42003-08-25 09:05:12 +0000904XMLPUBFUN int XMLCALL
905 xmlParseBalancedChunkMemory(xmlDocPtr doc,
Owen Taylor3473f882001-02-23 17:55:21 +0000906 xmlSAXHandlerPtr sax,
907 void *user_data,
908 int depth,
909 const xmlChar *string,
Daniel Veillardcda96922001-08-21 10:56:31 +0000910 xmlNodePtr *lst);
Igor Zlatkovic76874e42003-08-25 09:05:12 +0000911XMLPUBFUN int XMLCALL
912 xmlParseBalancedChunkMemoryRecover(xmlDocPtr doc,
Daniel Veillard58e44c92002-08-02 22:19:49 +0000913 xmlSAXHandlerPtr sax,
914 void *user_data,
915 int depth,
916 const xmlChar *string,
917 xmlNodePtr *lst,
918 int recover);
Igor Zlatkovic76874e42003-08-25 09:05:12 +0000919XMLPUBFUN int XMLCALL
920 xmlParseExternalEntity (xmlDocPtr doc,
Owen Taylor3473f882001-02-23 17:55:21 +0000921 xmlSAXHandlerPtr sax,
922 void *user_data,
923 int depth,
924 const xmlChar *URL,
925 const xmlChar *ID,
Daniel Veillardcda96922001-08-21 10:56:31 +0000926 xmlNodePtr *lst);
Igor Zlatkovic76874e42003-08-25 09:05:12 +0000927XMLPUBFUN int XMLCALL
928 xmlParseCtxtExternalEntity(xmlParserCtxtPtr ctx,
Owen Taylor3473f882001-02-23 17:55:21 +0000929 const xmlChar *URL,
930 const xmlChar *ID,
Daniel Veillardcda96922001-08-21 10:56:31 +0000931 xmlNodePtr *lst);
Owen Taylor3473f882001-02-23 17:55:21 +0000932
Daniel Veillardf69bb4b2001-05-19 13:24:56 +0000933/*
Owen Taylor3473f882001-02-23 17:55:21 +0000934 * Parser contexts handling.
935 */
Igor Zlatkovic76874e42003-08-25 09:05:12 +0000936XMLPUBFUN int XMLCALL
937 xmlInitParserCtxt (xmlParserCtxtPtr ctxt);
938XMLPUBFUN void XMLCALL
939 xmlClearParserCtxt (xmlParserCtxtPtr ctxt);
940XMLPUBFUN void XMLCALL
941 xmlFreeParserCtxt (xmlParserCtxtPtr ctxt);
942XMLPUBFUN void XMLCALL
943 xmlSetupParserForBuffer (xmlParserCtxtPtr ctxt,
Owen Taylor3473f882001-02-23 17:55:21 +0000944 const xmlChar* buffer,
Daniel Veillard963d2ae2002-01-20 22:08:18 +0000945 const char *filename);
Igor Zlatkovic76874e42003-08-25 09:05:12 +0000946XMLPUBFUN xmlParserCtxtPtr XMLCALL
Daniel Veillard16fa96c2003-09-23 21:50:54 +0000947 xmlCreateDocParserCtxt (const xmlChar *cur);
Owen Taylor3473f882001-02-23 17:55:21 +0000948
Daniel Veillardf69bb4b2001-05-19 13:24:56 +0000949/*
Owen Taylor3473f882001-02-23 17:55:21 +0000950 * Reading/setting optional parsing features.
951 */
952
Igor Zlatkovic76874e42003-08-25 09:05:12 +0000953XMLPUBFUN int XMLCALL
954 xmlGetFeaturesList (int *len,
Owen Taylor3473f882001-02-23 17:55:21 +0000955 const char **result);
Igor Zlatkovic76874e42003-08-25 09:05:12 +0000956XMLPUBFUN int XMLCALL
957 xmlGetFeature (xmlParserCtxtPtr ctxt,
Owen Taylor3473f882001-02-23 17:55:21 +0000958 const char *name,
959 void *result);
Igor Zlatkovic76874e42003-08-25 09:05:12 +0000960XMLPUBFUN int XMLCALL
961 xmlSetFeature (xmlParserCtxtPtr ctxt,
Owen Taylor3473f882001-02-23 17:55:21 +0000962 const char *name,
963 void *value);
964
Daniel Veillardf69bb4b2001-05-19 13:24:56 +0000965/*
Daniel Veillard61f26172002-03-12 18:46:39 +0000966 * Interfaces for the Push mode.
Owen Taylor3473f882001-02-23 17:55:21 +0000967 */
Igor Zlatkovic76874e42003-08-25 09:05:12 +0000968XMLPUBFUN xmlParserCtxtPtr XMLCALL
969 xmlCreatePushParserCtxt(xmlSAXHandlerPtr sax,
Owen Taylor3473f882001-02-23 17:55:21 +0000970 void *user_data,
971 const char *chunk,
972 int size,
973 const char *filename);
Igor Zlatkovic76874e42003-08-25 09:05:12 +0000974XMLPUBFUN int XMLCALL
975 xmlParseChunk (xmlParserCtxtPtr ctxt,
Owen Taylor3473f882001-02-23 17:55:21 +0000976 const char *chunk,
977 int size,
978 int terminate);
979
Daniel Veillardf69bb4b2001-05-19 13:24:56 +0000980/*
Daniel Veillard61f26172002-03-12 18:46:39 +0000981 * Special I/O mode.
Owen Taylor3473f882001-02-23 17:55:21 +0000982 */
983
Igor Zlatkovic76874e42003-08-25 09:05:12 +0000984XMLPUBFUN xmlParserCtxtPtr XMLCALL
985 xmlCreateIOParserCtxt (xmlSAXHandlerPtr sax,
Owen Taylor3473f882001-02-23 17:55:21 +0000986 void *user_data,
987 xmlInputReadCallback ioread,
988 xmlInputCloseCallback ioclose,
989 void *ioctx,
990 xmlCharEncoding enc);
991
Igor Zlatkovic76874e42003-08-25 09:05:12 +0000992XMLPUBFUN xmlParserInputPtr XMLCALL
993 xmlNewIOInputStream (xmlParserCtxtPtr ctxt,
Owen Taylor3473f882001-02-23 17:55:21 +0000994 xmlParserInputBufferPtr input,
995 xmlCharEncoding enc);
996
Daniel Veillardf69bb4b2001-05-19 13:24:56 +0000997/*
Daniel Veillard61f26172002-03-12 18:46:39 +0000998 * Node infos.
Owen Taylor3473f882001-02-23 17:55:21 +0000999 */
Igor Zlatkovic76874e42003-08-25 09:05:12 +00001000XMLPUBFUN const xmlParserNodeInfo* XMLCALL
Daniel Veillard963d2ae2002-01-20 22:08:18 +00001001 xmlParserFindNodeInfo (const xmlParserCtxtPtr ctxt,
1002 const xmlNodePtr node);
Igor Zlatkovic76874e42003-08-25 09:05:12 +00001003XMLPUBFUN void XMLCALL
1004 xmlInitNodeInfoSeq (xmlParserNodeInfoSeqPtr seq);
1005XMLPUBFUN void XMLCALL
1006 xmlClearNodeInfoSeq (xmlParserNodeInfoSeqPtr seq);
1007XMLPUBFUN unsigned long XMLCALL
1008 xmlParserFindNodeInfoIndex(const xmlParserNodeInfoSeqPtr seq,
Daniel Veillard963d2ae2002-01-20 22:08:18 +00001009 const xmlNodePtr node);
Igor Zlatkovic76874e42003-08-25 09:05:12 +00001010XMLPUBFUN void XMLCALL
1011 xmlParserAddNodeInfo (xmlParserCtxtPtr ctxt,
Daniel Veillard963d2ae2002-01-20 22:08:18 +00001012 const xmlParserNodeInfoPtr info);
Owen Taylor3473f882001-02-23 17:55:21 +00001013
1014/*
Daniel Veillard61f26172002-03-12 18:46:39 +00001015 * External entities handling actually implemented in xmlIO.
Owen Taylor3473f882001-02-23 17:55:21 +00001016 */
1017
Igor Zlatkovic76874e42003-08-25 09:05:12 +00001018XMLPUBFUN void XMLCALL
1019 xmlSetExternalEntityLoader(xmlExternalEntityLoader f);
1020XMLPUBFUN xmlExternalEntityLoader XMLCALL
Owen Taylor3473f882001-02-23 17:55:21 +00001021 xmlGetExternalEntityLoader(void);
Igor Zlatkovic76874e42003-08-25 09:05:12 +00001022XMLPUBFUN xmlParserInputPtr XMLCALL
Owen Taylor3473f882001-02-23 17:55:21 +00001023 xmlLoadExternalEntity (const char *URL,
1024 const char *ID,
Daniel Veillard9d06d302002-01-22 18:15:52 +00001025 xmlParserCtxtPtr ctxt);
Daniel Veillard16fa96c2003-09-23 21:50:54 +00001026/*
1027 * New set of simpler/more flexible APIs
1028 */
1029/**
1030 * xmlParserOption:
1031 *
1032 * This is the set of XML parser options that can be passed down
1033 * to the xmlReadDoc() and similar calls.
1034 */
1035typedef enum {
1036 XML_PARSE_RECOVER = 1<<0, /* recover on errors */
1037 XML_PARSE_NOENT = 1<<1, /* substitute entities */
1038 XML_PARSE_DTDLOAD = 1<<2, /* load the external subset */
1039 XML_PARSE_DTDATTR = 1<<3, /* default DTD attributes */
1040 XML_PARSE_DTDVALID = 1<<4, /* validate with the DTD */
1041 XML_PARSE_NOERROR = 1<<5, /* suppress error reports */
1042 XML_PARSE_NOWARNING = 1<<6, /* suppress warning reports */
1043 XML_PARSE_PEDANTIC = 1<<7, /* pedantic error reporting */
1044 XML_PARSE_NOBLANKS = 1<<8, /* remove blank nodes */
1045 XML_PARSE_SAX1 = 1<<9, /* use the SAX1 interface internally */
1046 XML_PARSE_XINCLUDE = 1<<10,/* Implement XInclude substitition */
Daniel Veillarde96a2a42003-09-24 21:23:56 +00001047 XML_PARSE_NONET = 1<<11,/* Forbid network access */
1048 XML_PARSE_NODICT = 1<<12 /* Do not reuse the context dictionnary */
Daniel Veillard16fa96c2003-09-23 21:50:54 +00001049} xmlParserOption;
1050
1051XMLPUBFUN void XMLCALL
1052 xmlCtxtReset (xmlParserCtxtPtr ctxt);
1053XMLPUBFUN int XMLCALL
1054 xmlCtxtUseOptions (xmlParserCtxtPtr ctxt,
1055 int options);
1056XMLPUBFUN xmlDocPtr XMLCALL
1057 xmlReadDoc (const xmlChar *cur,
1058 const char *encoding,
1059 int options);
1060XMLPUBFUN xmlDocPtr XMLCALL
1061 xmlReadFile (const char *filename,
1062 const char *encoding,
1063 int options);
1064XMLPUBFUN xmlDocPtr XMLCALL
1065 xmlReadMemory (const char *buffer,
1066 int size,
1067 const char *encoding,
1068 int options);
1069XMLPUBFUN xmlDocPtr XMLCALL
1070 xmlReadFd (int fd,
1071 const char *encoding,
1072 int options);
1073XMLPUBFUN xmlDocPtr XMLCALL
1074 xmlReadIO (xmlInputReadCallback ioread,
1075 xmlInputCloseCallback ioclose,
1076 void *ioctx,
1077 const char *encoding,
1078 int options);
1079XMLPUBFUN xmlDocPtr XMLCALL
1080 xmlCtxtReadDoc (xmlParserCtxtPtr ctxt,
1081 const xmlChar *cur,
1082 const char *encoding,
1083 int options);
1084XMLPUBFUN xmlDocPtr XMLCALL
1085 xmlCtxtReadFile (xmlParserCtxtPtr ctxt,
1086 const char *filename,
1087 const char *encoding,
1088 int options);
1089XMLPUBFUN xmlDocPtr XMLCALL
1090 xmlCtxtReadMemory (xmlParserCtxtPtr ctxt,
1091 const char *buffer,
1092 int size,
1093 const char *encoding,
1094 int options);
1095XMLPUBFUN xmlDocPtr XMLCALL
1096 xmlCtxtReadFd (xmlParserCtxtPtr ctxt,
1097 int fd,
1098 const char *encoding,
1099 int options);
1100XMLPUBFUN xmlDocPtr XMLCALL
1101 xmlCtxtReadIO (xmlParserCtxtPtr ctxt,
1102 xmlInputReadCallback ioread,
1103 xmlInputCloseCallback ioclose,
1104 void *ioctx,
1105 const char *encoding,
1106 int options);
Owen Taylor3473f882001-02-23 17:55:21 +00001107
1108#ifdef __cplusplus
1109}
1110#endif
Owen Taylor3473f882001-02-23 17:55:21 +00001111#endif /* __XML_PARSER_H__ */
1112