blob: c4b5ff3ec60ec086f677532fd63be5012418a7a6 [file] [log] [blame]
Owen Taylor3473f882001-02-23 17:55:21 +00001/*
Daniel Veillardbe586972003-11-18 20:56:51 +00002 * Summary: the core parser module
3 * Description: Interfaces, constants and types related to the XML parser
Owen Taylor3473f882001-02-23 17:55:21 +00004 *
Daniel Veillardbe586972003-11-18 20:56:51 +00005 * Copy: See Copyright for the status of this software.
Owen Taylor3473f882001-02-23 17:55:21 +00006 *
Daniel Veillardbe586972003-11-18 20:56:51 +00007 * Author: Daniel Veillard
Owen Taylor3473f882001-02-23 17:55:21 +00008 */
9
10#ifndef __XML_PARSER_H__
11#define __XML_PARSER_H__
12
Aleksey Saninb5a46da2003-10-29 15:51:17 +000013#include <stdarg.h>
14
Igor Zlatkovic76874e42003-08-25 09:05:12 +000015#include <libxml/xmlversion.h>
Owen Taylor3473f882001-02-23 17:55:21 +000016#include <libxml/tree.h>
Daniel Veillard2fdbd322003-08-18 12:15:38 +000017#include <libxml/dict.h>
Daniel Veillard07cb8222003-09-10 10:51:05 +000018#include <libxml/hash.h>
Owen Taylor3473f882001-02-23 17:55:21 +000019#include <libxml/valid.h>
Owen Taylor3473f882001-02-23 17:55:21 +000020#include <libxml/entities.h>
Daniel Veillard2b8c4a12003-10-02 22:28:19 +000021#include <libxml/xmlerror.h>
Owen Taylor3473f882001-02-23 17:55:21 +000022
23#ifdef __cplusplus
24extern "C" {
25#endif
26
Daniel Veillard5e2dace2001-07-18 19:30:27 +000027/**
28 * XML_DEFAULT_VERSION:
29 *
30 * The default version of XML used: 1.0
Owen Taylor3473f882001-02-23 17:55:21 +000031 */
32#define XML_DEFAULT_VERSION "1.0"
33
34/**
Daniel Veillardf69bb4b2001-05-19 13:24:56 +000035 * xmlParserInput:
36 *
Daniel Veillard61f26172002-03-12 18:46:39 +000037 * An xmlParserInput is an input flow for the XML processor.
Owen Taylor3473f882001-02-23 17:55:21 +000038 * Each entity parsed is associated an xmlParserInput (except the
39 * few predefined ones). This is the case both for internal entities
40 * - in which case the flow is already completely in memory - or
41 * external entities - in which case we use the buf structure for
42 * progressive reading and I18N conversions to the internal UTF-8 format.
43 */
44
Daniel Veillard9d06d302002-01-22 18:15:52 +000045/**
46 * xmlParserInputDeallocate:
47 * @str: the string to deallocate
48 *
Daniel Veillard61f26172002-03-12 18:46:39 +000049 * Callback for freeing some parser input allocations.
Daniel Veillard9d06d302002-01-22 18:15:52 +000050 */
51typedef void (* xmlParserInputDeallocate)(xmlChar *str);
Daniel Veillard5e2dace2001-07-18 19:30:27 +000052
Owen Taylor3473f882001-02-23 17:55:21 +000053struct _xmlParserInput {
54 /* Input buffer */
55 xmlParserInputBufferPtr buf; /* UTF-8 encoded buffer */
56
57 const char *filename; /* The file analyzed, if any */
Daniel Veillard60087f32001-10-10 09:45:09 +000058 const char *directory; /* the directory/base of the file */
Owen Taylor3473f882001-02-23 17:55:21 +000059 const xmlChar *base; /* Base of the array to parse */
60 const xmlChar *cur; /* Current char being parsed */
Daniel Veillardcbaf3992001-12-31 16:16:02 +000061 const xmlChar *end; /* end of the array to parse */
Owen Taylor3473f882001-02-23 17:55:21 +000062 int length; /* length if known */
63 int line; /* Current line */
64 int col; /* Current column */
Daniel Veillard3e59fc52003-04-18 12:34:58 +000065 /*
66 * NOTE: consumed is only tested for equality in the parser code,
67 * so even if there is an overflow this should not give troubles
68 * for parsing very large instances.
69 */
70 unsigned long consumed; /* How many xmlChars already consumed */
Owen Taylor3473f882001-02-23 17:55:21 +000071 xmlParserInputDeallocate free; /* function to deallocate the base */
72 const xmlChar *encoding; /* the encoding string for entity */
73 const xmlChar *version; /* the version string for entity */
74 int standalone; /* Was that entity marked standalone */
Daniel Veillardbdbe0d42003-09-14 19:56:14 +000075 int id; /* an unique identifier for the entity */
Owen Taylor3473f882001-02-23 17:55:21 +000076};
77
78/**
Daniel Veillardf69bb4b2001-05-19 13:24:56 +000079 * xmlParserNodeInfo:
80 *
Daniel Veillard61f26172002-03-12 18:46:39 +000081 * The parser can be asked to collect Node informations, i.e. at what
Owen Taylor3473f882001-02-23 17:55:21 +000082 * place in the file they were detected.
83 * NOTE: This is off by default and not very well tested.
84 */
85typedef struct _xmlParserNodeInfo xmlParserNodeInfo;
86typedef xmlParserNodeInfo *xmlParserNodeInfoPtr;
87
88struct _xmlParserNodeInfo {
89 const struct _xmlNode* node;
90 /* Position & line # that text that created the node begins & ends on */
91 unsigned long begin_pos;
92 unsigned long begin_line;
93 unsigned long end_pos;
94 unsigned long end_line;
95};
96
97typedef struct _xmlParserNodeInfoSeq xmlParserNodeInfoSeq;
98typedef xmlParserNodeInfoSeq *xmlParserNodeInfoSeqPtr;
99struct _xmlParserNodeInfoSeq {
100 unsigned long maximum;
101 unsigned long length;
102 xmlParserNodeInfo* buffer;
103};
104
105/**
Daniel Veillardf69bb4b2001-05-19 13:24:56 +0000106 * xmlParserInputState:
107 *
Daniel Veillard61f26172002-03-12 18:46:39 +0000108 * The parser is now working also as a state based parser.
109 * The recursive one use the state info for entities processing.
Owen Taylor3473f882001-02-23 17:55:21 +0000110 */
111typedef enum {
112 XML_PARSER_EOF = -1, /* nothing is to be parsed */
113 XML_PARSER_START = 0, /* nothing has been parsed */
114 XML_PARSER_MISC, /* Misc* before int subset */
Daniel Veillardcbaf3992001-12-31 16:16:02 +0000115 XML_PARSER_PI, /* Within a processing instruction */
Owen Taylor3473f882001-02-23 17:55:21 +0000116 XML_PARSER_DTD, /* within some DTD content */
117 XML_PARSER_PROLOG, /* Misc* after internal subset */
118 XML_PARSER_COMMENT, /* within a comment */
119 XML_PARSER_START_TAG, /* within a start tag */
120 XML_PARSER_CONTENT, /* within the content */
121 XML_PARSER_CDATA_SECTION, /* within a CDATA section */
122 XML_PARSER_END_TAG, /* within a closing tag */
123 XML_PARSER_ENTITY_DECL, /* within an entity declaration */
124 XML_PARSER_ENTITY_VALUE, /* within an entity value in a decl */
125 XML_PARSER_ATTRIBUTE_VALUE, /* within an attribute value */
126 XML_PARSER_SYSTEM_LITERAL, /* within a SYSTEM value */
127 XML_PARSER_EPILOG, /* the Misc* after the last end tag */
Daniel Veillard4a7ae502002-02-18 19:18:17 +0000128 XML_PARSER_IGNORE, /* within an IGNORED section */
129 XML_PARSER_PUBLIC_LITERAL /* within a PUBLIC value */
Owen Taylor3473f882001-02-23 17:55:21 +0000130} xmlParserInputState;
131
132/**
Daniel Veillardd16df9f2001-05-23 13:44:21 +0000133 * XML_DETECT_IDS:
134 *
Daniel Veillard61f26172002-03-12 18:46:39 +0000135 * Bit in the loadsubset context field to tell to do ID/REFs lookups.
136 * Use it to initialize xmlLoadExtDtdDefaultValue.
Daniel Veillardd16df9f2001-05-23 13:44:21 +0000137 */
138#define XML_DETECT_IDS 2
139
140/**
141 * XML_COMPLETE_ATTRS:
142 *
143 * Bit in the loadsubset context field to tell to do complete the
Daniel Veillard61f26172002-03-12 18:46:39 +0000144 * elements attributes lists with the ones defaulted from the DTDs.
145 * Use it to initialize xmlLoadExtDtdDefaultValue.
Daniel Veillardd16df9f2001-05-23 13:44:21 +0000146 */
147#define XML_COMPLETE_ATTRS 4
148
149/**
Daniel Veillardef8dd7b2003-03-23 12:02:56 +0000150 * XML_SKIP_IDS:
151 *
152 * Bit in the loadsubset context field to tell to not do ID/REFs registration.
153 * Used to initialize xmlLoadExtDtdDefaultValue in some special cases.
154 */
155#define XML_SKIP_IDS 8
156
157/**
Daniel Veillardf69bb4b2001-05-19 13:24:56 +0000158 * xmlParserCtxt:
159 *
Owen Taylor3473f882001-02-23 17:55:21 +0000160 * The parser context.
Daniel Veillard61f26172002-03-12 18:46:39 +0000161 * NOTE This doesn't completely define the parser state, the (current ?)
Owen Taylor3473f882001-02-23 17:55:21 +0000162 * design of the parser uses recursive function calls since this allow
163 * and easy mapping from the production rules of the specification
164 * to the actual code. The drawback is that the actual function call
165 * also reflect the parser state. However most of the parsing routines
166 * takes as the only argument the parser context pointer, so migrating
167 * to a state based parser for progressive parsing shouldn't be too hard.
168 */
Owen Taylor3473f882001-02-23 17:55:21 +0000169struct _xmlParserCtxt {
170 struct _xmlSAXHandler *sax; /* The SAX handler */
171 void *userData; /* For SAX interface only, used by DOM build */
172 xmlDocPtr myDoc; /* the document being built */
173 int wellFormed; /* is the document well formed */
174 int replaceEntities; /* shall we replace entities ? */
175 const xmlChar *version; /* the XML version string */
176 const xmlChar *encoding; /* the declared encoding, if any */
177 int standalone; /* standalone document */
178 int html; /* an HTML(1)/Docbook(2) document */
179
180 /* Input stream stack */
181 xmlParserInputPtr input; /* Current input stream */
182 int inputNr; /* Number of current input streams */
183 int inputMax; /* Max number of input streams */
184 xmlParserInputPtr *inputTab; /* stack of inputs */
185
186 /* Node analysis stack only used for DOM building */
187 xmlNodePtr node; /* Current parsed Node */
188 int nodeNr; /* Depth of the parsing stack */
189 int nodeMax; /* Max depth of the parsing stack */
190 xmlNodePtr *nodeTab; /* array of nodes */
191
192 int record_info; /* Whether node info should be kept */
193 xmlParserNodeInfoSeq node_seq; /* info about each node parsed */
194
195 int errNo; /* error code */
196
197 int hasExternalSubset; /* reference and external subset */
198 int hasPErefs; /* the internal subset has PE refs */
199 int external; /* are we parsing an external entity */
200
201 int valid; /* is the document valid */
202 int validate; /* shall we try to validate ? */
203 xmlValidCtxt vctxt; /* The validity context */
204
205 xmlParserInputState instate; /* current type of input */
206 int token; /* next char look-ahead */
207
208 char *directory; /* the data directory */
209
210 /* Node name stack */
Daniel Veillard2fdbd322003-08-18 12:15:38 +0000211 const xmlChar *name; /* Current parsed Node */
Owen Taylor3473f882001-02-23 17:55:21 +0000212 int nameNr; /* Depth of the parsing stack */
213 int nameMax; /* Max depth of the parsing stack */
Daniel Veillard2fdbd322003-08-18 12:15:38 +0000214 const xmlChar * *nameTab; /* array of nodes */
Owen Taylor3473f882001-02-23 17:55:21 +0000215
216 long nbChars; /* number of xmlChar processed */
217 long checkIndex; /* used by progressive parsing lookup */
218 int keepBlanks; /* ugly but ... */
219 int disableSAX; /* SAX callbacks are disabled */
220 int inSubset; /* Parsing is in int 1/ext 2 subset */
Daniel Veillard2fdbd322003-08-18 12:15:38 +0000221 const xmlChar * intSubName; /* name of subset */
Owen Taylor3473f882001-02-23 17:55:21 +0000222 xmlChar * extSubURI; /* URI of external subset */
223 xmlChar * extSubSystem; /* SYSTEM ID of external subset */
224
225 /* xml:space values */
226 int * space; /* Should the parser preserve spaces */
227 int spaceNr; /* Depth of the parsing stack */
228 int spaceMax; /* Max depth of the parsing stack */
229 int * spaceTab; /* array of space infos */
230
231 int depth; /* to prevent entity substitution loops */
232 xmlParserInputPtr entity; /* used to check entities boundaries */
233 int charset; /* encoding of the in-memory content
234 actually an xmlCharEncoding */
235 int nodelen; /* Those two fields are there to */
236 int nodemem; /* Speed up large node parsing */
237 int pedantic; /* signal pedantic warnings */
238 void *_private; /* For user data, libxml won't touch it */
239
240 int loadsubset; /* should the external subset be loaded */
Daniel Veillardd9bad132001-07-23 19:39:43 +0000241 int linenumbers; /* set line number in element content */
Daniel Veillard5d90b6c2001-08-22 14:29:45 +0000242 void *catalogs; /* document's own catalog */
Daniel Veillarddad3f682002-11-17 16:47:27 +0000243 int recovery; /* run in recovery mode */
Daniel Veillarda880b122003-04-21 21:36:41 +0000244 int progressive; /* is this a progressive parsing */
Daniel Veillard2fdbd322003-08-18 12:15:38 +0000245 xmlDictPtr dict; /* dictionnary for the parser */
Daniel Veillard40412cd2003-09-03 13:28:32 +0000246 const xmlChar * *atts; /* array for the attributes callbacks */
Daniel Veillard6155d8a2003-08-19 15:01:28 +0000247 int maxatts; /* the size of the array */
Daniel Veillard40412cd2003-09-03 13:28:32 +0000248 int docdict; /* use strings from dict to build tree */
Daniel Veillard0fb18932003-09-07 09:14:37 +0000249
250 /*
251 * pre-interned strings
252 */
253 const xmlChar *str_xml;
254 const xmlChar *str_xmlns;
Daniel Veillard07cb8222003-09-10 10:51:05 +0000255 const xmlChar *str_xml_ns;
Daniel Veillard0fb18932003-09-07 09:14:37 +0000256
257 /*
Daniel Veillard07cb8222003-09-10 10:51:05 +0000258 * Everything below is used only by the new SAX mode
Daniel Veillard0fb18932003-09-07 09:14:37 +0000259 */
260 int sax2; /* operating in the new SAX mode */
261 int nsNr; /* the number of inherited namespaces */
262 int nsMax; /* the size of the arrays */
263 const xmlChar * *nsTab; /* the array of prefix/namespace name */
Daniel Veillard07cb8222003-09-10 10:51:05 +0000264 int *attallocs; /* which attribute were allocated */
265 void * *pushTab; /* array of data for push */
266 xmlHashTablePtr attsDefault; /* defaulted attributes if any */
267 xmlHashTablePtr attsSpecial; /* non-CDATA attributes if any */
Daniel Veillard3b7840c2003-09-11 23:42:01 +0000268 int nsWellFormed; /* is the document XML Nanespace okay */
Daniel Veillard9475a352003-09-26 12:47:50 +0000269 int options; /* Extra options */
Daniel Veillard8a44e592003-09-15 14:50:06 +0000270
271 /*
272 * Those fields are needed only for treaming parsing so far
273 */
Daniel Veillard9475a352003-09-26 12:47:50 +0000274 int dictNames; /* Use dictionary names for the tree */
275 int freeElemsNr; /* number of freed element nodes */
276 xmlNodePtr freeElems; /* List of freed element nodes */
277 int freeAttrsNr; /* number of freed attributes nodes */
278 xmlAttrPtr freeAttrs; /* List of freed attributes nodes */
Daniel Veillard2b8c4a12003-10-02 22:28:19 +0000279
280 /*
281 * the complete error informations for the last error.
282 */
283 xmlError lastError;
Owen Taylor3473f882001-02-23 17:55:21 +0000284};
285
286/**
Daniel Veillardf69bb4b2001-05-19 13:24:56 +0000287 * xmlSAXLocator:
288 *
Daniel Veillard61f26172002-03-12 18:46:39 +0000289 * A SAX Locator.
Owen Taylor3473f882001-02-23 17:55:21 +0000290 */
Owen Taylor3473f882001-02-23 17:55:21 +0000291struct _xmlSAXLocator {
292 const xmlChar *(*getPublicId)(void *ctx);
293 const xmlChar *(*getSystemId)(void *ctx);
294 int (*getLineNumber)(void *ctx);
295 int (*getColumnNumber)(void *ctx);
296};
297
298/**
Daniel Veillardf69bb4b2001-05-19 13:24:56 +0000299 * xmlSAXHandler:
300 *
Daniel Veillard61f26172002-03-12 18:46:39 +0000301 * A SAX handler is bunch of callbacks called by the parser when processing
Owen Taylor3473f882001-02-23 17:55:21 +0000302 * of the input generate data or structure informations.
303 */
304
Daniel Veillard9d06d302002-01-22 18:15:52 +0000305/**
306 * resolveEntitySAXFunc:
307 * @ctx: the user data (XML parser context)
308 * @publicId: The public ID of the entity
309 * @systemId: The system ID of the entity
310 *
311 * Callback:
312 * The entity loader, to control the loading of external entities,
313 * the application can either:
314 * - override this resolveEntity() callback in the SAX block
315 * - or better use the xmlSetExternalEntityLoader() function to
316 * set up it's own entity resolution routine
317 *
318 * Returns the xmlParserInputPtr if inlined or NULL for DOM behaviour.
319 */
Owen Taylor3473f882001-02-23 17:55:21 +0000320typedef xmlParserInputPtr (*resolveEntitySAXFunc) (void *ctx,
Daniel Veillard9d06d302002-01-22 18:15:52 +0000321 const xmlChar *publicId,
322 const xmlChar *systemId);
323/**
324 * internalSubsetSAXFunc:
325 * @ctx: the user data (XML parser context)
326 * @name: the root element name
327 * @ExternalID: the external ID
328 * @SystemID: the SYSTEM ID (e.g. filename or URL)
329 *
330 * Callback on internal subset declaration.
331 */
332typedef void (*internalSubsetSAXFunc) (void *ctx,
333 const xmlChar *name,
334 const xmlChar *ExternalID,
335 const xmlChar *SystemID);
336/**
337 * externalSubsetSAXFunc:
338 * @ctx: the user data (XML parser context)
339 * @name: the root element name
340 * @ExternalID: the external ID
341 * @SystemID: the SYSTEM ID (e.g. filename or URL)
342 *
343 * Callback on external subset declaration.
344 */
345typedef void (*externalSubsetSAXFunc) (void *ctx,
346 const xmlChar *name,
347 const xmlChar *ExternalID,
348 const xmlChar *SystemID);
349/**
350 * getEntitySAXFunc:
351 * @ctx: the user data (XML parser context)
352 * @name: The entity name
353 *
Daniel Veillard61f26172002-03-12 18:46:39 +0000354 * Get an entity by name.
Daniel Veillard9d06d302002-01-22 18:15:52 +0000355 *
356 * Returns the xmlEntityPtr if found.
357 */
Owen Taylor3473f882001-02-23 17:55:21 +0000358typedef xmlEntityPtr (*getEntitySAXFunc) (void *ctx,
Daniel Veillard9d06d302002-01-22 18:15:52 +0000359 const xmlChar *name);
360/**
361 * getParameterEntitySAXFunc:
362 * @ctx: the user data (XML parser context)
363 * @name: The entity name
364 *
Daniel Veillard61f26172002-03-12 18:46:39 +0000365 * Get a parameter entity by name.
Daniel Veillard9d06d302002-01-22 18:15:52 +0000366 *
367 * Returns the xmlEntityPtr if found.
368 */
Owen Taylor3473f882001-02-23 17:55:21 +0000369typedef xmlEntityPtr (*getParameterEntitySAXFunc) (void *ctx,
Daniel Veillard9d06d302002-01-22 18:15:52 +0000370 const xmlChar *name);
371/**
372 * entityDeclSAXFunc:
373 * @ctx: the user data (XML parser context)
374 * @name: the entity name
375 * @type: the entity type
376 * @publicId: The public ID of the entity
377 * @systemId: The system ID of the entity
378 * @content: the entity value (without processing).
379 *
Daniel Veillard61f26172002-03-12 18:46:39 +0000380 * An entity definition has been parsed.
Daniel Veillard9d06d302002-01-22 18:15:52 +0000381 */
Owen Taylor3473f882001-02-23 17:55:21 +0000382typedef void (*entityDeclSAXFunc) (void *ctx,
Daniel Veillard9d06d302002-01-22 18:15:52 +0000383 const xmlChar *name,
384 int type,
385 const xmlChar *publicId,
386 const xmlChar *systemId,
387 xmlChar *content);
388/**
389 * notationDeclSAXFunc:
390 * @ctx: the user data (XML parser context)
391 * @name: The name of the notation
392 * @publicId: The public ID of the entity
393 * @systemId: The system ID of the entity
394 *
395 * What to do when a notation declaration has been parsed.
396 */
397typedef void (*notationDeclSAXFunc)(void *ctx,
398 const xmlChar *name,
399 const xmlChar *publicId,
400 const xmlChar *systemId);
401/**
402 * attributeDeclSAXFunc:
403 * @ctx: the user data (XML parser context)
404 * @elem: the name of the element
405 * @fullname: the attribute name
406 * @type: the attribute type
407 * @def: the type of default value
408 * @defaultValue: the attribute default value
409 * @tree: the tree of enumerated value set
410 *
Daniel Veillard61f26172002-03-12 18:46:39 +0000411 * An attribute definition has been parsed.
Daniel Veillard9d06d302002-01-22 18:15:52 +0000412 */
413typedef void (*attributeDeclSAXFunc)(void *ctx,
414 const xmlChar *elem,
415 const xmlChar *fullname,
416 int type,
417 int def,
418 const xmlChar *defaultValue,
419 xmlEnumerationPtr tree);
420/**
421 * elementDeclSAXFunc:
422 * @ctx: the user data (XML parser context)
423 * @name: the element name
424 * @type: the element type
425 * @content: the element value tree
426 *
Daniel Veillard61f26172002-03-12 18:46:39 +0000427 * An element definition has been parsed.
Daniel Veillard9d06d302002-01-22 18:15:52 +0000428 */
429typedef void (*elementDeclSAXFunc)(void *ctx,
430 const xmlChar *name,
431 int type,
432 xmlElementContentPtr content);
433/**
434 * unparsedEntityDeclSAXFunc:
435 * @ctx: the user data (XML parser context)
436 * @name: The name of the entity
437 * @publicId: The public ID of the entity
438 * @systemId: The system ID of the entity
439 * @notationName: the name of the notation
440 *
Daniel Veillard61f26172002-03-12 18:46:39 +0000441 * What to do when an unparsed entity declaration is parsed.
Daniel Veillard9d06d302002-01-22 18:15:52 +0000442 */
Owen Taylor3473f882001-02-23 17:55:21 +0000443typedef void (*unparsedEntityDeclSAXFunc)(void *ctx,
Daniel Veillard9d06d302002-01-22 18:15:52 +0000444 const xmlChar *name,
445 const xmlChar *publicId,
446 const xmlChar *systemId,
447 const xmlChar *notationName);
448/**
449 * setDocumentLocatorSAXFunc:
450 * @ctx: the user data (XML parser context)
451 * @loc: A SAX Locator
452 *
Daniel Veillard61f26172002-03-12 18:46:39 +0000453 * Receive the document locator at startup, actually xmlDefaultSAXLocator.
Daniel Veillard9d06d302002-01-22 18:15:52 +0000454 * Everything is available on the context, so this is useless in our case.
455 */
Owen Taylor3473f882001-02-23 17:55:21 +0000456typedef void (*setDocumentLocatorSAXFunc) (void *ctx,
Daniel Veillard9d06d302002-01-22 18:15:52 +0000457 xmlSAXLocatorPtr loc);
458/**
459 * startDocumentSAXFunc:
460 * @ctx: the user data (XML parser context)
461 *
Daniel Veillard61f26172002-03-12 18:46:39 +0000462 * Called when the document start being processed.
Daniel Veillard9d06d302002-01-22 18:15:52 +0000463 */
Owen Taylor3473f882001-02-23 17:55:21 +0000464typedef void (*startDocumentSAXFunc) (void *ctx);
Daniel Veillard9d06d302002-01-22 18:15:52 +0000465/**
466 * endDocumentSAXFunc:
467 * @ctx: the user data (XML parser context)
468 *
Daniel Veillard61f26172002-03-12 18:46:39 +0000469 * Called when the document end has been detected.
Daniel Veillard9d06d302002-01-22 18:15:52 +0000470 */
Owen Taylor3473f882001-02-23 17:55:21 +0000471typedef void (*endDocumentSAXFunc) (void *ctx);
Daniel Veillard9d06d302002-01-22 18:15:52 +0000472/**
473 * startElementSAXFunc:
474 * @ctx: the user data (XML parser context)
475 * @name: The element name, including namespace prefix
476 * @atts: An array of name/value attributes pairs, NULL terminated
477 *
Daniel Veillard61f26172002-03-12 18:46:39 +0000478 * Called when an opening tag has been processed.
Daniel Veillard9d06d302002-01-22 18:15:52 +0000479 */
480typedef void (*startElementSAXFunc) (void *ctx,
481 const xmlChar *name,
482 const xmlChar **atts);
483/**
484 * endElementSAXFunc:
485 * @ctx: the user data (XML parser context)
486 * @name: The element name
487 *
Daniel Veillard61f26172002-03-12 18:46:39 +0000488 * Called when the end of an element has been detected.
Daniel Veillard9d06d302002-01-22 18:15:52 +0000489 */
490typedef void (*endElementSAXFunc) (void *ctx,
491 const xmlChar *name);
492/**
493 * attributeSAXFunc:
494 * @ctx: the user data (XML parser context)
495 * @name: The attribute name, including namespace prefix
496 * @value: The attribute value
497 *
498 * Handle an attribute that has been read by the parser.
499 * The default handling is to convert the attribute into an
500 * DOM subtree and past it in a new xmlAttr element added to
501 * the element.
502 */
503typedef void (*attributeSAXFunc) (void *ctx,
504 const xmlChar *name,
505 const xmlChar *value);
506/**
507 * referenceSAXFunc:
508 * @ctx: the user data (XML parser context)
509 * @name: The entity name
510 *
Daniel Veillard61f26172002-03-12 18:46:39 +0000511 * Called when an entity reference is detected.
Daniel Veillard9d06d302002-01-22 18:15:52 +0000512 */
513typedef void (*referenceSAXFunc) (void *ctx,
514 const xmlChar *name);
515/**
516 * charactersSAXFunc:
517 * @ctx: the user data (XML parser context)
518 * @ch: a xmlChar string
519 * @len: the number of xmlChar
520 *
Daniel Veillard61f26172002-03-12 18:46:39 +0000521 * Receiving some chars from the parser.
Daniel Veillard9d06d302002-01-22 18:15:52 +0000522 */
523typedef void (*charactersSAXFunc) (void *ctx,
524 const xmlChar *ch,
525 int len);
526/**
527 * ignorableWhitespaceSAXFunc:
528 * @ctx: the user data (XML parser context)
529 * @ch: a xmlChar string
530 * @len: the number of xmlChar
531 *
Daniel Veillard61f26172002-03-12 18:46:39 +0000532 * Receiving some ignorable whitespaces from the parser.
533 * UNUSED: by default the DOM building will use characters.
Daniel Veillard9d06d302002-01-22 18:15:52 +0000534 */
Owen Taylor3473f882001-02-23 17:55:21 +0000535typedef void (*ignorableWhitespaceSAXFunc) (void *ctx,
Daniel Veillard9d06d302002-01-22 18:15:52 +0000536 const xmlChar *ch,
537 int len);
538/**
539 * processingInstructionSAXFunc:
540 * @ctx: the user data (XML parser context)
541 * @target: the target name
542 * @data: the PI data's
543 *
544 * A processing instruction has been parsed.
545 */
Owen Taylor3473f882001-02-23 17:55:21 +0000546typedef void (*processingInstructionSAXFunc) (void *ctx,
Daniel Veillard9d06d302002-01-22 18:15:52 +0000547 const xmlChar *target,
548 const xmlChar *data);
549/**
550 * commentSAXFunc:
551 * @ctx: the user data (XML parser context)
552 * @value: the comment content
553 *
554 * A comment has been parsed.
555 */
556typedef void (*commentSAXFunc) (void *ctx,
557 const xmlChar *value);
558/**
559 * cdataBlockSAXFunc:
560 * @ctx: the user data (XML parser context)
561 * @value: The pcdata content
562 * @len: the block length
563 *
Daniel Veillard61f26172002-03-12 18:46:39 +0000564 * Called when a pcdata block has been parsed.
Daniel Veillard9d06d302002-01-22 18:15:52 +0000565 */
566typedef void (*cdataBlockSAXFunc) (
567 void *ctx,
568 const xmlChar *value,
569 int len);
570/**
571 * warningSAXFunc:
572 * @ctx: an XML parser context
573 * @msg: the message to display/transmit
574 * @...: extra parameters for the message display
575 *
Daniel Veillard61f26172002-03-12 18:46:39 +0000576 * Display and format a warning messages, callback.
Daniel Veillard9d06d302002-01-22 18:15:52 +0000577 */
578typedef void (*warningSAXFunc) (void *ctx,
579 const char *msg, ...);
580/**
581 * errorSAXFunc:
582 * @ctx: an XML parser context
583 * @msg: the message to display/transmit
584 * @...: extra parameters for the message display
585 *
Daniel Veillard61f26172002-03-12 18:46:39 +0000586 * Display and format an error messages, callback.
Daniel Veillard9d06d302002-01-22 18:15:52 +0000587 */
588typedef void (*errorSAXFunc) (void *ctx,
589 const char *msg, ...);
590/**
591 * fatalErrorSAXFunc:
592 * @ctx: an XML parser context
593 * @msg: the message to display/transmit
594 * @...: extra parameters for the message display
595 *
Daniel Veillard61f26172002-03-12 18:46:39 +0000596 * Display and format fatal error messages, callback.
Daniel Veillard0821b152002-11-12 20:57:47 +0000597 * Note: so far fatalError() SAX callbacks are not used, error()
598 * get all the callbacks for errors.
Daniel Veillard9d06d302002-01-22 18:15:52 +0000599 */
600typedef void (*fatalErrorSAXFunc) (void *ctx,
601 const char *msg, ...);
602/**
603 * isStandaloneSAXFunc:
604 * @ctx: the user data (XML parser context)
605 *
Daniel Veillard61f26172002-03-12 18:46:39 +0000606 * Is this document tagged standalone?
Daniel Veillard9d06d302002-01-22 18:15:52 +0000607 *
608 * Returns 1 if true
609 */
Owen Taylor3473f882001-02-23 17:55:21 +0000610typedef int (*isStandaloneSAXFunc) (void *ctx);
Daniel Veillard9d06d302002-01-22 18:15:52 +0000611/**
612 * hasInternalSubsetSAXFunc:
613 * @ctx: the user data (XML parser context)
614 *
Daniel Veillard61f26172002-03-12 18:46:39 +0000615 * Does this document has an internal subset.
Daniel Veillard9d06d302002-01-22 18:15:52 +0000616 *
617 * Returns 1 if true
618 */
Owen Taylor3473f882001-02-23 17:55:21 +0000619typedef int (*hasInternalSubsetSAXFunc) (void *ctx);
Daniel Veillard1af9a412003-08-20 22:54:39 +0000620
Daniel Veillard9d06d302002-01-22 18:15:52 +0000621/**
622 * hasExternalSubsetSAXFunc:
623 * @ctx: the user data (XML parser context)
624 *
Daniel Veillard61f26172002-03-12 18:46:39 +0000625 * Does this document has an external subset?
Daniel Veillard9d06d302002-01-22 18:15:52 +0000626 *
627 * Returns 1 if true
628 */
Owen Taylor3473f882001-02-23 17:55:21 +0000629typedef int (*hasExternalSubsetSAXFunc) (void *ctx);
630
Daniel Veillard1af9a412003-08-20 22:54:39 +0000631/************************************************************************
632 * *
633 * The SAX version 2 API extensions *
634 * *
635 ************************************************************************/
636/**
637 * XML_SAX2_MAGIC:
638 *
639 * Special constant found in SAX2 blocks initialized fields
640 */
641#define XML_SAX2_MAGIC 0xDEEDBEAF
642
643/**
644 * startElementNsSAX2Func:
645 * @ctx: the user data (XML parser context)
646 * @localname: the local name of the element
647 * @prefix: the element namespace prefix if available
648 * @URI: the element namespace name if available
649 * @nb_namespaces: number of namespace definitions on that node
650 * @namespaces: pointer to the array of prefix/URI pairs namespace definitions
651 * @nb_attributes: the number of attributes on that node
Daniel Veillard07cb8222003-09-10 10:51:05 +0000652 * @nb_defaulted: the number of defaulted attributes. The defaulted
653 * ones are at the end of the array
654 * @attributes: pointer to the array of (localname/prefix/URI/value/end)
655 * attribute values.
Daniel Veillard1af9a412003-08-20 22:54:39 +0000656 *
657 * SAX2 callback when an element start has been detected by the parser.
658 * It provides the namespace informations for the element, as well as
659 * the new namespace declarations on the element.
Daniel Veillard1af9a412003-08-20 22:54:39 +0000660 */
661
662typedef void (*startElementNsSAX2Func) (void *ctx,
663 const xmlChar *localname,
664 const xmlChar *prefix,
665 const xmlChar *URI,
666 int nb_namespaces,
667 const xmlChar **namespaces,
Daniel Veillard07cb8222003-09-10 10:51:05 +0000668 int nb_attributes,
669 int nb_defaulted,
670 const xmlChar **attributes);
Daniel Veillard1af9a412003-08-20 22:54:39 +0000671
672/**
673 * endElementNsSAX2Func:
674 * @ctx: the user data (XML parser context)
675 * @localname: the local name of the element
676 * @prefix: the element namespace prefix if available
677 * @URI: the element namespace name if available
678 *
679 * SAX2 callback when an element end has been detected by the parser.
680 * It provides the namespace informations for the element.
681 */
682
683typedef void (*endElementNsSAX2Func) (void *ctx,
684 const xmlChar *localname,
685 const xmlChar *prefix,
686 const xmlChar *URI);
687
Daniel Veillard1af9a412003-08-20 22:54:39 +0000688
Owen Taylor3473f882001-02-23 17:55:21 +0000689struct _xmlSAXHandler {
690 internalSubsetSAXFunc internalSubset;
691 isStandaloneSAXFunc isStandalone;
692 hasInternalSubsetSAXFunc hasInternalSubset;
693 hasExternalSubsetSAXFunc hasExternalSubset;
694 resolveEntitySAXFunc resolveEntity;
695 getEntitySAXFunc getEntity;
696 entityDeclSAXFunc entityDecl;
697 notationDeclSAXFunc notationDecl;
698 attributeDeclSAXFunc attributeDecl;
699 elementDeclSAXFunc elementDecl;
700 unparsedEntityDeclSAXFunc unparsedEntityDecl;
701 setDocumentLocatorSAXFunc setDocumentLocator;
702 startDocumentSAXFunc startDocument;
703 endDocumentSAXFunc endDocument;
704 startElementSAXFunc startElement;
705 endElementSAXFunc endElement;
706 referenceSAXFunc reference;
707 charactersSAXFunc characters;
708 ignorableWhitespaceSAXFunc ignorableWhitespace;
709 processingInstructionSAXFunc processingInstruction;
710 commentSAXFunc comment;
711 warningSAXFunc warning;
712 errorSAXFunc error;
Daniel Veillard0821b152002-11-12 20:57:47 +0000713 fatalErrorSAXFunc fatalError; /* unused error() get all the errors */
Owen Taylor3473f882001-02-23 17:55:21 +0000714 getParameterEntitySAXFunc getParameterEntity;
715 cdataBlockSAXFunc cdataBlock;
716 externalSubsetSAXFunc externalSubset;
Daniel Veillard07cb8222003-09-10 10:51:05 +0000717 unsigned int initialized;
Daniel Veillard1af9a412003-08-20 22:54:39 +0000718 /* The following fields are extensions available only on version 2 */
719 void *_private;
720 startElementNsSAX2Func startElementNs;
721 endElementNsSAX2Func endElementNs;
Daniel Veillard659e71e2003-10-10 14:10:40 +0000722 xmlStructuredErrorFunc serror;
Owen Taylor3473f882001-02-23 17:55:21 +0000723};
724
Daniel Veillard9ee35f32003-09-28 00:19:54 +0000725/*
726 * SAX Version 1
727 */
728typedef struct _xmlSAXHandlerV1 xmlSAXHandlerV1;
729typedef xmlSAXHandlerV1 *xmlSAXHandlerV1Ptr;
730struct _xmlSAXHandlerV1 {
731 internalSubsetSAXFunc internalSubset;
732 isStandaloneSAXFunc isStandalone;
733 hasInternalSubsetSAXFunc hasInternalSubset;
734 hasExternalSubsetSAXFunc hasExternalSubset;
735 resolveEntitySAXFunc resolveEntity;
736 getEntitySAXFunc getEntity;
737 entityDeclSAXFunc entityDecl;
738 notationDeclSAXFunc notationDecl;
739 attributeDeclSAXFunc attributeDecl;
740 elementDeclSAXFunc elementDecl;
741 unparsedEntityDeclSAXFunc unparsedEntityDecl;
742 setDocumentLocatorSAXFunc setDocumentLocator;
743 startDocumentSAXFunc startDocument;
744 endDocumentSAXFunc endDocument;
745 startElementSAXFunc startElement;
746 endElementSAXFunc endElement;
747 referenceSAXFunc reference;
748 charactersSAXFunc characters;
749 ignorableWhitespaceSAXFunc ignorableWhitespace;
750 processingInstructionSAXFunc processingInstruction;
751 commentSAXFunc comment;
752 warningSAXFunc warning;
753 errorSAXFunc error;
754 fatalErrorSAXFunc fatalError; /* unused error() get all the errors */
755 getParameterEntitySAXFunc getParameterEntity;
756 cdataBlockSAXFunc cdataBlock;
757 externalSubsetSAXFunc externalSubset;
758 unsigned int initialized;
759};
760
761
Owen Taylor3473f882001-02-23 17:55:21 +0000762/**
Daniel Veillardf69bb4b2001-05-19 13:24:56 +0000763 * xmlExternalEntityLoader:
764 * @URL: The System ID of the resource requested
765 * @ID: The Public ID of the resource requested
Daniel Veillardcbaf3992001-12-31 16:16:02 +0000766 * @context: the XML parser context
Daniel Veillardf69bb4b2001-05-19 13:24:56 +0000767 *
Daniel Veillard61f26172002-03-12 18:46:39 +0000768 * External entity loaders types.
Daniel Veillardcbaf3992001-12-31 16:16:02 +0000769 *
Daniel Veillard61f26172002-03-12 18:46:39 +0000770 * Returns the entity input parser.
Owen Taylor3473f882001-02-23 17:55:21 +0000771 */
Daniel Veillard9d06d302002-01-22 18:15:52 +0000772typedef xmlParserInputPtr (*xmlExternalEntityLoader) (const char *URL,
773 const char *ID,
774 xmlParserCtxtPtr context);
Owen Taylor3473f882001-02-23 17:55:21 +0000775
Daniel Veillard6c4ffaf2002-02-11 08:54:05 +0000776#ifdef __cplusplus
777}
778#endif
Igor Zlatkovic76874e42003-08-25 09:05:12 +0000779
Daniel Veillard6c4ffaf2002-02-11 08:54:05 +0000780#include <libxml/encoding.h>
781#include <libxml/xmlIO.h>
782#include <libxml/globals.h>
Igor Zlatkovic76874e42003-08-25 09:05:12 +0000783
Daniel Veillard6c4ffaf2002-02-11 08:54:05 +0000784#ifdef __cplusplus
785extern "C" {
786#endif
787
Owen Taylor3473f882001-02-23 17:55:21 +0000788
Daniel Veillardf69bb4b2001-05-19 13:24:56 +0000789/*
Owen Taylor3473f882001-02-23 17:55:21 +0000790 * Init/Cleanup
791 */
Igor Zlatkovic76874e42003-08-25 09:05:12 +0000792XMLPUBFUN void XMLCALL
793 xmlInitParser (void);
794XMLPUBFUN void XMLCALL
795 xmlCleanupParser (void);
Owen Taylor3473f882001-02-23 17:55:21 +0000796
Daniel Veillardf69bb4b2001-05-19 13:24:56 +0000797/*
Owen Taylor3473f882001-02-23 17:55:21 +0000798 * Input functions
799 */
Igor Zlatkovic76874e42003-08-25 09:05:12 +0000800XMLPUBFUN int XMLCALL
801 xmlParserInputRead (xmlParserInputPtr in,
Owen Taylor3473f882001-02-23 17:55:21 +0000802 int len);
Igor Zlatkovic76874e42003-08-25 09:05:12 +0000803XMLPUBFUN int XMLCALL
804 xmlParserInputGrow (xmlParserInputPtr in,
Owen Taylor3473f882001-02-23 17:55:21 +0000805 int len);
806
Daniel Veillardf69bb4b2001-05-19 13:24:56 +0000807/*
Owen Taylor3473f882001-02-23 17:55:21 +0000808 * xmlChar handling
809 */
Igor Zlatkovic76874e42003-08-25 09:05:12 +0000810XMLPUBFUN xmlChar * XMLCALL
811 xmlStrdup (const xmlChar *cur);
812XMLPUBFUN xmlChar * XMLCALL
813 xmlStrndup (const xmlChar *cur,
Owen Taylor3473f882001-02-23 17:55:21 +0000814 int len);
Igor Zlatkovic76874e42003-08-25 09:05:12 +0000815XMLPUBFUN xmlChar * XMLCALL
816 xmlCharStrndup (const char *cur,
Daniel Veillard56a4cb82001-03-24 17:00:36 +0000817 int len);
Igor Zlatkovic76874e42003-08-25 09:05:12 +0000818XMLPUBFUN xmlChar * XMLCALL
819 xmlCharStrdup (const char *cur);
820XMLPUBFUN xmlChar * XMLCALL
821 xmlStrsub (const xmlChar *str,
Owen Taylor3473f882001-02-23 17:55:21 +0000822 int start,
823 int len);
Igor Zlatkovic76874e42003-08-25 09:05:12 +0000824XMLPUBFUN const xmlChar * XMLCALL
825 xmlStrchr (const xmlChar *str,
Owen Taylor3473f882001-02-23 17:55:21 +0000826 xmlChar val);
Igor Zlatkovic76874e42003-08-25 09:05:12 +0000827XMLPUBFUN const xmlChar * XMLCALL
828 xmlStrstr (const xmlChar *str,
Daniel Veillard77044732001-06-29 21:31:07 +0000829 const xmlChar *val);
Igor Zlatkovic76874e42003-08-25 09:05:12 +0000830XMLPUBFUN const xmlChar * XMLCALL
831 xmlStrcasestr (const xmlChar *str,
Owen Taylor3473f882001-02-23 17:55:21 +0000832 xmlChar *val);
Igor Zlatkovic76874e42003-08-25 09:05:12 +0000833XMLPUBFUN int XMLCALL
834 xmlStrcmp (const xmlChar *str1,
Owen Taylor3473f882001-02-23 17:55:21 +0000835 const xmlChar *str2);
Igor Zlatkovic76874e42003-08-25 09:05:12 +0000836XMLPUBFUN int XMLCALL
837 xmlStrncmp (const xmlChar *str1,
Owen Taylor3473f882001-02-23 17:55:21 +0000838 const xmlChar *str2,
839 int len);
Igor Zlatkovic76874e42003-08-25 09:05:12 +0000840XMLPUBFUN int XMLCALL
841 xmlStrcasecmp (const xmlChar *str1,
Owen Taylor3473f882001-02-23 17:55:21 +0000842 const xmlChar *str2);
Igor Zlatkovic76874e42003-08-25 09:05:12 +0000843XMLPUBFUN int XMLCALL
844 xmlStrncasecmp (const xmlChar *str1,
Owen Taylor3473f882001-02-23 17:55:21 +0000845 const xmlChar *str2,
846 int len);
Igor Zlatkovic76874e42003-08-25 09:05:12 +0000847XMLPUBFUN int XMLCALL
848 xmlStrEqual (const xmlChar *str1,
Owen Taylor3473f882001-02-23 17:55:21 +0000849 const xmlChar *str2);
Daniel Veillard07cb8222003-09-10 10:51:05 +0000850XMLPUBFUN int XMLCALL
851 xmlStrQEqual (const xmlChar *pref,
852 const xmlChar *name,
853 const xmlChar *str);
Igor Zlatkovic76874e42003-08-25 09:05:12 +0000854XMLPUBFUN int XMLCALL
855 xmlStrlen (const xmlChar *str);
856XMLPUBFUN xmlChar * XMLCALL
857 xmlStrcat (xmlChar *cur,
Owen Taylor3473f882001-02-23 17:55:21 +0000858 const xmlChar *add);
Igor Zlatkovic76874e42003-08-25 09:05:12 +0000859XMLPUBFUN xmlChar * XMLCALL
860 xmlStrncat (xmlChar *cur,
Owen Taylor3473f882001-02-23 17:55:21 +0000861 const xmlChar *add,
862 int len);
863
Aleksey Sanine7acf432003-10-02 20:05:27 +0000864XMLPUBFUN int XMLCALL
865 xmlStrPrintf (xmlChar *buf,
866 int len,
867 const xmlChar *msg,
868 ...);
869
Aleksey Saninb5a46da2003-10-29 15:51:17 +0000870XMLPUBFUN int XMLCALL
871 xmlStrVPrintf (xmlChar *buf,
872 int len,
873 const xmlChar *msg,
874 va_list ap);
875
Daniel Veillardf69bb4b2001-05-19 13:24:56 +0000876/*
Owen Taylor3473f882001-02-23 17:55:21 +0000877 * Basic parsing Interfaces
878 */
Igor Zlatkovic76874e42003-08-25 09:05:12 +0000879XMLPUBFUN xmlDocPtr XMLCALL
880 xmlParseDoc (xmlChar *cur);
881XMLPUBFUN xmlDocPtr XMLCALL
882 xmlParseMemory (const char *buffer,
Owen Taylor3473f882001-02-23 17:55:21 +0000883 int size);
Igor Zlatkovic76874e42003-08-25 09:05:12 +0000884XMLPUBFUN xmlDocPtr XMLCALL
885 xmlParseFile (const char *filename);
886XMLPUBFUN int XMLCALL
887 xmlSubstituteEntitiesDefault(int val);
888XMLPUBFUN int XMLCALL
889 xmlKeepBlanksDefault (int val);
890XMLPUBFUN void XMLCALL
891 xmlStopParser (xmlParserCtxtPtr ctxt);
892XMLPUBFUN int XMLCALL
893 xmlPedanticParserDefault(int val);
894XMLPUBFUN int XMLCALL
895 xmlLineNumbersDefault (int val);
Owen Taylor3473f882001-02-23 17:55:21 +0000896
Daniel Veillardf69bb4b2001-05-19 13:24:56 +0000897/*
Owen Taylor3473f882001-02-23 17:55:21 +0000898 * Recovery mode
899 */
Igor Zlatkovic76874e42003-08-25 09:05:12 +0000900XMLPUBFUN xmlDocPtr XMLCALL
901 xmlRecoverDoc (xmlChar *cur);
902XMLPUBFUN xmlDocPtr XMLCALL
903 xmlRecoverMemory (const char *buffer,
Owen Taylor3473f882001-02-23 17:55:21 +0000904 int size);
Igor Zlatkovic76874e42003-08-25 09:05:12 +0000905XMLPUBFUN xmlDocPtr XMLCALL
906 xmlRecoverFile (const char *filename);
Owen Taylor3473f882001-02-23 17:55:21 +0000907
Daniel Veillardf69bb4b2001-05-19 13:24:56 +0000908/*
Owen Taylor3473f882001-02-23 17:55:21 +0000909 * Less common routines and SAX interfaces
910 */
Igor Zlatkovic76874e42003-08-25 09:05:12 +0000911XMLPUBFUN int XMLCALL
912 xmlParseDocument (xmlParserCtxtPtr ctxt);
913XMLPUBFUN int XMLCALL
914 xmlParseExtParsedEnt (xmlParserCtxtPtr ctxt);
915XMLPUBFUN xmlDocPtr XMLCALL
916 xmlSAXParseDoc (xmlSAXHandlerPtr sax,
Owen Taylor3473f882001-02-23 17:55:21 +0000917 xmlChar *cur,
918 int recovery);
Igor Zlatkovic76874e42003-08-25 09:05:12 +0000919XMLPUBFUN int XMLCALL
920 xmlSAXUserParseFile (xmlSAXHandlerPtr sax,
Owen Taylor3473f882001-02-23 17:55:21 +0000921 void *user_data,
922 const char *filename);
Igor Zlatkovic76874e42003-08-25 09:05:12 +0000923XMLPUBFUN int XMLCALL
924 xmlSAXUserParseMemory (xmlSAXHandlerPtr sax,
Owen Taylor3473f882001-02-23 17:55:21 +0000925 void *user_data,
Daniel Veillardfd7ddca2001-05-16 10:57:35 +0000926 const char *buffer,
Owen Taylor3473f882001-02-23 17:55:21 +0000927 int size);
Igor Zlatkovic76874e42003-08-25 09:05:12 +0000928XMLPUBFUN xmlDocPtr XMLCALL
929 xmlSAXParseMemory (xmlSAXHandlerPtr sax,
Daniel Veillard50822cb2001-07-26 20:05:51 +0000930 const char *buffer,
Owen Taylor3473f882001-02-23 17:55:21 +0000931 int size,
932 int recovery);
Igor Zlatkovic76874e42003-08-25 09:05:12 +0000933XMLPUBFUN xmlDocPtr XMLCALL
934 xmlSAXParseMemoryWithData (xmlSAXHandlerPtr sax,
Daniel Veillard8606bbb2002-11-12 12:36:52 +0000935 const char *buffer,
936 int size,
937 int recovery,
938 void *data);
Igor Zlatkovic76874e42003-08-25 09:05:12 +0000939XMLPUBFUN xmlDocPtr XMLCALL
940 xmlSAXParseFile (xmlSAXHandlerPtr sax,
Owen Taylor3473f882001-02-23 17:55:21 +0000941 const char *filename,
942 int recovery);
Igor Zlatkovic76874e42003-08-25 09:05:12 +0000943XMLPUBFUN xmlDocPtr XMLCALL
944 xmlSAXParseFileWithData (xmlSAXHandlerPtr sax,
Daniel Veillarda293c322001-10-02 13:54:14 +0000945 const char *filename,
946 int recovery,
947 void *data);
Igor Zlatkovic76874e42003-08-25 09:05:12 +0000948XMLPUBFUN xmlDocPtr XMLCALL
949 xmlSAXParseEntity (xmlSAXHandlerPtr sax,
Owen Taylor3473f882001-02-23 17:55:21 +0000950 const char *filename);
Igor Zlatkovic76874e42003-08-25 09:05:12 +0000951XMLPUBFUN xmlDocPtr XMLCALL
952 xmlParseEntity (const char *filename);
953XMLPUBFUN xmlDtdPtr XMLCALL
954 xmlParseDTD (const xmlChar *ExternalID,
Owen Taylor3473f882001-02-23 17:55:21 +0000955 const xmlChar *SystemID);
Igor Zlatkovic76874e42003-08-25 09:05:12 +0000956XMLPUBFUN xmlDtdPtr XMLCALL
957 xmlSAXParseDTD (xmlSAXHandlerPtr sax,
Owen Taylor3473f882001-02-23 17:55:21 +0000958 const xmlChar *ExternalID,
959 const xmlChar *SystemID);
Igor Zlatkovic76874e42003-08-25 09:05:12 +0000960XMLPUBFUN xmlDtdPtr XMLCALL
961 xmlIOParseDTD (xmlSAXHandlerPtr sax,
Owen Taylor3473f882001-02-23 17:55:21 +0000962 xmlParserInputBufferPtr input,
963 xmlCharEncoding enc);
Igor Zlatkovic76874e42003-08-25 09:05:12 +0000964XMLPUBFUN int XMLCALL
965 xmlParseBalancedChunkMemory(xmlDocPtr doc,
Owen Taylor3473f882001-02-23 17:55:21 +0000966 xmlSAXHandlerPtr sax,
967 void *user_data,
968 int depth,
969 const xmlChar *string,
Daniel Veillardcda96922001-08-21 10:56:31 +0000970 xmlNodePtr *lst);
Igor Zlatkovic76874e42003-08-25 09:05:12 +0000971XMLPUBFUN int XMLCALL
972 xmlParseBalancedChunkMemoryRecover(xmlDocPtr doc,
Daniel Veillard58e44c92002-08-02 22:19:49 +0000973 xmlSAXHandlerPtr sax,
974 void *user_data,
975 int depth,
976 const xmlChar *string,
977 xmlNodePtr *lst,
978 int recover);
Igor Zlatkovic76874e42003-08-25 09:05:12 +0000979XMLPUBFUN int XMLCALL
980 xmlParseExternalEntity (xmlDocPtr doc,
Owen Taylor3473f882001-02-23 17:55:21 +0000981 xmlSAXHandlerPtr sax,
982 void *user_data,
983 int depth,
984 const xmlChar *URL,
985 const xmlChar *ID,
Daniel Veillardcda96922001-08-21 10:56:31 +0000986 xmlNodePtr *lst);
Igor Zlatkovic76874e42003-08-25 09:05:12 +0000987XMLPUBFUN int XMLCALL
988 xmlParseCtxtExternalEntity(xmlParserCtxtPtr ctx,
Owen Taylor3473f882001-02-23 17:55:21 +0000989 const xmlChar *URL,
990 const xmlChar *ID,
Daniel Veillardcda96922001-08-21 10:56:31 +0000991 xmlNodePtr *lst);
Owen Taylor3473f882001-02-23 17:55:21 +0000992
Daniel Veillardf69bb4b2001-05-19 13:24:56 +0000993/*
Owen Taylor3473f882001-02-23 17:55:21 +0000994 * Parser contexts handling.
995 */
Daniel Veillard2b8c4a12003-10-02 22:28:19 +0000996XMLPUBFUN xmlParserCtxtPtr XMLCALL
997 xmlNewParserCtxt (void);
Igor Zlatkovic76874e42003-08-25 09:05:12 +0000998XMLPUBFUN int XMLCALL
999 xmlInitParserCtxt (xmlParserCtxtPtr ctxt);
1000XMLPUBFUN void XMLCALL
1001 xmlClearParserCtxt (xmlParserCtxtPtr ctxt);
1002XMLPUBFUN void XMLCALL
1003 xmlFreeParserCtxt (xmlParserCtxtPtr ctxt);
1004XMLPUBFUN void XMLCALL
1005 xmlSetupParserForBuffer (xmlParserCtxtPtr ctxt,
Owen Taylor3473f882001-02-23 17:55:21 +00001006 const xmlChar* buffer,
Daniel Veillard963d2ae2002-01-20 22:08:18 +00001007 const char *filename);
Igor Zlatkovic76874e42003-08-25 09:05:12 +00001008XMLPUBFUN xmlParserCtxtPtr XMLCALL
Daniel Veillard16fa96c2003-09-23 21:50:54 +00001009 xmlCreateDocParserCtxt (const xmlChar *cur);
Owen Taylor3473f882001-02-23 17:55:21 +00001010
Daniel Veillardf69bb4b2001-05-19 13:24:56 +00001011/*
Owen Taylor3473f882001-02-23 17:55:21 +00001012 * Reading/setting optional parsing features.
1013 */
1014
Igor Zlatkovic76874e42003-08-25 09:05:12 +00001015XMLPUBFUN int XMLCALL
1016 xmlGetFeaturesList (int *len,
Owen Taylor3473f882001-02-23 17:55:21 +00001017 const char **result);
Igor Zlatkovic76874e42003-08-25 09:05:12 +00001018XMLPUBFUN int XMLCALL
1019 xmlGetFeature (xmlParserCtxtPtr ctxt,
Owen Taylor3473f882001-02-23 17:55:21 +00001020 const char *name,
1021 void *result);
Igor Zlatkovic76874e42003-08-25 09:05:12 +00001022XMLPUBFUN int XMLCALL
1023 xmlSetFeature (xmlParserCtxtPtr ctxt,
Owen Taylor3473f882001-02-23 17:55:21 +00001024 const char *name,
1025 void *value);
1026
Daniel Veillard73b013f2003-09-30 12:36:01 +00001027#ifdef LIBXML_PUSH_ENABLED
Daniel Veillardf69bb4b2001-05-19 13:24:56 +00001028/*
Daniel Veillard61f26172002-03-12 18:46:39 +00001029 * Interfaces for the Push mode.
Owen Taylor3473f882001-02-23 17:55:21 +00001030 */
Igor Zlatkovic76874e42003-08-25 09:05:12 +00001031XMLPUBFUN xmlParserCtxtPtr XMLCALL
1032 xmlCreatePushParserCtxt(xmlSAXHandlerPtr sax,
Owen Taylor3473f882001-02-23 17:55:21 +00001033 void *user_data,
1034 const char *chunk,
1035 int size,
1036 const char *filename);
Igor Zlatkovic76874e42003-08-25 09:05:12 +00001037XMLPUBFUN int XMLCALL
1038 xmlParseChunk (xmlParserCtxtPtr ctxt,
Owen Taylor3473f882001-02-23 17:55:21 +00001039 const char *chunk,
1040 int size,
1041 int terminate);
Daniel Veillard73b013f2003-09-30 12:36:01 +00001042#endif /* LIBXML_PUSH_ENABLED */
Owen Taylor3473f882001-02-23 17:55:21 +00001043
Daniel Veillardf69bb4b2001-05-19 13:24:56 +00001044/*
Daniel Veillard61f26172002-03-12 18:46:39 +00001045 * Special I/O mode.
Owen Taylor3473f882001-02-23 17:55:21 +00001046 */
1047
Igor Zlatkovic76874e42003-08-25 09:05:12 +00001048XMLPUBFUN xmlParserCtxtPtr XMLCALL
1049 xmlCreateIOParserCtxt (xmlSAXHandlerPtr sax,
Owen Taylor3473f882001-02-23 17:55:21 +00001050 void *user_data,
1051 xmlInputReadCallback ioread,
1052 xmlInputCloseCallback ioclose,
1053 void *ioctx,
1054 xmlCharEncoding enc);
1055
Igor Zlatkovic76874e42003-08-25 09:05:12 +00001056XMLPUBFUN xmlParserInputPtr XMLCALL
1057 xmlNewIOInputStream (xmlParserCtxtPtr ctxt,
Owen Taylor3473f882001-02-23 17:55:21 +00001058 xmlParserInputBufferPtr input,
1059 xmlCharEncoding enc);
1060
Daniel Veillardf69bb4b2001-05-19 13:24:56 +00001061/*
Daniel Veillard61f26172002-03-12 18:46:39 +00001062 * Node infos.
Owen Taylor3473f882001-02-23 17:55:21 +00001063 */
Igor Zlatkovic76874e42003-08-25 09:05:12 +00001064XMLPUBFUN const xmlParserNodeInfo* XMLCALL
Daniel Veillard963d2ae2002-01-20 22:08:18 +00001065 xmlParserFindNodeInfo (const xmlParserCtxtPtr ctxt,
1066 const xmlNodePtr node);
Igor Zlatkovic76874e42003-08-25 09:05:12 +00001067XMLPUBFUN void XMLCALL
1068 xmlInitNodeInfoSeq (xmlParserNodeInfoSeqPtr seq);
1069XMLPUBFUN void XMLCALL
1070 xmlClearNodeInfoSeq (xmlParserNodeInfoSeqPtr seq);
1071XMLPUBFUN unsigned long XMLCALL
1072 xmlParserFindNodeInfoIndex(const xmlParserNodeInfoSeqPtr seq,
Daniel Veillard963d2ae2002-01-20 22:08:18 +00001073 const xmlNodePtr node);
Igor Zlatkovic76874e42003-08-25 09:05:12 +00001074XMLPUBFUN void XMLCALL
1075 xmlParserAddNodeInfo (xmlParserCtxtPtr ctxt,
Daniel Veillard963d2ae2002-01-20 22:08:18 +00001076 const xmlParserNodeInfoPtr info);
Owen Taylor3473f882001-02-23 17:55:21 +00001077
1078/*
Daniel Veillard61f26172002-03-12 18:46:39 +00001079 * External entities handling actually implemented in xmlIO.
Owen Taylor3473f882001-02-23 17:55:21 +00001080 */
1081
Igor Zlatkovic76874e42003-08-25 09:05:12 +00001082XMLPUBFUN void XMLCALL
1083 xmlSetExternalEntityLoader(xmlExternalEntityLoader f);
1084XMLPUBFUN xmlExternalEntityLoader XMLCALL
Owen Taylor3473f882001-02-23 17:55:21 +00001085 xmlGetExternalEntityLoader(void);
Igor Zlatkovic76874e42003-08-25 09:05:12 +00001086XMLPUBFUN xmlParserInputPtr XMLCALL
Owen Taylor3473f882001-02-23 17:55:21 +00001087 xmlLoadExternalEntity (const char *URL,
1088 const char *ID,
Daniel Veillard9d06d302002-01-22 18:15:52 +00001089 xmlParserCtxtPtr ctxt);
Daniel Veillard16fa96c2003-09-23 21:50:54 +00001090/*
1091 * New set of simpler/more flexible APIs
1092 */
1093/**
1094 * xmlParserOption:
1095 *
1096 * This is the set of XML parser options that can be passed down
1097 * to the xmlReadDoc() and similar calls.
1098 */
1099typedef enum {
1100 XML_PARSE_RECOVER = 1<<0, /* recover on errors */
1101 XML_PARSE_NOENT = 1<<1, /* substitute entities */
1102 XML_PARSE_DTDLOAD = 1<<2, /* load the external subset */
1103 XML_PARSE_DTDATTR = 1<<3, /* default DTD attributes */
1104 XML_PARSE_DTDVALID = 1<<4, /* validate with the DTD */
1105 XML_PARSE_NOERROR = 1<<5, /* suppress error reports */
1106 XML_PARSE_NOWARNING = 1<<6, /* suppress warning reports */
1107 XML_PARSE_PEDANTIC = 1<<7, /* pedantic error reporting */
1108 XML_PARSE_NOBLANKS = 1<<8, /* remove blank nodes */
1109 XML_PARSE_SAX1 = 1<<9, /* use the SAX1 interface internally */
1110 XML_PARSE_XINCLUDE = 1<<10,/* Implement XInclude substitition */
Daniel Veillarde96a2a42003-09-24 21:23:56 +00001111 XML_PARSE_NONET = 1<<11,/* Forbid network access */
Daniel Veillard9475a352003-09-26 12:47:50 +00001112 XML_PARSE_NODICT = 1<<12,/* Do not reuse the context dictionnary */
1113 XML_PARSE_NSCLEAN = 1<<13,/* remove redundant namespaces declarations */
1114 XML_PARSE_NOCDATA = 1<<14 /* merge CDATA as text nodes */
Daniel Veillard16fa96c2003-09-23 21:50:54 +00001115} xmlParserOption;
1116
1117XMLPUBFUN void XMLCALL
1118 xmlCtxtReset (xmlParserCtxtPtr ctxt);
1119XMLPUBFUN int XMLCALL
Daniel Veillard9ba8e382003-10-28 21:31:45 +00001120 xmlCtxtResetPush (xmlParserCtxtPtr ctxt,
1121 const char *chunk,
1122 int size,
1123 const char *filename,
1124 const char *encoding);
1125XMLPUBFUN int XMLCALL
Daniel Veillard16fa96c2003-09-23 21:50:54 +00001126 xmlCtxtUseOptions (xmlParserCtxtPtr ctxt,
1127 int options);
1128XMLPUBFUN xmlDocPtr XMLCALL
1129 xmlReadDoc (const xmlChar *cur,
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
Daniel Veillard60942de2003-09-25 21:05:58 +00001134 xmlReadFile (const char *URL,
Daniel Veillard16fa96c2003-09-23 21:50:54 +00001135 const char *encoding,
1136 int options);
1137XMLPUBFUN xmlDocPtr XMLCALL
1138 xmlReadMemory (const char *buffer,
1139 int size,
Daniel Veillard60942de2003-09-25 21:05:58 +00001140 const char *URL,
Daniel Veillard16fa96c2003-09-23 21:50:54 +00001141 const char *encoding,
1142 int options);
1143XMLPUBFUN xmlDocPtr XMLCALL
1144 xmlReadFd (int fd,
Daniel Veillard60942de2003-09-25 21:05:58 +00001145 const char *URL,
Daniel Veillard16fa96c2003-09-23 21:50:54 +00001146 const char *encoding,
1147 int options);
1148XMLPUBFUN xmlDocPtr XMLCALL
1149 xmlReadIO (xmlInputReadCallback ioread,
1150 xmlInputCloseCallback ioclose,
1151 void *ioctx,
Daniel Veillard60942de2003-09-25 21:05:58 +00001152 const char *URL,
Daniel Veillard16fa96c2003-09-23 21:50:54 +00001153 const char *encoding,
1154 int options);
1155XMLPUBFUN xmlDocPtr XMLCALL
1156 xmlCtxtReadDoc (xmlParserCtxtPtr ctxt,
1157 const xmlChar *cur,
Daniel Veillard60942de2003-09-25 21:05:58 +00001158 const char *URL,
Daniel Veillard16fa96c2003-09-23 21:50:54 +00001159 const char *encoding,
1160 int options);
1161XMLPUBFUN xmlDocPtr XMLCALL
1162 xmlCtxtReadFile (xmlParserCtxtPtr ctxt,
1163 const char *filename,
1164 const char *encoding,
1165 int options);
1166XMLPUBFUN xmlDocPtr XMLCALL
1167 xmlCtxtReadMemory (xmlParserCtxtPtr ctxt,
1168 const char *buffer,
1169 int size,
Daniel Veillard60942de2003-09-25 21:05:58 +00001170 const char *URL,
Daniel Veillard16fa96c2003-09-23 21:50:54 +00001171 const char *encoding,
1172 int options);
1173XMLPUBFUN xmlDocPtr XMLCALL
1174 xmlCtxtReadFd (xmlParserCtxtPtr ctxt,
1175 int fd,
Daniel Veillard60942de2003-09-25 21:05:58 +00001176 const char *URL,
Daniel Veillard16fa96c2003-09-23 21:50:54 +00001177 const char *encoding,
1178 int options);
1179XMLPUBFUN xmlDocPtr XMLCALL
1180 xmlCtxtReadIO (xmlParserCtxtPtr ctxt,
1181 xmlInputReadCallback ioread,
1182 xmlInputCloseCallback ioclose,
1183 void *ioctx,
Daniel Veillard60942de2003-09-25 21:05:58 +00001184 const char *URL,
Daniel Veillard16fa96c2003-09-23 21:50:54 +00001185 const char *encoding,
1186 int options);
Owen Taylor3473f882001-02-23 17:55:21 +00001187
1188#ifdef __cplusplus
1189}
1190#endif
Owen Taylor3473f882001-02-23 17:55:21 +00001191#endif /* __XML_PARSER_H__ */
1192