blob: 70ee4b7ec31cd3709ec43f2f6c7a88574604ae68 [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>
Daniel Veillard2b8c4a12003-10-02 22:28:19 +000018#include <libxml/xmlerror.h>
Owen Taylor3473f882001-02-23 17:55:21 +000019
20#ifdef __cplusplus
21extern "C" {
22#endif
23
Daniel Veillard5e2dace2001-07-18 19:30:27 +000024/**
25 * XML_DEFAULT_VERSION:
26 *
27 * The default version of XML used: 1.0
Owen Taylor3473f882001-02-23 17:55:21 +000028 */
29#define XML_DEFAULT_VERSION "1.0"
30
31/**
Daniel Veillardf69bb4b2001-05-19 13:24:56 +000032 * xmlParserInput:
33 *
Daniel Veillard61f26172002-03-12 18:46:39 +000034 * An xmlParserInput is an input flow for the XML processor.
Owen Taylor3473f882001-02-23 17:55:21 +000035 * Each entity parsed is associated an xmlParserInput (except the
36 * few predefined ones). This is the case both for internal entities
37 * - in which case the flow is already completely in memory - or
38 * external entities - in which case we use the buf structure for
39 * progressive reading and I18N conversions to the internal UTF-8 format.
40 */
41
Daniel Veillard9d06d302002-01-22 18:15:52 +000042/**
43 * xmlParserInputDeallocate:
44 * @str: the string to deallocate
45 *
Daniel Veillard61f26172002-03-12 18:46:39 +000046 * Callback for freeing some parser input allocations.
Daniel Veillard9d06d302002-01-22 18:15:52 +000047 */
48typedef void (* xmlParserInputDeallocate)(xmlChar *str);
Daniel Veillard5e2dace2001-07-18 19:30:27 +000049
Owen Taylor3473f882001-02-23 17:55:21 +000050struct _xmlParserInput {
51 /* Input buffer */
52 xmlParserInputBufferPtr buf; /* UTF-8 encoded buffer */
53
54 const char *filename; /* The file analyzed, if any */
Daniel Veillard60087f32001-10-10 09:45:09 +000055 const char *directory; /* the directory/base of the file */
Owen Taylor3473f882001-02-23 17:55:21 +000056 const xmlChar *base; /* Base of the array to parse */
57 const xmlChar *cur; /* Current char being parsed */
Daniel Veillardcbaf3992001-12-31 16:16:02 +000058 const xmlChar *end; /* end of the array to parse */
Owen Taylor3473f882001-02-23 17:55:21 +000059 int length; /* length if known */
60 int line; /* Current line */
61 int col; /* Current column */
Daniel Veillard3e59fc52003-04-18 12:34:58 +000062 /*
63 * NOTE: consumed is only tested for equality in the parser code,
64 * so even if there is an overflow this should not give troubles
65 * for parsing very large instances.
66 */
67 unsigned long consumed; /* How many xmlChars already consumed */
Owen Taylor3473f882001-02-23 17:55:21 +000068 xmlParserInputDeallocate free; /* function to deallocate the base */
69 const xmlChar *encoding; /* the encoding string for entity */
70 const xmlChar *version; /* the version string for entity */
71 int standalone; /* Was that entity marked standalone */
Daniel Veillardbdbe0d42003-09-14 19:56:14 +000072 int id; /* an unique identifier for the entity */
Owen Taylor3473f882001-02-23 17:55:21 +000073};
74
75/**
Daniel Veillardf69bb4b2001-05-19 13:24:56 +000076 * xmlParserNodeInfo:
77 *
Daniel Veillard61f26172002-03-12 18:46:39 +000078 * The parser can be asked to collect Node informations, i.e. at what
Owen Taylor3473f882001-02-23 17:55:21 +000079 * place in the file they were detected.
80 * NOTE: This is off by default and not very well tested.
81 */
82typedef struct _xmlParserNodeInfo xmlParserNodeInfo;
83typedef xmlParserNodeInfo *xmlParserNodeInfoPtr;
84
85struct _xmlParserNodeInfo {
86 const struct _xmlNode* node;
87 /* Position & line # that text that created the node begins & ends on */
88 unsigned long begin_pos;
89 unsigned long begin_line;
90 unsigned long end_pos;
91 unsigned long end_line;
92};
93
94typedef struct _xmlParserNodeInfoSeq xmlParserNodeInfoSeq;
95typedef xmlParserNodeInfoSeq *xmlParserNodeInfoSeqPtr;
96struct _xmlParserNodeInfoSeq {
97 unsigned long maximum;
98 unsigned long length;
99 xmlParserNodeInfo* buffer;
100};
101
102/**
Daniel Veillardf69bb4b2001-05-19 13:24:56 +0000103 * xmlParserInputState:
104 *
Daniel Veillard61f26172002-03-12 18:46:39 +0000105 * The parser is now working also as a state based parser.
106 * The recursive one use the state info for entities processing.
Owen Taylor3473f882001-02-23 17:55:21 +0000107 */
108typedef enum {
109 XML_PARSER_EOF = -1, /* nothing is to be parsed */
110 XML_PARSER_START = 0, /* nothing has been parsed */
111 XML_PARSER_MISC, /* Misc* before int subset */
Daniel Veillardcbaf3992001-12-31 16:16:02 +0000112 XML_PARSER_PI, /* Within a processing instruction */
Owen Taylor3473f882001-02-23 17:55:21 +0000113 XML_PARSER_DTD, /* within some DTD content */
114 XML_PARSER_PROLOG, /* Misc* after internal subset */
115 XML_PARSER_COMMENT, /* within a comment */
116 XML_PARSER_START_TAG, /* within a start tag */
117 XML_PARSER_CONTENT, /* within the content */
118 XML_PARSER_CDATA_SECTION, /* within a CDATA section */
119 XML_PARSER_END_TAG, /* within a closing tag */
120 XML_PARSER_ENTITY_DECL, /* within an entity declaration */
121 XML_PARSER_ENTITY_VALUE, /* within an entity value in a decl */
122 XML_PARSER_ATTRIBUTE_VALUE, /* within an attribute value */
123 XML_PARSER_SYSTEM_LITERAL, /* within a SYSTEM value */
124 XML_PARSER_EPILOG, /* the Misc* after the last end tag */
Daniel Veillard4a7ae502002-02-18 19:18:17 +0000125 XML_PARSER_IGNORE, /* within an IGNORED section */
126 XML_PARSER_PUBLIC_LITERAL /* within a PUBLIC value */
Owen Taylor3473f882001-02-23 17:55:21 +0000127} xmlParserInputState;
128
129/**
Daniel Veillardd16df9f2001-05-23 13:44:21 +0000130 * XML_DETECT_IDS:
131 *
Daniel Veillard61f26172002-03-12 18:46:39 +0000132 * Bit in the loadsubset context field to tell to do ID/REFs lookups.
133 * Use it to initialize xmlLoadExtDtdDefaultValue.
Daniel Veillardd16df9f2001-05-23 13:44:21 +0000134 */
135#define XML_DETECT_IDS 2
136
137/**
138 * XML_COMPLETE_ATTRS:
139 *
140 * Bit in the loadsubset context field to tell to do complete the
Daniel Veillard61f26172002-03-12 18:46:39 +0000141 * elements attributes lists with the ones defaulted from the DTDs.
142 * Use it to initialize xmlLoadExtDtdDefaultValue.
Daniel Veillardd16df9f2001-05-23 13:44:21 +0000143 */
144#define XML_COMPLETE_ATTRS 4
145
146/**
Daniel Veillardef8dd7b2003-03-23 12:02:56 +0000147 * XML_SKIP_IDS:
148 *
149 * Bit in the loadsubset context field to tell to not do ID/REFs registration.
150 * Used to initialize xmlLoadExtDtdDefaultValue in some special cases.
151 */
152#define XML_SKIP_IDS 8
153
154/**
Daniel Veillardf69bb4b2001-05-19 13:24:56 +0000155 * xmlParserCtxt:
156 *
Owen Taylor3473f882001-02-23 17:55:21 +0000157 * The parser context.
Daniel Veillard61f26172002-03-12 18:46:39 +0000158 * NOTE This doesn't completely define the parser state, the (current ?)
Owen Taylor3473f882001-02-23 17:55:21 +0000159 * design of the parser uses recursive function calls since this allow
160 * and easy mapping from the production rules of the specification
161 * to the actual code. The drawback is that the actual function call
162 * also reflect the parser state. However most of the parsing routines
163 * takes as the only argument the parser context pointer, so migrating
164 * to a state based parser for progressive parsing shouldn't be too hard.
165 */
Owen Taylor3473f882001-02-23 17:55:21 +0000166struct _xmlParserCtxt {
167 struct _xmlSAXHandler *sax; /* The SAX handler */
168 void *userData; /* For SAX interface only, used by DOM build */
169 xmlDocPtr myDoc; /* the document being built */
170 int wellFormed; /* is the document well formed */
171 int replaceEntities; /* shall we replace entities ? */
172 const xmlChar *version; /* the XML version string */
173 const xmlChar *encoding; /* the declared encoding, if any */
174 int standalone; /* standalone document */
175 int html; /* an HTML(1)/Docbook(2) document */
176
177 /* Input stream stack */
178 xmlParserInputPtr input; /* Current input stream */
179 int inputNr; /* Number of current input streams */
180 int inputMax; /* Max number of input streams */
181 xmlParserInputPtr *inputTab; /* stack of inputs */
182
183 /* Node analysis stack only used for DOM building */
184 xmlNodePtr node; /* Current parsed Node */
185 int nodeNr; /* Depth of the parsing stack */
186 int nodeMax; /* Max depth of the parsing stack */
187 xmlNodePtr *nodeTab; /* array of nodes */
188
189 int record_info; /* Whether node info should be kept */
190 xmlParserNodeInfoSeq node_seq; /* info about each node parsed */
191
192 int errNo; /* error code */
193
194 int hasExternalSubset; /* reference and external subset */
195 int hasPErefs; /* the internal subset has PE refs */
196 int external; /* are we parsing an external entity */
197
198 int valid; /* is the document valid */
199 int validate; /* shall we try to validate ? */
200 xmlValidCtxt vctxt; /* The validity context */
201
202 xmlParserInputState instate; /* current type of input */
203 int token; /* next char look-ahead */
204
205 char *directory; /* the data directory */
206
207 /* Node name stack */
Daniel Veillard2fdbd322003-08-18 12:15:38 +0000208 const xmlChar *name; /* Current parsed Node */
Owen Taylor3473f882001-02-23 17:55:21 +0000209 int nameNr; /* Depth of the parsing stack */
210 int nameMax; /* Max depth of the parsing stack */
Daniel Veillard2fdbd322003-08-18 12:15:38 +0000211 const xmlChar * *nameTab; /* array of nodes */
Owen Taylor3473f882001-02-23 17:55:21 +0000212
213 long nbChars; /* number of xmlChar processed */
214 long checkIndex; /* used by progressive parsing lookup */
215 int keepBlanks; /* ugly but ... */
216 int disableSAX; /* SAX callbacks are disabled */
217 int inSubset; /* Parsing is in int 1/ext 2 subset */
Daniel Veillard2fdbd322003-08-18 12:15:38 +0000218 const xmlChar * intSubName; /* name of subset */
Owen Taylor3473f882001-02-23 17:55:21 +0000219 xmlChar * extSubURI; /* URI of external subset */
220 xmlChar * extSubSystem; /* SYSTEM ID of external subset */
221
222 /* xml:space values */
223 int * space; /* Should the parser preserve spaces */
224 int spaceNr; /* Depth of the parsing stack */
225 int spaceMax; /* Max depth of the parsing stack */
226 int * spaceTab; /* array of space infos */
227
228 int depth; /* to prevent entity substitution loops */
229 xmlParserInputPtr entity; /* used to check entities boundaries */
230 int charset; /* encoding of the in-memory content
231 actually an xmlCharEncoding */
232 int nodelen; /* Those two fields are there to */
233 int nodemem; /* Speed up large node parsing */
234 int pedantic; /* signal pedantic warnings */
235 void *_private; /* For user data, libxml won't touch it */
236
237 int loadsubset; /* should the external subset be loaded */
Daniel Veillardd9bad132001-07-23 19:39:43 +0000238 int linenumbers; /* set line number in element content */
Daniel Veillard5d90b6c2001-08-22 14:29:45 +0000239 void *catalogs; /* document's own catalog */
Daniel Veillarddad3f682002-11-17 16:47:27 +0000240 int recovery; /* run in recovery mode */
Daniel Veillarda880b122003-04-21 21:36:41 +0000241 int progressive; /* is this a progressive parsing */
Daniel Veillard2fdbd322003-08-18 12:15:38 +0000242 xmlDictPtr dict; /* dictionnary for the parser */
Daniel Veillard40412cd2003-09-03 13:28:32 +0000243 const xmlChar * *atts; /* array for the attributes callbacks */
Daniel Veillard6155d8a2003-08-19 15:01:28 +0000244 int maxatts; /* the size of the array */
Daniel Veillard40412cd2003-09-03 13:28:32 +0000245 int docdict; /* use strings from dict to build tree */
Daniel Veillard0fb18932003-09-07 09:14:37 +0000246
247 /*
248 * pre-interned strings
249 */
250 const xmlChar *str_xml;
251 const xmlChar *str_xmlns;
Daniel Veillard07cb8222003-09-10 10:51:05 +0000252 const xmlChar *str_xml_ns;
Daniel Veillard0fb18932003-09-07 09:14:37 +0000253
254 /*
Daniel Veillard07cb8222003-09-10 10:51:05 +0000255 * Everything below is used only by the new SAX mode
Daniel Veillard0fb18932003-09-07 09:14:37 +0000256 */
257 int sax2; /* operating in the new SAX mode */
258 int nsNr; /* the number of inherited namespaces */
259 int nsMax; /* the size of the arrays */
260 const xmlChar * *nsTab; /* the array of prefix/namespace name */
Daniel Veillard07cb8222003-09-10 10:51:05 +0000261 int *attallocs; /* which attribute were allocated */
262 void * *pushTab; /* array of data for push */
263 xmlHashTablePtr attsDefault; /* defaulted attributes if any */
264 xmlHashTablePtr attsSpecial; /* non-CDATA attributes if any */
Daniel Veillard3b7840c2003-09-11 23:42:01 +0000265 int nsWellFormed; /* is the document XML Nanespace okay */
Daniel Veillard9475a352003-09-26 12:47:50 +0000266 int options; /* Extra options */
Daniel Veillard8a44e592003-09-15 14:50:06 +0000267
268 /*
269 * Those fields are needed only for treaming parsing so far
270 */
Daniel Veillard9475a352003-09-26 12:47:50 +0000271 int dictNames; /* Use dictionary names for the tree */
272 int freeElemsNr; /* number of freed element nodes */
273 xmlNodePtr freeElems; /* List of freed element nodes */
274 int freeAttrsNr; /* number of freed attributes nodes */
275 xmlAttrPtr freeAttrs; /* List of freed attributes nodes */
Daniel Veillard2b8c4a12003-10-02 22:28:19 +0000276
277 /*
278 * the complete error informations for the last error.
279 */
280 xmlError lastError;
Owen Taylor3473f882001-02-23 17:55:21 +0000281};
282
283/**
Daniel Veillardf69bb4b2001-05-19 13:24:56 +0000284 * xmlSAXLocator:
285 *
Daniel Veillard61f26172002-03-12 18:46:39 +0000286 * A SAX Locator.
Owen Taylor3473f882001-02-23 17:55:21 +0000287 */
Owen Taylor3473f882001-02-23 17:55:21 +0000288struct _xmlSAXLocator {
289 const xmlChar *(*getPublicId)(void *ctx);
290 const xmlChar *(*getSystemId)(void *ctx);
291 int (*getLineNumber)(void *ctx);
292 int (*getColumnNumber)(void *ctx);
293};
294
295/**
Daniel Veillardf69bb4b2001-05-19 13:24:56 +0000296 * xmlSAXHandler:
297 *
Daniel Veillard61f26172002-03-12 18:46:39 +0000298 * A SAX handler is bunch of callbacks called by the parser when processing
Owen Taylor3473f882001-02-23 17:55:21 +0000299 * of the input generate data or structure informations.
300 */
301
Daniel Veillard9d06d302002-01-22 18:15:52 +0000302/**
303 * resolveEntitySAXFunc:
304 * @ctx: the user data (XML parser context)
305 * @publicId: The public ID of the entity
306 * @systemId: The system ID of the entity
307 *
308 * Callback:
309 * The entity loader, to control the loading of external entities,
310 * the application can either:
311 * - override this resolveEntity() callback in the SAX block
312 * - or better use the xmlSetExternalEntityLoader() function to
313 * set up it's own entity resolution routine
314 *
315 * Returns the xmlParserInputPtr if inlined or NULL for DOM behaviour.
316 */
Owen Taylor3473f882001-02-23 17:55:21 +0000317typedef xmlParserInputPtr (*resolveEntitySAXFunc) (void *ctx,
Daniel Veillard9d06d302002-01-22 18:15:52 +0000318 const xmlChar *publicId,
319 const xmlChar *systemId);
320/**
321 * internalSubsetSAXFunc:
322 * @ctx: the user data (XML parser context)
323 * @name: the root element name
324 * @ExternalID: the external ID
325 * @SystemID: the SYSTEM ID (e.g. filename or URL)
326 *
327 * Callback on internal subset declaration.
328 */
329typedef void (*internalSubsetSAXFunc) (void *ctx,
330 const xmlChar *name,
331 const xmlChar *ExternalID,
332 const xmlChar *SystemID);
333/**
334 * externalSubsetSAXFunc:
335 * @ctx: the user data (XML parser context)
336 * @name: the root element name
337 * @ExternalID: the external ID
338 * @SystemID: the SYSTEM ID (e.g. filename or URL)
339 *
340 * Callback on external subset declaration.
341 */
342typedef void (*externalSubsetSAXFunc) (void *ctx,
343 const xmlChar *name,
344 const xmlChar *ExternalID,
345 const xmlChar *SystemID);
346/**
347 * getEntitySAXFunc:
348 * @ctx: the user data (XML parser context)
349 * @name: The entity name
350 *
Daniel Veillard61f26172002-03-12 18:46:39 +0000351 * Get an entity by name.
Daniel Veillard9d06d302002-01-22 18:15:52 +0000352 *
353 * Returns the xmlEntityPtr if found.
354 */
Owen Taylor3473f882001-02-23 17:55:21 +0000355typedef xmlEntityPtr (*getEntitySAXFunc) (void *ctx,
Daniel Veillard9d06d302002-01-22 18:15:52 +0000356 const xmlChar *name);
357/**
358 * getParameterEntitySAXFunc:
359 * @ctx: the user data (XML parser context)
360 * @name: The entity name
361 *
Daniel Veillard61f26172002-03-12 18:46:39 +0000362 * Get a parameter entity by name.
Daniel Veillard9d06d302002-01-22 18:15:52 +0000363 *
364 * Returns the xmlEntityPtr if found.
365 */
Owen Taylor3473f882001-02-23 17:55:21 +0000366typedef xmlEntityPtr (*getParameterEntitySAXFunc) (void *ctx,
Daniel Veillard9d06d302002-01-22 18:15:52 +0000367 const xmlChar *name);
368/**
369 * entityDeclSAXFunc:
370 * @ctx: the user data (XML parser context)
371 * @name: the entity name
372 * @type: the entity type
373 * @publicId: The public ID of the entity
374 * @systemId: The system ID of the entity
375 * @content: the entity value (without processing).
376 *
Daniel Veillard61f26172002-03-12 18:46:39 +0000377 * An entity definition has been parsed.
Daniel Veillard9d06d302002-01-22 18:15:52 +0000378 */
Owen Taylor3473f882001-02-23 17:55:21 +0000379typedef void (*entityDeclSAXFunc) (void *ctx,
Daniel Veillard9d06d302002-01-22 18:15:52 +0000380 const xmlChar *name,
381 int type,
382 const xmlChar *publicId,
383 const xmlChar *systemId,
384 xmlChar *content);
385/**
386 * notationDeclSAXFunc:
387 * @ctx: the user data (XML parser context)
388 * @name: The name of the notation
389 * @publicId: The public ID of the entity
390 * @systemId: The system ID of the entity
391 *
392 * What to do when a notation declaration has been parsed.
393 */
394typedef void (*notationDeclSAXFunc)(void *ctx,
395 const xmlChar *name,
396 const xmlChar *publicId,
397 const xmlChar *systemId);
398/**
399 * attributeDeclSAXFunc:
400 * @ctx: the user data (XML parser context)
401 * @elem: the name of the element
402 * @fullname: the attribute name
403 * @type: the attribute type
404 * @def: the type of default value
405 * @defaultValue: the attribute default value
406 * @tree: the tree of enumerated value set
407 *
Daniel Veillard61f26172002-03-12 18:46:39 +0000408 * An attribute definition has been parsed.
Daniel Veillard9d06d302002-01-22 18:15:52 +0000409 */
410typedef void (*attributeDeclSAXFunc)(void *ctx,
411 const xmlChar *elem,
412 const xmlChar *fullname,
413 int type,
414 int def,
415 const xmlChar *defaultValue,
416 xmlEnumerationPtr tree);
417/**
418 * elementDeclSAXFunc:
419 * @ctx: the user data (XML parser context)
420 * @name: the element name
421 * @type: the element type
422 * @content: the element value tree
423 *
Daniel Veillard61f26172002-03-12 18:46:39 +0000424 * An element definition has been parsed.
Daniel Veillard9d06d302002-01-22 18:15:52 +0000425 */
426typedef void (*elementDeclSAXFunc)(void *ctx,
427 const xmlChar *name,
428 int type,
429 xmlElementContentPtr content);
430/**
431 * unparsedEntityDeclSAXFunc:
432 * @ctx: the user data (XML parser context)
433 * @name: The name of the entity
434 * @publicId: The public ID of the entity
435 * @systemId: The system ID of the entity
436 * @notationName: the name of the notation
437 *
Daniel Veillard61f26172002-03-12 18:46:39 +0000438 * What to do when an unparsed entity declaration is parsed.
Daniel Veillard9d06d302002-01-22 18:15:52 +0000439 */
Owen Taylor3473f882001-02-23 17:55:21 +0000440typedef void (*unparsedEntityDeclSAXFunc)(void *ctx,
Daniel Veillard9d06d302002-01-22 18:15:52 +0000441 const xmlChar *name,
442 const xmlChar *publicId,
443 const xmlChar *systemId,
444 const xmlChar *notationName);
445/**
446 * setDocumentLocatorSAXFunc:
447 * @ctx: the user data (XML parser context)
448 * @loc: A SAX Locator
449 *
Daniel Veillard61f26172002-03-12 18:46:39 +0000450 * Receive the document locator at startup, actually xmlDefaultSAXLocator.
Daniel Veillard9d06d302002-01-22 18:15:52 +0000451 * Everything is available on the context, so this is useless in our case.
452 */
Owen Taylor3473f882001-02-23 17:55:21 +0000453typedef void (*setDocumentLocatorSAXFunc) (void *ctx,
Daniel Veillard9d06d302002-01-22 18:15:52 +0000454 xmlSAXLocatorPtr loc);
455/**
456 * startDocumentSAXFunc:
457 * @ctx: the user data (XML parser context)
458 *
Daniel Veillard61f26172002-03-12 18:46:39 +0000459 * Called when the document start being processed.
Daniel Veillard9d06d302002-01-22 18:15:52 +0000460 */
Owen Taylor3473f882001-02-23 17:55:21 +0000461typedef void (*startDocumentSAXFunc) (void *ctx);
Daniel Veillard9d06d302002-01-22 18:15:52 +0000462/**
463 * endDocumentSAXFunc:
464 * @ctx: the user data (XML parser context)
465 *
Daniel Veillard61f26172002-03-12 18:46:39 +0000466 * Called when the document end has been detected.
Daniel Veillard9d06d302002-01-22 18:15:52 +0000467 */
Owen Taylor3473f882001-02-23 17:55:21 +0000468typedef void (*endDocumentSAXFunc) (void *ctx);
Daniel Veillard9d06d302002-01-22 18:15:52 +0000469/**
470 * startElementSAXFunc:
471 * @ctx: the user data (XML parser context)
472 * @name: The element name, including namespace prefix
473 * @atts: An array of name/value attributes pairs, NULL terminated
474 *
Daniel Veillard61f26172002-03-12 18:46:39 +0000475 * Called when an opening tag has been processed.
Daniel Veillard9d06d302002-01-22 18:15:52 +0000476 */
477typedef void (*startElementSAXFunc) (void *ctx,
478 const xmlChar *name,
479 const xmlChar **atts);
480/**
481 * endElementSAXFunc:
482 * @ctx: the user data (XML parser context)
483 * @name: The element name
484 *
Daniel Veillard61f26172002-03-12 18:46:39 +0000485 * Called when the end of an element has been detected.
Daniel Veillard9d06d302002-01-22 18:15:52 +0000486 */
487typedef void (*endElementSAXFunc) (void *ctx,
488 const xmlChar *name);
489/**
490 * attributeSAXFunc:
491 * @ctx: the user data (XML parser context)
492 * @name: The attribute name, including namespace prefix
493 * @value: The attribute value
494 *
495 * Handle an attribute that has been read by the parser.
496 * The default handling is to convert the attribute into an
497 * DOM subtree and past it in a new xmlAttr element added to
498 * the element.
499 */
500typedef void (*attributeSAXFunc) (void *ctx,
501 const xmlChar *name,
502 const xmlChar *value);
503/**
504 * referenceSAXFunc:
505 * @ctx: the user data (XML parser context)
506 * @name: The entity name
507 *
Daniel Veillard61f26172002-03-12 18:46:39 +0000508 * Called when an entity reference is detected.
Daniel Veillard9d06d302002-01-22 18:15:52 +0000509 */
510typedef void (*referenceSAXFunc) (void *ctx,
511 const xmlChar *name);
512/**
513 * charactersSAXFunc:
514 * @ctx: the user data (XML parser context)
515 * @ch: a xmlChar string
516 * @len: the number of xmlChar
517 *
Daniel Veillard61f26172002-03-12 18:46:39 +0000518 * Receiving some chars from the parser.
Daniel Veillard9d06d302002-01-22 18:15:52 +0000519 */
520typedef void (*charactersSAXFunc) (void *ctx,
521 const xmlChar *ch,
522 int len);
523/**
524 * ignorableWhitespaceSAXFunc:
525 * @ctx: the user data (XML parser context)
526 * @ch: a xmlChar string
527 * @len: the number of xmlChar
528 *
Daniel Veillard61f26172002-03-12 18:46:39 +0000529 * Receiving some ignorable whitespaces from the parser.
530 * UNUSED: by default the DOM building will use characters.
Daniel Veillard9d06d302002-01-22 18:15:52 +0000531 */
Owen Taylor3473f882001-02-23 17:55:21 +0000532typedef void (*ignorableWhitespaceSAXFunc) (void *ctx,
Daniel Veillard9d06d302002-01-22 18:15:52 +0000533 const xmlChar *ch,
534 int len);
535/**
536 * processingInstructionSAXFunc:
537 * @ctx: the user data (XML parser context)
538 * @target: the target name
539 * @data: the PI data's
540 *
541 * A processing instruction has been parsed.
542 */
Owen Taylor3473f882001-02-23 17:55:21 +0000543typedef void (*processingInstructionSAXFunc) (void *ctx,
Daniel Veillard9d06d302002-01-22 18:15:52 +0000544 const xmlChar *target,
545 const xmlChar *data);
546/**
547 * commentSAXFunc:
548 * @ctx: the user data (XML parser context)
549 * @value: the comment content
550 *
551 * A comment has been parsed.
552 */
553typedef void (*commentSAXFunc) (void *ctx,
554 const xmlChar *value);
555/**
556 * cdataBlockSAXFunc:
557 * @ctx: the user data (XML parser context)
558 * @value: The pcdata content
559 * @len: the block length
560 *
Daniel Veillard61f26172002-03-12 18:46:39 +0000561 * Called when a pcdata block has been parsed.
Daniel Veillard9d06d302002-01-22 18:15:52 +0000562 */
563typedef void (*cdataBlockSAXFunc) (
564 void *ctx,
565 const xmlChar *value,
566 int len);
567/**
568 * warningSAXFunc:
569 * @ctx: an XML parser context
570 * @msg: the message to display/transmit
571 * @...: extra parameters for the message display
572 *
Daniel Veillard61f26172002-03-12 18:46:39 +0000573 * Display and format a warning messages, callback.
Daniel Veillard9d06d302002-01-22 18:15:52 +0000574 */
575typedef void (*warningSAXFunc) (void *ctx,
576 const char *msg, ...);
577/**
578 * errorSAXFunc:
579 * @ctx: an XML parser context
580 * @msg: the message to display/transmit
581 * @...: extra parameters for the message display
582 *
Daniel Veillard61f26172002-03-12 18:46:39 +0000583 * Display and format an error messages, callback.
Daniel Veillard9d06d302002-01-22 18:15:52 +0000584 */
585typedef void (*errorSAXFunc) (void *ctx,
586 const char *msg, ...);
587/**
588 * fatalErrorSAXFunc:
589 * @ctx: an XML parser context
590 * @msg: the message to display/transmit
591 * @...: extra parameters for the message display
592 *
Daniel Veillard61f26172002-03-12 18:46:39 +0000593 * Display and format fatal error messages, callback.
Daniel Veillard0821b152002-11-12 20:57:47 +0000594 * Note: so far fatalError() SAX callbacks are not used, error()
595 * get all the callbacks for errors.
Daniel Veillard9d06d302002-01-22 18:15:52 +0000596 */
597typedef void (*fatalErrorSAXFunc) (void *ctx,
598 const char *msg, ...);
599/**
600 * isStandaloneSAXFunc:
601 * @ctx: the user data (XML parser context)
602 *
Daniel Veillard61f26172002-03-12 18:46:39 +0000603 * Is this document tagged standalone?
Daniel Veillard9d06d302002-01-22 18:15:52 +0000604 *
605 * Returns 1 if true
606 */
Owen Taylor3473f882001-02-23 17:55:21 +0000607typedef int (*isStandaloneSAXFunc) (void *ctx);
Daniel Veillard9d06d302002-01-22 18:15:52 +0000608/**
609 * hasInternalSubsetSAXFunc:
610 * @ctx: the user data (XML parser context)
611 *
Daniel Veillard61f26172002-03-12 18:46:39 +0000612 * Does this document has an internal subset.
Daniel Veillard9d06d302002-01-22 18:15:52 +0000613 *
614 * Returns 1 if true
615 */
Owen Taylor3473f882001-02-23 17:55:21 +0000616typedef int (*hasInternalSubsetSAXFunc) (void *ctx);
Daniel Veillard1af9a412003-08-20 22:54:39 +0000617
Daniel Veillard9d06d302002-01-22 18:15:52 +0000618/**
619 * hasExternalSubsetSAXFunc:
620 * @ctx: the user data (XML parser context)
621 *
Daniel Veillard61f26172002-03-12 18:46:39 +0000622 * Does this document has an external subset?
Daniel Veillard9d06d302002-01-22 18:15:52 +0000623 *
624 * Returns 1 if true
625 */
Owen Taylor3473f882001-02-23 17:55:21 +0000626typedef int (*hasExternalSubsetSAXFunc) (void *ctx);
627
Daniel Veillard1af9a412003-08-20 22:54:39 +0000628/************************************************************************
629 * *
630 * The SAX version 2 API extensions *
631 * *
632 ************************************************************************/
633/**
634 * XML_SAX2_MAGIC:
635 *
636 * Special constant found in SAX2 blocks initialized fields
637 */
638#define XML_SAX2_MAGIC 0xDEEDBEAF
639
640/**
641 * startElementNsSAX2Func:
642 * @ctx: the user data (XML parser context)
643 * @localname: the local name of the element
644 * @prefix: the element namespace prefix if available
645 * @URI: the element namespace name if available
646 * @nb_namespaces: number of namespace definitions on that node
647 * @namespaces: pointer to the array of prefix/URI pairs namespace definitions
648 * @nb_attributes: the number of attributes on that node
Daniel Veillard07cb8222003-09-10 10:51:05 +0000649 * @nb_defaulted: the number of defaulted attributes. The defaulted
650 * ones are at the end of the array
651 * @attributes: pointer to the array of (localname/prefix/URI/value/end)
652 * attribute values.
Daniel Veillard1af9a412003-08-20 22:54:39 +0000653 *
654 * SAX2 callback when an element start has been detected by the parser.
655 * It provides the namespace informations for the element, as well as
656 * the new namespace declarations on the element.
Daniel Veillard1af9a412003-08-20 22:54:39 +0000657 */
658
659typedef void (*startElementNsSAX2Func) (void *ctx,
660 const xmlChar *localname,
661 const xmlChar *prefix,
662 const xmlChar *URI,
663 int nb_namespaces,
664 const xmlChar **namespaces,
Daniel Veillard07cb8222003-09-10 10:51:05 +0000665 int nb_attributes,
666 int nb_defaulted,
667 const xmlChar **attributes);
Daniel Veillard1af9a412003-08-20 22:54:39 +0000668
669/**
670 * endElementNsSAX2Func:
671 * @ctx: the user data (XML parser context)
672 * @localname: the local name of the element
673 * @prefix: the element namespace prefix if available
674 * @URI: the element namespace name if available
675 *
676 * SAX2 callback when an element end has been detected by the parser.
677 * It provides the namespace informations for the element.
678 */
679
680typedef void (*endElementNsSAX2Func) (void *ctx,
681 const xmlChar *localname,
682 const xmlChar *prefix,
683 const xmlChar *URI);
684
Daniel Veillard1af9a412003-08-20 22:54:39 +0000685
Owen Taylor3473f882001-02-23 17:55:21 +0000686struct _xmlSAXHandler {
687 internalSubsetSAXFunc internalSubset;
688 isStandaloneSAXFunc isStandalone;
689 hasInternalSubsetSAXFunc hasInternalSubset;
690 hasExternalSubsetSAXFunc hasExternalSubset;
691 resolveEntitySAXFunc resolveEntity;
692 getEntitySAXFunc getEntity;
693 entityDeclSAXFunc entityDecl;
694 notationDeclSAXFunc notationDecl;
695 attributeDeclSAXFunc attributeDecl;
696 elementDeclSAXFunc elementDecl;
697 unparsedEntityDeclSAXFunc unparsedEntityDecl;
698 setDocumentLocatorSAXFunc setDocumentLocator;
699 startDocumentSAXFunc startDocument;
700 endDocumentSAXFunc endDocument;
701 startElementSAXFunc startElement;
702 endElementSAXFunc endElement;
703 referenceSAXFunc reference;
704 charactersSAXFunc characters;
705 ignorableWhitespaceSAXFunc ignorableWhitespace;
706 processingInstructionSAXFunc processingInstruction;
707 commentSAXFunc comment;
708 warningSAXFunc warning;
709 errorSAXFunc error;
Daniel Veillard0821b152002-11-12 20:57:47 +0000710 fatalErrorSAXFunc fatalError; /* unused error() get all the errors */
Owen Taylor3473f882001-02-23 17:55:21 +0000711 getParameterEntitySAXFunc getParameterEntity;
712 cdataBlockSAXFunc cdataBlock;
713 externalSubsetSAXFunc externalSubset;
Daniel Veillard07cb8222003-09-10 10:51:05 +0000714 unsigned int initialized;
Daniel Veillard1af9a412003-08-20 22:54:39 +0000715 /* The following fields are extensions available only on version 2 */
716 void *_private;
717 startElementNsSAX2Func startElementNs;
718 endElementNsSAX2Func endElementNs;
Owen Taylor3473f882001-02-23 17:55:21 +0000719};
720
Daniel Veillard9ee35f32003-09-28 00:19:54 +0000721/*
722 * SAX Version 1
723 */
724typedef struct _xmlSAXHandlerV1 xmlSAXHandlerV1;
725typedef xmlSAXHandlerV1 *xmlSAXHandlerV1Ptr;
726struct _xmlSAXHandlerV1 {
727 internalSubsetSAXFunc internalSubset;
728 isStandaloneSAXFunc isStandalone;
729 hasInternalSubsetSAXFunc hasInternalSubset;
730 hasExternalSubsetSAXFunc hasExternalSubset;
731 resolveEntitySAXFunc resolveEntity;
732 getEntitySAXFunc getEntity;
733 entityDeclSAXFunc entityDecl;
734 notationDeclSAXFunc notationDecl;
735 attributeDeclSAXFunc attributeDecl;
736 elementDeclSAXFunc elementDecl;
737 unparsedEntityDeclSAXFunc unparsedEntityDecl;
738 setDocumentLocatorSAXFunc setDocumentLocator;
739 startDocumentSAXFunc startDocument;
740 endDocumentSAXFunc endDocument;
741 startElementSAXFunc startElement;
742 endElementSAXFunc endElement;
743 referenceSAXFunc reference;
744 charactersSAXFunc characters;
745 ignorableWhitespaceSAXFunc ignorableWhitespace;
746 processingInstructionSAXFunc processingInstruction;
747 commentSAXFunc comment;
748 warningSAXFunc warning;
749 errorSAXFunc error;
750 fatalErrorSAXFunc fatalError; /* unused error() get all the errors */
751 getParameterEntitySAXFunc getParameterEntity;
752 cdataBlockSAXFunc cdataBlock;
753 externalSubsetSAXFunc externalSubset;
754 unsigned int initialized;
755};
756
757
Owen Taylor3473f882001-02-23 17:55:21 +0000758/**
Daniel Veillardf69bb4b2001-05-19 13:24:56 +0000759 * xmlExternalEntityLoader:
760 * @URL: The System ID of the resource requested
761 * @ID: The Public ID of the resource requested
Daniel Veillardcbaf3992001-12-31 16:16:02 +0000762 * @context: the XML parser context
Daniel Veillardf69bb4b2001-05-19 13:24:56 +0000763 *
Daniel Veillard61f26172002-03-12 18:46:39 +0000764 * External entity loaders types.
Daniel Veillardcbaf3992001-12-31 16:16:02 +0000765 *
Daniel Veillard61f26172002-03-12 18:46:39 +0000766 * Returns the entity input parser.
Owen Taylor3473f882001-02-23 17:55:21 +0000767 */
Daniel Veillard9d06d302002-01-22 18:15:52 +0000768typedef xmlParserInputPtr (*xmlExternalEntityLoader) (const char *URL,
769 const char *ID,
770 xmlParserCtxtPtr context);
Owen Taylor3473f882001-02-23 17:55:21 +0000771
Daniel Veillard6c4ffaf2002-02-11 08:54:05 +0000772#ifdef __cplusplus
773}
774#endif
Igor Zlatkovic76874e42003-08-25 09:05:12 +0000775
Daniel Veillard6c4ffaf2002-02-11 08:54:05 +0000776#include <libxml/encoding.h>
777#include <libxml/xmlIO.h>
778#include <libxml/globals.h>
Igor Zlatkovic76874e42003-08-25 09:05:12 +0000779
Daniel Veillard6c4ffaf2002-02-11 08:54:05 +0000780#ifdef __cplusplus
781extern "C" {
782#endif
783
Owen Taylor3473f882001-02-23 17:55:21 +0000784
Daniel Veillardf69bb4b2001-05-19 13:24:56 +0000785/*
Owen Taylor3473f882001-02-23 17:55:21 +0000786 * Init/Cleanup
787 */
Igor Zlatkovic76874e42003-08-25 09:05:12 +0000788XMLPUBFUN void XMLCALL
789 xmlInitParser (void);
790XMLPUBFUN void XMLCALL
791 xmlCleanupParser (void);
Owen Taylor3473f882001-02-23 17:55:21 +0000792
Daniel Veillardf69bb4b2001-05-19 13:24:56 +0000793/*
Owen Taylor3473f882001-02-23 17:55:21 +0000794 * Input functions
795 */
Igor Zlatkovic76874e42003-08-25 09:05:12 +0000796XMLPUBFUN int XMLCALL
797 xmlParserInputRead (xmlParserInputPtr in,
Owen Taylor3473f882001-02-23 17:55:21 +0000798 int len);
Igor Zlatkovic76874e42003-08-25 09:05:12 +0000799XMLPUBFUN int XMLCALL
800 xmlParserInputGrow (xmlParserInputPtr in,
Owen Taylor3473f882001-02-23 17:55:21 +0000801 int len);
802
Daniel Veillardf69bb4b2001-05-19 13:24:56 +0000803/*
Owen Taylor3473f882001-02-23 17:55:21 +0000804 * xmlChar handling
805 */
Igor Zlatkovic76874e42003-08-25 09:05:12 +0000806XMLPUBFUN xmlChar * XMLCALL
807 xmlStrdup (const xmlChar *cur);
808XMLPUBFUN xmlChar * XMLCALL
809 xmlStrndup (const xmlChar *cur,
Owen Taylor3473f882001-02-23 17:55:21 +0000810 int len);
Igor Zlatkovic76874e42003-08-25 09:05:12 +0000811XMLPUBFUN xmlChar * XMLCALL
812 xmlCharStrndup (const char *cur,
Daniel Veillard56a4cb82001-03-24 17:00:36 +0000813 int len);
Igor Zlatkovic76874e42003-08-25 09:05:12 +0000814XMLPUBFUN xmlChar * XMLCALL
815 xmlCharStrdup (const char *cur);
816XMLPUBFUN xmlChar * XMLCALL
817 xmlStrsub (const xmlChar *str,
Owen Taylor3473f882001-02-23 17:55:21 +0000818 int start,
819 int len);
Igor Zlatkovic76874e42003-08-25 09:05:12 +0000820XMLPUBFUN const xmlChar * XMLCALL
821 xmlStrchr (const xmlChar *str,
Owen Taylor3473f882001-02-23 17:55:21 +0000822 xmlChar val);
Igor Zlatkovic76874e42003-08-25 09:05:12 +0000823XMLPUBFUN const xmlChar * XMLCALL
824 xmlStrstr (const xmlChar *str,
Daniel Veillard77044732001-06-29 21:31:07 +0000825 const xmlChar *val);
Igor Zlatkovic76874e42003-08-25 09:05:12 +0000826XMLPUBFUN const xmlChar * XMLCALL
827 xmlStrcasestr (const xmlChar *str,
Owen Taylor3473f882001-02-23 17:55:21 +0000828 xmlChar *val);
Igor Zlatkovic76874e42003-08-25 09:05:12 +0000829XMLPUBFUN int XMLCALL
830 xmlStrcmp (const xmlChar *str1,
Owen Taylor3473f882001-02-23 17:55:21 +0000831 const xmlChar *str2);
Igor Zlatkovic76874e42003-08-25 09:05:12 +0000832XMLPUBFUN int XMLCALL
833 xmlStrncmp (const xmlChar *str1,
Owen Taylor3473f882001-02-23 17:55:21 +0000834 const xmlChar *str2,
835 int len);
Igor Zlatkovic76874e42003-08-25 09:05:12 +0000836XMLPUBFUN int XMLCALL
837 xmlStrcasecmp (const xmlChar *str1,
Owen Taylor3473f882001-02-23 17:55:21 +0000838 const xmlChar *str2);
Igor Zlatkovic76874e42003-08-25 09:05:12 +0000839XMLPUBFUN int XMLCALL
840 xmlStrncasecmp (const xmlChar *str1,
Owen Taylor3473f882001-02-23 17:55:21 +0000841 const xmlChar *str2,
842 int len);
Igor Zlatkovic76874e42003-08-25 09:05:12 +0000843XMLPUBFUN int XMLCALL
844 xmlStrEqual (const xmlChar *str1,
Owen Taylor3473f882001-02-23 17:55:21 +0000845 const xmlChar *str2);
Daniel Veillard07cb8222003-09-10 10:51:05 +0000846XMLPUBFUN int XMLCALL
847 xmlStrQEqual (const xmlChar *pref,
848 const xmlChar *name,
849 const xmlChar *str);
Igor Zlatkovic76874e42003-08-25 09:05:12 +0000850XMLPUBFUN int XMLCALL
851 xmlStrlen (const xmlChar *str);
852XMLPUBFUN xmlChar * XMLCALL
853 xmlStrcat (xmlChar *cur,
Owen Taylor3473f882001-02-23 17:55:21 +0000854 const xmlChar *add);
Igor Zlatkovic76874e42003-08-25 09:05:12 +0000855XMLPUBFUN xmlChar * XMLCALL
856 xmlStrncat (xmlChar *cur,
Owen Taylor3473f882001-02-23 17:55:21 +0000857 const xmlChar *add,
858 int len);
859
Aleksey Sanine7acf432003-10-02 20:05:27 +0000860XMLPUBFUN int XMLCALL
861 xmlStrPrintf (xmlChar *buf,
862 int len,
863 const xmlChar *msg,
864 ...);
865
Daniel Veillardf69bb4b2001-05-19 13:24:56 +0000866/*
Owen Taylor3473f882001-02-23 17:55:21 +0000867 * Basic parsing Interfaces
868 */
Igor Zlatkovic76874e42003-08-25 09:05:12 +0000869XMLPUBFUN xmlDocPtr XMLCALL
870 xmlParseDoc (xmlChar *cur);
871XMLPUBFUN xmlDocPtr XMLCALL
872 xmlParseMemory (const char *buffer,
Owen Taylor3473f882001-02-23 17:55:21 +0000873 int size);
Igor Zlatkovic76874e42003-08-25 09:05:12 +0000874XMLPUBFUN xmlDocPtr XMLCALL
875 xmlParseFile (const char *filename);
876XMLPUBFUN int XMLCALL
877 xmlSubstituteEntitiesDefault(int val);
878XMLPUBFUN int XMLCALL
879 xmlKeepBlanksDefault (int val);
880XMLPUBFUN void XMLCALL
881 xmlStopParser (xmlParserCtxtPtr ctxt);
882XMLPUBFUN int XMLCALL
883 xmlPedanticParserDefault(int val);
884XMLPUBFUN int XMLCALL
885 xmlLineNumbersDefault (int val);
Owen Taylor3473f882001-02-23 17:55:21 +0000886
Daniel Veillardf69bb4b2001-05-19 13:24:56 +0000887/*
Owen Taylor3473f882001-02-23 17:55:21 +0000888 * Recovery mode
889 */
Igor Zlatkovic76874e42003-08-25 09:05:12 +0000890XMLPUBFUN xmlDocPtr XMLCALL
891 xmlRecoverDoc (xmlChar *cur);
892XMLPUBFUN xmlDocPtr XMLCALL
893 xmlRecoverMemory (const char *buffer,
Owen Taylor3473f882001-02-23 17:55:21 +0000894 int size);
Igor Zlatkovic76874e42003-08-25 09:05:12 +0000895XMLPUBFUN xmlDocPtr XMLCALL
896 xmlRecoverFile (const char *filename);
Owen Taylor3473f882001-02-23 17:55:21 +0000897
Daniel Veillardf69bb4b2001-05-19 13:24:56 +0000898/*
Owen Taylor3473f882001-02-23 17:55:21 +0000899 * Less common routines and SAX interfaces
900 */
Igor Zlatkovic76874e42003-08-25 09:05:12 +0000901XMLPUBFUN int XMLCALL
902 xmlParseDocument (xmlParserCtxtPtr ctxt);
903XMLPUBFUN int XMLCALL
904 xmlParseExtParsedEnt (xmlParserCtxtPtr ctxt);
905XMLPUBFUN xmlDocPtr XMLCALL
906 xmlSAXParseDoc (xmlSAXHandlerPtr sax,
Owen Taylor3473f882001-02-23 17:55:21 +0000907 xmlChar *cur,
908 int recovery);
Igor Zlatkovic76874e42003-08-25 09:05:12 +0000909XMLPUBFUN int XMLCALL
910 xmlSAXUserParseFile (xmlSAXHandlerPtr sax,
Owen Taylor3473f882001-02-23 17:55:21 +0000911 void *user_data,
912 const char *filename);
Igor Zlatkovic76874e42003-08-25 09:05:12 +0000913XMLPUBFUN int XMLCALL
914 xmlSAXUserParseMemory (xmlSAXHandlerPtr sax,
Owen Taylor3473f882001-02-23 17:55:21 +0000915 void *user_data,
Daniel Veillardfd7ddca2001-05-16 10:57:35 +0000916 const char *buffer,
Owen Taylor3473f882001-02-23 17:55:21 +0000917 int size);
Igor Zlatkovic76874e42003-08-25 09:05:12 +0000918XMLPUBFUN xmlDocPtr XMLCALL
919 xmlSAXParseMemory (xmlSAXHandlerPtr sax,
Daniel Veillard50822cb2001-07-26 20:05:51 +0000920 const char *buffer,
Owen Taylor3473f882001-02-23 17:55:21 +0000921 int size,
922 int recovery);
Igor Zlatkovic76874e42003-08-25 09:05:12 +0000923XMLPUBFUN xmlDocPtr XMLCALL
924 xmlSAXParseMemoryWithData (xmlSAXHandlerPtr sax,
Daniel Veillard8606bbb2002-11-12 12:36:52 +0000925 const char *buffer,
926 int size,
927 int recovery,
928 void *data);
Igor Zlatkovic76874e42003-08-25 09:05:12 +0000929XMLPUBFUN xmlDocPtr XMLCALL
930 xmlSAXParseFile (xmlSAXHandlerPtr sax,
Owen Taylor3473f882001-02-23 17:55:21 +0000931 const char *filename,
932 int recovery);
Igor Zlatkovic76874e42003-08-25 09:05:12 +0000933XMLPUBFUN xmlDocPtr XMLCALL
934 xmlSAXParseFileWithData (xmlSAXHandlerPtr sax,
Daniel Veillarda293c322001-10-02 13:54:14 +0000935 const char *filename,
936 int recovery,
937 void *data);
Igor Zlatkovic76874e42003-08-25 09:05:12 +0000938XMLPUBFUN xmlDocPtr XMLCALL
939 xmlSAXParseEntity (xmlSAXHandlerPtr sax,
Owen Taylor3473f882001-02-23 17:55:21 +0000940 const char *filename);
Igor Zlatkovic76874e42003-08-25 09:05:12 +0000941XMLPUBFUN xmlDocPtr XMLCALL
942 xmlParseEntity (const char *filename);
943XMLPUBFUN xmlDtdPtr XMLCALL
944 xmlParseDTD (const xmlChar *ExternalID,
Owen Taylor3473f882001-02-23 17:55:21 +0000945 const xmlChar *SystemID);
Igor Zlatkovic76874e42003-08-25 09:05:12 +0000946XMLPUBFUN xmlDtdPtr XMLCALL
947 xmlSAXParseDTD (xmlSAXHandlerPtr sax,
Owen Taylor3473f882001-02-23 17:55:21 +0000948 const xmlChar *ExternalID,
949 const xmlChar *SystemID);
Igor Zlatkovic76874e42003-08-25 09:05:12 +0000950XMLPUBFUN xmlDtdPtr XMLCALL
951 xmlIOParseDTD (xmlSAXHandlerPtr sax,
Owen Taylor3473f882001-02-23 17:55:21 +0000952 xmlParserInputBufferPtr input,
953 xmlCharEncoding enc);
Igor Zlatkovic76874e42003-08-25 09:05:12 +0000954XMLPUBFUN int XMLCALL
955 xmlParseBalancedChunkMemory(xmlDocPtr doc,
Owen Taylor3473f882001-02-23 17:55:21 +0000956 xmlSAXHandlerPtr sax,
957 void *user_data,
958 int depth,
959 const xmlChar *string,
Daniel Veillardcda96922001-08-21 10:56:31 +0000960 xmlNodePtr *lst);
Igor Zlatkovic76874e42003-08-25 09:05:12 +0000961XMLPUBFUN int XMLCALL
962 xmlParseBalancedChunkMemoryRecover(xmlDocPtr doc,
Daniel Veillard58e44c92002-08-02 22:19:49 +0000963 xmlSAXHandlerPtr sax,
964 void *user_data,
965 int depth,
966 const xmlChar *string,
967 xmlNodePtr *lst,
968 int recover);
Igor Zlatkovic76874e42003-08-25 09:05:12 +0000969XMLPUBFUN int XMLCALL
970 xmlParseExternalEntity (xmlDocPtr doc,
Owen Taylor3473f882001-02-23 17:55:21 +0000971 xmlSAXHandlerPtr sax,
972 void *user_data,
973 int depth,
974 const xmlChar *URL,
975 const xmlChar *ID,
Daniel Veillardcda96922001-08-21 10:56:31 +0000976 xmlNodePtr *lst);
Igor Zlatkovic76874e42003-08-25 09:05:12 +0000977XMLPUBFUN int XMLCALL
978 xmlParseCtxtExternalEntity(xmlParserCtxtPtr ctx,
Owen Taylor3473f882001-02-23 17:55:21 +0000979 const xmlChar *URL,
980 const xmlChar *ID,
Daniel Veillardcda96922001-08-21 10:56:31 +0000981 xmlNodePtr *lst);
Owen Taylor3473f882001-02-23 17:55:21 +0000982
Daniel Veillardf69bb4b2001-05-19 13:24:56 +0000983/*
Owen Taylor3473f882001-02-23 17:55:21 +0000984 * Parser contexts handling.
985 */
Daniel Veillard2b8c4a12003-10-02 22:28:19 +0000986XMLPUBFUN xmlParserCtxtPtr XMLCALL
987 xmlNewParserCtxt (void);
Igor Zlatkovic76874e42003-08-25 09:05:12 +0000988XMLPUBFUN int XMLCALL
989 xmlInitParserCtxt (xmlParserCtxtPtr ctxt);
990XMLPUBFUN void XMLCALL
991 xmlClearParserCtxt (xmlParserCtxtPtr ctxt);
992XMLPUBFUN void XMLCALL
993 xmlFreeParserCtxt (xmlParserCtxtPtr ctxt);
994XMLPUBFUN void XMLCALL
995 xmlSetupParserForBuffer (xmlParserCtxtPtr ctxt,
Owen Taylor3473f882001-02-23 17:55:21 +0000996 const xmlChar* buffer,
Daniel Veillard963d2ae2002-01-20 22:08:18 +0000997 const char *filename);
Igor Zlatkovic76874e42003-08-25 09:05:12 +0000998XMLPUBFUN xmlParserCtxtPtr XMLCALL
Daniel Veillard16fa96c2003-09-23 21:50:54 +0000999 xmlCreateDocParserCtxt (const xmlChar *cur);
Owen Taylor3473f882001-02-23 17:55:21 +00001000
Daniel Veillardf69bb4b2001-05-19 13:24:56 +00001001/*
Owen Taylor3473f882001-02-23 17:55:21 +00001002 * Reading/setting optional parsing features.
1003 */
1004
Igor Zlatkovic76874e42003-08-25 09:05:12 +00001005XMLPUBFUN int XMLCALL
1006 xmlGetFeaturesList (int *len,
Owen Taylor3473f882001-02-23 17:55:21 +00001007 const char **result);
Igor Zlatkovic76874e42003-08-25 09:05:12 +00001008XMLPUBFUN int XMLCALL
1009 xmlGetFeature (xmlParserCtxtPtr ctxt,
Owen Taylor3473f882001-02-23 17:55:21 +00001010 const char *name,
1011 void *result);
Igor Zlatkovic76874e42003-08-25 09:05:12 +00001012XMLPUBFUN int XMLCALL
1013 xmlSetFeature (xmlParserCtxtPtr ctxt,
Owen Taylor3473f882001-02-23 17:55:21 +00001014 const char *name,
1015 void *value);
1016
Daniel Veillard73b013f2003-09-30 12:36:01 +00001017#ifdef LIBXML_PUSH_ENABLED
Daniel Veillardf69bb4b2001-05-19 13:24:56 +00001018/*
Daniel Veillard61f26172002-03-12 18:46:39 +00001019 * Interfaces for the Push mode.
Owen Taylor3473f882001-02-23 17:55:21 +00001020 */
Igor Zlatkovic76874e42003-08-25 09:05:12 +00001021XMLPUBFUN xmlParserCtxtPtr XMLCALL
1022 xmlCreatePushParserCtxt(xmlSAXHandlerPtr sax,
Owen Taylor3473f882001-02-23 17:55:21 +00001023 void *user_data,
1024 const char *chunk,
1025 int size,
1026 const char *filename);
Igor Zlatkovic76874e42003-08-25 09:05:12 +00001027XMLPUBFUN int XMLCALL
1028 xmlParseChunk (xmlParserCtxtPtr ctxt,
Owen Taylor3473f882001-02-23 17:55:21 +00001029 const char *chunk,
1030 int size,
1031 int terminate);
Daniel Veillard73b013f2003-09-30 12:36:01 +00001032#endif /* LIBXML_PUSH_ENABLED */
Owen Taylor3473f882001-02-23 17:55:21 +00001033
Daniel Veillardf69bb4b2001-05-19 13:24:56 +00001034/*
Daniel Veillard61f26172002-03-12 18:46:39 +00001035 * Special I/O mode.
Owen Taylor3473f882001-02-23 17:55:21 +00001036 */
1037
Igor Zlatkovic76874e42003-08-25 09:05:12 +00001038XMLPUBFUN xmlParserCtxtPtr XMLCALL
1039 xmlCreateIOParserCtxt (xmlSAXHandlerPtr sax,
Owen Taylor3473f882001-02-23 17:55:21 +00001040 void *user_data,
1041 xmlInputReadCallback ioread,
1042 xmlInputCloseCallback ioclose,
1043 void *ioctx,
1044 xmlCharEncoding enc);
1045
Igor Zlatkovic76874e42003-08-25 09:05:12 +00001046XMLPUBFUN xmlParserInputPtr XMLCALL
1047 xmlNewIOInputStream (xmlParserCtxtPtr ctxt,
Owen Taylor3473f882001-02-23 17:55:21 +00001048 xmlParserInputBufferPtr input,
1049 xmlCharEncoding enc);
1050
Daniel Veillardf69bb4b2001-05-19 13:24:56 +00001051/*
Daniel Veillard61f26172002-03-12 18:46:39 +00001052 * Node infos.
Owen Taylor3473f882001-02-23 17:55:21 +00001053 */
Igor Zlatkovic76874e42003-08-25 09:05:12 +00001054XMLPUBFUN const xmlParserNodeInfo* XMLCALL
Daniel Veillard963d2ae2002-01-20 22:08:18 +00001055 xmlParserFindNodeInfo (const xmlParserCtxtPtr ctxt,
1056 const xmlNodePtr node);
Igor Zlatkovic76874e42003-08-25 09:05:12 +00001057XMLPUBFUN void XMLCALL
1058 xmlInitNodeInfoSeq (xmlParserNodeInfoSeqPtr seq);
1059XMLPUBFUN void XMLCALL
1060 xmlClearNodeInfoSeq (xmlParserNodeInfoSeqPtr seq);
1061XMLPUBFUN unsigned long XMLCALL
1062 xmlParserFindNodeInfoIndex(const xmlParserNodeInfoSeqPtr seq,
Daniel Veillard963d2ae2002-01-20 22:08:18 +00001063 const xmlNodePtr node);
Igor Zlatkovic76874e42003-08-25 09:05:12 +00001064XMLPUBFUN void XMLCALL
1065 xmlParserAddNodeInfo (xmlParserCtxtPtr ctxt,
Daniel Veillard963d2ae2002-01-20 22:08:18 +00001066 const xmlParserNodeInfoPtr info);
Owen Taylor3473f882001-02-23 17:55:21 +00001067
1068/*
Daniel Veillard61f26172002-03-12 18:46:39 +00001069 * External entities handling actually implemented in xmlIO.
Owen Taylor3473f882001-02-23 17:55:21 +00001070 */
1071
Igor Zlatkovic76874e42003-08-25 09:05:12 +00001072XMLPUBFUN void XMLCALL
1073 xmlSetExternalEntityLoader(xmlExternalEntityLoader f);
1074XMLPUBFUN xmlExternalEntityLoader XMLCALL
Owen Taylor3473f882001-02-23 17:55:21 +00001075 xmlGetExternalEntityLoader(void);
Igor Zlatkovic76874e42003-08-25 09:05:12 +00001076XMLPUBFUN xmlParserInputPtr XMLCALL
Owen Taylor3473f882001-02-23 17:55:21 +00001077 xmlLoadExternalEntity (const char *URL,
1078 const char *ID,
Daniel Veillard9d06d302002-01-22 18:15:52 +00001079 xmlParserCtxtPtr ctxt);
Daniel Veillard16fa96c2003-09-23 21:50:54 +00001080/*
1081 * New set of simpler/more flexible APIs
1082 */
1083/**
1084 * xmlParserOption:
1085 *
1086 * This is the set of XML parser options that can be passed down
1087 * to the xmlReadDoc() and similar calls.
1088 */
1089typedef enum {
1090 XML_PARSE_RECOVER = 1<<0, /* recover on errors */
1091 XML_PARSE_NOENT = 1<<1, /* substitute entities */
1092 XML_PARSE_DTDLOAD = 1<<2, /* load the external subset */
1093 XML_PARSE_DTDATTR = 1<<3, /* default DTD attributes */
1094 XML_PARSE_DTDVALID = 1<<4, /* validate with the DTD */
1095 XML_PARSE_NOERROR = 1<<5, /* suppress error reports */
1096 XML_PARSE_NOWARNING = 1<<6, /* suppress warning reports */
1097 XML_PARSE_PEDANTIC = 1<<7, /* pedantic error reporting */
1098 XML_PARSE_NOBLANKS = 1<<8, /* remove blank nodes */
1099 XML_PARSE_SAX1 = 1<<9, /* use the SAX1 interface internally */
1100 XML_PARSE_XINCLUDE = 1<<10,/* Implement XInclude substitition */
Daniel Veillarde96a2a42003-09-24 21:23:56 +00001101 XML_PARSE_NONET = 1<<11,/* Forbid network access */
Daniel Veillard9475a352003-09-26 12:47:50 +00001102 XML_PARSE_NODICT = 1<<12,/* Do not reuse the context dictionnary */
1103 XML_PARSE_NSCLEAN = 1<<13,/* remove redundant namespaces declarations */
1104 XML_PARSE_NOCDATA = 1<<14 /* merge CDATA as text nodes */
Daniel Veillard16fa96c2003-09-23 21:50:54 +00001105} xmlParserOption;
1106
1107XMLPUBFUN void XMLCALL
1108 xmlCtxtReset (xmlParserCtxtPtr ctxt);
1109XMLPUBFUN int XMLCALL
1110 xmlCtxtUseOptions (xmlParserCtxtPtr ctxt,
1111 int options);
1112XMLPUBFUN xmlDocPtr XMLCALL
1113 xmlReadDoc (const xmlChar *cur,
Daniel Veillard60942de2003-09-25 21:05:58 +00001114 const char *URL,
Daniel Veillard16fa96c2003-09-23 21:50:54 +00001115 const char *encoding,
1116 int options);
1117XMLPUBFUN xmlDocPtr XMLCALL
Daniel Veillard60942de2003-09-25 21:05:58 +00001118 xmlReadFile (const char *URL,
Daniel Veillard16fa96c2003-09-23 21:50:54 +00001119 const char *encoding,
1120 int options);
1121XMLPUBFUN xmlDocPtr XMLCALL
1122 xmlReadMemory (const char *buffer,
1123 int size,
Daniel Veillard60942de2003-09-25 21:05:58 +00001124 const char *URL,
Daniel Veillard16fa96c2003-09-23 21:50:54 +00001125 const char *encoding,
1126 int options);
1127XMLPUBFUN xmlDocPtr XMLCALL
1128 xmlReadFd (int fd,
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 xmlReadIO (xmlInputReadCallback ioread,
1134 xmlInputCloseCallback ioclose,
1135 void *ioctx,
Daniel Veillard60942de2003-09-25 21:05:58 +00001136 const char *URL,
Daniel Veillard16fa96c2003-09-23 21:50:54 +00001137 const char *encoding,
1138 int options);
1139XMLPUBFUN xmlDocPtr XMLCALL
1140 xmlCtxtReadDoc (xmlParserCtxtPtr ctxt,
1141 const xmlChar *cur,
Daniel Veillard60942de2003-09-25 21:05:58 +00001142 const char *URL,
Daniel Veillard16fa96c2003-09-23 21:50:54 +00001143 const char *encoding,
1144 int options);
1145XMLPUBFUN xmlDocPtr XMLCALL
1146 xmlCtxtReadFile (xmlParserCtxtPtr ctxt,
1147 const char *filename,
1148 const char *encoding,
1149 int options);
1150XMLPUBFUN xmlDocPtr XMLCALL
1151 xmlCtxtReadMemory (xmlParserCtxtPtr ctxt,
1152 const char *buffer,
1153 int size,
Daniel Veillard60942de2003-09-25 21:05:58 +00001154 const char *URL,
Daniel Veillard16fa96c2003-09-23 21:50:54 +00001155 const char *encoding,
1156 int options);
1157XMLPUBFUN xmlDocPtr XMLCALL
1158 xmlCtxtReadFd (xmlParserCtxtPtr ctxt,
1159 int fd,
Daniel Veillard60942de2003-09-25 21:05:58 +00001160 const char *URL,
Daniel Veillard16fa96c2003-09-23 21:50:54 +00001161 const char *encoding,
1162 int options);
1163XMLPUBFUN xmlDocPtr XMLCALL
1164 xmlCtxtReadIO (xmlParserCtxtPtr ctxt,
1165 xmlInputReadCallback ioread,
1166 xmlInputCloseCallback ioclose,
1167 void *ioctx,
Daniel Veillard60942de2003-09-25 21:05:58 +00001168 const char *URL,
Daniel Veillard16fa96c2003-09-23 21:50:54 +00001169 const char *encoding,
1170 int options);
Owen Taylor3473f882001-02-23 17:55:21 +00001171
1172#ifdef __cplusplus
1173}
1174#endif
Owen Taylor3473f882001-02-23 17:55:21 +00001175#endif /* __XML_PARSER_H__ */
1176