blob: 9c4c272f0fbe238aa53b8c71e78d3e0b15248f78 [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
12#include <libxml/tree.h>
13#include <libxml/valid.h>
14#include <libxml/xmlIO.h>
15#include <libxml/entities.h>
16
17
18#ifdef __cplusplus
19extern "C" {
20#endif
21
Daniel Veillard5e2dace2001-07-18 19:30:27 +000022/**
23 * XML_DEFAULT_VERSION:
24 *
25 * The default version of XML used: 1.0
Owen Taylor3473f882001-02-23 17:55:21 +000026 */
27#define XML_DEFAULT_VERSION "1.0"
28
29/**
Daniel Veillardf69bb4b2001-05-19 13:24:56 +000030 * xmlParserInput:
31 *
Owen Taylor3473f882001-02-23 17:55:21 +000032 * an xmlParserInput is an input flow for the XML processor.
33 * Each entity parsed is associated an xmlParserInput (except the
34 * few predefined ones). This is the case both for internal entities
35 * - in which case the flow is already completely in memory - or
36 * external entities - in which case we use the buf structure for
37 * progressive reading and I18N conversions to the internal UTF-8 format.
38 */
39
40typedef void (* xmlParserInputDeallocate)(xmlChar *);
Daniel Veillard5e2dace2001-07-18 19:30:27 +000041
Owen Taylor3473f882001-02-23 17:55:21 +000042typedef struct _xmlParserInput xmlParserInput;
43typedef xmlParserInput *xmlParserInputPtr;
44struct _xmlParserInput {
45 /* Input buffer */
46 xmlParserInputBufferPtr buf; /* UTF-8 encoded buffer */
47
48 const char *filename; /* The file analyzed, if any */
49 const char *directory; /* the directory/base of teh file */
50 const xmlChar *base; /* Base of the array to parse */
51 const xmlChar *cur; /* Current char being parsed */
Daniel Veillard48b2f892001-02-25 16:11:03 +000052 const xmlChar *end; /* end of the arry to parse */
Owen Taylor3473f882001-02-23 17:55:21 +000053 int length; /* length if known */
54 int line; /* Current line */
55 int col; /* Current column */
56 int consumed; /* How many xmlChars already consumed */
57 xmlParserInputDeallocate free; /* function to deallocate the base */
58 const xmlChar *encoding; /* the encoding string for entity */
59 const xmlChar *version; /* the version string for entity */
60 int standalone; /* Was that entity marked standalone */
61};
62
63/**
Daniel Veillardf69bb4b2001-05-19 13:24:56 +000064 * xmlParserNodeInfo:
65 *
Owen Taylor3473f882001-02-23 17:55:21 +000066 * the parser can be asked to collect Node informations, i.e. at what
67 * place in the file they were detected.
68 * NOTE: This is off by default and not very well tested.
69 */
70typedef struct _xmlParserNodeInfo xmlParserNodeInfo;
71typedef xmlParserNodeInfo *xmlParserNodeInfoPtr;
72
73struct _xmlParserNodeInfo {
74 const struct _xmlNode* node;
75 /* Position & line # that text that created the node begins & ends on */
76 unsigned long begin_pos;
77 unsigned long begin_line;
78 unsigned long end_pos;
79 unsigned long end_line;
80};
81
82typedef struct _xmlParserNodeInfoSeq xmlParserNodeInfoSeq;
83typedef xmlParserNodeInfoSeq *xmlParserNodeInfoSeqPtr;
84struct _xmlParserNodeInfoSeq {
85 unsigned long maximum;
86 unsigned long length;
87 xmlParserNodeInfo* buffer;
88};
89
90/**
Daniel Veillardf69bb4b2001-05-19 13:24:56 +000091 * xmlParserInputState:
92 *
Owen Taylor3473f882001-02-23 17:55:21 +000093 * The parser is now working also as a state based parser
94 * The recursive one use the stagte info for entities processing
95 */
96typedef enum {
97 XML_PARSER_EOF = -1, /* nothing is to be parsed */
98 XML_PARSER_START = 0, /* nothing has been parsed */
99 XML_PARSER_MISC, /* Misc* before int subset */
100 XML_PARSER_PI, /* Whithin a processing instruction */
101 XML_PARSER_DTD, /* within some DTD content */
102 XML_PARSER_PROLOG, /* Misc* after internal subset */
103 XML_PARSER_COMMENT, /* within a comment */
104 XML_PARSER_START_TAG, /* within a start tag */
105 XML_PARSER_CONTENT, /* within the content */
106 XML_PARSER_CDATA_SECTION, /* within a CDATA section */
107 XML_PARSER_END_TAG, /* within a closing tag */
108 XML_PARSER_ENTITY_DECL, /* within an entity declaration */
109 XML_PARSER_ENTITY_VALUE, /* within an entity value in a decl */
110 XML_PARSER_ATTRIBUTE_VALUE, /* within an attribute value */
111 XML_PARSER_SYSTEM_LITERAL, /* within a SYSTEM value */
112 XML_PARSER_EPILOG, /* the Misc* after the last end tag */
113 XML_PARSER_IGNORE /* within an IGNORED section */
114} xmlParserInputState;
115
116/**
Daniel Veillardd16df9f2001-05-23 13:44:21 +0000117 * XML_DETECT_IDS:
118 *
119 * Bit in the loadsubset context field to tell to do ID/REFs lookups
120 * Use it to initialize xmlLoadExtDtdDefaultValue
121 */
122#define XML_DETECT_IDS 2
123
124/**
125 * XML_COMPLETE_ATTRS:
126 *
127 * Bit in the loadsubset context field to tell to do complete the
128 * elements attributes lists with the ones defaulted from the DTDs
129 * Use it to initialize xmlLoadExtDtdDefaultValue
130 */
131#define XML_COMPLETE_ATTRS 4
132
133/**
Daniel Veillardf69bb4b2001-05-19 13:24:56 +0000134 * xmlParserCtxt:
135 *
Owen Taylor3473f882001-02-23 17:55:21 +0000136 * The parser context.
137 * NOTE This doesn't completely defines the parser state, the (current ?)
138 * design of the parser uses recursive function calls since this allow
139 * and easy mapping from the production rules of the specification
140 * to the actual code. The drawback is that the actual function call
141 * also reflect the parser state. However most of the parsing routines
142 * takes as the only argument the parser context pointer, so migrating
143 * to a state based parser for progressive parsing shouldn't be too hard.
144 */
145typedef struct _xmlParserCtxt xmlParserCtxt;
146typedef xmlParserCtxt *xmlParserCtxtPtr;
147struct _xmlParserCtxt {
148 struct _xmlSAXHandler *sax; /* The SAX handler */
149 void *userData; /* For SAX interface only, used by DOM build */
150 xmlDocPtr myDoc; /* the document being built */
151 int wellFormed; /* is the document well formed */
152 int replaceEntities; /* shall we replace entities ? */
153 const xmlChar *version; /* the XML version string */
154 const xmlChar *encoding; /* the declared encoding, if any */
155 int standalone; /* standalone document */
156 int html; /* an HTML(1)/Docbook(2) document */
157
158 /* Input stream stack */
159 xmlParserInputPtr input; /* Current input stream */
160 int inputNr; /* Number of current input streams */
161 int inputMax; /* Max number of input streams */
162 xmlParserInputPtr *inputTab; /* stack of inputs */
163
164 /* Node analysis stack only used for DOM building */
165 xmlNodePtr node; /* Current parsed Node */
166 int nodeNr; /* Depth of the parsing stack */
167 int nodeMax; /* Max depth of the parsing stack */
168 xmlNodePtr *nodeTab; /* array of nodes */
169
170 int record_info; /* Whether node info should be kept */
171 xmlParserNodeInfoSeq node_seq; /* info about each node parsed */
172
173 int errNo; /* error code */
174
175 int hasExternalSubset; /* reference and external subset */
176 int hasPErefs; /* the internal subset has PE refs */
177 int external; /* are we parsing an external entity */
178
179 int valid; /* is the document valid */
180 int validate; /* shall we try to validate ? */
181 xmlValidCtxt vctxt; /* The validity context */
182
183 xmlParserInputState instate; /* current type of input */
184 int token; /* next char look-ahead */
185
186 char *directory; /* the data directory */
187
188 /* Node name stack */
189 xmlChar *name; /* Current parsed Node */
190 int nameNr; /* Depth of the parsing stack */
191 int nameMax; /* Max depth of the parsing stack */
192 xmlChar * *nameTab; /* array of nodes */
193
194 long nbChars; /* number of xmlChar processed */
195 long checkIndex; /* used by progressive parsing lookup */
196 int keepBlanks; /* ugly but ... */
197 int disableSAX; /* SAX callbacks are disabled */
198 int inSubset; /* Parsing is in int 1/ext 2 subset */
199 xmlChar * intSubName; /* name of subset */
200 xmlChar * extSubURI; /* URI of external subset */
201 xmlChar * extSubSystem; /* SYSTEM ID of external subset */
202
203 /* xml:space values */
204 int * space; /* Should the parser preserve spaces */
205 int spaceNr; /* Depth of the parsing stack */
206 int spaceMax; /* Max depth of the parsing stack */
207 int * spaceTab; /* array of space infos */
208
209 int depth; /* to prevent entity substitution loops */
210 xmlParserInputPtr entity; /* used to check entities boundaries */
211 int charset; /* encoding of the in-memory content
212 actually an xmlCharEncoding */
213 int nodelen; /* Those two fields are there to */
214 int nodemem; /* Speed up large node parsing */
215 int pedantic; /* signal pedantic warnings */
216 void *_private; /* For user data, libxml won't touch it */
217
218 int loadsubset; /* should the external subset be loaded */
Daniel Veillardd9bad132001-07-23 19:39:43 +0000219 int linenumbers; /* set line number in element content */
Daniel Veillard5d90b6c2001-08-22 14:29:45 +0000220 void *catalogs; /* document's own catalog */
Owen Taylor3473f882001-02-23 17:55:21 +0000221};
222
223/**
Daniel Veillardf69bb4b2001-05-19 13:24:56 +0000224 * xmlSAXLocator:
225 *
Owen Taylor3473f882001-02-23 17:55:21 +0000226 * a SAX Locator.
227 */
228typedef struct _xmlSAXLocator xmlSAXLocator;
229typedef xmlSAXLocator *xmlSAXLocatorPtr;
230struct _xmlSAXLocator {
231 const xmlChar *(*getPublicId)(void *ctx);
232 const xmlChar *(*getSystemId)(void *ctx);
233 int (*getLineNumber)(void *ctx);
234 int (*getColumnNumber)(void *ctx);
235};
236
237/**
Daniel Veillardf69bb4b2001-05-19 13:24:56 +0000238 * xmlSAXHandler:
239 *
Owen Taylor3473f882001-02-23 17:55:21 +0000240 * a SAX handler is bunch of callbacks called by the parser when processing
241 * of the input generate data or structure informations.
242 */
243
244typedef xmlParserInputPtr (*resolveEntitySAXFunc) (void *ctx,
245 const xmlChar *publicId, const xmlChar *systemId);
246typedef void (*internalSubsetSAXFunc) (void *ctx, const xmlChar *name,
247 const xmlChar *ExternalID, const xmlChar *SystemID);
248typedef void (*externalSubsetSAXFunc) (void *ctx, const xmlChar *name,
249 const xmlChar *ExternalID, const xmlChar *SystemID);
250typedef xmlEntityPtr (*getEntitySAXFunc) (void *ctx,
251 const xmlChar *name);
252typedef xmlEntityPtr (*getParameterEntitySAXFunc) (void *ctx,
253 const xmlChar *name);
254typedef void (*entityDeclSAXFunc) (void *ctx,
255 const xmlChar *name, int type, const xmlChar *publicId,
256 const xmlChar *systemId, xmlChar *content);
257typedef void (*notationDeclSAXFunc)(void *ctx, const xmlChar *name,
258 const xmlChar *publicId, const xmlChar *systemId);
259typedef void (*attributeDeclSAXFunc)(void *ctx, const xmlChar *elem,
260 const xmlChar *name, int type, int def,
261 const xmlChar *defaultValue, xmlEnumerationPtr tree);
262typedef void (*elementDeclSAXFunc)(void *ctx, const xmlChar *name,
263 int type, xmlElementContentPtr content);
264typedef void (*unparsedEntityDeclSAXFunc)(void *ctx,
265 const xmlChar *name, const xmlChar *publicId,
266 const xmlChar *systemId, const xmlChar *notationName);
267typedef void (*setDocumentLocatorSAXFunc) (void *ctx,
268 xmlSAXLocatorPtr loc);
269typedef void (*startDocumentSAXFunc) (void *ctx);
270typedef void (*endDocumentSAXFunc) (void *ctx);
271typedef void (*startElementSAXFunc) (void *ctx, const xmlChar *name,
272 const xmlChar **atts);
273typedef void (*endElementSAXFunc) (void *ctx, const xmlChar *name);
274typedef void (*attributeSAXFunc) (void *ctx, const xmlChar *name,
275 const xmlChar *value);
276typedef void (*referenceSAXFunc) (void *ctx, const xmlChar *name);
277typedef void (*charactersSAXFunc) (void *ctx, const xmlChar *ch,
278 int len);
279typedef void (*ignorableWhitespaceSAXFunc) (void *ctx,
280 const xmlChar *ch, int len);
281typedef void (*processingInstructionSAXFunc) (void *ctx,
282 const xmlChar *target, const xmlChar *data);
283typedef void (*commentSAXFunc) (void *ctx, const xmlChar *value);
284typedef void (*cdataBlockSAXFunc) (void *ctx, const xmlChar *value, int len);
285typedef void (*warningSAXFunc) (void *ctx, const char *msg, ...);
286typedef void (*errorSAXFunc) (void *ctx, const char *msg, ...);
287typedef void (*fatalErrorSAXFunc) (void *ctx, const char *msg, ...);
288typedef int (*isStandaloneSAXFunc) (void *ctx);
289typedef int (*hasInternalSubsetSAXFunc) (void *ctx);
290typedef int (*hasExternalSubsetSAXFunc) (void *ctx);
291
292typedef struct _xmlSAXHandler xmlSAXHandler;
293typedef xmlSAXHandler *xmlSAXHandlerPtr;
294struct _xmlSAXHandler {
295 internalSubsetSAXFunc internalSubset;
296 isStandaloneSAXFunc isStandalone;
297 hasInternalSubsetSAXFunc hasInternalSubset;
298 hasExternalSubsetSAXFunc hasExternalSubset;
299 resolveEntitySAXFunc resolveEntity;
300 getEntitySAXFunc getEntity;
301 entityDeclSAXFunc entityDecl;
302 notationDeclSAXFunc notationDecl;
303 attributeDeclSAXFunc attributeDecl;
304 elementDeclSAXFunc elementDecl;
305 unparsedEntityDeclSAXFunc unparsedEntityDecl;
306 setDocumentLocatorSAXFunc setDocumentLocator;
307 startDocumentSAXFunc startDocument;
308 endDocumentSAXFunc endDocument;
309 startElementSAXFunc startElement;
310 endElementSAXFunc endElement;
311 referenceSAXFunc reference;
312 charactersSAXFunc characters;
313 ignorableWhitespaceSAXFunc ignorableWhitespace;
314 processingInstructionSAXFunc processingInstruction;
315 commentSAXFunc comment;
316 warningSAXFunc warning;
317 errorSAXFunc error;
318 fatalErrorSAXFunc fatalError;
319 getParameterEntitySAXFunc getParameterEntity;
320 cdataBlockSAXFunc cdataBlock;
321 externalSubsetSAXFunc externalSubset;
322};
323
324/**
Daniel Veillardf69bb4b2001-05-19 13:24:56 +0000325 * xmlExternalEntityLoader:
326 * @URL: The System ID of the resource requested
327 * @ID: The Public ID of the resource requested
328 * @xmlParserCtxtPtr: the XML parser context
329 *
Owen Taylor3473f882001-02-23 17:55:21 +0000330 * External entity loaders types
331 */
332typedef xmlParserInputPtr (*xmlExternalEntityLoader)(const char *URL,
333 const char *ID,
334 xmlParserCtxtPtr context);
335
Daniel Veillardf69bb4b2001-05-19 13:24:56 +0000336/*
Owen Taylor3473f882001-02-23 17:55:21 +0000337 * Global variables: just the default SAX interface tables and XML
338 * version infos.
339 */
340LIBXML_DLL_IMPORT extern const char *xmlParserVersion;
341
342LIBXML_DLL_IMPORT extern xmlSAXLocator xmlDefaultSAXLocator;
343LIBXML_DLL_IMPORT extern xmlSAXHandler xmlDefaultSAXHandler;
344LIBXML_DLL_IMPORT extern xmlSAXHandler htmlDefaultSAXHandler;
Daniel Veillardeae522a2001-04-23 13:41:34 +0000345LIBXML_DLL_IMPORT extern xmlSAXHandler docbDefaultSAXHandler;
Owen Taylor3473f882001-02-23 17:55:21 +0000346
Daniel Veillardf69bb4b2001-05-19 13:24:56 +0000347/*
Owen Taylor3473f882001-02-23 17:55:21 +0000348 * entity substitution default behaviour.
349 */
350
351#ifdef VMS
Daniel Veillard5e2dace2001-07-18 19:30:27 +0000352/**
353 * xmlSubstituteEntitiesDefaultValue:
354 *
355 * global variable controlling the entity substitution default behaviour
356 */
Owen Taylor3473f882001-02-23 17:55:21 +0000357LIBXML_DLL_IMPORT extern int xmlSubstituteEntitiesDefaultVal;
358#define xmlSubstituteEntitiesDefaultValue xmlSubstituteEntitiesDefaultVal
359#else
360LIBXML_DLL_IMPORT extern int xmlSubstituteEntitiesDefaultValue;
361#endif
362LIBXML_DLL_IMPORT extern int xmlGetWarningsDefaultValue;
363
364
Daniel Veillardf69bb4b2001-05-19 13:24:56 +0000365/*
Owen Taylor3473f882001-02-23 17:55:21 +0000366 * Init/Cleanup
367 */
368void xmlInitParser (void);
369void xmlCleanupParser (void);
370
Daniel Veillardf69bb4b2001-05-19 13:24:56 +0000371/*
Owen Taylor3473f882001-02-23 17:55:21 +0000372 * Input functions
373 */
374int xmlParserInputRead (xmlParserInputPtr in,
375 int len);
376int xmlParserInputGrow (xmlParserInputPtr in,
377 int len);
378
Daniel Veillardf69bb4b2001-05-19 13:24:56 +0000379/*
Owen Taylor3473f882001-02-23 17:55:21 +0000380 * xmlChar handling
381 */
382xmlChar * xmlStrdup (const xmlChar *cur);
383xmlChar * xmlStrndup (const xmlChar *cur,
384 int len);
Daniel Veillard56a4cb82001-03-24 17:00:36 +0000385xmlChar * xmlCharStrndup (const char *cur,
386 int len);
387xmlChar * xmlCharStrdup (const char *cur);
Owen Taylor3473f882001-02-23 17:55:21 +0000388xmlChar * xmlStrsub (const xmlChar *str,
389 int start,
390 int len);
391const xmlChar * xmlStrchr (const xmlChar *str,
392 xmlChar val);
393const xmlChar * xmlStrstr (const xmlChar *str,
Daniel Veillard77044732001-06-29 21:31:07 +0000394 const xmlChar *val);
Owen Taylor3473f882001-02-23 17:55:21 +0000395const xmlChar * xmlStrcasestr (const xmlChar *str,
396 xmlChar *val);
397int xmlStrcmp (const xmlChar *str1,
398 const xmlChar *str2);
399int xmlStrncmp (const xmlChar *str1,
400 const xmlChar *str2,
401 int len);
402int xmlStrcasecmp (const xmlChar *str1,
403 const xmlChar *str2);
404int xmlStrncasecmp (const xmlChar *str1,
405 const xmlChar *str2,
406 int len);
407int xmlStrEqual (const xmlChar *str1,
408 const xmlChar *str2);
409int xmlStrlen (const xmlChar *str);
410xmlChar * xmlStrcat (xmlChar *cur,
411 const xmlChar *add);
412xmlChar * xmlStrncat (xmlChar *cur,
413 const xmlChar *add,
414 int len);
415
Daniel Veillardf69bb4b2001-05-19 13:24:56 +0000416/*
Owen Taylor3473f882001-02-23 17:55:21 +0000417 * Basic parsing Interfaces
418 */
419xmlDocPtr xmlParseDoc (xmlChar *cur);
Daniel Veillard50822cb2001-07-26 20:05:51 +0000420xmlDocPtr xmlParseMemory (const char *buffer,
Owen Taylor3473f882001-02-23 17:55:21 +0000421 int size);
422xmlDocPtr xmlParseFile (const char *filename);
423int xmlSubstituteEntitiesDefault(int val);
424int xmlKeepBlanksDefault (int val);
425void xmlStopParser (xmlParserCtxtPtr ctxt);
426int xmlPedanticParserDefault(int val);
Daniel Veillardd9bad132001-07-23 19:39:43 +0000427int xmlLineNumbersDefault (int val);
Owen Taylor3473f882001-02-23 17:55:21 +0000428
Daniel Veillardf69bb4b2001-05-19 13:24:56 +0000429/*
Owen Taylor3473f882001-02-23 17:55:21 +0000430 * Recovery mode
431 */
432xmlDocPtr xmlRecoverDoc (xmlChar *cur);
Daniel Veillard50822cb2001-07-26 20:05:51 +0000433xmlDocPtr xmlRecoverMemory (const char *buffer,
Owen Taylor3473f882001-02-23 17:55:21 +0000434 int size);
435xmlDocPtr xmlRecoverFile (const char *filename);
436
Daniel Veillardf69bb4b2001-05-19 13:24:56 +0000437/*
Owen Taylor3473f882001-02-23 17:55:21 +0000438 * Less common routines and SAX interfaces
439 */
440int xmlParseDocument (xmlParserCtxtPtr ctxt);
441int xmlParseExtParsedEnt (xmlParserCtxtPtr ctxt);
442xmlDocPtr xmlSAXParseDoc (xmlSAXHandlerPtr sax,
443 xmlChar *cur,
444 int recovery);
445int xmlSAXUserParseFile (xmlSAXHandlerPtr sax,
446 void *user_data,
447 const char *filename);
448int xmlSAXUserParseMemory (xmlSAXHandlerPtr sax,
449 void *user_data,
Daniel Veillardfd7ddca2001-05-16 10:57:35 +0000450 const char *buffer,
Owen Taylor3473f882001-02-23 17:55:21 +0000451 int size);
452xmlDocPtr xmlSAXParseMemory (xmlSAXHandlerPtr sax,
Daniel Veillard50822cb2001-07-26 20:05:51 +0000453 const char *buffer,
Owen Taylor3473f882001-02-23 17:55:21 +0000454 int size,
455 int recovery);
456xmlDocPtr xmlSAXParseFile (xmlSAXHandlerPtr sax,
457 const char *filename,
458 int recovery);
Daniel Veillarda293c322001-10-02 13:54:14 +0000459xmlDocPtr xmlSAXParseFileWithData (xmlSAXHandlerPtr sax,
460 const char *filename,
461 int recovery,
462 void *data);
Owen Taylor3473f882001-02-23 17:55:21 +0000463xmlDocPtr xmlSAXParseEntity (xmlSAXHandlerPtr sax,
464 const char *filename);
465xmlDocPtr xmlParseEntity (const char *filename);
466xmlDtdPtr xmlParseDTD (const xmlChar *ExternalID,
467 const xmlChar *SystemID);
468xmlDtdPtr xmlSAXParseDTD (xmlSAXHandlerPtr sax,
469 const xmlChar *ExternalID,
470 const xmlChar *SystemID);
471xmlDtdPtr xmlIOParseDTD (xmlSAXHandlerPtr sax,
472 xmlParserInputBufferPtr input,
473 xmlCharEncoding enc);
474int xmlParseBalancedChunkMemory(xmlDocPtr doc,
475 xmlSAXHandlerPtr sax,
476 void *user_data,
477 int depth,
478 const xmlChar *string,
Daniel Veillardcda96922001-08-21 10:56:31 +0000479 xmlNodePtr *lst);
Owen Taylor3473f882001-02-23 17:55:21 +0000480int xmlParseExternalEntity (xmlDocPtr doc,
481 xmlSAXHandlerPtr sax,
482 void *user_data,
483 int depth,
484 const xmlChar *URL,
485 const xmlChar *ID,
Daniel Veillardcda96922001-08-21 10:56:31 +0000486 xmlNodePtr *lst);
Owen Taylor3473f882001-02-23 17:55:21 +0000487int xmlParseCtxtExternalEntity(xmlParserCtxtPtr ctx,
488 const xmlChar *URL,
489 const xmlChar *ID,
Daniel Veillardcda96922001-08-21 10:56:31 +0000490 xmlNodePtr *lst);
Owen Taylor3473f882001-02-23 17:55:21 +0000491
Daniel Veillardf69bb4b2001-05-19 13:24:56 +0000492/*
Owen Taylor3473f882001-02-23 17:55:21 +0000493 * SAX initialization routines
494 */
495void xmlDefaultSAXHandlerInit(void);
496void htmlDefaultSAXHandlerInit(void);
497
Daniel Veillardf69bb4b2001-05-19 13:24:56 +0000498/*
Owen Taylor3473f882001-02-23 17:55:21 +0000499 * Parser contexts handling.
500 */
501void xmlInitParserCtxt (xmlParserCtxtPtr ctxt);
502void xmlClearParserCtxt (xmlParserCtxtPtr ctxt);
503void xmlFreeParserCtxt (xmlParserCtxtPtr ctxt);
504void xmlSetupParserForBuffer (xmlParserCtxtPtr ctxt,
505 const xmlChar* buffer,
506 const char* filename);
507xmlParserCtxtPtr xmlCreateDocParserCtxt (xmlChar *cur);
508
Daniel Veillardf69bb4b2001-05-19 13:24:56 +0000509/*
Owen Taylor3473f882001-02-23 17:55:21 +0000510 * Reading/setting optional parsing features.
511 */
512
513int xmlGetFeaturesList (int *len,
514 const char **result);
515int xmlGetFeature (xmlParserCtxtPtr ctxt,
516 const char *name,
517 void *result);
518int xmlSetFeature (xmlParserCtxtPtr ctxt,
519 const char *name,
520 void *value);
521
Daniel Veillardf69bb4b2001-05-19 13:24:56 +0000522/*
Owen Taylor3473f882001-02-23 17:55:21 +0000523 * Interfaces for the Push mode
524 */
525xmlParserCtxtPtr xmlCreatePushParserCtxt(xmlSAXHandlerPtr sax,
526 void *user_data,
527 const char *chunk,
528 int size,
529 const char *filename);
530int xmlParseChunk (xmlParserCtxtPtr ctxt,
531 const char *chunk,
532 int size,
533 int terminate);
534
Daniel Veillardf69bb4b2001-05-19 13:24:56 +0000535/*
Owen Taylor3473f882001-02-23 17:55:21 +0000536 * Special I/O mode
537 */
538
539xmlParserCtxtPtr xmlCreateIOParserCtxt (xmlSAXHandlerPtr sax,
540 void *user_data,
541 xmlInputReadCallback ioread,
542 xmlInputCloseCallback ioclose,
543 void *ioctx,
544 xmlCharEncoding enc);
545
546xmlParserInputPtr xmlNewIOInputStream (xmlParserCtxtPtr ctxt,
547 xmlParserInputBufferPtr input,
548 xmlCharEncoding enc);
549
Daniel Veillardf69bb4b2001-05-19 13:24:56 +0000550/*
Owen Taylor3473f882001-02-23 17:55:21 +0000551 * Node infos
552 */
553const xmlParserNodeInfo*
554 xmlParserFindNodeInfo (const xmlParserCtxt* ctxt,
555 const xmlNode* node);
556void xmlInitNodeInfoSeq (xmlParserNodeInfoSeqPtr seq);
557void xmlClearNodeInfoSeq (xmlParserNodeInfoSeqPtr seq);
558unsigned long xmlParserFindNodeInfoIndex(const xmlParserNodeInfoSeq* seq,
559 const xmlNode* node);
560void xmlParserAddNodeInfo (xmlParserCtxtPtr ctxt,
561 const xmlParserNodeInfo* info);
562
563/*
564 * External entities handling actually implemented in xmlIO
565 */
566
567void xmlSetExternalEntityLoader(xmlExternalEntityLoader f);
568xmlExternalEntityLoader
569 xmlGetExternalEntityLoader(void);
570xmlParserInputPtr
571 xmlLoadExternalEntity (const char *URL,
572 const char *ID,
573 xmlParserCtxtPtr context);
574
575#ifdef __cplusplus
576}
577#endif
578
579#endif /* __XML_PARSER_H__ */
580