blob: 9da48cbda8f9fa26476eaa5f6e6507b6906bd536 [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;
Daniel Veillard659e71e2003-10-10 14:10:40 +0000719 xmlStructuredErrorFunc serror;
Owen Taylor3473f882001-02-23 17:55:21 +0000720};
721
Daniel Veillard9ee35f32003-09-28 00:19:54 +0000722/*
723 * SAX Version 1
724 */
725typedef struct _xmlSAXHandlerV1 xmlSAXHandlerV1;
726typedef xmlSAXHandlerV1 *xmlSAXHandlerV1Ptr;
727struct _xmlSAXHandlerV1 {
728 internalSubsetSAXFunc internalSubset;
729 isStandaloneSAXFunc isStandalone;
730 hasInternalSubsetSAXFunc hasInternalSubset;
731 hasExternalSubsetSAXFunc hasExternalSubset;
732 resolveEntitySAXFunc resolveEntity;
733 getEntitySAXFunc getEntity;
734 entityDeclSAXFunc entityDecl;
735 notationDeclSAXFunc notationDecl;
736 attributeDeclSAXFunc attributeDecl;
737 elementDeclSAXFunc elementDecl;
738 unparsedEntityDeclSAXFunc unparsedEntityDecl;
739 setDocumentLocatorSAXFunc setDocumentLocator;
740 startDocumentSAXFunc startDocument;
741 endDocumentSAXFunc endDocument;
742 startElementSAXFunc startElement;
743 endElementSAXFunc endElement;
744 referenceSAXFunc reference;
745 charactersSAXFunc characters;
746 ignorableWhitespaceSAXFunc ignorableWhitespace;
747 processingInstructionSAXFunc processingInstruction;
748 commentSAXFunc comment;
749 warningSAXFunc warning;
750 errorSAXFunc error;
751 fatalErrorSAXFunc fatalError; /* unused error() get all the errors */
752 getParameterEntitySAXFunc getParameterEntity;
753 cdataBlockSAXFunc cdataBlock;
754 externalSubsetSAXFunc externalSubset;
755 unsigned int initialized;
756};
757
758
Owen Taylor3473f882001-02-23 17:55:21 +0000759/**
Daniel Veillardf69bb4b2001-05-19 13:24:56 +0000760 * xmlExternalEntityLoader:
761 * @URL: The System ID of the resource requested
762 * @ID: The Public ID of the resource requested
Daniel Veillardcbaf3992001-12-31 16:16:02 +0000763 * @context: the XML parser context
Daniel Veillardf69bb4b2001-05-19 13:24:56 +0000764 *
Daniel Veillard61f26172002-03-12 18:46:39 +0000765 * External entity loaders types.
Daniel Veillardcbaf3992001-12-31 16:16:02 +0000766 *
Daniel Veillard61f26172002-03-12 18:46:39 +0000767 * Returns the entity input parser.
Owen Taylor3473f882001-02-23 17:55:21 +0000768 */
Daniel Veillard9d06d302002-01-22 18:15:52 +0000769typedef xmlParserInputPtr (*xmlExternalEntityLoader) (const char *URL,
770 const char *ID,
771 xmlParserCtxtPtr context);
Owen Taylor3473f882001-02-23 17:55:21 +0000772
Daniel Veillard6c4ffaf2002-02-11 08:54:05 +0000773#ifdef __cplusplus
774}
775#endif
Igor Zlatkovic76874e42003-08-25 09:05:12 +0000776
Daniel Veillard6c4ffaf2002-02-11 08:54:05 +0000777#include <libxml/encoding.h>
778#include <libxml/xmlIO.h>
779#include <libxml/globals.h>
Igor Zlatkovic76874e42003-08-25 09:05:12 +0000780
Daniel Veillard6c4ffaf2002-02-11 08:54:05 +0000781#ifdef __cplusplus
782extern "C" {
783#endif
784
Owen Taylor3473f882001-02-23 17:55:21 +0000785
Daniel Veillardf69bb4b2001-05-19 13:24:56 +0000786/*
Owen Taylor3473f882001-02-23 17:55:21 +0000787 * Init/Cleanup
788 */
Igor Zlatkovic76874e42003-08-25 09:05:12 +0000789XMLPUBFUN void XMLCALL
790 xmlInitParser (void);
791XMLPUBFUN void XMLCALL
792 xmlCleanupParser (void);
Owen Taylor3473f882001-02-23 17:55:21 +0000793
Daniel Veillardf69bb4b2001-05-19 13:24:56 +0000794/*
Owen Taylor3473f882001-02-23 17:55:21 +0000795 * Input functions
796 */
Igor Zlatkovic76874e42003-08-25 09:05:12 +0000797XMLPUBFUN int XMLCALL
798 xmlParserInputRead (xmlParserInputPtr in,
Owen Taylor3473f882001-02-23 17:55:21 +0000799 int len);
Igor Zlatkovic76874e42003-08-25 09:05:12 +0000800XMLPUBFUN int XMLCALL
801 xmlParserInputGrow (xmlParserInputPtr in,
Owen Taylor3473f882001-02-23 17:55:21 +0000802 int len);
803
Daniel Veillardf69bb4b2001-05-19 13:24:56 +0000804/*
Owen Taylor3473f882001-02-23 17:55:21 +0000805 * xmlChar handling
806 */
Igor Zlatkovic76874e42003-08-25 09:05:12 +0000807XMLPUBFUN xmlChar * XMLCALL
808 xmlStrdup (const xmlChar *cur);
809XMLPUBFUN xmlChar * XMLCALL
810 xmlStrndup (const xmlChar *cur,
Owen Taylor3473f882001-02-23 17:55:21 +0000811 int len);
Igor Zlatkovic76874e42003-08-25 09:05:12 +0000812XMLPUBFUN xmlChar * XMLCALL
813 xmlCharStrndup (const char *cur,
Daniel Veillard56a4cb82001-03-24 17:00:36 +0000814 int len);
Igor Zlatkovic76874e42003-08-25 09:05:12 +0000815XMLPUBFUN xmlChar * XMLCALL
816 xmlCharStrdup (const char *cur);
817XMLPUBFUN xmlChar * XMLCALL
818 xmlStrsub (const xmlChar *str,
Owen Taylor3473f882001-02-23 17:55:21 +0000819 int start,
820 int len);
Igor Zlatkovic76874e42003-08-25 09:05:12 +0000821XMLPUBFUN const xmlChar * XMLCALL
822 xmlStrchr (const xmlChar *str,
Owen Taylor3473f882001-02-23 17:55:21 +0000823 xmlChar val);
Igor Zlatkovic76874e42003-08-25 09:05:12 +0000824XMLPUBFUN const xmlChar * XMLCALL
825 xmlStrstr (const xmlChar *str,
Daniel Veillard77044732001-06-29 21:31:07 +0000826 const xmlChar *val);
Igor Zlatkovic76874e42003-08-25 09:05:12 +0000827XMLPUBFUN const xmlChar * XMLCALL
828 xmlStrcasestr (const xmlChar *str,
Owen Taylor3473f882001-02-23 17:55:21 +0000829 xmlChar *val);
Igor Zlatkovic76874e42003-08-25 09:05:12 +0000830XMLPUBFUN int XMLCALL
831 xmlStrcmp (const xmlChar *str1,
Owen Taylor3473f882001-02-23 17:55:21 +0000832 const xmlChar *str2);
Igor Zlatkovic76874e42003-08-25 09:05:12 +0000833XMLPUBFUN int XMLCALL
834 xmlStrncmp (const xmlChar *str1,
Owen Taylor3473f882001-02-23 17:55:21 +0000835 const xmlChar *str2,
836 int len);
Igor Zlatkovic76874e42003-08-25 09:05:12 +0000837XMLPUBFUN int XMLCALL
838 xmlStrcasecmp (const xmlChar *str1,
Owen Taylor3473f882001-02-23 17:55:21 +0000839 const xmlChar *str2);
Igor Zlatkovic76874e42003-08-25 09:05:12 +0000840XMLPUBFUN int XMLCALL
841 xmlStrncasecmp (const xmlChar *str1,
Owen Taylor3473f882001-02-23 17:55:21 +0000842 const xmlChar *str2,
843 int len);
Igor Zlatkovic76874e42003-08-25 09:05:12 +0000844XMLPUBFUN int XMLCALL
845 xmlStrEqual (const xmlChar *str1,
Owen Taylor3473f882001-02-23 17:55:21 +0000846 const xmlChar *str2);
Daniel Veillard07cb8222003-09-10 10:51:05 +0000847XMLPUBFUN int XMLCALL
848 xmlStrQEqual (const xmlChar *pref,
849 const xmlChar *name,
850 const xmlChar *str);
Igor Zlatkovic76874e42003-08-25 09:05:12 +0000851XMLPUBFUN int XMLCALL
852 xmlStrlen (const xmlChar *str);
853XMLPUBFUN xmlChar * XMLCALL
854 xmlStrcat (xmlChar *cur,
Owen Taylor3473f882001-02-23 17:55:21 +0000855 const xmlChar *add);
Igor Zlatkovic76874e42003-08-25 09:05:12 +0000856XMLPUBFUN xmlChar * XMLCALL
857 xmlStrncat (xmlChar *cur,
Owen Taylor3473f882001-02-23 17:55:21 +0000858 const xmlChar *add,
859 int len);
860
Aleksey Sanine7acf432003-10-02 20:05:27 +0000861XMLPUBFUN int XMLCALL
862 xmlStrPrintf (xmlChar *buf,
863 int len,
864 const xmlChar *msg,
865 ...);
866
Daniel Veillardf69bb4b2001-05-19 13:24:56 +0000867/*
Owen Taylor3473f882001-02-23 17:55:21 +0000868 * Basic parsing Interfaces
869 */
Igor Zlatkovic76874e42003-08-25 09:05:12 +0000870XMLPUBFUN xmlDocPtr XMLCALL
871 xmlParseDoc (xmlChar *cur);
872XMLPUBFUN xmlDocPtr XMLCALL
873 xmlParseMemory (const char *buffer,
Owen Taylor3473f882001-02-23 17:55:21 +0000874 int size);
Igor Zlatkovic76874e42003-08-25 09:05:12 +0000875XMLPUBFUN xmlDocPtr XMLCALL
876 xmlParseFile (const char *filename);
877XMLPUBFUN int XMLCALL
878 xmlSubstituteEntitiesDefault(int val);
879XMLPUBFUN int XMLCALL
880 xmlKeepBlanksDefault (int val);
881XMLPUBFUN void XMLCALL
882 xmlStopParser (xmlParserCtxtPtr ctxt);
883XMLPUBFUN int XMLCALL
884 xmlPedanticParserDefault(int val);
885XMLPUBFUN int XMLCALL
886 xmlLineNumbersDefault (int val);
Owen Taylor3473f882001-02-23 17:55:21 +0000887
Daniel Veillardf69bb4b2001-05-19 13:24:56 +0000888/*
Owen Taylor3473f882001-02-23 17:55:21 +0000889 * Recovery mode
890 */
Igor Zlatkovic76874e42003-08-25 09:05:12 +0000891XMLPUBFUN xmlDocPtr XMLCALL
892 xmlRecoverDoc (xmlChar *cur);
893XMLPUBFUN xmlDocPtr XMLCALL
894 xmlRecoverMemory (const char *buffer,
Owen Taylor3473f882001-02-23 17:55:21 +0000895 int size);
Igor Zlatkovic76874e42003-08-25 09:05:12 +0000896XMLPUBFUN xmlDocPtr XMLCALL
897 xmlRecoverFile (const char *filename);
Owen Taylor3473f882001-02-23 17:55:21 +0000898
Daniel Veillardf69bb4b2001-05-19 13:24:56 +0000899/*
Owen Taylor3473f882001-02-23 17:55:21 +0000900 * Less common routines and SAX interfaces
901 */
Igor Zlatkovic76874e42003-08-25 09:05:12 +0000902XMLPUBFUN int XMLCALL
903 xmlParseDocument (xmlParserCtxtPtr ctxt);
904XMLPUBFUN int XMLCALL
905 xmlParseExtParsedEnt (xmlParserCtxtPtr ctxt);
906XMLPUBFUN xmlDocPtr XMLCALL
907 xmlSAXParseDoc (xmlSAXHandlerPtr sax,
Owen Taylor3473f882001-02-23 17:55:21 +0000908 xmlChar *cur,
909 int recovery);
Igor Zlatkovic76874e42003-08-25 09:05:12 +0000910XMLPUBFUN int XMLCALL
911 xmlSAXUserParseFile (xmlSAXHandlerPtr sax,
Owen Taylor3473f882001-02-23 17:55:21 +0000912 void *user_data,
913 const char *filename);
Igor Zlatkovic76874e42003-08-25 09:05:12 +0000914XMLPUBFUN int XMLCALL
915 xmlSAXUserParseMemory (xmlSAXHandlerPtr sax,
Owen Taylor3473f882001-02-23 17:55:21 +0000916 void *user_data,
Daniel Veillardfd7ddca2001-05-16 10:57:35 +0000917 const char *buffer,
Owen Taylor3473f882001-02-23 17:55:21 +0000918 int size);
Igor Zlatkovic76874e42003-08-25 09:05:12 +0000919XMLPUBFUN xmlDocPtr XMLCALL
920 xmlSAXParseMemory (xmlSAXHandlerPtr sax,
Daniel Veillard50822cb2001-07-26 20:05:51 +0000921 const char *buffer,
Owen Taylor3473f882001-02-23 17:55:21 +0000922 int size,
923 int recovery);
Igor Zlatkovic76874e42003-08-25 09:05:12 +0000924XMLPUBFUN xmlDocPtr XMLCALL
925 xmlSAXParseMemoryWithData (xmlSAXHandlerPtr sax,
Daniel Veillard8606bbb2002-11-12 12:36:52 +0000926 const char *buffer,
927 int size,
928 int recovery,
929 void *data);
Igor Zlatkovic76874e42003-08-25 09:05:12 +0000930XMLPUBFUN xmlDocPtr XMLCALL
931 xmlSAXParseFile (xmlSAXHandlerPtr sax,
Owen Taylor3473f882001-02-23 17:55:21 +0000932 const char *filename,
933 int recovery);
Igor Zlatkovic76874e42003-08-25 09:05:12 +0000934XMLPUBFUN xmlDocPtr XMLCALL
935 xmlSAXParseFileWithData (xmlSAXHandlerPtr sax,
Daniel Veillarda293c322001-10-02 13:54:14 +0000936 const char *filename,
937 int recovery,
938 void *data);
Igor Zlatkovic76874e42003-08-25 09:05:12 +0000939XMLPUBFUN xmlDocPtr XMLCALL
940 xmlSAXParseEntity (xmlSAXHandlerPtr sax,
Owen Taylor3473f882001-02-23 17:55:21 +0000941 const char *filename);
Igor Zlatkovic76874e42003-08-25 09:05:12 +0000942XMLPUBFUN xmlDocPtr XMLCALL
943 xmlParseEntity (const char *filename);
944XMLPUBFUN xmlDtdPtr XMLCALL
945 xmlParseDTD (const xmlChar *ExternalID,
Owen Taylor3473f882001-02-23 17:55:21 +0000946 const xmlChar *SystemID);
Igor Zlatkovic76874e42003-08-25 09:05:12 +0000947XMLPUBFUN xmlDtdPtr XMLCALL
948 xmlSAXParseDTD (xmlSAXHandlerPtr sax,
Owen Taylor3473f882001-02-23 17:55:21 +0000949 const xmlChar *ExternalID,
950 const xmlChar *SystemID);
Igor Zlatkovic76874e42003-08-25 09:05:12 +0000951XMLPUBFUN xmlDtdPtr XMLCALL
952 xmlIOParseDTD (xmlSAXHandlerPtr sax,
Owen Taylor3473f882001-02-23 17:55:21 +0000953 xmlParserInputBufferPtr input,
954 xmlCharEncoding enc);
Igor Zlatkovic76874e42003-08-25 09:05:12 +0000955XMLPUBFUN int XMLCALL
956 xmlParseBalancedChunkMemory(xmlDocPtr doc,
Owen Taylor3473f882001-02-23 17:55:21 +0000957 xmlSAXHandlerPtr sax,
958 void *user_data,
959 int depth,
960 const xmlChar *string,
Daniel Veillardcda96922001-08-21 10:56:31 +0000961 xmlNodePtr *lst);
Igor Zlatkovic76874e42003-08-25 09:05:12 +0000962XMLPUBFUN int XMLCALL
963 xmlParseBalancedChunkMemoryRecover(xmlDocPtr doc,
Daniel Veillard58e44c92002-08-02 22:19:49 +0000964 xmlSAXHandlerPtr sax,
965 void *user_data,
966 int depth,
967 const xmlChar *string,
968 xmlNodePtr *lst,
969 int recover);
Igor Zlatkovic76874e42003-08-25 09:05:12 +0000970XMLPUBFUN int XMLCALL
971 xmlParseExternalEntity (xmlDocPtr doc,
Owen Taylor3473f882001-02-23 17:55:21 +0000972 xmlSAXHandlerPtr sax,
973 void *user_data,
974 int depth,
975 const xmlChar *URL,
976 const xmlChar *ID,
Daniel Veillardcda96922001-08-21 10:56:31 +0000977 xmlNodePtr *lst);
Igor Zlatkovic76874e42003-08-25 09:05:12 +0000978XMLPUBFUN int XMLCALL
979 xmlParseCtxtExternalEntity(xmlParserCtxtPtr ctx,
Owen Taylor3473f882001-02-23 17:55:21 +0000980 const xmlChar *URL,
981 const xmlChar *ID,
Daniel Veillardcda96922001-08-21 10:56:31 +0000982 xmlNodePtr *lst);
Owen Taylor3473f882001-02-23 17:55:21 +0000983
Daniel Veillardf69bb4b2001-05-19 13:24:56 +0000984/*
Owen Taylor3473f882001-02-23 17:55:21 +0000985 * Parser contexts handling.
986 */
Daniel Veillard2b8c4a12003-10-02 22:28:19 +0000987XMLPUBFUN xmlParserCtxtPtr XMLCALL
988 xmlNewParserCtxt (void);
Igor Zlatkovic76874e42003-08-25 09:05:12 +0000989XMLPUBFUN int XMLCALL
990 xmlInitParserCtxt (xmlParserCtxtPtr ctxt);
991XMLPUBFUN void XMLCALL
992 xmlClearParserCtxt (xmlParserCtxtPtr ctxt);
993XMLPUBFUN void XMLCALL
994 xmlFreeParserCtxt (xmlParserCtxtPtr ctxt);
995XMLPUBFUN void XMLCALL
996 xmlSetupParserForBuffer (xmlParserCtxtPtr ctxt,
Owen Taylor3473f882001-02-23 17:55:21 +0000997 const xmlChar* buffer,
Daniel Veillard963d2ae2002-01-20 22:08:18 +0000998 const char *filename);
Igor Zlatkovic76874e42003-08-25 09:05:12 +0000999XMLPUBFUN xmlParserCtxtPtr XMLCALL
Daniel Veillard16fa96c2003-09-23 21:50:54 +00001000 xmlCreateDocParserCtxt (const xmlChar *cur);
Owen Taylor3473f882001-02-23 17:55:21 +00001001
Daniel Veillardf69bb4b2001-05-19 13:24:56 +00001002/*
Owen Taylor3473f882001-02-23 17:55:21 +00001003 * Reading/setting optional parsing features.
1004 */
1005
Igor Zlatkovic76874e42003-08-25 09:05:12 +00001006XMLPUBFUN int XMLCALL
1007 xmlGetFeaturesList (int *len,
Owen Taylor3473f882001-02-23 17:55:21 +00001008 const char **result);
Igor Zlatkovic76874e42003-08-25 09:05:12 +00001009XMLPUBFUN int XMLCALL
1010 xmlGetFeature (xmlParserCtxtPtr ctxt,
Owen Taylor3473f882001-02-23 17:55:21 +00001011 const char *name,
1012 void *result);
Igor Zlatkovic76874e42003-08-25 09:05:12 +00001013XMLPUBFUN int XMLCALL
1014 xmlSetFeature (xmlParserCtxtPtr ctxt,
Owen Taylor3473f882001-02-23 17:55:21 +00001015 const char *name,
1016 void *value);
1017
Daniel Veillard73b013f2003-09-30 12:36:01 +00001018#ifdef LIBXML_PUSH_ENABLED
Daniel Veillardf69bb4b2001-05-19 13:24:56 +00001019/*
Daniel Veillard61f26172002-03-12 18:46:39 +00001020 * Interfaces for the Push mode.
Owen Taylor3473f882001-02-23 17:55:21 +00001021 */
Igor Zlatkovic76874e42003-08-25 09:05:12 +00001022XMLPUBFUN xmlParserCtxtPtr XMLCALL
1023 xmlCreatePushParserCtxt(xmlSAXHandlerPtr sax,
Owen Taylor3473f882001-02-23 17:55:21 +00001024 void *user_data,
1025 const char *chunk,
1026 int size,
1027 const char *filename);
Igor Zlatkovic76874e42003-08-25 09:05:12 +00001028XMLPUBFUN int XMLCALL
1029 xmlParseChunk (xmlParserCtxtPtr ctxt,
Owen Taylor3473f882001-02-23 17:55:21 +00001030 const char *chunk,
1031 int size,
1032 int terminate);
Daniel Veillard73b013f2003-09-30 12:36:01 +00001033#endif /* LIBXML_PUSH_ENABLED */
Owen Taylor3473f882001-02-23 17:55:21 +00001034
Daniel Veillardf69bb4b2001-05-19 13:24:56 +00001035/*
Daniel Veillard61f26172002-03-12 18:46:39 +00001036 * Special I/O mode.
Owen Taylor3473f882001-02-23 17:55:21 +00001037 */
1038
Igor Zlatkovic76874e42003-08-25 09:05:12 +00001039XMLPUBFUN xmlParserCtxtPtr XMLCALL
1040 xmlCreateIOParserCtxt (xmlSAXHandlerPtr sax,
Owen Taylor3473f882001-02-23 17:55:21 +00001041 void *user_data,
1042 xmlInputReadCallback ioread,
1043 xmlInputCloseCallback ioclose,
1044 void *ioctx,
1045 xmlCharEncoding enc);
1046
Igor Zlatkovic76874e42003-08-25 09:05:12 +00001047XMLPUBFUN xmlParserInputPtr XMLCALL
1048 xmlNewIOInputStream (xmlParserCtxtPtr ctxt,
Owen Taylor3473f882001-02-23 17:55:21 +00001049 xmlParserInputBufferPtr input,
1050 xmlCharEncoding enc);
1051
Daniel Veillardf69bb4b2001-05-19 13:24:56 +00001052/*
Daniel Veillard61f26172002-03-12 18:46:39 +00001053 * Node infos.
Owen Taylor3473f882001-02-23 17:55:21 +00001054 */
Igor Zlatkovic76874e42003-08-25 09:05:12 +00001055XMLPUBFUN const xmlParserNodeInfo* XMLCALL
Daniel Veillard963d2ae2002-01-20 22:08:18 +00001056 xmlParserFindNodeInfo (const xmlParserCtxtPtr ctxt,
1057 const xmlNodePtr node);
Igor Zlatkovic76874e42003-08-25 09:05:12 +00001058XMLPUBFUN void XMLCALL
1059 xmlInitNodeInfoSeq (xmlParserNodeInfoSeqPtr seq);
1060XMLPUBFUN void XMLCALL
1061 xmlClearNodeInfoSeq (xmlParserNodeInfoSeqPtr seq);
1062XMLPUBFUN unsigned long XMLCALL
1063 xmlParserFindNodeInfoIndex(const xmlParserNodeInfoSeqPtr seq,
Daniel Veillard963d2ae2002-01-20 22:08:18 +00001064 const xmlNodePtr node);
Igor Zlatkovic76874e42003-08-25 09:05:12 +00001065XMLPUBFUN void XMLCALL
1066 xmlParserAddNodeInfo (xmlParserCtxtPtr ctxt,
Daniel Veillard963d2ae2002-01-20 22:08:18 +00001067 const xmlParserNodeInfoPtr info);
Owen Taylor3473f882001-02-23 17:55:21 +00001068
1069/*
Daniel Veillard61f26172002-03-12 18:46:39 +00001070 * External entities handling actually implemented in xmlIO.
Owen Taylor3473f882001-02-23 17:55:21 +00001071 */
1072
Igor Zlatkovic76874e42003-08-25 09:05:12 +00001073XMLPUBFUN void XMLCALL
1074 xmlSetExternalEntityLoader(xmlExternalEntityLoader f);
1075XMLPUBFUN xmlExternalEntityLoader XMLCALL
Owen Taylor3473f882001-02-23 17:55:21 +00001076 xmlGetExternalEntityLoader(void);
Igor Zlatkovic76874e42003-08-25 09:05:12 +00001077XMLPUBFUN xmlParserInputPtr XMLCALL
Owen Taylor3473f882001-02-23 17:55:21 +00001078 xmlLoadExternalEntity (const char *URL,
1079 const char *ID,
Daniel Veillard9d06d302002-01-22 18:15:52 +00001080 xmlParserCtxtPtr ctxt);
Daniel Veillard16fa96c2003-09-23 21:50:54 +00001081/*
1082 * New set of simpler/more flexible APIs
1083 */
1084/**
1085 * xmlParserOption:
1086 *
1087 * This is the set of XML parser options that can be passed down
1088 * to the xmlReadDoc() and similar calls.
1089 */
1090typedef enum {
1091 XML_PARSE_RECOVER = 1<<0, /* recover on errors */
1092 XML_PARSE_NOENT = 1<<1, /* substitute entities */
1093 XML_PARSE_DTDLOAD = 1<<2, /* load the external subset */
1094 XML_PARSE_DTDATTR = 1<<3, /* default DTD attributes */
1095 XML_PARSE_DTDVALID = 1<<4, /* validate with the DTD */
1096 XML_PARSE_NOERROR = 1<<5, /* suppress error reports */
1097 XML_PARSE_NOWARNING = 1<<6, /* suppress warning reports */
1098 XML_PARSE_PEDANTIC = 1<<7, /* pedantic error reporting */
1099 XML_PARSE_NOBLANKS = 1<<8, /* remove blank nodes */
1100 XML_PARSE_SAX1 = 1<<9, /* use the SAX1 interface internally */
1101 XML_PARSE_XINCLUDE = 1<<10,/* Implement XInclude substitition */
Daniel Veillarde96a2a42003-09-24 21:23:56 +00001102 XML_PARSE_NONET = 1<<11,/* Forbid network access */
Daniel Veillard9475a352003-09-26 12:47:50 +00001103 XML_PARSE_NODICT = 1<<12,/* Do not reuse the context dictionnary */
1104 XML_PARSE_NSCLEAN = 1<<13,/* remove redundant namespaces declarations */
1105 XML_PARSE_NOCDATA = 1<<14 /* merge CDATA as text nodes */
Daniel Veillard16fa96c2003-09-23 21:50:54 +00001106} xmlParserOption;
1107
1108XMLPUBFUN void XMLCALL
1109 xmlCtxtReset (xmlParserCtxtPtr ctxt);
1110XMLPUBFUN int XMLCALL
1111 xmlCtxtUseOptions (xmlParserCtxtPtr ctxt,
1112 int options);
1113XMLPUBFUN xmlDocPtr XMLCALL
1114 xmlReadDoc (const xmlChar *cur,
Daniel Veillard60942de2003-09-25 21:05:58 +00001115 const char *URL,
Daniel Veillard16fa96c2003-09-23 21:50:54 +00001116 const char *encoding,
1117 int options);
1118XMLPUBFUN xmlDocPtr XMLCALL
Daniel Veillard60942de2003-09-25 21:05:58 +00001119 xmlReadFile (const char *URL,
Daniel Veillard16fa96c2003-09-23 21:50:54 +00001120 const char *encoding,
1121 int options);
1122XMLPUBFUN xmlDocPtr XMLCALL
1123 xmlReadMemory (const char *buffer,
1124 int size,
Daniel Veillard60942de2003-09-25 21:05:58 +00001125 const char *URL,
Daniel Veillard16fa96c2003-09-23 21:50:54 +00001126 const char *encoding,
1127 int options);
1128XMLPUBFUN xmlDocPtr XMLCALL
1129 xmlReadFd (int fd,
Daniel Veillard60942de2003-09-25 21:05:58 +00001130 const char *URL,
Daniel Veillard16fa96c2003-09-23 21:50:54 +00001131 const char *encoding,
1132 int options);
1133XMLPUBFUN xmlDocPtr XMLCALL
1134 xmlReadIO (xmlInputReadCallback ioread,
1135 xmlInputCloseCallback ioclose,
1136 void *ioctx,
Daniel Veillard60942de2003-09-25 21:05:58 +00001137 const char *URL,
Daniel Veillard16fa96c2003-09-23 21:50:54 +00001138 const char *encoding,
1139 int options);
1140XMLPUBFUN xmlDocPtr XMLCALL
1141 xmlCtxtReadDoc (xmlParserCtxtPtr ctxt,
1142 const xmlChar *cur,
Daniel Veillard60942de2003-09-25 21:05:58 +00001143 const char *URL,
Daniel Veillard16fa96c2003-09-23 21:50:54 +00001144 const char *encoding,
1145 int options);
1146XMLPUBFUN xmlDocPtr XMLCALL
1147 xmlCtxtReadFile (xmlParserCtxtPtr ctxt,
1148 const char *filename,
1149 const char *encoding,
1150 int options);
1151XMLPUBFUN xmlDocPtr XMLCALL
1152 xmlCtxtReadMemory (xmlParserCtxtPtr ctxt,
1153 const char *buffer,
1154 int size,
Daniel Veillard60942de2003-09-25 21:05:58 +00001155 const char *URL,
Daniel Veillard16fa96c2003-09-23 21:50:54 +00001156 const char *encoding,
1157 int options);
1158XMLPUBFUN xmlDocPtr XMLCALL
1159 xmlCtxtReadFd (xmlParserCtxtPtr ctxt,
1160 int fd,
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);
1164XMLPUBFUN xmlDocPtr XMLCALL
1165 xmlCtxtReadIO (xmlParserCtxtPtr ctxt,
1166 xmlInputReadCallback ioread,
1167 xmlInputCloseCallback ioclose,
1168 void *ioctx,
Daniel Veillard60942de2003-09-25 21:05:58 +00001169 const char *URL,
Daniel Veillard16fa96c2003-09-23 21:50:54 +00001170 const char *encoding,
1171 int options);
Owen Taylor3473f882001-02-23 17:55:21 +00001172
1173#ifdef __cplusplus
1174}
1175#endif
Owen Taylor3473f882001-02-23 17:55:21 +00001176#endif /* __XML_PARSER_H__ */
1177