blob: eb7e62fec2fc70d1bff96788fa4d421c6f466e57 [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>
Owen Taylor3473f882001-02-23 17:55:21 +000015
16#ifdef __cplusplus
17extern "C" {
18#endif
19
Daniel Veillard5e2dace2001-07-18 19:30:27 +000020/**
21 * XML_DEFAULT_VERSION:
22 *
23 * The default version of XML used: 1.0
Owen Taylor3473f882001-02-23 17:55:21 +000024 */
25#define XML_DEFAULT_VERSION "1.0"
26
27/**
Daniel Veillardf69bb4b2001-05-19 13:24:56 +000028 * xmlParserInput:
29 *
Owen Taylor3473f882001-02-23 17:55:21 +000030 * an xmlParserInput is an input flow for the XML processor.
31 * Each entity parsed is associated an xmlParserInput (except the
32 * few predefined ones). This is the case both for internal entities
33 * - in which case the flow is already completely in memory - or
34 * external entities - in which case we use the buf structure for
35 * progressive reading and I18N conversions to the internal UTF-8 format.
36 */
37
Daniel Veillard9d06d302002-01-22 18:15:52 +000038/**
39 * xmlParserInputDeallocate:
40 * @str: the string to deallocate
41 *
42 * Callback for freeing some parser input allocations
43 */
44typedef void (* xmlParserInputDeallocate)(xmlChar *str);
Daniel Veillard5e2dace2001-07-18 19:30:27 +000045
Owen Taylor3473f882001-02-23 17:55:21 +000046struct _xmlParserInput {
47 /* Input buffer */
48 xmlParserInputBufferPtr buf; /* UTF-8 encoded buffer */
49
50 const char *filename; /* The file analyzed, if any */
Daniel Veillard60087f32001-10-10 09:45:09 +000051 const char *directory; /* the directory/base of the file */
Owen Taylor3473f882001-02-23 17:55:21 +000052 const xmlChar *base; /* Base of the array to parse */
53 const xmlChar *cur; /* Current char being parsed */
Daniel Veillardcbaf3992001-12-31 16:16:02 +000054 const xmlChar *end; /* end of the array to parse */
Owen Taylor3473f882001-02-23 17:55:21 +000055 int length; /* length if known */
56 int line; /* Current line */
57 int col; /* Current column */
58 int consumed; /* How many xmlChars already consumed */
59 xmlParserInputDeallocate free; /* function to deallocate the base */
60 const xmlChar *encoding; /* the encoding string for entity */
61 const xmlChar *version; /* the version string for entity */
62 int standalone; /* Was that entity marked standalone */
63};
64
65/**
Daniel Veillardf69bb4b2001-05-19 13:24:56 +000066 * xmlParserNodeInfo:
67 *
Owen Taylor3473f882001-02-23 17:55:21 +000068 * the parser can be asked to collect Node informations, i.e. at what
69 * place in the file they were detected.
70 * NOTE: This is off by default and not very well tested.
71 */
72typedef struct _xmlParserNodeInfo xmlParserNodeInfo;
73typedef xmlParserNodeInfo *xmlParserNodeInfoPtr;
74
75struct _xmlParserNodeInfo {
76 const struct _xmlNode* node;
77 /* Position & line # that text that created the node begins & ends on */
78 unsigned long begin_pos;
79 unsigned long begin_line;
80 unsigned long end_pos;
81 unsigned long end_line;
82};
83
84typedef struct _xmlParserNodeInfoSeq xmlParserNodeInfoSeq;
85typedef xmlParserNodeInfoSeq *xmlParserNodeInfoSeqPtr;
86struct _xmlParserNodeInfoSeq {
87 unsigned long maximum;
88 unsigned long length;
89 xmlParserNodeInfo* buffer;
90};
91
92/**
Daniel Veillardf69bb4b2001-05-19 13:24:56 +000093 * xmlParserInputState:
94 *
Owen Taylor3473f882001-02-23 17:55:21 +000095 * The parser is now working also as a state based parser
Daniel Veillardcbaf3992001-12-31 16:16:02 +000096 * The recursive one use the state info for entities processing
Owen Taylor3473f882001-02-23 17:55:21 +000097 */
98typedef enum {
99 XML_PARSER_EOF = -1, /* nothing is to be parsed */
100 XML_PARSER_START = 0, /* nothing has been parsed */
101 XML_PARSER_MISC, /* Misc* before int subset */
Daniel Veillardcbaf3992001-12-31 16:16:02 +0000102 XML_PARSER_PI, /* Within a processing instruction */
Owen Taylor3473f882001-02-23 17:55:21 +0000103 XML_PARSER_DTD, /* within some DTD content */
104 XML_PARSER_PROLOG, /* Misc* after internal subset */
105 XML_PARSER_COMMENT, /* within a comment */
106 XML_PARSER_START_TAG, /* within a start tag */
107 XML_PARSER_CONTENT, /* within the content */
108 XML_PARSER_CDATA_SECTION, /* within a CDATA section */
109 XML_PARSER_END_TAG, /* within a closing tag */
110 XML_PARSER_ENTITY_DECL, /* within an entity declaration */
111 XML_PARSER_ENTITY_VALUE, /* within an entity value in a decl */
112 XML_PARSER_ATTRIBUTE_VALUE, /* within an attribute value */
113 XML_PARSER_SYSTEM_LITERAL, /* within a SYSTEM value */
114 XML_PARSER_EPILOG, /* the Misc* after the last end tag */
115 XML_PARSER_IGNORE /* within an IGNORED section */
116} xmlParserInputState;
117
118/**
Daniel Veillardd16df9f2001-05-23 13:44:21 +0000119 * XML_DETECT_IDS:
120 *
121 * Bit in the loadsubset context field to tell to do ID/REFs lookups
122 * Use it to initialize xmlLoadExtDtdDefaultValue
123 */
124#define XML_DETECT_IDS 2
125
126/**
127 * XML_COMPLETE_ATTRS:
128 *
129 * Bit in the loadsubset context field to tell to do complete the
130 * elements attributes lists with the ones defaulted from the DTDs
131 * Use it to initialize xmlLoadExtDtdDefaultValue
132 */
133#define XML_COMPLETE_ATTRS 4
134
135/**
Daniel Veillardf69bb4b2001-05-19 13:24:56 +0000136 * xmlParserCtxt:
137 *
Owen Taylor3473f882001-02-23 17:55:21 +0000138 * The parser context.
139 * NOTE This doesn't completely defines the parser state, the (current ?)
140 * design of the parser uses recursive function calls since this allow
141 * and easy mapping from the production rules of the specification
142 * to the actual code. The drawback is that the actual function call
143 * also reflect the parser state. However most of the parsing routines
144 * takes as the only argument the parser context pointer, so migrating
145 * to a state based parser for progressive parsing shouldn't be too hard.
146 */
Owen Taylor3473f882001-02-23 17:55:21 +0000147struct _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 */
Owen Taylor3473f882001-02-23 17:55:21 +0000228struct _xmlSAXLocator {
229 const xmlChar *(*getPublicId)(void *ctx);
230 const xmlChar *(*getSystemId)(void *ctx);
231 int (*getLineNumber)(void *ctx);
232 int (*getColumnNumber)(void *ctx);
233};
234
235/**
Daniel Veillardf69bb4b2001-05-19 13:24:56 +0000236 * xmlSAXHandler:
237 *
Owen Taylor3473f882001-02-23 17:55:21 +0000238 * a SAX handler is bunch of callbacks called by the parser when processing
239 * of the input generate data or structure informations.
240 */
241
Daniel Veillard9d06d302002-01-22 18:15:52 +0000242/**
243 * resolveEntitySAXFunc:
244 * @ctx: the user data (XML parser context)
245 * @publicId: The public ID of the entity
246 * @systemId: The system ID of the entity
247 *
248 * Callback:
249 * The entity loader, to control the loading of external entities,
250 * the application can either:
251 * - override this resolveEntity() callback in the SAX block
252 * - or better use the xmlSetExternalEntityLoader() function to
253 * set up it's own entity resolution routine
254 *
255 * Returns the xmlParserInputPtr if inlined or NULL for DOM behaviour.
256 */
Owen Taylor3473f882001-02-23 17:55:21 +0000257typedef xmlParserInputPtr (*resolveEntitySAXFunc) (void *ctx,
Daniel Veillard9d06d302002-01-22 18:15:52 +0000258 const xmlChar *publicId,
259 const xmlChar *systemId);
260/**
261 * internalSubsetSAXFunc:
262 * @ctx: the user data (XML parser context)
263 * @name: the root element name
264 * @ExternalID: the external ID
265 * @SystemID: the SYSTEM ID (e.g. filename or URL)
266 *
267 * Callback on internal subset declaration.
268 */
269typedef void (*internalSubsetSAXFunc) (void *ctx,
270 const xmlChar *name,
271 const xmlChar *ExternalID,
272 const xmlChar *SystemID);
273/**
274 * externalSubsetSAXFunc:
275 * @ctx: the user data (XML parser context)
276 * @name: the root element name
277 * @ExternalID: the external ID
278 * @SystemID: the SYSTEM ID (e.g. filename or URL)
279 *
280 * Callback on external subset declaration.
281 */
282typedef void (*externalSubsetSAXFunc) (void *ctx,
283 const xmlChar *name,
284 const xmlChar *ExternalID,
285 const xmlChar *SystemID);
286/**
287 * getEntitySAXFunc:
288 * @ctx: the user data (XML parser context)
289 * @name: The entity name
290 *
291 * Get an entity by name
292 *
293 * Returns the xmlEntityPtr if found.
294 */
Owen Taylor3473f882001-02-23 17:55:21 +0000295typedef xmlEntityPtr (*getEntitySAXFunc) (void *ctx,
Daniel Veillard9d06d302002-01-22 18:15:52 +0000296 const xmlChar *name);
297/**
298 * getParameterEntitySAXFunc:
299 * @ctx: the user data (XML parser context)
300 * @name: The entity name
301 *
302 * Get a parameter entity by name
303 *
304 * Returns the xmlEntityPtr if found.
305 */
Owen Taylor3473f882001-02-23 17:55:21 +0000306typedef xmlEntityPtr (*getParameterEntitySAXFunc) (void *ctx,
Daniel Veillard9d06d302002-01-22 18:15:52 +0000307 const xmlChar *name);
308/**
309 * entityDeclSAXFunc:
310 * @ctx: the user data (XML parser context)
311 * @name: the entity name
312 * @type: the entity type
313 * @publicId: The public ID of the entity
314 * @systemId: The system ID of the entity
315 * @content: the entity value (without processing).
316 *
317 * An entity definition has been parsed
318 */
Owen Taylor3473f882001-02-23 17:55:21 +0000319typedef void (*entityDeclSAXFunc) (void *ctx,
Daniel Veillard9d06d302002-01-22 18:15:52 +0000320 const xmlChar *name,
321 int type,
322 const xmlChar *publicId,
323 const xmlChar *systemId,
324 xmlChar *content);
325/**
326 * notationDeclSAXFunc:
327 * @ctx: the user data (XML parser context)
328 * @name: The name of the notation
329 * @publicId: The public ID of the entity
330 * @systemId: The system ID of the entity
331 *
332 * What to do when a notation declaration has been parsed.
333 */
334typedef void (*notationDeclSAXFunc)(void *ctx,
335 const xmlChar *name,
336 const xmlChar *publicId,
337 const xmlChar *systemId);
338/**
339 * attributeDeclSAXFunc:
340 * @ctx: the user data (XML parser context)
341 * @elem: the name of the element
342 * @fullname: the attribute name
343 * @type: the attribute type
344 * @def: the type of default value
345 * @defaultValue: the attribute default value
346 * @tree: the tree of enumerated value set
347 *
348 * An attribute definition has been parsed
349 */
350typedef void (*attributeDeclSAXFunc)(void *ctx,
351 const xmlChar *elem,
352 const xmlChar *fullname,
353 int type,
354 int def,
355 const xmlChar *defaultValue,
356 xmlEnumerationPtr tree);
357/**
358 * elementDeclSAXFunc:
359 * @ctx: the user data (XML parser context)
360 * @name: the element name
361 * @type: the element type
362 * @content: the element value tree
363 *
364 * An element definition has been parsed
365 */
366typedef void (*elementDeclSAXFunc)(void *ctx,
367 const xmlChar *name,
368 int type,
369 xmlElementContentPtr content);
370/**
371 * unparsedEntityDeclSAXFunc:
372 * @ctx: the user data (XML parser context)
373 * @name: The name of the entity
374 * @publicId: The public ID of the entity
375 * @systemId: The system ID of the entity
376 * @notationName: the name of the notation
377 *
378 * What to do when an unparsed entity declaration is parsed
379 */
Owen Taylor3473f882001-02-23 17:55:21 +0000380typedef void (*unparsedEntityDeclSAXFunc)(void *ctx,
Daniel Veillard9d06d302002-01-22 18:15:52 +0000381 const xmlChar *name,
382 const xmlChar *publicId,
383 const xmlChar *systemId,
384 const xmlChar *notationName);
385/**
386 * setDocumentLocatorSAXFunc:
387 * @ctx: the user data (XML parser context)
388 * @loc: A SAX Locator
389 *
390 * Receive the document locator at startup, actually xmlDefaultSAXLocator
391 * Everything is available on the context, so this is useless in our case.
392 */
Owen Taylor3473f882001-02-23 17:55:21 +0000393typedef void (*setDocumentLocatorSAXFunc) (void *ctx,
Daniel Veillard9d06d302002-01-22 18:15:52 +0000394 xmlSAXLocatorPtr loc);
395/**
396 * startDocumentSAXFunc:
397 * @ctx: the user data (XML parser context)
398 *
399 * called when the document start being processed.
400 */
Owen Taylor3473f882001-02-23 17:55:21 +0000401typedef void (*startDocumentSAXFunc) (void *ctx);
Daniel Veillard9d06d302002-01-22 18:15:52 +0000402/**
403 * endDocumentSAXFunc:
404 * @ctx: the user data (XML parser context)
405 *
406 * called when the document end has been detected.
407 */
Owen Taylor3473f882001-02-23 17:55:21 +0000408typedef void (*endDocumentSAXFunc) (void *ctx);
Daniel Veillard9d06d302002-01-22 18:15:52 +0000409/**
410 * startElementSAXFunc:
411 * @ctx: the user data (XML parser context)
412 * @name: The element name, including namespace prefix
413 * @atts: An array of name/value attributes pairs, NULL terminated
414 *
415 * called when an opening tag has been processed.
416 */
417typedef void (*startElementSAXFunc) (void *ctx,
418 const xmlChar *name,
419 const xmlChar **atts);
420/**
421 * endElementSAXFunc:
422 * @ctx: the user data (XML parser context)
423 * @name: The element name
424 *
425 * called when the end of an element has been detected.
426 */
427typedef void (*endElementSAXFunc) (void *ctx,
428 const xmlChar *name);
429/**
430 * attributeSAXFunc:
431 * @ctx: the user data (XML parser context)
432 * @name: The attribute name, including namespace prefix
433 * @value: The attribute value
434 *
435 * Handle an attribute that has been read by the parser.
436 * The default handling is to convert the attribute into an
437 * DOM subtree and past it in a new xmlAttr element added to
438 * the element.
439 */
440typedef void (*attributeSAXFunc) (void *ctx,
441 const xmlChar *name,
442 const xmlChar *value);
443/**
444 * referenceSAXFunc:
445 * @ctx: the user data (XML parser context)
446 * @name: The entity name
447 *
448 * called when an entity reference is detected.
449 */
450typedef void (*referenceSAXFunc) (void *ctx,
451 const xmlChar *name);
452/**
453 * charactersSAXFunc:
454 * @ctx: the user data (XML parser context)
455 * @ch: a xmlChar string
456 * @len: the number of xmlChar
457 *
458 * receiving some chars from the parser.
459 */
460typedef void (*charactersSAXFunc) (void *ctx,
461 const xmlChar *ch,
462 int len);
463/**
464 * ignorableWhitespaceSAXFunc:
465 * @ctx: the user data (XML parser context)
466 * @ch: a xmlChar string
467 * @len: the number of xmlChar
468 *
469 * receiving some ignorable whitespaces from the parser.
470 * UNUSED: by default the DOM building will use characters
471 */
Owen Taylor3473f882001-02-23 17:55:21 +0000472typedef void (*ignorableWhitespaceSAXFunc) (void *ctx,
Daniel Veillard9d06d302002-01-22 18:15:52 +0000473 const xmlChar *ch,
474 int len);
475/**
476 * processingInstructionSAXFunc:
477 * @ctx: the user data (XML parser context)
478 * @target: the target name
479 * @data: the PI data's
480 *
481 * A processing instruction has been parsed.
482 */
Owen Taylor3473f882001-02-23 17:55:21 +0000483typedef void (*processingInstructionSAXFunc) (void *ctx,
Daniel Veillard9d06d302002-01-22 18:15:52 +0000484 const xmlChar *target,
485 const xmlChar *data);
486/**
487 * commentSAXFunc:
488 * @ctx: the user data (XML parser context)
489 * @value: the comment content
490 *
491 * A comment has been parsed.
492 */
493typedef void (*commentSAXFunc) (void *ctx,
494 const xmlChar *value);
495/**
496 * cdataBlockSAXFunc:
497 * @ctx: the user data (XML parser context)
498 * @value: The pcdata content
499 * @len: the block length
500 *
501 * called when a pcdata block has been parsed
502 */
503typedef void (*cdataBlockSAXFunc) (
504 void *ctx,
505 const xmlChar *value,
506 int len);
507/**
508 * warningSAXFunc:
509 * @ctx: an XML parser context
510 * @msg: the message to display/transmit
511 * @...: extra parameters for the message display
512 *
513 * Display and format a warning messages, callback
514 */
515typedef void (*warningSAXFunc) (void *ctx,
516 const char *msg, ...);
517/**
518 * errorSAXFunc:
519 * @ctx: an XML parser context
520 * @msg: the message to display/transmit
521 * @...: extra parameters for the message display
522 *
523 * Display and format an error messages, callback
524 */
525typedef void (*errorSAXFunc) (void *ctx,
526 const char *msg, ...);
527/**
528 * fatalErrorSAXFunc:
529 * @ctx: an XML parser context
530 * @msg: the message to display/transmit
531 * @...: extra parameters for the message display
532 *
533 * Display and format fatal error messages, callback
534 */
535typedef void (*fatalErrorSAXFunc) (void *ctx,
536 const char *msg, ...);
537/**
538 * isStandaloneSAXFunc:
539 * @ctx: the user data (XML parser context)
540 *
541 * Is this document tagged standalone ?
542 *
543 * Returns 1 if true
544 */
Owen Taylor3473f882001-02-23 17:55:21 +0000545typedef int (*isStandaloneSAXFunc) (void *ctx);
Daniel Veillard9d06d302002-01-22 18:15:52 +0000546/**
547 * hasInternalSubsetSAXFunc:
548 * @ctx: the user data (XML parser context)
549 *
550 * Does this document has an internal subset
551 *
552 * Returns 1 if true
553 */
Owen Taylor3473f882001-02-23 17:55:21 +0000554typedef int (*hasInternalSubsetSAXFunc) (void *ctx);
Daniel Veillard9d06d302002-01-22 18:15:52 +0000555/**
556 * hasExternalSubsetSAXFunc:
557 * @ctx: the user data (XML parser context)
558 *
559 * Does this document has an external subset
560 *
561 * Returns 1 if true
562 */
Owen Taylor3473f882001-02-23 17:55:21 +0000563typedef int (*hasExternalSubsetSAXFunc) (void *ctx);
564
Owen Taylor3473f882001-02-23 17:55:21 +0000565struct _xmlSAXHandler {
566 internalSubsetSAXFunc internalSubset;
567 isStandaloneSAXFunc isStandalone;
568 hasInternalSubsetSAXFunc hasInternalSubset;
569 hasExternalSubsetSAXFunc hasExternalSubset;
570 resolveEntitySAXFunc resolveEntity;
571 getEntitySAXFunc getEntity;
572 entityDeclSAXFunc entityDecl;
573 notationDeclSAXFunc notationDecl;
574 attributeDeclSAXFunc attributeDecl;
575 elementDeclSAXFunc elementDecl;
576 unparsedEntityDeclSAXFunc unparsedEntityDecl;
577 setDocumentLocatorSAXFunc setDocumentLocator;
578 startDocumentSAXFunc startDocument;
579 endDocumentSAXFunc endDocument;
580 startElementSAXFunc startElement;
581 endElementSAXFunc endElement;
582 referenceSAXFunc reference;
583 charactersSAXFunc characters;
584 ignorableWhitespaceSAXFunc ignorableWhitespace;
585 processingInstructionSAXFunc processingInstruction;
586 commentSAXFunc comment;
587 warningSAXFunc warning;
588 errorSAXFunc error;
589 fatalErrorSAXFunc fatalError;
590 getParameterEntitySAXFunc getParameterEntity;
591 cdataBlockSAXFunc cdataBlock;
592 externalSubsetSAXFunc externalSubset;
Daniel Veillardd0463562001-10-13 09:15:48 +0000593 int initialized;
Owen Taylor3473f882001-02-23 17:55:21 +0000594};
595
596/**
Daniel Veillardf69bb4b2001-05-19 13:24:56 +0000597 * xmlExternalEntityLoader:
598 * @URL: The System ID of the resource requested
599 * @ID: The Public ID of the resource requested
Daniel Veillardcbaf3992001-12-31 16:16:02 +0000600 * @context: the XML parser context
Daniel Veillardf69bb4b2001-05-19 13:24:56 +0000601 *
Owen Taylor3473f882001-02-23 17:55:21 +0000602 * External entity loaders types
Daniel Veillardcbaf3992001-12-31 16:16:02 +0000603 *
604 * Returns the entity input parser
Owen Taylor3473f882001-02-23 17:55:21 +0000605 */
Daniel Veillard9d06d302002-01-22 18:15:52 +0000606typedef xmlParserInputPtr (*xmlExternalEntityLoader) (const char *URL,
607 const char *ID,
608 xmlParserCtxtPtr context);
Owen Taylor3473f882001-02-23 17:55:21 +0000609
Daniel Veillardf69bb4b2001-05-19 13:24:56 +0000610/*
Owen Taylor3473f882001-02-23 17:55:21 +0000611 * Global variables: just the default SAX interface tables and XML
612 * version infos.
613 */
Daniel Veillard0ba59232002-02-10 13:20:39 +0000614#if 0
Owen Taylor3473f882001-02-23 17:55:21 +0000615LIBXML_DLL_IMPORT extern const char *xmlParserVersion;
Daniel Veillard0ba59232002-02-10 13:20:39 +0000616#endif
Owen Taylor3473f882001-02-23 17:55:21 +0000617
Daniel Veillard0ba59232002-02-10 13:20:39 +0000618/*
Owen Taylor3473f882001-02-23 17:55:21 +0000619LIBXML_DLL_IMPORT extern xmlSAXLocator xmlDefaultSAXLocator;
620LIBXML_DLL_IMPORT extern xmlSAXHandler xmlDefaultSAXHandler;
621LIBXML_DLL_IMPORT extern xmlSAXHandler htmlDefaultSAXHandler;
Daniel Veillardeae522a2001-04-23 13:41:34 +0000622LIBXML_DLL_IMPORT extern xmlSAXHandler docbDefaultSAXHandler;
Daniel Veillard0ba59232002-02-10 13:20:39 +0000623 */
Owen Taylor3473f882001-02-23 17:55:21 +0000624
Daniel Veillardf69bb4b2001-05-19 13:24:56 +0000625/*
Daniel Veillardcbaf3992001-12-31 16:16:02 +0000626 * entity substitution default behavior.
Owen Taylor3473f882001-02-23 17:55:21 +0000627 */
628
629#ifdef VMS
Daniel Veillard5e2dace2001-07-18 19:30:27 +0000630/**
631 * xmlSubstituteEntitiesDefaultValue:
632 *
Daniel Veillardcbaf3992001-12-31 16:16:02 +0000633 * global variable controlling the entity substitution default behavior
Daniel Veillard5e2dace2001-07-18 19:30:27 +0000634 */
Owen Taylor3473f882001-02-23 17:55:21 +0000635LIBXML_DLL_IMPORT extern int xmlSubstituteEntitiesDefaultVal;
636#define xmlSubstituteEntitiesDefaultValue xmlSubstituteEntitiesDefaultVal
Owen Taylor3473f882001-02-23 17:55:21 +0000637#endif
Daniel Veillard0ba59232002-02-10 13:20:39 +0000638#if 0
639LIBXML_DLL_IMPORT extern int xmlSubstituteEntitiesDefaultValue;
Owen Taylor3473f882001-02-23 17:55:21 +0000640LIBXML_DLL_IMPORT extern int xmlGetWarningsDefaultValue;
Daniel Veillard0ba59232002-02-10 13:20:39 +0000641#endif
Owen Taylor3473f882001-02-23 17:55:21 +0000642
Daniel Veillard6c4ffaf2002-02-11 08:54:05 +0000643#ifdef __cplusplus
644}
645#endif
646#include <libxml/encoding.h>
647#include <libxml/xmlIO.h>
648#include <libxml/globals.h>
649#ifdef __cplusplus
650extern "C" {
651#endif
652
Owen Taylor3473f882001-02-23 17:55:21 +0000653
Daniel Veillardf69bb4b2001-05-19 13:24:56 +0000654/*
Owen Taylor3473f882001-02-23 17:55:21 +0000655 * Init/Cleanup
656 */
657void xmlInitParser (void);
658void xmlCleanupParser (void);
659
Daniel Veillardf69bb4b2001-05-19 13:24:56 +0000660/*
Owen Taylor3473f882001-02-23 17:55:21 +0000661 * Input functions
662 */
663int xmlParserInputRead (xmlParserInputPtr in,
664 int len);
665int xmlParserInputGrow (xmlParserInputPtr in,
666 int len);
667
Daniel Veillardf69bb4b2001-05-19 13:24:56 +0000668/*
Owen Taylor3473f882001-02-23 17:55:21 +0000669 * xmlChar handling
670 */
671xmlChar * xmlStrdup (const xmlChar *cur);
672xmlChar * xmlStrndup (const xmlChar *cur,
673 int len);
Daniel Veillard56a4cb82001-03-24 17:00:36 +0000674xmlChar * xmlCharStrndup (const char *cur,
675 int len);
676xmlChar * xmlCharStrdup (const char *cur);
Owen Taylor3473f882001-02-23 17:55:21 +0000677xmlChar * xmlStrsub (const xmlChar *str,
678 int start,
679 int len);
680const xmlChar * xmlStrchr (const xmlChar *str,
681 xmlChar val);
682const xmlChar * xmlStrstr (const xmlChar *str,
Daniel Veillard77044732001-06-29 21:31:07 +0000683 const xmlChar *val);
Owen Taylor3473f882001-02-23 17:55:21 +0000684const xmlChar * xmlStrcasestr (const xmlChar *str,
685 xmlChar *val);
686int xmlStrcmp (const xmlChar *str1,
687 const xmlChar *str2);
688int xmlStrncmp (const xmlChar *str1,
689 const xmlChar *str2,
690 int len);
691int xmlStrcasecmp (const xmlChar *str1,
692 const xmlChar *str2);
693int xmlStrncasecmp (const xmlChar *str1,
694 const xmlChar *str2,
695 int len);
696int xmlStrEqual (const xmlChar *str1,
697 const xmlChar *str2);
698int xmlStrlen (const xmlChar *str);
699xmlChar * xmlStrcat (xmlChar *cur,
700 const xmlChar *add);
701xmlChar * xmlStrncat (xmlChar *cur,
702 const xmlChar *add,
703 int len);
704
Daniel Veillardf69bb4b2001-05-19 13:24:56 +0000705/*
Owen Taylor3473f882001-02-23 17:55:21 +0000706 * Basic parsing Interfaces
707 */
708xmlDocPtr xmlParseDoc (xmlChar *cur);
Daniel Veillard50822cb2001-07-26 20:05:51 +0000709xmlDocPtr xmlParseMemory (const char *buffer,
Owen Taylor3473f882001-02-23 17:55:21 +0000710 int size);
711xmlDocPtr xmlParseFile (const char *filename);
712int xmlSubstituteEntitiesDefault(int val);
713int xmlKeepBlanksDefault (int val);
714void xmlStopParser (xmlParserCtxtPtr ctxt);
715int xmlPedanticParserDefault(int val);
Daniel Veillardd9bad132001-07-23 19:39:43 +0000716int xmlLineNumbersDefault (int val);
Owen Taylor3473f882001-02-23 17:55:21 +0000717
Daniel Veillardf69bb4b2001-05-19 13:24:56 +0000718/*
Owen Taylor3473f882001-02-23 17:55:21 +0000719 * Recovery mode
720 */
721xmlDocPtr xmlRecoverDoc (xmlChar *cur);
Daniel Veillard50822cb2001-07-26 20:05:51 +0000722xmlDocPtr xmlRecoverMemory (const char *buffer,
Owen Taylor3473f882001-02-23 17:55:21 +0000723 int size);
724xmlDocPtr xmlRecoverFile (const char *filename);
725
Daniel Veillardf69bb4b2001-05-19 13:24:56 +0000726/*
Owen Taylor3473f882001-02-23 17:55:21 +0000727 * Less common routines and SAX interfaces
728 */
729int xmlParseDocument (xmlParserCtxtPtr ctxt);
730int xmlParseExtParsedEnt (xmlParserCtxtPtr ctxt);
731xmlDocPtr xmlSAXParseDoc (xmlSAXHandlerPtr sax,
732 xmlChar *cur,
733 int recovery);
734int xmlSAXUserParseFile (xmlSAXHandlerPtr sax,
735 void *user_data,
736 const char *filename);
737int xmlSAXUserParseMemory (xmlSAXHandlerPtr sax,
738 void *user_data,
Daniel Veillardfd7ddca2001-05-16 10:57:35 +0000739 const char *buffer,
Owen Taylor3473f882001-02-23 17:55:21 +0000740 int size);
741xmlDocPtr xmlSAXParseMemory (xmlSAXHandlerPtr sax,
Daniel Veillard50822cb2001-07-26 20:05:51 +0000742 const char *buffer,
Owen Taylor3473f882001-02-23 17:55:21 +0000743 int size,
744 int recovery);
745xmlDocPtr xmlSAXParseFile (xmlSAXHandlerPtr sax,
746 const char *filename,
747 int recovery);
Daniel Veillarda293c322001-10-02 13:54:14 +0000748xmlDocPtr xmlSAXParseFileWithData (xmlSAXHandlerPtr sax,
749 const char *filename,
750 int recovery,
751 void *data);
Owen Taylor3473f882001-02-23 17:55:21 +0000752xmlDocPtr xmlSAXParseEntity (xmlSAXHandlerPtr sax,
753 const char *filename);
754xmlDocPtr xmlParseEntity (const char *filename);
755xmlDtdPtr xmlParseDTD (const xmlChar *ExternalID,
756 const xmlChar *SystemID);
757xmlDtdPtr xmlSAXParseDTD (xmlSAXHandlerPtr sax,
758 const xmlChar *ExternalID,
759 const xmlChar *SystemID);
760xmlDtdPtr xmlIOParseDTD (xmlSAXHandlerPtr sax,
761 xmlParserInputBufferPtr input,
762 xmlCharEncoding enc);
763int xmlParseBalancedChunkMemory(xmlDocPtr doc,
764 xmlSAXHandlerPtr sax,
765 void *user_data,
766 int depth,
767 const xmlChar *string,
Daniel Veillardcda96922001-08-21 10:56:31 +0000768 xmlNodePtr *lst);
Owen Taylor3473f882001-02-23 17:55:21 +0000769int xmlParseExternalEntity (xmlDocPtr doc,
770 xmlSAXHandlerPtr sax,
771 void *user_data,
772 int depth,
773 const xmlChar *URL,
774 const xmlChar *ID,
Daniel Veillardcda96922001-08-21 10:56:31 +0000775 xmlNodePtr *lst);
Owen Taylor3473f882001-02-23 17:55:21 +0000776int xmlParseCtxtExternalEntity(xmlParserCtxtPtr ctx,
777 const xmlChar *URL,
778 const xmlChar *ID,
Daniel Veillardcda96922001-08-21 10:56:31 +0000779 xmlNodePtr *lst);
Owen Taylor3473f882001-02-23 17:55:21 +0000780
Daniel Veillardf69bb4b2001-05-19 13:24:56 +0000781/*
Owen Taylor3473f882001-02-23 17:55:21 +0000782 * Parser contexts handling.
783 */
784void xmlInitParserCtxt (xmlParserCtxtPtr ctxt);
785void xmlClearParserCtxt (xmlParserCtxtPtr ctxt);
786void xmlFreeParserCtxt (xmlParserCtxtPtr ctxt);
787void xmlSetupParserForBuffer (xmlParserCtxtPtr ctxt,
788 const xmlChar* buffer,
Daniel Veillard963d2ae2002-01-20 22:08:18 +0000789 const char *filename);
Owen Taylor3473f882001-02-23 17:55:21 +0000790xmlParserCtxtPtr xmlCreateDocParserCtxt (xmlChar *cur);
791
Daniel Veillardf69bb4b2001-05-19 13:24:56 +0000792/*
Owen Taylor3473f882001-02-23 17:55:21 +0000793 * Reading/setting optional parsing features.
794 */
795
796int xmlGetFeaturesList (int *len,
797 const char **result);
798int xmlGetFeature (xmlParserCtxtPtr ctxt,
799 const char *name,
800 void *result);
801int xmlSetFeature (xmlParserCtxtPtr ctxt,
802 const char *name,
803 void *value);
804
Daniel Veillardf69bb4b2001-05-19 13:24:56 +0000805/*
Owen Taylor3473f882001-02-23 17:55:21 +0000806 * Interfaces for the Push mode
807 */
808xmlParserCtxtPtr xmlCreatePushParserCtxt(xmlSAXHandlerPtr sax,
809 void *user_data,
810 const char *chunk,
811 int size,
812 const char *filename);
813int xmlParseChunk (xmlParserCtxtPtr ctxt,
814 const char *chunk,
815 int size,
816 int terminate);
817
Daniel Veillardf69bb4b2001-05-19 13:24:56 +0000818/*
Owen Taylor3473f882001-02-23 17:55:21 +0000819 * Special I/O mode
820 */
821
822xmlParserCtxtPtr xmlCreateIOParserCtxt (xmlSAXHandlerPtr sax,
823 void *user_data,
824 xmlInputReadCallback ioread,
825 xmlInputCloseCallback ioclose,
826 void *ioctx,
827 xmlCharEncoding enc);
828
829xmlParserInputPtr xmlNewIOInputStream (xmlParserCtxtPtr ctxt,
830 xmlParserInputBufferPtr input,
831 xmlCharEncoding enc);
832
Daniel Veillardf69bb4b2001-05-19 13:24:56 +0000833/*
Owen Taylor3473f882001-02-23 17:55:21 +0000834 * Node infos
835 */
836const xmlParserNodeInfo*
Daniel Veillard963d2ae2002-01-20 22:08:18 +0000837 xmlParserFindNodeInfo (const xmlParserCtxtPtr ctxt,
838 const xmlNodePtr node);
Owen Taylor3473f882001-02-23 17:55:21 +0000839void xmlInitNodeInfoSeq (xmlParserNodeInfoSeqPtr seq);
840void xmlClearNodeInfoSeq (xmlParserNodeInfoSeqPtr seq);
Daniel Veillard963d2ae2002-01-20 22:08:18 +0000841unsigned long xmlParserFindNodeInfoIndex(const xmlParserNodeInfoSeqPtr seq,
842 const xmlNodePtr node);
Owen Taylor3473f882001-02-23 17:55:21 +0000843void xmlParserAddNodeInfo (xmlParserCtxtPtr ctxt,
Daniel Veillard963d2ae2002-01-20 22:08:18 +0000844 const xmlParserNodeInfoPtr info);
Owen Taylor3473f882001-02-23 17:55:21 +0000845
846/*
847 * External entities handling actually implemented in xmlIO
848 */
849
850void xmlSetExternalEntityLoader(xmlExternalEntityLoader f);
851xmlExternalEntityLoader
852 xmlGetExternalEntityLoader(void);
853xmlParserInputPtr
854 xmlLoadExternalEntity (const char *URL,
855 const char *ID,
Daniel Veillard9d06d302002-01-22 18:15:52 +0000856 xmlParserCtxtPtr ctxt);
Owen Taylor3473f882001-02-23 17:55:21 +0000857
858#ifdef __cplusplus
859}
860#endif
Owen Taylor3473f882001-02-23 17:55:21 +0000861#endif /* __XML_PARSER_H__ */
862