blob: 6e750e71b75ff175ab2627618bb08e6f6dd6803e [file] [log] [blame]
Owen Taylor3473f882001-02-23 17:55:21 +00001/*
Daniel Veillardbe586972003-11-18 20:56:51 +00002 * Summary: the core parser module
3 * Description: Interfaces, constants and types related to the XML parser
Owen Taylor3473f882001-02-23 17:55:21 +00004 *
Daniel Veillardbe586972003-11-18 20:56:51 +00005 * Copy: See Copyright for the status of this software.
Owen Taylor3473f882001-02-23 17:55:21 +00006 *
Daniel Veillardbe586972003-11-18 20:56:51 +00007 * Author: Daniel Veillard
Owen Taylor3473f882001-02-23 17:55:21 +00008 */
9
10#ifndef __XML_PARSER_H__
11#define __XML_PARSER_H__
12
Aleksey Saninb5a46da2003-10-29 15:51:17 +000013#include <stdarg.h>
14
Igor Zlatkovic76874e42003-08-25 09:05:12 +000015#include <libxml/xmlversion.h>
Owen Taylor3473f882001-02-23 17:55:21 +000016#include <libxml/tree.h>
Daniel Veillard2fdbd322003-08-18 12:15:38 +000017#include <libxml/dict.h>
Daniel Veillard07cb8222003-09-10 10:51:05 +000018#include <libxml/hash.h>
Owen Taylor3473f882001-02-23 17:55:21 +000019#include <libxml/valid.h>
Owen Taylor3473f882001-02-23 17:55:21 +000020#include <libxml/entities.h>
Daniel Veillard2b8c4a12003-10-02 22:28:19 +000021#include <libxml/xmlerror.h>
William M. Bracka2e844a2004-01-06 11:52:13 +000022#include <libxml/xmlstring.h>
Owen Taylor3473f882001-02-23 17:55:21 +000023
24#ifdef __cplusplus
25extern "C" {
26#endif
27
Daniel Veillard5e2dace2001-07-18 19:30:27 +000028/**
29 * XML_DEFAULT_VERSION:
30 *
31 * The default version of XML used: 1.0
Owen Taylor3473f882001-02-23 17:55:21 +000032 */
33#define XML_DEFAULT_VERSION "1.0"
34
35/**
Daniel Veillardf69bb4b2001-05-19 13:24:56 +000036 * xmlParserInput:
37 *
Daniel Veillard61f26172002-03-12 18:46:39 +000038 * An xmlParserInput is an input flow for the XML processor.
Owen Taylor3473f882001-02-23 17:55:21 +000039 * Each entity parsed is associated an xmlParserInput (except the
40 * few predefined ones). This is the case both for internal entities
41 * - in which case the flow is already completely in memory - or
42 * external entities - in which case we use the buf structure for
43 * progressive reading and I18N conversions to the internal UTF-8 format.
44 */
45
Daniel Veillard9d06d302002-01-22 18:15:52 +000046/**
47 * xmlParserInputDeallocate:
48 * @str: the string to deallocate
49 *
Daniel Veillard61f26172002-03-12 18:46:39 +000050 * Callback for freeing some parser input allocations.
Daniel Veillard9d06d302002-01-22 18:15:52 +000051 */
52typedef void (* xmlParserInputDeallocate)(xmlChar *str);
Daniel Veillard5e2dace2001-07-18 19:30:27 +000053
Owen Taylor3473f882001-02-23 17:55:21 +000054struct _xmlParserInput {
55 /* Input buffer */
56 xmlParserInputBufferPtr buf; /* UTF-8 encoded buffer */
57
58 const char *filename; /* The file analyzed, if any */
Daniel Veillard60087f32001-10-10 09:45:09 +000059 const char *directory; /* the directory/base of the file */
Owen Taylor3473f882001-02-23 17:55:21 +000060 const xmlChar *base; /* Base of the array to parse */
61 const xmlChar *cur; /* Current char being parsed */
Daniel Veillardcbaf3992001-12-31 16:16:02 +000062 const xmlChar *end; /* end of the array to parse */
Owen Taylor3473f882001-02-23 17:55:21 +000063 int length; /* length if known */
64 int line; /* Current line */
65 int col; /* Current column */
Daniel Veillard3e59fc52003-04-18 12:34:58 +000066 /*
67 * NOTE: consumed is only tested for equality in the parser code,
68 * so even if there is an overflow this should not give troubles
69 * for parsing very large instances.
70 */
71 unsigned long consumed; /* How many xmlChars already consumed */
Owen Taylor3473f882001-02-23 17:55:21 +000072 xmlParserInputDeallocate free; /* function to deallocate the base */
73 const xmlChar *encoding; /* the encoding string for entity */
74 const xmlChar *version; /* the version string for entity */
75 int standalone; /* Was that entity marked standalone */
Daniel Veillardbdbe0d42003-09-14 19:56:14 +000076 int id; /* an unique identifier for the entity */
Owen Taylor3473f882001-02-23 17:55:21 +000077};
78
79/**
Daniel Veillardf69bb4b2001-05-19 13:24:56 +000080 * xmlParserNodeInfo:
81 *
Daniel Veillard61f26172002-03-12 18:46:39 +000082 * The parser can be asked to collect Node informations, i.e. at what
Owen Taylor3473f882001-02-23 17:55:21 +000083 * place in the file they were detected.
84 * NOTE: This is off by default and not very well tested.
85 */
86typedef struct _xmlParserNodeInfo xmlParserNodeInfo;
87typedef xmlParserNodeInfo *xmlParserNodeInfoPtr;
88
89struct _xmlParserNodeInfo {
90 const struct _xmlNode* node;
91 /* Position & line # that text that created the node begins & ends on */
92 unsigned long begin_pos;
93 unsigned long begin_line;
94 unsigned long end_pos;
95 unsigned long end_line;
96};
97
98typedef struct _xmlParserNodeInfoSeq xmlParserNodeInfoSeq;
99typedef xmlParserNodeInfoSeq *xmlParserNodeInfoSeqPtr;
100struct _xmlParserNodeInfoSeq {
101 unsigned long maximum;
102 unsigned long length;
103 xmlParserNodeInfo* buffer;
104};
105
106/**
Daniel Veillardf69bb4b2001-05-19 13:24:56 +0000107 * xmlParserInputState:
108 *
Daniel Veillard61f26172002-03-12 18:46:39 +0000109 * The parser is now working also as a state based parser.
110 * The recursive one use the state info for entities processing.
Owen Taylor3473f882001-02-23 17:55:21 +0000111 */
112typedef enum {
113 XML_PARSER_EOF = -1, /* nothing is to be parsed */
114 XML_PARSER_START = 0, /* nothing has been parsed */
115 XML_PARSER_MISC, /* Misc* before int subset */
Daniel Veillardcbaf3992001-12-31 16:16:02 +0000116 XML_PARSER_PI, /* Within a processing instruction */
Owen Taylor3473f882001-02-23 17:55:21 +0000117 XML_PARSER_DTD, /* within some DTD content */
118 XML_PARSER_PROLOG, /* Misc* after internal subset */
119 XML_PARSER_COMMENT, /* within a comment */
120 XML_PARSER_START_TAG, /* within a start tag */
121 XML_PARSER_CONTENT, /* within the content */
122 XML_PARSER_CDATA_SECTION, /* within a CDATA section */
123 XML_PARSER_END_TAG, /* within a closing tag */
124 XML_PARSER_ENTITY_DECL, /* within an entity declaration */
125 XML_PARSER_ENTITY_VALUE, /* within an entity value in a decl */
126 XML_PARSER_ATTRIBUTE_VALUE, /* within an attribute value */
127 XML_PARSER_SYSTEM_LITERAL, /* within a SYSTEM value */
128 XML_PARSER_EPILOG, /* the Misc* after the last end tag */
Daniel Veillard4a7ae502002-02-18 19:18:17 +0000129 XML_PARSER_IGNORE, /* within an IGNORED section */
130 XML_PARSER_PUBLIC_LITERAL /* within a PUBLIC value */
Owen Taylor3473f882001-02-23 17:55:21 +0000131} xmlParserInputState;
132
133/**
Daniel Veillardd16df9f2001-05-23 13:44:21 +0000134 * XML_DETECT_IDS:
135 *
Daniel Veillard61f26172002-03-12 18:46:39 +0000136 * Bit in the loadsubset context field to tell to do ID/REFs lookups.
137 * Use it to initialize xmlLoadExtDtdDefaultValue.
Daniel Veillardd16df9f2001-05-23 13:44:21 +0000138 */
139#define XML_DETECT_IDS 2
140
141/**
142 * XML_COMPLETE_ATTRS:
143 *
144 * Bit in the loadsubset context field to tell to do complete the
Daniel Veillard61f26172002-03-12 18:46:39 +0000145 * elements attributes lists with the ones defaulted from the DTDs.
146 * Use it to initialize xmlLoadExtDtdDefaultValue.
Daniel Veillardd16df9f2001-05-23 13:44:21 +0000147 */
148#define XML_COMPLETE_ATTRS 4
149
150/**
Daniel Veillardef8dd7b2003-03-23 12:02:56 +0000151 * XML_SKIP_IDS:
152 *
153 * Bit in the loadsubset context field to tell to not do ID/REFs registration.
154 * Used to initialize xmlLoadExtDtdDefaultValue in some special cases.
155 */
156#define XML_SKIP_IDS 8
157
158/**
Daniel Veillard0df3bc32004-06-08 12:03:41 +0000159 * xmlParserMode:
160 *
161 * A parser can operate in various modes
162 */
163typedef enum {
164 XML_PARSE_UNKNOWN = 0,
165 XML_PARSE_DOM = 1,
166 XML_PARSE_SAX = 2,
167 XML_PARSE_PUSH_DOM = 3,
168 XML_PARSE_PUSH_SAX = 4,
169 XML_PARSE_READER = 5
170} xmlParserMode;
171
172/**
Daniel Veillardf69bb4b2001-05-19 13:24:56 +0000173 * xmlParserCtxt:
174 *
Owen Taylor3473f882001-02-23 17:55:21 +0000175 * The parser context.
Daniel Veillard61f26172002-03-12 18:46:39 +0000176 * NOTE This doesn't completely define the parser state, the (current ?)
Owen Taylor3473f882001-02-23 17:55:21 +0000177 * design of the parser uses recursive function calls since this allow
178 * and easy mapping from the production rules of the specification
179 * to the actual code. The drawback is that the actual function call
180 * also reflect the parser state. However most of the parsing routines
181 * takes as the only argument the parser context pointer, so migrating
182 * to a state based parser for progressive parsing shouldn't be too hard.
183 */
Owen Taylor3473f882001-02-23 17:55:21 +0000184struct _xmlParserCtxt {
185 struct _xmlSAXHandler *sax; /* The SAX handler */
186 void *userData; /* For SAX interface only, used by DOM build */
187 xmlDocPtr myDoc; /* the document being built */
188 int wellFormed; /* is the document well formed */
189 int replaceEntities; /* shall we replace entities ? */
190 const xmlChar *version; /* the XML version string */
191 const xmlChar *encoding; /* the declared encoding, if any */
192 int standalone; /* standalone document */
193 int html; /* an HTML(1)/Docbook(2) document */
194
195 /* Input stream stack */
196 xmlParserInputPtr input; /* Current input stream */
197 int inputNr; /* Number of current input streams */
198 int inputMax; /* Max number of input streams */
199 xmlParserInputPtr *inputTab; /* stack of inputs */
200
201 /* Node analysis stack only used for DOM building */
202 xmlNodePtr node; /* Current parsed Node */
203 int nodeNr; /* Depth of the parsing stack */
204 int nodeMax; /* Max depth of the parsing stack */
205 xmlNodePtr *nodeTab; /* array of nodes */
206
207 int record_info; /* Whether node info should be kept */
208 xmlParserNodeInfoSeq node_seq; /* info about each node parsed */
209
210 int errNo; /* error code */
211
212 int hasExternalSubset; /* reference and external subset */
213 int hasPErefs; /* the internal subset has PE refs */
214 int external; /* are we parsing an external entity */
215
216 int valid; /* is the document valid */
217 int validate; /* shall we try to validate ? */
218 xmlValidCtxt vctxt; /* The validity context */
219
220 xmlParserInputState instate; /* current type of input */
221 int token; /* next char look-ahead */
222
223 char *directory; /* the data directory */
224
225 /* Node name stack */
Daniel Veillard2fdbd322003-08-18 12:15:38 +0000226 const xmlChar *name; /* Current parsed Node */
Owen Taylor3473f882001-02-23 17:55:21 +0000227 int nameNr; /* Depth of the parsing stack */
228 int nameMax; /* Max depth of the parsing stack */
Daniel Veillard2fdbd322003-08-18 12:15:38 +0000229 const xmlChar * *nameTab; /* array of nodes */
Owen Taylor3473f882001-02-23 17:55:21 +0000230
231 long nbChars; /* number of xmlChar processed */
232 long checkIndex; /* used by progressive parsing lookup */
233 int keepBlanks; /* ugly but ... */
234 int disableSAX; /* SAX callbacks are disabled */
235 int inSubset; /* Parsing is in int 1/ext 2 subset */
Daniel Veillard2fdbd322003-08-18 12:15:38 +0000236 const xmlChar * intSubName; /* name of subset */
Owen Taylor3473f882001-02-23 17:55:21 +0000237 xmlChar * extSubURI; /* URI of external subset */
238 xmlChar * extSubSystem; /* SYSTEM ID of external subset */
239
240 /* xml:space values */
241 int * space; /* Should the parser preserve spaces */
242 int spaceNr; /* Depth of the parsing stack */
243 int spaceMax; /* Max depth of the parsing stack */
244 int * spaceTab; /* array of space infos */
245
246 int depth; /* to prevent entity substitution loops */
247 xmlParserInputPtr entity; /* used to check entities boundaries */
248 int charset; /* encoding of the in-memory content
249 actually an xmlCharEncoding */
250 int nodelen; /* Those two fields are there to */
251 int nodemem; /* Speed up large node parsing */
252 int pedantic; /* signal pedantic warnings */
253 void *_private; /* For user data, libxml won't touch it */
254
255 int loadsubset; /* should the external subset be loaded */
Daniel Veillardd9bad132001-07-23 19:39:43 +0000256 int linenumbers; /* set line number in element content */
Daniel Veillard0df3bc32004-06-08 12:03:41 +0000257 void *catalogs; /* document's own catalog */
Daniel Veillarddad3f682002-11-17 16:47:27 +0000258 int recovery; /* run in recovery mode */
Daniel Veillarda880b122003-04-21 21:36:41 +0000259 int progressive; /* is this a progressive parsing */
Daniel Veillard2fdbd322003-08-18 12:15:38 +0000260 xmlDictPtr dict; /* dictionnary for the parser */
Daniel Veillard40412cd2003-09-03 13:28:32 +0000261 const xmlChar * *atts; /* array for the attributes callbacks */
Daniel Veillard6155d8a2003-08-19 15:01:28 +0000262 int maxatts; /* the size of the array */
Daniel Veillard40412cd2003-09-03 13:28:32 +0000263 int docdict; /* use strings from dict to build tree */
Daniel Veillard0fb18932003-09-07 09:14:37 +0000264
265 /*
266 * pre-interned strings
267 */
268 const xmlChar *str_xml;
269 const xmlChar *str_xmlns;
Daniel Veillard07cb8222003-09-10 10:51:05 +0000270 const xmlChar *str_xml_ns;
Daniel Veillard0fb18932003-09-07 09:14:37 +0000271
272 /*
Daniel Veillard07cb8222003-09-10 10:51:05 +0000273 * Everything below is used only by the new SAX mode
Daniel Veillard0fb18932003-09-07 09:14:37 +0000274 */
275 int sax2; /* operating in the new SAX mode */
276 int nsNr; /* the number of inherited namespaces */
277 int nsMax; /* the size of the arrays */
278 const xmlChar * *nsTab; /* the array of prefix/namespace name */
Daniel Veillard07cb8222003-09-10 10:51:05 +0000279 int *attallocs; /* which attribute were allocated */
280 void * *pushTab; /* array of data for push */
281 xmlHashTablePtr attsDefault; /* defaulted attributes if any */
282 xmlHashTablePtr attsSpecial; /* non-CDATA attributes if any */
Daniel Veillard3b7840c2003-09-11 23:42:01 +0000283 int nsWellFormed; /* is the document XML Nanespace okay */
Daniel Veillard9475a352003-09-26 12:47:50 +0000284 int options; /* Extra options */
Daniel Veillard8a44e592003-09-15 14:50:06 +0000285
286 /*
287 * Those fields are needed only for treaming parsing so far
288 */
Daniel Veillard9475a352003-09-26 12:47:50 +0000289 int dictNames; /* Use dictionary names for the tree */
290 int freeElemsNr; /* number of freed element nodes */
291 xmlNodePtr freeElems; /* List of freed element nodes */
292 int freeAttrsNr; /* number of freed attributes nodes */
293 xmlAttrPtr freeAttrs; /* List of freed attributes nodes */
Daniel Veillard2b8c4a12003-10-02 22:28:19 +0000294
295 /*
296 * the complete error informations for the last error.
297 */
298 xmlError lastError;
Daniel Veillard0df3bc32004-06-08 12:03:41 +0000299 xmlParserMode parseMode; /* the parser mode */
Owen Taylor3473f882001-02-23 17:55:21 +0000300};
301
302/**
Daniel Veillardf69bb4b2001-05-19 13:24:56 +0000303 * xmlSAXLocator:
304 *
Daniel Veillard61f26172002-03-12 18:46:39 +0000305 * A SAX Locator.
Owen Taylor3473f882001-02-23 17:55:21 +0000306 */
Owen Taylor3473f882001-02-23 17:55:21 +0000307struct _xmlSAXLocator {
308 const xmlChar *(*getPublicId)(void *ctx);
309 const xmlChar *(*getSystemId)(void *ctx);
310 int (*getLineNumber)(void *ctx);
311 int (*getColumnNumber)(void *ctx);
312};
313
314/**
Daniel Veillardf69bb4b2001-05-19 13:24:56 +0000315 * xmlSAXHandler:
316 *
Daniel Veillard61f26172002-03-12 18:46:39 +0000317 * A SAX handler is bunch of callbacks called by the parser when processing
Owen Taylor3473f882001-02-23 17:55:21 +0000318 * of the input generate data or structure informations.
319 */
320
Daniel Veillard9d06d302002-01-22 18:15:52 +0000321/**
322 * resolveEntitySAXFunc:
323 * @ctx: the user data (XML parser context)
324 * @publicId: The public ID of the entity
325 * @systemId: The system ID of the entity
326 *
327 * Callback:
328 * The entity loader, to control the loading of external entities,
329 * the application can either:
330 * - override this resolveEntity() callback in the SAX block
331 * - or better use the xmlSetExternalEntityLoader() function to
332 * set up it's own entity resolution routine
333 *
334 * Returns the xmlParserInputPtr if inlined or NULL for DOM behaviour.
335 */
Owen Taylor3473f882001-02-23 17:55:21 +0000336typedef xmlParserInputPtr (*resolveEntitySAXFunc) (void *ctx,
Daniel Veillard9d06d302002-01-22 18:15:52 +0000337 const xmlChar *publicId,
338 const xmlChar *systemId);
339/**
340 * internalSubsetSAXFunc:
341 * @ctx: the user data (XML parser context)
342 * @name: the root element name
343 * @ExternalID: the external ID
344 * @SystemID: the SYSTEM ID (e.g. filename or URL)
345 *
346 * Callback on internal subset declaration.
347 */
348typedef void (*internalSubsetSAXFunc) (void *ctx,
349 const xmlChar *name,
350 const xmlChar *ExternalID,
351 const xmlChar *SystemID);
352/**
353 * externalSubsetSAXFunc:
354 * @ctx: the user data (XML parser context)
355 * @name: the root element name
356 * @ExternalID: the external ID
357 * @SystemID: the SYSTEM ID (e.g. filename or URL)
358 *
359 * Callback on external subset declaration.
360 */
361typedef void (*externalSubsetSAXFunc) (void *ctx,
362 const xmlChar *name,
363 const xmlChar *ExternalID,
364 const xmlChar *SystemID);
365/**
366 * getEntitySAXFunc:
367 * @ctx: the user data (XML parser context)
368 * @name: The entity name
369 *
Daniel Veillard61f26172002-03-12 18:46:39 +0000370 * Get an entity by name.
Daniel Veillard9d06d302002-01-22 18:15:52 +0000371 *
372 * Returns the xmlEntityPtr if found.
373 */
Owen Taylor3473f882001-02-23 17:55:21 +0000374typedef xmlEntityPtr (*getEntitySAXFunc) (void *ctx,
Daniel Veillard9d06d302002-01-22 18:15:52 +0000375 const xmlChar *name);
376/**
377 * getParameterEntitySAXFunc:
378 * @ctx: the user data (XML parser context)
379 * @name: The entity name
380 *
Daniel Veillard61f26172002-03-12 18:46:39 +0000381 * Get a parameter entity by name.
Daniel Veillard9d06d302002-01-22 18:15:52 +0000382 *
383 * Returns the xmlEntityPtr if found.
384 */
Owen Taylor3473f882001-02-23 17:55:21 +0000385typedef xmlEntityPtr (*getParameterEntitySAXFunc) (void *ctx,
Daniel Veillard9d06d302002-01-22 18:15:52 +0000386 const xmlChar *name);
387/**
388 * entityDeclSAXFunc:
389 * @ctx: the user data (XML parser context)
390 * @name: the entity name
391 * @type: the entity type
392 * @publicId: The public ID of the entity
393 * @systemId: The system ID of the entity
394 * @content: the entity value (without processing).
395 *
Daniel Veillard61f26172002-03-12 18:46:39 +0000396 * An entity definition has been parsed.
Daniel Veillard9d06d302002-01-22 18:15:52 +0000397 */
Owen Taylor3473f882001-02-23 17:55:21 +0000398typedef void (*entityDeclSAXFunc) (void *ctx,
Daniel Veillard9d06d302002-01-22 18:15:52 +0000399 const xmlChar *name,
400 int type,
401 const xmlChar *publicId,
402 const xmlChar *systemId,
403 xmlChar *content);
404/**
405 * notationDeclSAXFunc:
406 * @ctx: the user data (XML parser context)
407 * @name: The name of the notation
408 * @publicId: The public ID of the entity
409 * @systemId: The system ID of the entity
410 *
411 * What to do when a notation declaration has been parsed.
412 */
413typedef void (*notationDeclSAXFunc)(void *ctx,
414 const xmlChar *name,
415 const xmlChar *publicId,
416 const xmlChar *systemId);
417/**
418 * attributeDeclSAXFunc:
419 * @ctx: the user data (XML parser context)
420 * @elem: the name of the element
421 * @fullname: the attribute name
422 * @type: the attribute type
423 * @def: the type of default value
424 * @defaultValue: the attribute default value
425 * @tree: the tree of enumerated value set
426 *
Daniel Veillard61f26172002-03-12 18:46:39 +0000427 * An attribute definition has been parsed.
Daniel Veillard9d06d302002-01-22 18:15:52 +0000428 */
429typedef void (*attributeDeclSAXFunc)(void *ctx,
430 const xmlChar *elem,
431 const xmlChar *fullname,
432 int type,
433 int def,
434 const xmlChar *defaultValue,
435 xmlEnumerationPtr tree);
436/**
437 * elementDeclSAXFunc:
438 * @ctx: the user data (XML parser context)
439 * @name: the element name
440 * @type: the element type
441 * @content: the element value tree
442 *
Daniel Veillard61f26172002-03-12 18:46:39 +0000443 * An element definition has been parsed.
Daniel Veillard9d06d302002-01-22 18:15:52 +0000444 */
445typedef void (*elementDeclSAXFunc)(void *ctx,
446 const xmlChar *name,
447 int type,
448 xmlElementContentPtr content);
449/**
450 * unparsedEntityDeclSAXFunc:
451 * @ctx: the user data (XML parser context)
452 * @name: The name of the entity
453 * @publicId: The public ID of the entity
454 * @systemId: The system ID of the entity
455 * @notationName: the name of the notation
456 *
Daniel Veillard61f26172002-03-12 18:46:39 +0000457 * What to do when an unparsed entity declaration is parsed.
Daniel Veillard9d06d302002-01-22 18:15:52 +0000458 */
Owen Taylor3473f882001-02-23 17:55:21 +0000459typedef void (*unparsedEntityDeclSAXFunc)(void *ctx,
Daniel Veillard9d06d302002-01-22 18:15:52 +0000460 const xmlChar *name,
461 const xmlChar *publicId,
462 const xmlChar *systemId,
463 const xmlChar *notationName);
464/**
465 * setDocumentLocatorSAXFunc:
466 * @ctx: the user data (XML parser context)
467 * @loc: A SAX Locator
468 *
Daniel Veillard61f26172002-03-12 18:46:39 +0000469 * Receive the document locator at startup, actually xmlDefaultSAXLocator.
Daniel Veillard9d06d302002-01-22 18:15:52 +0000470 * Everything is available on the context, so this is useless in our case.
471 */
Owen Taylor3473f882001-02-23 17:55:21 +0000472typedef void (*setDocumentLocatorSAXFunc) (void *ctx,
Daniel Veillard9d06d302002-01-22 18:15:52 +0000473 xmlSAXLocatorPtr loc);
474/**
475 * startDocumentSAXFunc:
476 * @ctx: the user data (XML parser context)
477 *
Daniel Veillard61f26172002-03-12 18:46:39 +0000478 * Called when the document start being processed.
Daniel Veillard9d06d302002-01-22 18:15:52 +0000479 */
Owen Taylor3473f882001-02-23 17:55:21 +0000480typedef void (*startDocumentSAXFunc) (void *ctx);
Daniel Veillard9d06d302002-01-22 18:15:52 +0000481/**
482 * endDocumentSAXFunc:
483 * @ctx: the user data (XML parser context)
484 *
Daniel Veillard61f26172002-03-12 18:46:39 +0000485 * Called when the document end has been detected.
Daniel Veillard9d06d302002-01-22 18:15:52 +0000486 */
Owen Taylor3473f882001-02-23 17:55:21 +0000487typedef void (*endDocumentSAXFunc) (void *ctx);
Daniel Veillard9d06d302002-01-22 18:15:52 +0000488/**
489 * startElementSAXFunc:
490 * @ctx: the user data (XML parser context)
491 * @name: The element name, including namespace prefix
492 * @atts: An array of name/value attributes pairs, NULL terminated
493 *
Daniel Veillard61f26172002-03-12 18:46:39 +0000494 * Called when an opening tag has been processed.
Daniel Veillard9d06d302002-01-22 18:15:52 +0000495 */
496typedef void (*startElementSAXFunc) (void *ctx,
497 const xmlChar *name,
498 const xmlChar **atts);
499/**
500 * endElementSAXFunc:
501 * @ctx: the user data (XML parser context)
502 * @name: The element name
503 *
Daniel Veillard61f26172002-03-12 18:46:39 +0000504 * Called when the end of an element has been detected.
Daniel Veillard9d06d302002-01-22 18:15:52 +0000505 */
506typedef void (*endElementSAXFunc) (void *ctx,
507 const xmlChar *name);
508/**
509 * attributeSAXFunc:
510 * @ctx: the user data (XML parser context)
511 * @name: The attribute name, including namespace prefix
512 * @value: The attribute value
513 *
514 * Handle an attribute that has been read by the parser.
515 * The default handling is to convert the attribute into an
516 * DOM subtree and past it in a new xmlAttr element added to
517 * the element.
518 */
519typedef void (*attributeSAXFunc) (void *ctx,
520 const xmlChar *name,
521 const xmlChar *value);
522/**
523 * referenceSAXFunc:
524 * @ctx: the user data (XML parser context)
525 * @name: The entity name
526 *
Daniel Veillard61f26172002-03-12 18:46:39 +0000527 * Called when an entity reference is detected.
Daniel Veillard9d06d302002-01-22 18:15:52 +0000528 */
529typedef void (*referenceSAXFunc) (void *ctx,
530 const xmlChar *name);
531/**
532 * charactersSAXFunc:
533 * @ctx: the user data (XML parser context)
534 * @ch: a xmlChar string
535 * @len: the number of xmlChar
536 *
Daniel Veillard61f26172002-03-12 18:46:39 +0000537 * Receiving some chars from the parser.
Daniel Veillard9d06d302002-01-22 18:15:52 +0000538 */
539typedef void (*charactersSAXFunc) (void *ctx,
540 const xmlChar *ch,
541 int len);
542/**
543 * ignorableWhitespaceSAXFunc:
544 * @ctx: the user data (XML parser context)
545 * @ch: a xmlChar string
546 * @len: the number of xmlChar
547 *
Daniel Veillard61f26172002-03-12 18:46:39 +0000548 * Receiving some ignorable whitespaces from the parser.
549 * UNUSED: by default the DOM building will use characters.
Daniel Veillard9d06d302002-01-22 18:15:52 +0000550 */
Owen Taylor3473f882001-02-23 17:55:21 +0000551typedef void (*ignorableWhitespaceSAXFunc) (void *ctx,
Daniel Veillard9d06d302002-01-22 18:15:52 +0000552 const xmlChar *ch,
553 int len);
554/**
555 * processingInstructionSAXFunc:
556 * @ctx: the user data (XML parser context)
557 * @target: the target name
558 * @data: the PI data's
559 *
560 * A processing instruction has been parsed.
561 */
Owen Taylor3473f882001-02-23 17:55:21 +0000562typedef void (*processingInstructionSAXFunc) (void *ctx,
Daniel Veillard9d06d302002-01-22 18:15:52 +0000563 const xmlChar *target,
564 const xmlChar *data);
565/**
566 * commentSAXFunc:
567 * @ctx: the user data (XML parser context)
568 * @value: the comment content
569 *
570 * A comment has been parsed.
571 */
572typedef void (*commentSAXFunc) (void *ctx,
573 const xmlChar *value);
574/**
575 * cdataBlockSAXFunc:
576 * @ctx: the user data (XML parser context)
577 * @value: The pcdata content
578 * @len: the block length
579 *
Daniel Veillard61f26172002-03-12 18:46:39 +0000580 * Called when a pcdata block has been parsed.
Daniel Veillard9d06d302002-01-22 18:15:52 +0000581 */
582typedef void (*cdataBlockSAXFunc) (
583 void *ctx,
584 const xmlChar *value,
585 int len);
586/**
587 * warningSAXFunc:
588 * @ctx: an XML parser context
589 * @msg: the message to display/transmit
590 * @...: extra parameters for the message display
591 *
Daniel Veillard61f26172002-03-12 18:46:39 +0000592 * Display and format a warning messages, callback.
Daniel Veillard9d06d302002-01-22 18:15:52 +0000593 */
Daniel Veillardffa3c742005-07-21 13:24:09 +0000594typedef void (XMLCDECL *warningSAXFunc) (void *ctx,
Daniel Veillard9d06d302002-01-22 18:15:52 +0000595 const char *msg, ...);
596/**
597 * errorSAXFunc:
598 * @ctx: an XML parser context
599 * @msg: the message to display/transmit
600 * @...: extra parameters for the message display
601 *
Daniel Veillard61f26172002-03-12 18:46:39 +0000602 * Display and format an error messages, callback.
Daniel Veillard9d06d302002-01-22 18:15:52 +0000603 */
Daniel Veillardffa3c742005-07-21 13:24:09 +0000604typedef void (XMLCDECL *errorSAXFunc) (void *ctx,
Daniel Veillard9d06d302002-01-22 18:15:52 +0000605 const char *msg, ...);
606/**
607 * fatalErrorSAXFunc:
608 * @ctx: an XML parser context
609 * @msg: the message to display/transmit
610 * @...: extra parameters for the message display
611 *
Daniel Veillard61f26172002-03-12 18:46:39 +0000612 * Display and format fatal error messages, callback.
Daniel Veillard0821b152002-11-12 20:57:47 +0000613 * Note: so far fatalError() SAX callbacks are not used, error()
614 * get all the callbacks for errors.
Daniel Veillard9d06d302002-01-22 18:15:52 +0000615 */
Daniel Veillardffa3c742005-07-21 13:24:09 +0000616typedef void (XMLCDECL *fatalErrorSAXFunc) (void *ctx,
Daniel Veillard9d06d302002-01-22 18:15:52 +0000617 const char *msg, ...);
618/**
619 * isStandaloneSAXFunc:
620 * @ctx: the user data (XML parser context)
621 *
Daniel Veillard61f26172002-03-12 18:46:39 +0000622 * Is this document tagged standalone?
Daniel Veillard9d06d302002-01-22 18:15:52 +0000623 *
624 * Returns 1 if true
625 */
Owen Taylor3473f882001-02-23 17:55:21 +0000626typedef int (*isStandaloneSAXFunc) (void *ctx);
Daniel Veillard9d06d302002-01-22 18:15:52 +0000627/**
628 * hasInternalSubsetSAXFunc:
629 * @ctx: the user data (XML parser context)
630 *
Daniel Veillard61f26172002-03-12 18:46:39 +0000631 * Does this document has an internal subset.
Daniel Veillard9d06d302002-01-22 18:15:52 +0000632 *
633 * Returns 1 if true
634 */
Owen Taylor3473f882001-02-23 17:55:21 +0000635typedef int (*hasInternalSubsetSAXFunc) (void *ctx);
Daniel Veillard1af9a412003-08-20 22:54:39 +0000636
Daniel Veillard9d06d302002-01-22 18:15:52 +0000637/**
638 * hasExternalSubsetSAXFunc:
639 * @ctx: the user data (XML parser context)
640 *
Daniel Veillard61f26172002-03-12 18:46:39 +0000641 * Does this document has an external subset?
Daniel Veillard9d06d302002-01-22 18:15:52 +0000642 *
643 * Returns 1 if true
644 */
Owen Taylor3473f882001-02-23 17:55:21 +0000645typedef int (*hasExternalSubsetSAXFunc) (void *ctx);
646
Daniel Veillard1af9a412003-08-20 22:54:39 +0000647/************************************************************************
648 * *
649 * The SAX version 2 API extensions *
650 * *
651 ************************************************************************/
652/**
653 * XML_SAX2_MAGIC:
654 *
655 * Special constant found in SAX2 blocks initialized fields
656 */
657#define XML_SAX2_MAGIC 0xDEEDBEAF
658
659/**
660 * startElementNsSAX2Func:
661 * @ctx: the user data (XML parser context)
662 * @localname: the local name of the element
663 * @prefix: the element namespace prefix if available
664 * @URI: the element namespace name if available
665 * @nb_namespaces: number of namespace definitions on that node
666 * @namespaces: pointer to the array of prefix/URI pairs namespace definitions
667 * @nb_attributes: the number of attributes on that node
Daniel Veillard07cb8222003-09-10 10:51:05 +0000668 * @nb_defaulted: the number of defaulted attributes. The defaulted
669 * ones are at the end of the array
670 * @attributes: pointer to the array of (localname/prefix/URI/value/end)
671 * attribute values.
Daniel Veillard1af9a412003-08-20 22:54:39 +0000672 *
673 * SAX2 callback when an element start has been detected by the parser.
674 * It provides the namespace informations for the element, as well as
675 * the new namespace declarations on the element.
Daniel Veillard1af9a412003-08-20 22:54:39 +0000676 */
677
678typedef void (*startElementNsSAX2Func) (void *ctx,
679 const xmlChar *localname,
680 const xmlChar *prefix,
681 const xmlChar *URI,
682 int nb_namespaces,
683 const xmlChar **namespaces,
Daniel Veillard07cb8222003-09-10 10:51:05 +0000684 int nb_attributes,
685 int nb_defaulted,
686 const xmlChar **attributes);
Daniel Veillard1af9a412003-08-20 22:54:39 +0000687
688/**
689 * endElementNsSAX2Func:
690 * @ctx: the user data (XML parser context)
691 * @localname: the local name of the element
692 * @prefix: the element namespace prefix if available
693 * @URI: the element namespace name if available
694 *
695 * SAX2 callback when an element end has been detected by the parser.
696 * It provides the namespace informations for the element.
697 */
698
699typedef void (*endElementNsSAX2Func) (void *ctx,
700 const xmlChar *localname,
701 const xmlChar *prefix,
702 const xmlChar *URI);
703
Daniel Veillard1af9a412003-08-20 22:54:39 +0000704
Owen Taylor3473f882001-02-23 17:55:21 +0000705struct _xmlSAXHandler {
706 internalSubsetSAXFunc internalSubset;
707 isStandaloneSAXFunc isStandalone;
708 hasInternalSubsetSAXFunc hasInternalSubset;
709 hasExternalSubsetSAXFunc hasExternalSubset;
710 resolveEntitySAXFunc resolveEntity;
711 getEntitySAXFunc getEntity;
712 entityDeclSAXFunc entityDecl;
713 notationDeclSAXFunc notationDecl;
714 attributeDeclSAXFunc attributeDecl;
715 elementDeclSAXFunc elementDecl;
716 unparsedEntityDeclSAXFunc unparsedEntityDecl;
717 setDocumentLocatorSAXFunc setDocumentLocator;
718 startDocumentSAXFunc startDocument;
719 endDocumentSAXFunc endDocument;
720 startElementSAXFunc startElement;
721 endElementSAXFunc endElement;
722 referenceSAXFunc reference;
723 charactersSAXFunc characters;
724 ignorableWhitespaceSAXFunc ignorableWhitespace;
725 processingInstructionSAXFunc processingInstruction;
726 commentSAXFunc comment;
727 warningSAXFunc warning;
728 errorSAXFunc error;
Daniel Veillard0821b152002-11-12 20:57:47 +0000729 fatalErrorSAXFunc fatalError; /* unused error() get all the errors */
Owen Taylor3473f882001-02-23 17:55:21 +0000730 getParameterEntitySAXFunc getParameterEntity;
731 cdataBlockSAXFunc cdataBlock;
732 externalSubsetSAXFunc externalSubset;
Daniel Veillard07cb8222003-09-10 10:51:05 +0000733 unsigned int initialized;
Daniel Veillard1af9a412003-08-20 22:54:39 +0000734 /* The following fields are extensions available only on version 2 */
735 void *_private;
736 startElementNsSAX2Func startElementNs;
737 endElementNsSAX2Func endElementNs;
Daniel Veillard659e71e2003-10-10 14:10:40 +0000738 xmlStructuredErrorFunc serror;
Owen Taylor3473f882001-02-23 17:55:21 +0000739};
740
Daniel Veillard9ee35f32003-09-28 00:19:54 +0000741/*
742 * SAX Version 1
743 */
744typedef struct _xmlSAXHandlerV1 xmlSAXHandlerV1;
745typedef xmlSAXHandlerV1 *xmlSAXHandlerV1Ptr;
746struct _xmlSAXHandlerV1 {
747 internalSubsetSAXFunc internalSubset;
748 isStandaloneSAXFunc isStandalone;
749 hasInternalSubsetSAXFunc hasInternalSubset;
750 hasExternalSubsetSAXFunc hasExternalSubset;
751 resolveEntitySAXFunc resolveEntity;
752 getEntitySAXFunc getEntity;
753 entityDeclSAXFunc entityDecl;
754 notationDeclSAXFunc notationDecl;
755 attributeDeclSAXFunc attributeDecl;
756 elementDeclSAXFunc elementDecl;
757 unparsedEntityDeclSAXFunc unparsedEntityDecl;
758 setDocumentLocatorSAXFunc setDocumentLocator;
759 startDocumentSAXFunc startDocument;
760 endDocumentSAXFunc endDocument;
761 startElementSAXFunc startElement;
762 endElementSAXFunc endElement;
763 referenceSAXFunc reference;
764 charactersSAXFunc characters;
765 ignorableWhitespaceSAXFunc ignorableWhitespace;
766 processingInstructionSAXFunc processingInstruction;
767 commentSAXFunc comment;
768 warningSAXFunc warning;
769 errorSAXFunc error;
770 fatalErrorSAXFunc fatalError; /* unused error() get all the errors */
771 getParameterEntitySAXFunc getParameterEntity;
772 cdataBlockSAXFunc cdataBlock;
773 externalSubsetSAXFunc externalSubset;
774 unsigned int initialized;
775};
776
777
Owen Taylor3473f882001-02-23 17:55:21 +0000778/**
Daniel Veillardf69bb4b2001-05-19 13:24:56 +0000779 * xmlExternalEntityLoader:
780 * @URL: The System ID of the resource requested
781 * @ID: The Public ID of the resource requested
Daniel Veillardcbaf3992001-12-31 16:16:02 +0000782 * @context: the XML parser context
Daniel Veillardf69bb4b2001-05-19 13:24:56 +0000783 *
Daniel Veillard61f26172002-03-12 18:46:39 +0000784 * External entity loaders types.
Daniel Veillardcbaf3992001-12-31 16:16:02 +0000785 *
Daniel Veillard61f26172002-03-12 18:46:39 +0000786 * Returns the entity input parser.
Owen Taylor3473f882001-02-23 17:55:21 +0000787 */
Daniel Veillard9d06d302002-01-22 18:15:52 +0000788typedef xmlParserInputPtr (*xmlExternalEntityLoader) (const char *URL,
789 const char *ID,
790 xmlParserCtxtPtr context);
Owen Taylor3473f882001-02-23 17:55:21 +0000791
Daniel Veillard6c4ffaf2002-02-11 08:54:05 +0000792#ifdef __cplusplus
793}
794#endif
Igor Zlatkovic76874e42003-08-25 09:05:12 +0000795
Daniel Veillard6c4ffaf2002-02-11 08:54:05 +0000796#include <libxml/encoding.h>
797#include <libxml/xmlIO.h>
798#include <libxml/globals.h>
Igor Zlatkovic76874e42003-08-25 09:05:12 +0000799
Daniel Veillard6c4ffaf2002-02-11 08:54:05 +0000800#ifdef __cplusplus
801extern "C" {
802#endif
803
Owen Taylor3473f882001-02-23 17:55:21 +0000804
Daniel Veillardf69bb4b2001-05-19 13:24:56 +0000805/*
Owen Taylor3473f882001-02-23 17:55:21 +0000806 * Init/Cleanup
807 */
Igor Zlatkovic76874e42003-08-25 09:05:12 +0000808XMLPUBFUN void XMLCALL
809 xmlInitParser (void);
810XMLPUBFUN void XMLCALL
811 xmlCleanupParser (void);
Owen Taylor3473f882001-02-23 17:55:21 +0000812
Daniel Veillardf69bb4b2001-05-19 13:24:56 +0000813/*
Owen Taylor3473f882001-02-23 17:55:21 +0000814 * Input functions
815 */
Igor Zlatkovic76874e42003-08-25 09:05:12 +0000816XMLPUBFUN int XMLCALL
817 xmlParserInputRead (xmlParserInputPtr in,
Owen Taylor3473f882001-02-23 17:55:21 +0000818 int len);
Igor Zlatkovic76874e42003-08-25 09:05:12 +0000819XMLPUBFUN int XMLCALL
820 xmlParserInputGrow (xmlParserInputPtr in,
Owen Taylor3473f882001-02-23 17:55:21 +0000821 int len);
822
Daniel Veillardf69bb4b2001-05-19 13:24:56 +0000823/*
Owen Taylor3473f882001-02-23 17:55:21 +0000824 * Basic parsing Interfaces
825 */
William M. Brack21e4ef22005-01-02 09:53:13 +0000826#ifdef LIBXML_SAX1_ENABLED
Igor Zlatkovic76874e42003-08-25 09:05:12 +0000827XMLPUBFUN xmlDocPtr XMLCALL
Daniel Veillard7331e5c2005-03-31 14:59:00 +0000828 xmlParseDoc (const xmlChar *cur);
Igor Zlatkovic76874e42003-08-25 09:05:12 +0000829XMLPUBFUN xmlDocPtr XMLCALL
William M. Brack21e4ef22005-01-02 09:53:13 +0000830 xmlParseFile (const char *filename);
831XMLPUBFUN xmlDocPtr XMLCALL
Igor Zlatkovic76874e42003-08-25 09:05:12 +0000832 xmlParseMemory (const char *buffer,
Owen Taylor3473f882001-02-23 17:55:21 +0000833 int size);
William M. Brack21e4ef22005-01-02 09:53:13 +0000834#endif /* LIBXML_SAX1_ENABLED */
Igor Zlatkovic76874e42003-08-25 09:05:12 +0000835XMLPUBFUN int XMLCALL
836 xmlSubstituteEntitiesDefault(int val);
837XMLPUBFUN int XMLCALL
838 xmlKeepBlanksDefault (int val);
839XMLPUBFUN void XMLCALL
840 xmlStopParser (xmlParserCtxtPtr ctxt);
841XMLPUBFUN int XMLCALL
842 xmlPedanticParserDefault(int val);
843XMLPUBFUN int XMLCALL
844 xmlLineNumbersDefault (int val);
Owen Taylor3473f882001-02-23 17:55:21 +0000845
William M. Brack21e4ef22005-01-02 09:53:13 +0000846#ifdef LIBXML_SAX1_ENABLED
Daniel Veillardf69bb4b2001-05-19 13:24:56 +0000847/*
Owen Taylor3473f882001-02-23 17:55:21 +0000848 * Recovery mode
849 */
Igor Zlatkovic76874e42003-08-25 09:05:12 +0000850XMLPUBFUN xmlDocPtr XMLCALL
851 xmlRecoverDoc (xmlChar *cur);
852XMLPUBFUN xmlDocPtr XMLCALL
853 xmlRecoverMemory (const char *buffer,
Owen Taylor3473f882001-02-23 17:55:21 +0000854 int size);
Igor Zlatkovic76874e42003-08-25 09:05:12 +0000855XMLPUBFUN xmlDocPtr XMLCALL
856 xmlRecoverFile (const char *filename);
William M. Brack21e4ef22005-01-02 09:53:13 +0000857#endif /* LIBXML_SAX1_ENABLED */
Owen Taylor3473f882001-02-23 17:55:21 +0000858
Daniel Veillardf69bb4b2001-05-19 13:24:56 +0000859/*
Owen Taylor3473f882001-02-23 17:55:21 +0000860 * Less common routines and SAX interfaces
861 */
Igor Zlatkovic76874e42003-08-25 09:05:12 +0000862XMLPUBFUN int XMLCALL
863 xmlParseDocument (xmlParserCtxtPtr ctxt);
864XMLPUBFUN int XMLCALL
865 xmlParseExtParsedEnt (xmlParserCtxtPtr ctxt);
William M. Brack21e4ef22005-01-02 09:53:13 +0000866#ifdef LIBXML_SAX1_ENABLED
Igor Zlatkovic76874e42003-08-25 09:05:12 +0000867XMLPUBFUN int XMLCALL
868 xmlSAXUserParseFile (xmlSAXHandlerPtr sax,
Owen Taylor3473f882001-02-23 17:55:21 +0000869 void *user_data,
870 const char *filename);
Igor Zlatkovic76874e42003-08-25 09:05:12 +0000871XMLPUBFUN int XMLCALL
872 xmlSAXUserParseMemory (xmlSAXHandlerPtr sax,
Owen Taylor3473f882001-02-23 17:55:21 +0000873 void *user_data,
Daniel Veillardfd7ddca2001-05-16 10:57:35 +0000874 const char *buffer,
Owen Taylor3473f882001-02-23 17:55:21 +0000875 int size);
Igor Zlatkovic76874e42003-08-25 09:05:12 +0000876XMLPUBFUN xmlDocPtr XMLCALL
William M. Brack21e4ef22005-01-02 09:53:13 +0000877 xmlSAXParseDoc (xmlSAXHandlerPtr sax,
Daniel Veillard7331e5c2005-03-31 14:59:00 +0000878 const xmlChar *cur,
William M. Brack21e4ef22005-01-02 09:53:13 +0000879 int recovery);
880XMLPUBFUN xmlDocPtr XMLCALL
Igor Zlatkovic76874e42003-08-25 09:05:12 +0000881 xmlSAXParseMemory (xmlSAXHandlerPtr sax,
Daniel Veillard50822cb2001-07-26 20:05:51 +0000882 const char *buffer,
Owen Taylor3473f882001-02-23 17:55:21 +0000883 int size,
884 int recovery);
Igor Zlatkovic76874e42003-08-25 09:05:12 +0000885XMLPUBFUN xmlDocPtr XMLCALL
886 xmlSAXParseMemoryWithData (xmlSAXHandlerPtr sax,
Daniel Veillard8606bbb2002-11-12 12:36:52 +0000887 const char *buffer,
888 int size,
889 int recovery,
890 void *data);
Igor Zlatkovic76874e42003-08-25 09:05:12 +0000891XMLPUBFUN xmlDocPtr XMLCALL
892 xmlSAXParseFile (xmlSAXHandlerPtr sax,
Owen Taylor3473f882001-02-23 17:55:21 +0000893 const char *filename,
894 int recovery);
Igor Zlatkovic76874e42003-08-25 09:05:12 +0000895XMLPUBFUN xmlDocPtr XMLCALL
896 xmlSAXParseFileWithData (xmlSAXHandlerPtr sax,
Daniel Veillarda293c322001-10-02 13:54:14 +0000897 const char *filename,
898 int recovery,
899 void *data);
Igor Zlatkovic76874e42003-08-25 09:05:12 +0000900XMLPUBFUN xmlDocPtr XMLCALL
901 xmlSAXParseEntity (xmlSAXHandlerPtr sax,
Owen Taylor3473f882001-02-23 17:55:21 +0000902 const char *filename);
Igor Zlatkovic76874e42003-08-25 09:05:12 +0000903XMLPUBFUN xmlDocPtr XMLCALL
904 xmlParseEntity (const char *filename);
William M. Brack21e4ef22005-01-02 09:53:13 +0000905#endif /* LIBXML_SAX1_ENABLED */
906
907#ifdef LIBXML_VALID_ENABLED
Igor Zlatkovic76874e42003-08-25 09:05:12 +0000908XMLPUBFUN xmlDtdPtr XMLCALL
909 xmlSAXParseDTD (xmlSAXHandlerPtr sax,
Owen Taylor3473f882001-02-23 17:55:21 +0000910 const xmlChar *ExternalID,
911 const xmlChar *SystemID);
Igor Zlatkovic76874e42003-08-25 09:05:12 +0000912XMLPUBFUN xmlDtdPtr XMLCALL
William M. Brack21e4ef22005-01-02 09:53:13 +0000913 xmlParseDTD (const xmlChar *ExternalID,
914 const xmlChar *SystemID);
915XMLPUBFUN xmlDtdPtr XMLCALL
Igor Zlatkovic76874e42003-08-25 09:05:12 +0000916 xmlIOParseDTD (xmlSAXHandlerPtr sax,
Owen Taylor3473f882001-02-23 17:55:21 +0000917 xmlParserInputBufferPtr input,
918 xmlCharEncoding enc);
William M. Brack21e4ef22005-01-02 09:53:13 +0000919#endif /* LIBXML_VALID_ENABLE */
920#ifdef LIBXML_SAX1_ENABLED
Igor Zlatkovic76874e42003-08-25 09:05:12 +0000921XMLPUBFUN int XMLCALL
922 xmlParseBalancedChunkMemory(xmlDocPtr doc,
Owen Taylor3473f882001-02-23 17:55:21 +0000923 xmlSAXHandlerPtr sax,
924 void *user_data,
925 int depth,
926 const xmlChar *string,
Daniel Veillardcda96922001-08-21 10:56:31 +0000927 xmlNodePtr *lst);
William M. Brack21e4ef22005-01-02 09:53:13 +0000928#endif /* LIBXML_SAX1_ENABLED */
Daniel Veillard29b17482004-08-16 00:39:03 +0000929XMLPUBFUN xmlParserErrors XMLCALL
930 xmlParseInNodeContext (xmlNodePtr node,
931 const char *data,
932 int datalen,
933 int options,
934 xmlNodePtr *lst);
William M. Brack21e4ef22005-01-02 09:53:13 +0000935#ifdef LIBXML_SAX1_ENABLED
Igor Zlatkovic76874e42003-08-25 09:05:12 +0000936XMLPUBFUN int XMLCALL
937 xmlParseBalancedChunkMemoryRecover(xmlDocPtr doc,
Daniel Veillard58e44c92002-08-02 22:19:49 +0000938 xmlSAXHandlerPtr sax,
939 void *user_data,
940 int depth,
941 const xmlChar *string,
942 xmlNodePtr *lst,
943 int recover);
Igor Zlatkovic76874e42003-08-25 09:05:12 +0000944XMLPUBFUN int XMLCALL
945 xmlParseExternalEntity (xmlDocPtr doc,
Owen Taylor3473f882001-02-23 17:55:21 +0000946 xmlSAXHandlerPtr sax,
947 void *user_data,
948 int depth,
949 const xmlChar *URL,
950 const xmlChar *ID,
Daniel Veillardcda96922001-08-21 10:56:31 +0000951 xmlNodePtr *lst);
William M. Brack21e4ef22005-01-02 09:53:13 +0000952#endif /* LIBXML_SAX1_ENABLED */
Igor Zlatkovic76874e42003-08-25 09:05:12 +0000953XMLPUBFUN int XMLCALL
954 xmlParseCtxtExternalEntity(xmlParserCtxtPtr ctx,
Owen Taylor3473f882001-02-23 17:55:21 +0000955 const xmlChar *URL,
956 const xmlChar *ID,
Daniel Veillardcda96922001-08-21 10:56:31 +0000957 xmlNodePtr *lst);
Owen Taylor3473f882001-02-23 17:55:21 +0000958
Daniel Veillardf69bb4b2001-05-19 13:24:56 +0000959/*
Owen Taylor3473f882001-02-23 17:55:21 +0000960 * Parser contexts handling.
961 */
Daniel Veillard2b8c4a12003-10-02 22:28:19 +0000962XMLPUBFUN xmlParserCtxtPtr XMLCALL
963 xmlNewParserCtxt (void);
Igor Zlatkovic76874e42003-08-25 09:05:12 +0000964XMLPUBFUN int XMLCALL
965 xmlInitParserCtxt (xmlParserCtxtPtr ctxt);
966XMLPUBFUN void XMLCALL
967 xmlClearParserCtxt (xmlParserCtxtPtr ctxt);
968XMLPUBFUN void XMLCALL
969 xmlFreeParserCtxt (xmlParserCtxtPtr ctxt);
William M. Brack21e4ef22005-01-02 09:53:13 +0000970#ifdef LIBXML_SAX1_ENABLED
Igor Zlatkovic76874e42003-08-25 09:05:12 +0000971XMLPUBFUN void XMLCALL
972 xmlSetupParserForBuffer (xmlParserCtxtPtr ctxt,
Owen Taylor3473f882001-02-23 17:55:21 +0000973 const xmlChar* buffer,
Daniel Veillard963d2ae2002-01-20 22:08:18 +0000974 const char *filename);
William M. Brack21e4ef22005-01-02 09:53:13 +0000975#endif /* LIBXML_SAX1_ENABLED */
Igor Zlatkovic76874e42003-08-25 09:05:12 +0000976XMLPUBFUN xmlParserCtxtPtr XMLCALL
Daniel Veillard16fa96c2003-09-23 21:50:54 +0000977 xmlCreateDocParserCtxt (const xmlChar *cur);
Owen Taylor3473f882001-02-23 17:55:21 +0000978
William M. Brack21e4ef22005-01-02 09:53:13 +0000979#ifdef LIBXML_LEGACY_ENABLED
Daniel Veillardf69bb4b2001-05-19 13:24:56 +0000980/*
Owen Taylor3473f882001-02-23 17:55:21 +0000981 * Reading/setting optional parsing features.
982 */
Igor Zlatkovic76874e42003-08-25 09:05:12 +0000983XMLPUBFUN int XMLCALL
984 xmlGetFeaturesList (int *len,
Owen Taylor3473f882001-02-23 17:55:21 +0000985 const char **result);
Igor Zlatkovic76874e42003-08-25 09:05:12 +0000986XMLPUBFUN int XMLCALL
987 xmlGetFeature (xmlParserCtxtPtr ctxt,
Owen Taylor3473f882001-02-23 17:55:21 +0000988 const char *name,
989 void *result);
Igor Zlatkovic76874e42003-08-25 09:05:12 +0000990XMLPUBFUN int XMLCALL
991 xmlSetFeature (xmlParserCtxtPtr ctxt,
Owen Taylor3473f882001-02-23 17:55:21 +0000992 const char *name,
993 void *value);
William M. Brack21e4ef22005-01-02 09:53:13 +0000994#endif /* LIBXML_LEGACY_ENABLED */
Owen Taylor3473f882001-02-23 17:55:21 +0000995
Daniel Veillard73b013f2003-09-30 12:36:01 +0000996#ifdef LIBXML_PUSH_ENABLED
Daniel Veillardf69bb4b2001-05-19 13:24:56 +0000997/*
Daniel Veillard61f26172002-03-12 18:46:39 +0000998 * Interfaces for the Push mode.
Owen Taylor3473f882001-02-23 17:55:21 +0000999 */
Igor Zlatkovic76874e42003-08-25 09:05:12 +00001000XMLPUBFUN xmlParserCtxtPtr XMLCALL
1001 xmlCreatePushParserCtxt(xmlSAXHandlerPtr sax,
Owen Taylor3473f882001-02-23 17:55:21 +00001002 void *user_data,
1003 const char *chunk,
1004 int size,
1005 const char *filename);
Igor Zlatkovic76874e42003-08-25 09:05:12 +00001006XMLPUBFUN int XMLCALL
1007 xmlParseChunk (xmlParserCtxtPtr ctxt,
Owen Taylor3473f882001-02-23 17:55:21 +00001008 const char *chunk,
1009 int size,
1010 int terminate);
Daniel Veillard73b013f2003-09-30 12:36:01 +00001011#endif /* LIBXML_PUSH_ENABLED */
Owen Taylor3473f882001-02-23 17:55:21 +00001012
Daniel Veillardf69bb4b2001-05-19 13:24:56 +00001013/*
Daniel Veillard61f26172002-03-12 18:46:39 +00001014 * Special I/O mode.
Owen Taylor3473f882001-02-23 17:55:21 +00001015 */
1016
Igor Zlatkovic76874e42003-08-25 09:05:12 +00001017XMLPUBFUN xmlParserCtxtPtr XMLCALL
1018 xmlCreateIOParserCtxt (xmlSAXHandlerPtr sax,
Owen Taylor3473f882001-02-23 17:55:21 +00001019 void *user_data,
1020 xmlInputReadCallback ioread,
1021 xmlInputCloseCallback ioclose,
1022 void *ioctx,
1023 xmlCharEncoding enc);
1024
Igor Zlatkovic76874e42003-08-25 09:05:12 +00001025XMLPUBFUN xmlParserInputPtr XMLCALL
1026 xmlNewIOInputStream (xmlParserCtxtPtr ctxt,
Owen Taylor3473f882001-02-23 17:55:21 +00001027 xmlParserInputBufferPtr input,
1028 xmlCharEncoding enc);
1029
Daniel Veillardf69bb4b2001-05-19 13:24:56 +00001030/*
Daniel Veillard61f26172002-03-12 18:46:39 +00001031 * Node infos.
Owen Taylor3473f882001-02-23 17:55:21 +00001032 */
Igor Zlatkovic76874e42003-08-25 09:05:12 +00001033XMLPUBFUN const xmlParserNodeInfo* XMLCALL
Daniel Veillard963d2ae2002-01-20 22:08:18 +00001034 xmlParserFindNodeInfo (const xmlParserCtxtPtr ctxt,
1035 const xmlNodePtr node);
Igor Zlatkovic76874e42003-08-25 09:05:12 +00001036XMLPUBFUN void XMLCALL
1037 xmlInitNodeInfoSeq (xmlParserNodeInfoSeqPtr seq);
1038XMLPUBFUN void XMLCALL
1039 xmlClearNodeInfoSeq (xmlParserNodeInfoSeqPtr seq);
1040XMLPUBFUN unsigned long XMLCALL
1041 xmlParserFindNodeInfoIndex(const xmlParserNodeInfoSeqPtr seq,
Daniel Veillard963d2ae2002-01-20 22:08:18 +00001042 const xmlNodePtr node);
Igor Zlatkovic76874e42003-08-25 09:05:12 +00001043XMLPUBFUN void XMLCALL
1044 xmlParserAddNodeInfo (xmlParserCtxtPtr ctxt,
Daniel Veillard963d2ae2002-01-20 22:08:18 +00001045 const xmlParserNodeInfoPtr info);
Owen Taylor3473f882001-02-23 17:55:21 +00001046
1047/*
Daniel Veillard61f26172002-03-12 18:46:39 +00001048 * External entities handling actually implemented in xmlIO.
Owen Taylor3473f882001-02-23 17:55:21 +00001049 */
1050
Igor Zlatkovic76874e42003-08-25 09:05:12 +00001051XMLPUBFUN void XMLCALL
1052 xmlSetExternalEntityLoader(xmlExternalEntityLoader f);
1053XMLPUBFUN xmlExternalEntityLoader XMLCALL
Owen Taylor3473f882001-02-23 17:55:21 +00001054 xmlGetExternalEntityLoader(void);
Igor Zlatkovic76874e42003-08-25 09:05:12 +00001055XMLPUBFUN xmlParserInputPtr XMLCALL
Owen Taylor3473f882001-02-23 17:55:21 +00001056 xmlLoadExternalEntity (const char *URL,
1057 const char *ID,
Daniel Veillard9d06d302002-01-22 18:15:52 +00001058 xmlParserCtxtPtr ctxt);
Daniel Veillard36711902004-02-11 13:25:26 +00001059
1060/*
1061 * Index lookup, actually implemented in the encoding module
1062 */
1063XMLPUBFUN long XMLCALL
1064 xmlByteConsumed (xmlParserCtxtPtr ctxt);
1065
Daniel Veillard16fa96c2003-09-23 21:50:54 +00001066/*
1067 * New set of simpler/more flexible APIs
1068 */
1069/**
1070 * xmlParserOption:
1071 *
1072 * This is the set of XML parser options that can be passed down
1073 * to the xmlReadDoc() and similar calls.
1074 */
1075typedef enum {
1076 XML_PARSE_RECOVER = 1<<0, /* recover on errors */
1077 XML_PARSE_NOENT = 1<<1, /* substitute entities */
1078 XML_PARSE_DTDLOAD = 1<<2, /* load the external subset */
1079 XML_PARSE_DTDATTR = 1<<3, /* default DTD attributes */
1080 XML_PARSE_DTDVALID = 1<<4, /* validate with the DTD */
1081 XML_PARSE_NOERROR = 1<<5, /* suppress error reports */
1082 XML_PARSE_NOWARNING = 1<<6, /* suppress warning reports */
1083 XML_PARSE_PEDANTIC = 1<<7, /* pedantic error reporting */
1084 XML_PARSE_NOBLANKS = 1<<8, /* remove blank nodes */
1085 XML_PARSE_SAX1 = 1<<9, /* use the SAX1 interface internally */
1086 XML_PARSE_XINCLUDE = 1<<10,/* Implement XInclude substitition */
Daniel Veillarde96a2a42003-09-24 21:23:56 +00001087 XML_PARSE_NONET = 1<<11,/* Forbid network access */
Daniel Veillard9475a352003-09-26 12:47:50 +00001088 XML_PARSE_NODICT = 1<<12,/* Do not reuse the context dictionnary */
1089 XML_PARSE_NSCLEAN = 1<<13,/* remove redundant namespaces declarations */
Daniel Veillardc14c3892004-08-16 12:34:50 +00001090 XML_PARSE_NOCDATA = 1<<14,/* merge CDATA as text nodes */
1091 XML_PARSE_NOXINCNODE= 1<<15 /* do not generate XINCLUDE START/END nodes */
Daniel Veillard16fa96c2003-09-23 21:50:54 +00001092} xmlParserOption;
1093
1094XMLPUBFUN void XMLCALL
1095 xmlCtxtReset (xmlParserCtxtPtr ctxt);
1096XMLPUBFUN int XMLCALL
Daniel Veillard9ba8e382003-10-28 21:31:45 +00001097 xmlCtxtResetPush (xmlParserCtxtPtr ctxt,
1098 const char *chunk,
1099 int size,
1100 const char *filename,
1101 const char *encoding);
1102XMLPUBFUN int XMLCALL
Daniel Veillard16fa96c2003-09-23 21:50:54 +00001103 xmlCtxtUseOptions (xmlParserCtxtPtr ctxt,
1104 int options);
1105XMLPUBFUN xmlDocPtr XMLCALL
1106 xmlReadDoc (const xmlChar *cur,
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
Daniel Veillard60942de2003-09-25 21:05:58 +00001111 xmlReadFile (const char *URL,
Daniel Veillard16fa96c2003-09-23 21:50:54 +00001112 const char *encoding,
1113 int options);
1114XMLPUBFUN xmlDocPtr XMLCALL
1115 xmlReadMemory (const char *buffer,
1116 int size,
Daniel Veillard60942de2003-09-25 21:05:58 +00001117 const char *URL,
Daniel Veillard16fa96c2003-09-23 21:50:54 +00001118 const char *encoding,
1119 int options);
1120XMLPUBFUN xmlDocPtr XMLCALL
1121 xmlReadFd (int fd,
Daniel Veillard60942de2003-09-25 21:05:58 +00001122 const char *URL,
Daniel Veillard16fa96c2003-09-23 21:50:54 +00001123 const char *encoding,
1124 int options);
1125XMLPUBFUN xmlDocPtr XMLCALL
1126 xmlReadIO (xmlInputReadCallback ioread,
1127 xmlInputCloseCallback ioclose,
1128 void *ioctx,
Daniel Veillard60942de2003-09-25 21:05:58 +00001129 const char *URL,
Daniel Veillard16fa96c2003-09-23 21:50:54 +00001130 const char *encoding,
1131 int options);
1132XMLPUBFUN xmlDocPtr XMLCALL
1133 xmlCtxtReadDoc (xmlParserCtxtPtr ctxt,
1134 const xmlChar *cur,
Daniel Veillard60942de2003-09-25 21:05:58 +00001135 const char *URL,
Daniel Veillard16fa96c2003-09-23 21:50:54 +00001136 const char *encoding,
1137 int options);
1138XMLPUBFUN xmlDocPtr XMLCALL
1139 xmlCtxtReadFile (xmlParserCtxtPtr ctxt,
1140 const char *filename,
1141 const char *encoding,
1142 int options);
1143XMLPUBFUN xmlDocPtr XMLCALL
1144 xmlCtxtReadMemory (xmlParserCtxtPtr ctxt,
1145 const char *buffer,
1146 int size,
Daniel Veillard60942de2003-09-25 21:05:58 +00001147 const char *URL,
Daniel Veillard16fa96c2003-09-23 21:50:54 +00001148 const char *encoding,
1149 int options);
1150XMLPUBFUN xmlDocPtr XMLCALL
1151 xmlCtxtReadFd (xmlParserCtxtPtr ctxt,
1152 int fd,
Daniel Veillard60942de2003-09-25 21:05:58 +00001153 const char *URL,
Daniel Veillard16fa96c2003-09-23 21:50:54 +00001154 const char *encoding,
1155 int options);
1156XMLPUBFUN xmlDocPtr XMLCALL
1157 xmlCtxtReadIO (xmlParserCtxtPtr ctxt,
1158 xmlInputReadCallback ioread,
1159 xmlInputCloseCallback ioclose,
1160 void *ioctx,
Daniel Veillard60942de2003-09-25 21:05:58 +00001161 const char *URL,
Daniel Veillard16fa96c2003-09-23 21:50:54 +00001162 const char *encoding,
1163 int options);
Owen Taylor3473f882001-02-23 17:55:21 +00001164
1165#ifdef __cplusplus
1166}
1167#endif
Owen Taylor3473f882001-02-23 17:55:21 +00001168#endif /* __XML_PARSER_H__ */
1169