blob: 8271bb9605cc14c53925ce5180b0587a9fbbc844 [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>
Owen Taylor3473f882001-02-23 17:55:21 +000014#include <libxml/entities.h>
Daniel Veillard8bdb91d2001-10-31 17:52:43 +000015#include <libxml/encoding.h>
16#include <libxml/xmlIO.h>
Owen Taylor3473f882001-02-23 17:55:21 +000017
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
Daniel Veillard9d06d302002-01-22 18:15:52 +000040/**
41 * xmlParserInputDeallocate:
42 * @str: the string to deallocate
43 *
44 * Callback for freeing some parser input allocations
45 */
46typedef void (* xmlParserInputDeallocate)(xmlChar *str);
Daniel Veillard5e2dace2001-07-18 19:30:27 +000047
Owen Taylor3473f882001-02-23 17:55:21 +000048struct _xmlParserInput {
49 /* Input buffer */
50 xmlParserInputBufferPtr buf; /* UTF-8 encoded buffer */
51
52 const char *filename; /* The file analyzed, if any */
Daniel Veillard60087f32001-10-10 09:45:09 +000053 const char *directory; /* the directory/base of the file */
Owen Taylor3473f882001-02-23 17:55:21 +000054 const xmlChar *base; /* Base of the array to parse */
55 const xmlChar *cur; /* Current char being parsed */
Daniel Veillardcbaf3992001-12-31 16:16:02 +000056 const xmlChar *end; /* end of the array to parse */
Owen Taylor3473f882001-02-23 17:55:21 +000057 int length; /* length if known */
58 int line; /* Current line */
59 int col; /* Current column */
60 int consumed; /* How many xmlChars already consumed */
61 xmlParserInputDeallocate free; /* function to deallocate the base */
62 const xmlChar *encoding; /* the encoding string for entity */
63 const xmlChar *version; /* the version string for entity */
64 int standalone; /* Was that entity marked standalone */
65};
66
67/**
Daniel Veillardf69bb4b2001-05-19 13:24:56 +000068 * xmlParserNodeInfo:
69 *
Owen Taylor3473f882001-02-23 17:55:21 +000070 * the parser can be asked to collect Node informations, i.e. at what
71 * place in the file they were detected.
72 * NOTE: This is off by default and not very well tested.
73 */
74typedef struct _xmlParserNodeInfo xmlParserNodeInfo;
75typedef xmlParserNodeInfo *xmlParserNodeInfoPtr;
76
77struct _xmlParserNodeInfo {
78 const struct _xmlNode* node;
79 /* Position & line # that text that created the node begins & ends on */
80 unsigned long begin_pos;
81 unsigned long begin_line;
82 unsigned long end_pos;
83 unsigned long end_line;
84};
85
86typedef struct _xmlParserNodeInfoSeq xmlParserNodeInfoSeq;
87typedef xmlParserNodeInfoSeq *xmlParserNodeInfoSeqPtr;
88struct _xmlParserNodeInfoSeq {
89 unsigned long maximum;
90 unsigned long length;
91 xmlParserNodeInfo* buffer;
92};
93
94/**
Daniel Veillardf69bb4b2001-05-19 13:24:56 +000095 * xmlParserInputState:
96 *
Owen Taylor3473f882001-02-23 17:55:21 +000097 * The parser is now working also as a state based parser
Daniel Veillardcbaf3992001-12-31 16:16:02 +000098 * The recursive one use the state info for entities processing
Owen Taylor3473f882001-02-23 17:55:21 +000099 */
100typedef enum {
101 XML_PARSER_EOF = -1, /* nothing is to be parsed */
102 XML_PARSER_START = 0, /* nothing has been parsed */
103 XML_PARSER_MISC, /* Misc* before int subset */
Daniel Veillardcbaf3992001-12-31 16:16:02 +0000104 XML_PARSER_PI, /* Within a processing instruction */
Owen Taylor3473f882001-02-23 17:55:21 +0000105 XML_PARSER_DTD, /* within some DTD content */
106 XML_PARSER_PROLOG, /* Misc* after internal subset */
107 XML_PARSER_COMMENT, /* within a comment */
108 XML_PARSER_START_TAG, /* within a start tag */
109 XML_PARSER_CONTENT, /* within the content */
110 XML_PARSER_CDATA_SECTION, /* within a CDATA section */
111 XML_PARSER_END_TAG, /* within a closing tag */
112 XML_PARSER_ENTITY_DECL, /* within an entity declaration */
113 XML_PARSER_ENTITY_VALUE, /* within an entity value in a decl */
114 XML_PARSER_ATTRIBUTE_VALUE, /* within an attribute value */
115 XML_PARSER_SYSTEM_LITERAL, /* within a SYSTEM value */
116 XML_PARSER_EPILOG, /* the Misc* after the last end tag */
117 XML_PARSER_IGNORE /* within an IGNORED section */
118} xmlParserInputState;
119
120/**
Daniel Veillardd16df9f2001-05-23 13:44:21 +0000121 * XML_DETECT_IDS:
122 *
123 * Bit in the loadsubset context field to tell to do ID/REFs lookups
124 * Use it to initialize xmlLoadExtDtdDefaultValue
125 */
126#define XML_DETECT_IDS 2
127
128/**
129 * XML_COMPLETE_ATTRS:
130 *
131 * Bit in the loadsubset context field to tell to do complete the
132 * elements attributes lists with the ones defaulted from the DTDs
133 * Use it to initialize xmlLoadExtDtdDefaultValue
134 */
135#define XML_COMPLETE_ATTRS 4
136
137/**
Daniel Veillardf69bb4b2001-05-19 13:24:56 +0000138 * xmlParserCtxt:
139 *
Owen Taylor3473f882001-02-23 17:55:21 +0000140 * The parser context.
141 * NOTE This doesn't completely defines the parser state, the (current ?)
142 * design of the parser uses recursive function calls since this allow
143 * and easy mapping from the production rules of the specification
144 * to the actual code. The drawback is that the actual function call
145 * also reflect the parser state. However most of the parsing routines
146 * takes as the only argument the parser context pointer, so migrating
147 * to a state based parser for progressive parsing shouldn't be too hard.
148 */
Owen Taylor3473f882001-02-23 17:55:21 +0000149struct _xmlParserCtxt {
150 struct _xmlSAXHandler *sax; /* The SAX handler */
151 void *userData; /* For SAX interface only, used by DOM build */
152 xmlDocPtr myDoc; /* the document being built */
153 int wellFormed; /* is the document well formed */
154 int replaceEntities; /* shall we replace entities ? */
155 const xmlChar *version; /* the XML version string */
156 const xmlChar *encoding; /* the declared encoding, if any */
157 int standalone; /* standalone document */
158 int html; /* an HTML(1)/Docbook(2) document */
159
160 /* Input stream stack */
161 xmlParserInputPtr input; /* Current input stream */
162 int inputNr; /* Number of current input streams */
163 int inputMax; /* Max number of input streams */
164 xmlParserInputPtr *inputTab; /* stack of inputs */
165
166 /* Node analysis stack only used for DOM building */
167 xmlNodePtr node; /* Current parsed Node */
168 int nodeNr; /* Depth of the parsing stack */
169 int nodeMax; /* Max depth of the parsing stack */
170 xmlNodePtr *nodeTab; /* array of nodes */
171
172 int record_info; /* Whether node info should be kept */
173 xmlParserNodeInfoSeq node_seq; /* info about each node parsed */
174
175 int errNo; /* error code */
176
177 int hasExternalSubset; /* reference and external subset */
178 int hasPErefs; /* the internal subset has PE refs */
179 int external; /* are we parsing an external entity */
180
181 int valid; /* is the document valid */
182 int validate; /* shall we try to validate ? */
183 xmlValidCtxt vctxt; /* The validity context */
184
185 xmlParserInputState instate; /* current type of input */
186 int token; /* next char look-ahead */
187
188 char *directory; /* the data directory */
189
190 /* Node name stack */
191 xmlChar *name; /* Current parsed Node */
192 int nameNr; /* Depth of the parsing stack */
193 int nameMax; /* Max depth of the parsing stack */
194 xmlChar * *nameTab; /* array of nodes */
195
196 long nbChars; /* number of xmlChar processed */
197 long checkIndex; /* used by progressive parsing lookup */
198 int keepBlanks; /* ugly but ... */
199 int disableSAX; /* SAX callbacks are disabled */
200 int inSubset; /* Parsing is in int 1/ext 2 subset */
201 xmlChar * intSubName; /* name of subset */
202 xmlChar * extSubURI; /* URI of external subset */
203 xmlChar * extSubSystem; /* SYSTEM ID of external subset */
204
205 /* xml:space values */
206 int * space; /* Should the parser preserve spaces */
207 int spaceNr; /* Depth of the parsing stack */
208 int spaceMax; /* Max depth of the parsing stack */
209 int * spaceTab; /* array of space infos */
210
211 int depth; /* to prevent entity substitution loops */
212 xmlParserInputPtr entity; /* used to check entities boundaries */
213 int charset; /* encoding of the in-memory content
214 actually an xmlCharEncoding */
215 int nodelen; /* Those two fields are there to */
216 int nodemem; /* Speed up large node parsing */
217 int pedantic; /* signal pedantic warnings */
218 void *_private; /* For user data, libxml won't touch it */
219
220 int loadsubset; /* should the external subset be loaded */
Daniel Veillardd9bad132001-07-23 19:39:43 +0000221 int linenumbers; /* set line number in element content */
Daniel Veillard5d90b6c2001-08-22 14:29:45 +0000222 void *catalogs; /* document's own catalog */
Owen Taylor3473f882001-02-23 17:55:21 +0000223};
224
225/**
Daniel Veillardf69bb4b2001-05-19 13:24:56 +0000226 * xmlSAXLocator:
227 *
Owen Taylor3473f882001-02-23 17:55:21 +0000228 * a SAX Locator.
229 */
230typedef struct _xmlSAXLocator xmlSAXLocator;
231typedef xmlSAXLocator *xmlSAXLocatorPtr;
232struct _xmlSAXLocator {
233 const xmlChar *(*getPublicId)(void *ctx);
234 const xmlChar *(*getSystemId)(void *ctx);
235 int (*getLineNumber)(void *ctx);
236 int (*getColumnNumber)(void *ctx);
237};
238
239/**
Daniel Veillardf69bb4b2001-05-19 13:24:56 +0000240 * xmlSAXHandler:
241 *
Owen Taylor3473f882001-02-23 17:55:21 +0000242 * a SAX handler is bunch of callbacks called by the parser when processing
243 * of the input generate data or structure informations.
244 */
245
Daniel Veillard9d06d302002-01-22 18:15:52 +0000246/**
247 * resolveEntitySAXFunc:
248 * @ctx: the user data (XML parser context)
249 * @publicId: The public ID of the entity
250 * @systemId: The system ID of the entity
251 *
252 * Callback:
253 * The entity loader, to control the loading of external entities,
254 * the application can either:
255 * - override this resolveEntity() callback in the SAX block
256 * - or better use the xmlSetExternalEntityLoader() function to
257 * set up it's own entity resolution routine
258 *
259 * Returns the xmlParserInputPtr if inlined or NULL for DOM behaviour.
260 */
Owen Taylor3473f882001-02-23 17:55:21 +0000261typedef xmlParserInputPtr (*resolveEntitySAXFunc) (void *ctx,
Daniel Veillard9d06d302002-01-22 18:15:52 +0000262 const xmlChar *publicId,
263 const xmlChar *systemId);
264/**
265 * internalSubsetSAXFunc:
266 * @ctx: the user data (XML parser context)
267 * @name: the root element name
268 * @ExternalID: the external ID
269 * @SystemID: the SYSTEM ID (e.g. filename or URL)
270 *
271 * Callback on internal subset declaration.
272 */
273typedef void (*internalSubsetSAXFunc) (void *ctx,
274 const xmlChar *name,
275 const xmlChar *ExternalID,
276 const xmlChar *SystemID);
277/**
278 * externalSubsetSAXFunc:
279 * @ctx: the user data (XML parser context)
280 * @name: the root element name
281 * @ExternalID: the external ID
282 * @SystemID: the SYSTEM ID (e.g. filename or URL)
283 *
284 * Callback on external subset declaration.
285 */
286typedef void (*externalSubsetSAXFunc) (void *ctx,
287 const xmlChar *name,
288 const xmlChar *ExternalID,
289 const xmlChar *SystemID);
290/**
291 * getEntitySAXFunc:
292 * @ctx: the user data (XML parser context)
293 * @name: The entity name
294 *
295 * Get an entity by name
296 *
297 * Returns the xmlEntityPtr if found.
298 */
Owen Taylor3473f882001-02-23 17:55:21 +0000299typedef xmlEntityPtr (*getEntitySAXFunc) (void *ctx,
Daniel Veillard9d06d302002-01-22 18:15:52 +0000300 const xmlChar *name);
301/**
302 * getParameterEntitySAXFunc:
303 * @ctx: the user data (XML parser context)
304 * @name: The entity name
305 *
306 * Get a parameter entity by name
307 *
308 * Returns the xmlEntityPtr if found.
309 */
Owen Taylor3473f882001-02-23 17:55:21 +0000310typedef xmlEntityPtr (*getParameterEntitySAXFunc) (void *ctx,
Daniel Veillard9d06d302002-01-22 18:15:52 +0000311 const xmlChar *name);
312/**
313 * entityDeclSAXFunc:
314 * @ctx: the user data (XML parser context)
315 * @name: the entity name
316 * @type: the entity type
317 * @publicId: The public ID of the entity
318 * @systemId: The system ID of the entity
319 * @content: the entity value (without processing).
320 *
321 * An entity definition has been parsed
322 */
Owen Taylor3473f882001-02-23 17:55:21 +0000323typedef void (*entityDeclSAXFunc) (void *ctx,
Daniel Veillard9d06d302002-01-22 18:15:52 +0000324 const xmlChar *name,
325 int type,
326 const xmlChar *publicId,
327 const xmlChar *systemId,
328 xmlChar *content);
329/**
330 * notationDeclSAXFunc:
331 * @ctx: the user data (XML parser context)
332 * @name: The name of the notation
333 * @publicId: The public ID of the entity
334 * @systemId: The system ID of the entity
335 *
336 * What to do when a notation declaration has been parsed.
337 */
338typedef void (*notationDeclSAXFunc)(void *ctx,
339 const xmlChar *name,
340 const xmlChar *publicId,
341 const xmlChar *systemId);
342/**
343 * attributeDeclSAXFunc:
344 * @ctx: the user data (XML parser context)
345 * @elem: the name of the element
346 * @fullname: the attribute name
347 * @type: the attribute type
348 * @def: the type of default value
349 * @defaultValue: the attribute default value
350 * @tree: the tree of enumerated value set
351 *
352 * An attribute definition has been parsed
353 */
354typedef void (*attributeDeclSAXFunc)(void *ctx,
355 const xmlChar *elem,
356 const xmlChar *fullname,
357 int type,
358 int def,
359 const xmlChar *defaultValue,
360 xmlEnumerationPtr tree);
361/**
362 * elementDeclSAXFunc:
363 * @ctx: the user data (XML parser context)
364 * @name: the element name
365 * @type: the element type
366 * @content: the element value tree
367 *
368 * An element definition has been parsed
369 */
370typedef void (*elementDeclSAXFunc)(void *ctx,
371 const xmlChar *name,
372 int type,
373 xmlElementContentPtr content);
374/**
375 * unparsedEntityDeclSAXFunc:
376 * @ctx: the user data (XML parser context)
377 * @name: The name of the entity
378 * @publicId: The public ID of the entity
379 * @systemId: The system ID of the entity
380 * @notationName: the name of the notation
381 *
382 * What to do when an unparsed entity declaration is parsed
383 */
Owen Taylor3473f882001-02-23 17:55:21 +0000384typedef void (*unparsedEntityDeclSAXFunc)(void *ctx,
Daniel Veillard9d06d302002-01-22 18:15:52 +0000385 const xmlChar *name,
386 const xmlChar *publicId,
387 const xmlChar *systemId,
388 const xmlChar *notationName);
389/**
390 * setDocumentLocatorSAXFunc:
391 * @ctx: the user data (XML parser context)
392 * @loc: A SAX Locator
393 *
394 * Receive the document locator at startup, actually xmlDefaultSAXLocator
395 * Everything is available on the context, so this is useless in our case.
396 */
Owen Taylor3473f882001-02-23 17:55:21 +0000397typedef void (*setDocumentLocatorSAXFunc) (void *ctx,
Daniel Veillard9d06d302002-01-22 18:15:52 +0000398 xmlSAXLocatorPtr loc);
399/**
400 * startDocumentSAXFunc:
401 * @ctx: the user data (XML parser context)
402 *
403 * called when the document start being processed.
404 */
Owen Taylor3473f882001-02-23 17:55:21 +0000405typedef void (*startDocumentSAXFunc) (void *ctx);
Daniel Veillard9d06d302002-01-22 18:15:52 +0000406/**
407 * endDocumentSAXFunc:
408 * @ctx: the user data (XML parser context)
409 *
410 * called when the document end has been detected.
411 */
Owen Taylor3473f882001-02-23 17:55:21 +0000412typedef void (*endDocumentSAXFunc) (void *ctx);
Daniel Veillard9d06d302002-01-22 18:15:52 +0000413/**
414 * startElementSAXFunc:
415 * @ctx: the user data (XML parser context)
416 * @name: The element name, including namespace prefix
417 * @atts: An array of name/value attributes pairs, NULL terminated
418 *
419 * called when an opening tag has been processed.
420 */
421typedef void (*startElementSAXFunc) (void *ctx,
422 const xmlChar *name,
423 const xmlChar **atts);
424/**
425 * endElementSAXFunc:
426 * @ctx: the user data (XML parser context)
427 * @name: The element name
428 *
429 * called when the end of an element has been detected.
430 */
431typedef void (*endElementSAXFunc) (void *ctx,
432 const xmlChar *name);
433/**
434 * attributeSAXFunc:
435 * @ctx: the user data (XML parser context)
436 * @name: The attribute name, including namespace prefix
437 * @value: The attribute value
438 *
439 * Handle an attribute that has been read by the parser.
440 * The default handling is to convert the attribute into an
441 * DOM subtree and past it in a new xmlAttr element added to
442 * the element.
443 */
444typedef void (*attributeSAXFunc) (void *ctx,
445 const xmlChar *name,
446 const xmlChar *value);
447/**
448 * referenceSAXFunc:
449 * @ctx: the user data (XML parser context)
450 * @name: The entity name
451 *
452 * called when an entity reference is detected.
453 */
454typedef void (*referenceSAXFunc) (void *ctx,
455 const xmlChar *name);
456/**
457 * charactersSAXFunc:
458 * @ctx: the user data (XML parser context)
459 * @ch: a xmlChar string
460 * @len: the number of xmlChar
461 *
462 * receiving some chars from the parser.
463 */
464typedef void (*charactersSAXFunc) (void *ctx,
465 const xmlChar *ch,
466 int len);
467/**
468 * ignorableWhitespaceSAXFunc:
469 * @ctx: the user data (XML parser context)
470 * @ch: a xmlChar string
471 * @len: the number of xmlChar
472 *
473 * receiving some ignorable whitespaces from the parser.
474 * UNUSED: by default the DOM building will use characters
475 */
Owen Taylor3473f882001-02-23 17:55:21 +0000476typedef void (*ignorableWhitespaceSAXFunc) (void *ctx,
Daniel Veillard9d06d302002-01-22 18:15:52 +0000477 const xmlChar *ch,
478 int len);
479/**
480 * processingInstructionSAXFunc:
481 * @ctx: the user data (XML parser context)
482 * @target: the target name
483 * @data: the PI data's
484 *
485 * A processing instruction has been parsed.
486 */
Owen Taylor3473f882001-02-23 17:55:21 +0000487typedef void (*processingInstructionSAXFunc) (void *ctx,
Daniel Veillard9d06d302002-01-22 18:15:52 +0000488 const xmlChar *target,
489 const xmlChar *data);
490/**
491 * commentSAXFunc:
492 * @ctx: the user data (XML parser context)
493 * @value: the comment content
494 *
495 * A comment has been parsed.
496 */
497typedef void (*commentSAXFunc) (void *ctx,
498 const xmlChar *value);
499/**
500 * cdataBlockSAXFunc:
501 * @ctx: the user data (XML parser context)
502 * @value: The pcdata content
503 * @len: the block length
504 *
505 * called when a pcdata block has been parsed
506 */
507typedef void (*cdataBlockSAXFunc) (
508 void *ctx,
509 const xmlChar *value,
510 int len);
511/**
512 * warningSAXFunc:
513 * @ctx: an XML parser context
514 * @msg: the message to display/transmit
515 * @...: extra parameters for the message display
516 *
517 * Display and format a warning messages, callback
518 */
519typedef void (*warningSAXFunc) (void *ctx,
520 const char *msg, ...);
521/**
522 * errorSAXFunc:
523 * @ctx: an XML parser context
524 * @msg: the message to display/transmit
525 * @...: extra parameters for the message display
526 *
527 * Display and format an error messages, callback
528 */
529typedef void (*errorSAXFunc) (void *ctx,
530 const char *msg, ...);
531/**
532 * fatalErrorSAXFunc:
533 * @ctx: an XML parser context
534 * @msg: the message to display/transmit
535 * @...: extra parameters for the message display
536 *
537 * Display and format fatal error messages, callback
538 */
539typedef void (*fatalErrorSAXFunc) (void *ctx,
540 const char *msg, ...);
541/**
542 * isStandaloneSAXFunc:
543 * @ctx: the user data (XML parser context)
544 *
545 * Is this document tagged standalone ?
546 *
547 * Returns 1 if true
548 */
Owen Taylor3473f882001-02-23 17:55:21 +0000549typedef int (*isStandaloneSAXFunc) (void *ctx);
Daniel Veillard9d06d302002-01-22 18:15:52 +0000550/**
551 * hasInternalSubsetSAXFunc:
552 * @ctx: the user data (XML parser context)
553 *
554 * Does this document has an internal subset
555 *
556 * Returns 1 if true
557 */
Owen Taylor3473f882001-02-23 17:55:21 +0000558typedef int (*hasInternalSubsetSAXFunc) (void *ctx);
Daniel Veillard9d06d302002-01-22 18:15:52 +0000559/**
560 * hasExternalSubsetSAXFunc:
561 * @ctx: the user data (XML parser context)
562 *
563 * Does this document has an external subset
564 *
565 * Returns 1 if true
566 */
Owen Taylor3473f882001-02-23 17:55:21 +0000567typedef int (*hasExternalSubsetSAXFunc) (void *ctx);
568
569typedef struct _xmlSAXHandler xmlSAXHandler;
570typedef xmlSAXHandler *xmlSAXHandlerPtr;
571struct _xmlSAXHandler {
572 internalSubsetSAXFunc internalSubset;
573 isStandaloneSAXFunc isStandalone;
574 hasInternalSubsetSAXFunc hasInternalSubset;
575 hasExternalSubsetSAXFunc hasExternalSubset;
576 resolveEntitySAXFunc resolveEntity;
577 getEntitySAXFunc getEntity;
578 entityDeclSAXFunc entityDecl;
579 notationDeclSAXFunc notationDecl;
580 attributeDeclSAXFunc attributeDecl;
581 elementDeclSAXFunc elementDecl;
582 unparsedEntityDeclSAXFunc unparsedEntityDecl;
583 setDocumentLocatorSAXFunc setDocumentLocator;
584 startDocumentSAXFunc startDocument;
585 endDocumentSAXFunc endDocument;
586 startElementSAXFunc startElement;
587 endElementSAXFunc endElement;
588 referenceSAXFunc reference;
589 charactersSAXFunc characters;
590 ignorableWhitespaceSAXFunc ignorableWhitespace;
591 processingInstructionSAXFunc processingInstruction;
592 commentSAXFunc comment;
593 warningSAXFunc warning;
594 errorSAXFunc error;
595 fatalErrorSAXFunc fatalError;
596 getParameterEntitySAXFunc getParameterEntity;
597 cdataBlockSAXFunc cdataBlock;
598 externalSubsetSAXFunc externalSubset;
Daniel Veillardd0463562001-10-13 09:15:48 +0000599 int initialized;
Owen Taylor3473f882001-02-23 17:55:21 +0000600};
601
602/**
Daniel Veillardf69bb4b2001-05-19 13:24:56 +0000603 * xmlExternalEntityLoader:
604 * @URL: The System ID of the resource requested
605 * @ID: The Public ID of the resource requested
Daniel Veillardcbaf3992001-12-31 16:16:02 +0000606 * @context: the XML parser context
Daniel Veillardf69bb4b2001-05-19 13:24:56 +0000607 *
Owen Taylor3473f882001-02-23 17:55:21 +0000608 * External entity loaders types
Daniel Veillardcbaf3992001-12-31 16:16:02 +0000609 *
610 * Returns the entity input parser
Owen Taylor3473f882001-02-23 17:55:21 +0000611 */
Daniel Veillard9d06d302002-01-22 18:15:52 +0000612typedef xmlParserInputPtr (*xmlExternalEntityLoader) (const char *URL,
613 const char *ID,
614 xmlParserCtxtPtr context);
Owen Taylor3473f882001-02-23 17:55:21 +0000615
Daniel Veillardf69bb4b2001-05-19 13:24:56 +0000616/*
Owen Taylor3473f882001-02-23 17:55:21 +0000617 * Global variables: just the default SAX interface tables and XML
618 * version infos.
619 */
620LIBXML_DLL_IMPORT extern const char *xmlParserVersion;
621
622LIBXML_DLL_IMPORT extern xmlSAXLocator xmlDefaultSAXLocator;
623LIBXML_DLL_IMPORT extern xmlSAXHandler xmlDefaultSAXHandler;
624LIBXML_DLL_IMPORT extern xmlSAXHandler htmlDefaultSAXHandler;
Daniel Veillardeae522a2001-04-23 13:41:34 +0000625LIBXML_DLL_IMPORT extern xmlSAXHandler docbDefaultSAXHandler;
Owen Taylor3473f882001-02-23 17:55:21 +0000626
Daniel Veillardf69bb4b2001-05-19 13:24:56 +0000627/*
Daniel Veillardcbaf3992001-12-31 16:16:02 +0000628 * entity substitution default behavior.
Owen Taylor3473f882001-02-23 17:55:21 +0000629 */
630
631#ifdef VMS
Daniel Veillard5e2dace2001-07-18 19:30:27 +0000632/**
633 * xmlSubstituteEntitiesDefaultValue:
634 *
Daniel Veillardcbaf3992001-12-31 16:16:02 +0000635 * global variable controlling the entity substitution default behavior
Daniel Veillard5e2dace2001-07-18 19:30:27 +0000636 */
Owen Taylor3473f882001-02-23 17:55:21 +0000637LIBXML_DLL_IMPORT extern int xmlSubstituteEntitiesDefaultVal;
638#define xmlSubstituteEntitiesDefaultValue xmlSubstituteEntitiesDefaultVal
639#else
640LIBXML_DLL_IMPORT extern int xmlSubstituteEntitiesDefaultValue;
641#endif
642LIBXML_DLL_IMPORT extern int xmlGetWarningsDefaultValue;
643
644
Daniel Veillardf69bb4b2001-05-19 13:24:56 +0000645/*
Owen Taylor3473f882001-02-23 17:55:21 +0000646 * Init/Cleanup
647 */
648void xmlInitParser (void);
649void xmlCleanupParser (void);
650
Daniel Veillardf69bb4b2001-05-19 13:24:56 +0000651/*
Owen Taylor3473f882001-02-23 17:55:21 +0000652 * Input functions
653 */
654int xmlParserInputRead (xmlParserInputPtr in,
655 int len);
656int xmlParserInputGrow (xmlParserInputPtr in,
657 int len);
658
Daniel Veillardf69bb4b2001-05-19 13:24:56 +0000659/*
Owen Taylor3473f882001-02-23 17:55:21 +0000660 * xmlChar handling
661 */
662xmlChar * xmlStrdup (const xmlChar *cur);
663xmlChar * xmlStrndup (const xmlChar *cur,
664 int len);
Daniel Veillard56a4cb82001-03-24 17:00:36 +0000665xmlChar * xmlCharStrndup (const char *cur,
666 int len);
667xmlChar * xmlCharStrdup (const char *cur);
Owen Taylor3473f882001-02-23 17:55:21 +0000668xmlChar * xmlStrsub (const xmlChar *str,
669 int start,
670 int len);
671const xmlChar * xmlStrchr (const xmlChar *str,
672 xmlChar val);
673const xmlChar * xmlStrstr (const xmlChar *str,
Daniel Veillard77044732001-06-29 21:31:07 +0000674 const xmlChar *val);
Owen Taylor3473f882001-02-23 17:55:21 +0000675const xmlChar * xmlStrcasestr (const xmlChar *str,
676 xmlChar *val);
677int xmlStrcmp (const xmlChar *str1,
678 const xmlChar *str2);
679int xmlStrncmp (const xmlChar *str1,
680 const xmlChar *str2,
681 int len);
682int xmlStrcasecmp (const xmlChar *str1,
683 const xmlChar *str2);
684int xmlStrncasecmp (const xmlChar *str1,
685 const xmlChar *str2,
686 int len);
687int xmlStrEqual (const xmlChar *str1,
688 const xmlChar *str2);
689int xmlStrlen (const xmlChar *str);
690xmlChar * xmlStrcat (xmlChar *cur,
691 const xmlChar *add);
692xmlChar * xmlStrncat (xmlChar *cur,
693 const xmlChar *add,
694 int len);
695
Daniel Veillardf69bb4b2001-05-19 13:24:56 +0000696/*
Owen Taylor3473f882001-02-23 17:55:21 +0000697 * Basic parsing Interfaces
698 */
699xmlDocPtr xmlParseDoc (xmlChar *cur);
Daniel Veillard50822cb2001-07-26 20:05:51 +0000700xmlDocPtr xmlParseMemory (const char *buffer,
Owen Taylor3473f882001-02-23 17:55:21 +0000701 int size);
702xmlDocPtr xmlParseFile (const char *filename);
703int xmlSubstituteEntitiesDefault(int val);
704int xmlKeepBlanksDefault (int val);
705void xmlStopParser (xmlParserCtxtPtr ctxt);
706int xmlPedanticParserDefault(int val);
Daniel Veillardd9bad132001-07-23 19:39:43 +0000707int xmlLineNumbersDefault (int val);
Owen Taylor3473f882001-02-23 17:55:21 +0000708
Daniel Veillardf69bb4b2001-05-19 13:24:56 +0000709/*
Owen Taylor3473f882001-02-23 17:55:21 +0000710 * Recovery mode
711 */
712xmlDocPtr xmlRecoverDoc (xmlChar *cur);
Daniel Veillard50822cb2001-07-26 20:05:51 +0000713xmlDocPtr xmlRecoverMemory (const char *buffer,
Owen Taylor3473f882001-02-23 17:55:21 +0000714 int size);
715xmlDocPtr xmlRecoverFile (const char *filename);
716
Daniel Veillardf69bb4b2001-05-19 13:24:56 +0000717/*
Owen Taylor3473f882001-02-23 17:55:21 +0000718 * Less common routines and SAX interfaces
719 */
720int xmlParseDocument (xmlParserCtxtPtr ctxt);
721int xmlParseExtParsedEnt (xmlParserCtxtPtr ctxt);
722xmlDocPtr xmlSAXParseDoc (xmlSAXHandlerPtr sax,
723 xmlChar *cur,
724 int recovery);
725int xmlSAXUserParseFile (xmlSAXHandlerPtr sax,
726 void *user_data,
727 const char *filename);
728int xmlSAXUserParseMemory (xmlSAXHandlerPtr sax,
729 void *user_data,
Daniel Veillardfd7ddca2001-05-16 10:57:35 +0000730 const char *buffer,
Owen Taylor3473f882001-02-23 17:55:21 +0000731 int size);
732xmlDocPtr xmlSAXParseMemory (xmlSAXHandlerPtr sax,
Daniel Veillard50822cb2001-07-26 20:05:51 +0000733 const char *buffer,
Owen Taylor3473f882001-02-23 17:55:21 +0000734 int size,
735 int recovery);
736xmlDocPtr xmlSAXParseFile (xmlSAXHandlerPtr sax,
737 const char *filename,
738 int recovery);
Daniel Veillarda293c322001-10-02 13:54:14 +0000739xmlDocPtr xmlSAXParseFileWithData (xmlSAXHandlerPtr sax,
740 const char *filename,
741 int recovery,
742 void *data);
Owen Taylor3473f882001-02-23 17:55:21 +0000743xmlDocPtr xmlSAXParseEntity (xmlSAXHandlerPtr sax,
744 const char *filename);
745xmlDocPtr xmlParseEntity (const char *filename);
746xmlDtdPtr xmlParseDTD (const xmlChar *ExternalID,
747 const xmlChar *SystemID);
748xmlDtdPtr xmlSAXParseDTD (xmlSAXHandlerPtr sax,
749 const xmlChar *ExternalID,
750 const xmlChar *SystemID);
751xmlDtdPtr xmlIOParseDTD (xmlSAXHandlerPtr sax,
752 xmlParserInputBufferPtr input,
753 xmlCharEncoding enc);
754int xmlParseBalancedChunkMemory(xmlDocPtr doc,
755 xmlSAXHandlerPtr sax,
756 void *user_data,
757 int depth,
758 const xmlChar *string,
Daniel Veillardcda96922001-08-21 10:56:31 +0000759 xmlNodePtr *lst);
Owen Taylor3473f882001-02-23 17:55:21 +0000760int xmlParseExternalEntity (xmlDocPtr doc,
761 xmlSAXHandlerPtr sax,
762 void *user_data,
763 int depth,
764 const xmlChar *URL,
765 const xmlChar *ID,
Daniel Veillardcda96922001-08-21 10:56:31 +0000766 xmlNodePtr *lst);
Owen Taylor3473f882001-02-23 17:55:21 +0000767int xmlParseCtxtExternalEntity(xmlParserCtxtPtr ctx,
768 const xmlChar *URL,
769 const xmlChar *ID,
Daniel Veillardcda96922001-08-21 10:56:31 +0000770 xmlNodePtr *lst);
Owen Taylor3473f882001-02-23 17:55:21 +0000771
Daniel Veillardf69bb4b2001-05-19 13:24:56 +0000772/*
Owen Taylor3473f882001-02-23 17:55:21 +0000773 * SAX initialization routines
774 */
775void xmlDefaultSAXHandlerInit(void);
776void htmlDefaultSAXHandlerInit(void);
777
Daniel Veillardf69bb4b2001-05-19 13:24:56 +0000778/*
Owen Taylor3473f882001-02-23 17:55:21 +0000779 * Parser contexts handling.
780 */
781void xmlInitParserCtxt (xmlParserCtxtPtr ctxt);
782void xmlClearParserCtxt (xmlParserCtxtPtr ctxt);
783void xmlFreeParserCtxt (xmlParserCtxtPtr ctxt);
784void xmlSetupParserForBuffer (xmlParserCtxtPtr ctxt,
785 const xmlChar* buffer,
Daniel Veillard963d2ae2002-01-20 22:08:18 +0000786 const char *filename);
Owen Taylor3473f882001-02-23 17:55:21 +0000787xmlParserCtxtPtr xmlCreateDocParserCtxt (xmlChar *cur);
788
Daniel Veillardf69bb4b2001-05-19 13:24:56 +0000789/*
Owen Taylor3473f882001-02-23 17:55:21 +0000790 * Reading/setting optional parsing features.
791 */
792
793int xmlGetFeaturesList (int *len,
794 const char **result);
795int xmlGetFeature (xmlParserCtxtPtr ctxt,
796 const char *name,
797 void *result);
798int xmlSetFeature (xmlParserCtxtPtr ctxt,
799 const char *name,
800 void *value);
801
Daniel Veillardf69bb4b2001-05-19 13:24:56 +0000802/*
Owen Taylor3473f882001-02-23 17:55:21 +0000803 * Interfaces for the Push mode
804 */
805xmlParserCtxtPtr xmlCreatePushParserCtxt(xmlSAXHandlerPtr sax,
806 void *user_data,
807 const char *chunk,
808 int size,
809 const char *filename);
810int xmlParseChunk (xmlParserCtxtPtr ctxt,
811 const char *chunk,
812 int size,
813 int terminate);
814
Daniel Veillardf69bb4b2001-05-19 13:24:56 +0000815/*
Owen Taylor3473f882001-02-23 17:55:21 +0000816 * Special I/O mode
817 */
818
819xmlParserCtxtPtr xmlCreateIOParserCtxt (xmlSAXHandlerPtr sax,
820 void *user_data,
821 xmlInputReadCallback ioread,
822 xmlInputCloseCallback ioclose,
823 void *ioctx,
824 xmlCharEncoding enc);
825
826xmlParserInputPtr xmlNewIOInputStream (xmlParserCtxtPtr ctxt,
827 xmlParserInputBufferPtr input,
828 xmlCharEncoding enc);
829
Daniel Veillardf69bb4b2001-05-19 13:24:56 +0000830/*
Owen Taylor3473f882001-02-23 17:55:21 +0000831 * Node infos
832 */
833const xmlParserNodeInfo*
Daniel Veillard963d2ae2002-01-20 22:08:18 +0000834 xmlParserFindNodeInfo (const xmlParserCtxtPtr ctxt,
835 const xmlNodePtr node);
Owen Taylor3473f882001-02-23 17:55:21 +0000836void xmlInitNodeInfoSeq (xmlParserNodeInfoSeqPtr seq);
837void xmlClearNodeInfoSeq (xmlParserNodeInfoSeqPtr seq);
Daniel Veillard963d2ae2002-01-20 22:08:18 +0000838unsigned long xmlParserFindNodeInfoIndex(const xmlParserNodeInfoSeqPtr seq,
839 const xmlNodePtr node);
Owen Taylor3473f882001-02-23 17:55:21 +0000840void xmlParserAddNodeInfo (xmlParserCtxtPtr ctxt,
Daniel Veillard963d2ae2002-01-20 22:08:18 +0000841 const xmlParserNodeInfoPtr info);
Owen Taylor3473f882001-02-23 17:55:21 +0000842
843/*
844 * External entities handling actually implemented in xmlIO
845 */
846
847void xmlSetExternalEntityLoader(xmlExternalEntityLoader f);
848xmlExternalEntityLoader
849 xmlGetExternalEntityLoader(void);
850xmlParserInputPtr
851 xmlLoadExternalEntity (const char *URL,
852 const char *ID,
Daniel Veillard9d06d302002-01-22 18:15:52 +0000853 xmlParserCtxtPtr ctxt);
Owen Taylor3473f882001-02-23 17:55:21 +0000854
855#ifdef __cplusplus
856}
857#endif
858
Daniel Veillard64a411c2001-10-15 12:32:07 +0000859#include <libxml/globals.h>
860
Owen Taylor3473f882001-02-23 17:55:21 +0000861#endif /* __XML_PARSER_H__ */
862