Initial revision
[TestXSLT.git] / libxml2 / include / libxml / parser.h
1 /*
2  * parser.h : Interfaces, constants and types related to the XML parser.
3  *
4  * See Copyright for the status of this software.
5  *
6  * daniel@veillard.com
7  */
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/entities.h>
15
16 #ifdef __cplusplus
17 extern "C" {
18 #endif
19
20 /**
21  * XML_DEFAULT_VERSION:
22  *
23  * The default version of XML used: 1.0
24  */
25 #define XML_DEFAULT_VERSION     "1.0"
26
27 /**
28  * xmlParserInput:
29  *
30  * 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
38 /**
39  * xmlParserInputDeallocate:
40  * @str:  the string to deallocate
41  *
42  * Callback for freeing some parser input allocations.
43  */
44 typedef void (* xmlParserInputDeallocate)(xmlChar *str);
45
46 struct _xmlParserInput {
47     /* Input buffer */
48     xmlParserInputBufferPtr buf;      /* UTF-8 encoded buffer */
49
50     const char *filename;             /* The file analyzed, if any */
51     const char *directory;            /* the directory/base of the file */
52     const xmlChar *base;              /* Base of the array to parse */
53     const xmlChar *cur;               /* Current char being parsed */
54     const xmlChar *end;               /* end of the array to parse */
55     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 /**
66  * xmlParserNodeInfo:
67  *
68  * 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  */
72 typedef struct _xmlParserNodeInfo xmlParserNodeInfo;
73 typedef xmlParserNodeInfo *xmlParserNodeInfoPtr;
74
75 struct _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
84 typedef struct _xmlParserNodeInfoSeq xmlParserNodeInfoSeq;
85 typedef xmlParserNodeInfoSeq *xmlParserNodeInfoSeqPtr;
86 struct _xmlParserNodeInfoSeq {
87   unsigned long maximum;
88   unsigned long length;
89   xmlParserNodeInfo* buffer;
90 };
91
92 /**
93  * xmlParserInputState:
94  *
95  * The parser is now working also as a state based parser.
96  * The recursive one use the state info for entities processing.
97  */
98 typedef 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 */
102     XML_PARSER_PI,              /* Within a processing instruction */
103     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     XML_PARSER_PUBLIC_LITERAL   /* within a PUBLIC value */
117 } xmlParserInputState;
118
119 /**
120  * XML_DETECT_IDS:
121  *
122  * Bit in the loadsubset context field to tell to do ID/REFs lookups.
123  * Use it to initialize xmlLoadExtDtdDefaultValue.
124  */
125 #define XML_DETECT_IDS          2
126
127 /**
128  * XML_COMPLETE_ATTRS:
129  *
130  * Bit in the loadsubset context field to tell to do complete the
131  * elements attributes lists with the ones defaulted from the DTDs.
132  * Use it to initialize xmlLoadExtDtdDefaultValue.
133  */
134 #define XML_COMPLETE_ATTRS      4
135
136 /**
137  * xmlParserCtxt:
138  *
139  * The parser context.
140  * NOTE This doesn't completely define the parser state, the (current ?)
141  *      design of the parser uses recursive function calls since this allow
142  *      and easy mapping from the production rules of the specification
143  *      to the actual code. The drawback is that the actual function call
144  *      also reflect the parser state. However most of the parsing routines
145  *      takes as the only argument the parser context pointer, so migrating
146  *      to a state based parser for progressive parsing shouldn't be too hard.
147  */
148 struct _xmlParserCtxt {
149     struct _xmlSAXHandler *sax;       /* The SAX handler */
150     void            *userData;        /* For SAX interface only, used by DOM build */
151     xmlDocPtr           myDoc;        /* the document being built */
152     int            wellFormed;        /* is the document well formed */
153     int       replaceEntities;        /* shall we replace entities ? */
154     const xmlChar    *version;        /* the XML version string */
155     const xmlChar   *encoding;        /* the declared encoding, if any */
156     int            standalone;        /* standalone document */
157     int                  html;        /* an HTML(1)/Docbook(2) document */
158
159     /* Input stream stack */
160     xmlParserInputPtr  input;         /* Current input stream */
161     int                inputNr;       /* Number of current input streams */
162     int                inputMax;      /* Max number of input streams */
163     xmlParserInputPtr *inputTab;      /* stack of inputs */
164
165     /* Node analysis stack only used for DOM building */
166     xmlNodePtr         node;          /* Current parsed Node */
167     int                nodeNr;        /* Depth of the parsing stack */
168     int                nodeMax;       /* Max depth of the parsing stack */
169     xmlNodePtr        *nodeTab;       /* array of nodes */
170
171     int record_info;                  /* Whether node info should be kept */
172     xmlParserNodeInfoSeq node_seq;    /* info about each node parsed */
173
174     int errNo;                        /* error code */
175
176     int     hasExternalSubset;        /* reference and external subset */
177     int             hasPErefs;        /* the internal subset has PE refs */
178     int              external;        /* are we parsing an external entity */
179
180     int                 valid;        /* is the document valid */
181     int              validate;        /* shall we try to validate ? */
182     xmlValidCtxt        vctxt;        /* The validity context */
183
184     xmlParserInputState instate;      /* current type of input */
185     int                 token;        /* next char look-ahead */    
186
187     char           *directory;        /* the data directory */
188
189     /* Node name stack */
190     xmlChar           *name;          /* Current parsed Node */
191     int                nameNr;        /* Depth of the parsing stack */
192     int                nameMax;       /* Max depth of the parsing stack */
193     xmlChar *         *nameTab;       /* array of nodes */
194
195     long               nbChars;       /* number of xmlChar processed */
196     long            checkIndex;       /* used by progressive parsing lookup */
197     int             keepBlanks;       /* ugly but ... */
198     int             disableSAX;       /* SAX callbacks are disabled */
199     int               inSubset;       /* Parsing is in int 1/ext 2 subset */
200     xmlChar *          intSubName;    /* name of subset */
201     xmlChar *          extSubURI;     /* URI of external subset */
202     xmlChar *          extSubSystem;  /* SYSTEM ID of external subset */
203
204     /* xml:space values */
205     int *              space;         /* Should the parser preserve spaces */
206     int                spaceNr;       /* Depth of the parsing stack */
207     int                spaceMax;      /* Max depth of the parsing stack */
208     int *              spaceTab;      /* array of space infos */
209
210     int                depth;         /* to prevent entity substitution loops */
211     xmlParserInputPtr  entity;        /* used to check entities boundaries */
212     int                charset;       /* encoding of the in-memory content
213                                          actually an xmlCharEncoding */
214     int                nodelen;       /* Those two fields are there to */
215     int                nodemem;       /* Speed up large node parsing */
216     int                pedantic;      /* signal pedantic warnings */
217     void              *_private;      /* For user data, libxml won't touch it */
218
219     int                loadsubset;    /* should the external subset be loaded */
220     int                linenumbers;   /* set line number in element content */
221     void              *catalogs;       /* document's own catalog */
222     int                recovery;      /* run in recovery mode */
223 };
224
225 /**
226  * xmlSAXLocator:
227  *
228  * A SAX Locator.
229  */
230 struct _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 /**
238  * xmlSAXHandler:
239  *
240  * A SAX handler is bunch of callbacks called by the parser when processing
241  * of the input generate data or structure informations.
242  */
243
244 /**
245  * resolveEntitySAXFunc:
246  * @ctx:  the user data (XML parser context)
247  * @publicId: The public ID of the entity
248  * @systemId: The system ID of the entity
249  *
250  * Callback:
251  * The entity loader, to control the loading of external entities,
252  * the application can either:
253  *    - override this resolveEntity() callback in the SAX block
254  *    - or better use the xmlSetExternalEntityLoader() function to
255  *      set up it's own entity resolution routine
256  *
257  * Returns the xmlParserInputPtr if inlined or NULL for DOM behaviour.
258  */
259 typedef xmlParserInputPtr (*resolveEntitySAXFunc) (void *ctx,
260                                 const xmlChar *publicId,
261                                 const xmlChar *systemId);
262 /**
263  * internalSubsetSAXFunc:
264  * @ctx:  the user data (XML parser context)
265  * @name:  the root element name
266  * @ExternalID:  the external ID
267  * @SystemID:  the SYSTEM ID (e.g. filename or URL)
268  *
269  * Callback on internal subset declaration.
270  */
271 typedef void (*internalSubsetSAXFunc) (void *ctx,
272                                 const xmlChar *name,
273                                 const xmlChar *ExternalID,
274                                 const xmlChar *SystemID);
275 /**
276  * externalSubsetSAXFunc:
277  * @ctx:  the user data (XML parser context)
278  * @name:  the root element name
279  * @ExternalID:  the external ID
280  * @SystemID:  the SYSTEM ID (e.g. filename or URL)
281  *
282  * Callback on external subset declaration.
283  */
284 typedef void (*externalSubsetSAXFunc) (void *ctx,
285                                 const xmlChar *name,
286                                 const xmlChar *ExternalID,
287                                 const xmlChar *SystemID);
288 /**
289  * getEntitySAXFunc:
290  * @ctx:  the user data (XML parser context)
291  * @name: The entity name
292  *
293  * Get an entity by name.
294  *
295  * Returns the xmlEntityPtr if found.
296  */
297 typedef xmlEntityPtr (*getEntitySAXFunc) (void *ctx,
298                                 const xmlChar *name);
299 /**
300  * getParameterEntitySAXFunc:
301  * @ctx:  the user data (XML parser context)
302  * @name: The entity name
303  *
304  * Get a parameter entity by name.
305  *
306  * Returns the xmlEntityPtr if found.
307  */
308 typedef xmlEntityPtr (*getParameterEntitySAXFunc) (void *ctx,
309                                 const xmlChar *name);
310 /**
311  * entityDeclSAXFunc:
312  * @ctx:  the user data (XML parser context)
313  * @name:  the entity name 
314  * @type:  the entity type 
315  * @publicId: The public ID of the entity
316  * @systemId: The system ID of the entity
317  * @content: the entity value (without processing).
318  *
319  * An entity definition has been parsed.
320  */
321 typedef void (*entityDeclSAXFunc) (void *ctx,
322                                 const xmlChar *name,
323                                 int type,
324                                 const xmlChar *publicId,
325                                 const xmlChar *systemId,
326                                 xmlChar *content);
327 /**
328  * notationDeclSAXFunc:
329  * @ctx:  the user data (XML parser context)
330  * @name: The name of the notation
331  * @publicId: The public ID of the entity
332  * @systemId: The system ID of the entity
333  *
334  * What to do when a notation declaration has been parsed.
335  */
336 typedef void (*notationDeclSAXFunc)(void *ctx,
337                                 const xmlChar *name,
338                                 const xmlChar *publicId,
339                                 const xmlChar *systemId);
340 /**
341  * attributeDeclSAXFunc:
342  * @ctx:  the user data (XML parser context)
343  * @elem:  the name of the element
344  * @fullname:  the attribute name 
345  * @type:  the attribute type 
346  * @def:  the type of default value
347  * @defaultValue: the attribute default value
348  * @tree:  the tree of enumerated value set
349  *
350  * An attribute definition has been parsed.
351  */
352 typedef void (*attributeDeclSAXFunc)(void *ctx,
353                                 const xmlChar *elem,
354                                 const xmlChar *fullname,
355                                 int type,
356                                 int def,
357                                 const xmlChar *defaultValue,
358                                 xmlEnumerationPtr tree);
359 /**
360  * elementDeclSAXFunc:
361  * @ctx:  the user data (XML parser context)
362  * @name:  the element name 
363  * @type:  the element type 
364  * @content: the element value tree
365  *
366  * An element definition has been parsed.
367  */
368 typedef void (*elementDeclSAXFunc)(void *ctx,
369                                 const xmlChar *name,
370                                 int type,
371                                 xmlElementContentPtr content);
372 /**
373  * unparsedEntityDeclSAXFunc:
374  * @ctx:  the user data (XML parser context)
375  * @name: The name of the entity
376  * @publicId: The public ID of the entity
377  * @systemId: The system ID of the entity
378  * @notationName: the name of the notation
379  *
380  * What to do when an unparsed entity declaration is parsed.
381  */
382 typedef void (*unparsedEntityDeclSAXFunc)(void *ctx,
383                                 const xmlChar *name,
384                                 const xmlChar *publicId,
385                                 const xmlChar *systemId,
386                                 const xmlChar *notationName);
387 /**
388  * setDocumentLocatorSAXFunc:
389  * @ctx:  the user data (XML parser context)
390  * @loc: A SAX Locator
391  *
392  * Receive the document locator at startup, actually xmlDefaultSAXLocator.
393  * Everything is available on the context, so this is useless in our case.
394  */
395 typedef void (*setDocumentLocatorSAXFunc) (void *ctx,
396                                 xmlSAXLocatorPtr loc);
397 /**
398  * startDocumentSAXFunc:
399  * @ctx:  the user data (XML parser context)
400  *
401  * Called when the document start being processed.
402  */
403 typedef void (*startDocumentSAXFunc) (void *ctx);
404 /**
405  * endDocumentSAXFunc:
406  * @ctx:  the user data (XML parser context)
407  *
408  * Called when the document end has been detected.
409  */
410 typedef void (*endDocumentSAXFunc) (void *ctx);
411 /**
412  * startElementSAXFunc:
413  * @ctx:  the user data (XML parser context)
414  * @name:  The element name, including namespace prefix
415  * @atts:  An array of name/value attributes pairs, NULL terminated
416  *
417  * Called when an opening tag has been processed.
418  */
419 typedef void (*startElementSAXFunc) (void *ctx,
420                                 const xmlChar *name,
421                                 const xmlChar **atts);
422 /**
423  * endElementSAXFunc:
424  * @ctx:  the user data (XML parser context)
425  * @name:  The element name
426  *
427  * Called when the end of an element has been detected.
428  */
429 typedef void (*endElementSAXFunc) (void *ctx,
430                                 const xmlChar *name);
431 /**
432  * attributeSAXFunc:
433  * @ctx:  the user data (XML parser context)
434  * @name:  The attribute name, including namespace prefix
435  * @value:  The attribute value
436  *
437  * Handle an attribute that has been read by the parser.
438  * The default handling is to convert the attribute into an
439  * DOM subtree and past it in a new xmlAttr element added to
440  * the element.
441  */
442 typedef void (*attributeSAXFunc) (void *ctx,
443                                 const xmlChar *name,
444                                 const xmlChar *value);
445 /**
446  * referenceSAXFunc:
447  * @ctx:  the user data (XML parser context)
448  * @name:  The entity name
449  *
450  * Called when an entity reference is detected. 
451  */
452 typedef void (*referenceSAXFunc) (void *ctx,
453                                 const xmlChar *name);
454 /**
455  * charactersSAXFunc:
456  * @ctx:  the user data (XML parser context)
457  * @ch:  a xmlChar string
458  * @len: the number of xmlChar
459  *
460  * Receiving some chars from the parser.
461  */
462 typedef void (*charactersSAXFunc) (void *ctx,
463                                 const xmlChar *ch,
464                                 int len);
465 /**
466  * ignorableWhitespaceSAXFunc:
467  * @ctx:  the user data (XML parser context)
468  * @ch:  a xmlChar string
469  * @len: the number of xmlChar
470  *
471  * Receiving some ignorable whitespaces from the parser.
472  * UNUSED: by default the DOM building will use characters.
473  */
474 typedef void (*ignorableWhitespaceSAXFunc) (void *ctx,
475                                 const xmlChar *ch,
476                                 int len);
477 /**
478  * processingInstructionSAXFunc:
479  * @ctx:  the user data (XML parser context)
480  * @target:  the target name
481  * @data: the PI data's
482  *
483  * A processing instruction has been parsed.
484  */
485 typedef void (*processingInstructionSAXFunc) (void *ctx,
486                                 const xmlChar *target,
487                                 const xmlChar *data);
488 /**
489  * commentSAXFunc:
490  * @ctx:  the user data (XML parser context)
491  * @value:  the comment content
492  *
493  * A comment has been parsed.
494  */
495 typedef void (*commentSAXFunc) (void *ctx,
496                                 const xmlChar *value);
497 /**
498  * cdataBlockSAXFunc:
499  * @ctx:  the user data (XML parser context)
500  * @value:  The pcdata content
501  * @len:  the block length
502  *
503  * Called when a pcdata block has been parsed.
504  */
505 typedef void (*cdataBlockSAXFunc) (
506                                 void *ctx,
507                                 const xmlChar *value,
508                                 int len);
509 /**
510  * warningSAXFunc:
511  * @ctx:  an XML parser context
512  * @msg:  the message to display/transmit
513  * @...:  extra parameters for the message display
514  * 
515  * Display and format a warning messages, callback.
516  */
517 typedef void (*warningSAXFunc) (void *ctx,
518                                 const char *msg, ...);
519 /**
520  * errorSAXFunc:
521  * @ctx:  an XML parser context
522  * @msg:  the message to display/transmit
523  * @...:  extra parameters for the message display
524  * 
525  * Display and format an error messages, callback.
526  */
527 typedef void (*errorSAXFunc) (void *ctx,
528                                 const char *msg, ...);
529 /**
530  * fatalErrorSAXFunc:
531  * @ctx:  an XML parser context
532  * @msg:  the message to display/transmit
533  * @...:  extra parameters for the message display
534  * 
535  * Display and format fatal error messages, callback.
536  * Note: so far fatalError() SAX callbacks are not used, error()
537  *       get all the callbacks for errors.
538  */
539 typedef 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  */
549 typedef int (*isStandaloneSAXFunc) (void *ctx);
550 /**
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  */
558 typedef int (*hasInternalSubsetSAXFunc) (void *ctx);
559 /**
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  */
567 typedef int (*hasExternalSubsetSAXFunc) (void *ctx);
568
569 struct _xmlSAXHandler {
570     internalSubsetSAXFunc internalSubset;
571     isStandaloneSAXFunc isStandalone;
572     hasInternalSubsetSAXFunc hasInternalSubset;
573     hasExternalSubsetSAXFunc hasExternalSubset;
574     resolveEntitySAXFunc resolveEntity;
575     getEntitySAXFunc getEntity;
576     entityDeclSAXFunc entityDecl;
577     notationDeclSAXFunc notationDecl;
578     attributeDeclSAXFunc attributeDecl;
579     elementDeclSAXFunc elementDecl;
580     unparsedEntityDeclSAXFunc unparsedEntityDecl;
581     setDocumentLocatorSAXFunc setDocumentLocator;
582     startDocumentSAXFunc startDocument;
583     endDocumentSAXFunc endDocument;
584     startElementSAXFunc startElement;
585     endElementSAXFunc endElement;
586     referenceSAXFunc reference;
587     charactersSAXFunc characters;
588     ignorableWhitespaceSAXFunc ignorableWhitespace;
589     processingInstructionSAXFunc processingInstruction;
590     commentSAXFunc comment;
591     warningSAXFunc warning;
592     errorSAXFunc error;
593     fatalErrorSAXFunc fatalError; /* unused error() get all the errors */
594     getParameterEntitySAXFunc getParameterEntity;
595     cdataBlockSAXFunc cdataBlock;
596     externalSubsetSAXFunc externalSubset;
597     int initialized;
598 };
599
600 /**
601  * xmlExternalEntityLoader:
602  * @URL: The System ID of the resource requested
603  * @ID: The Public ID of the resource requested
604  * @context: the XML parser context 
605  *
606  * External entity loaders types.
607  *
608  * Returns the entity input parser.
609  */
610 typedef xmlParserInputPtr (*xmlExternalEntityLoader) (const char *URL,
611                                          const char *ID,
612                                          xmlParserCtxtPtr context);
613
614 /*
615  * Global variables: just the default SAX interface tables and XML
616  * version infos.
617  */
618 #if 0
619 LIBXML_DLL_IMPORT extern const char *xmlParserVersion;
620 #endif
621
622 /*
623 LIBXML_DLL_IMPORT extern xmlSAXLocator xmlDefaultSAXLocator;
624 LIBXML_DLL_IMPORT extern xmlSAXHandler xmlDefaultSAXHandler;
625 LIBXML_DLL_IMPORT extern xmlSAXHandler htmlDefaultSAXHandler;
626 LIBXML_DLL_IMPORT extern xmlSAXHandler docbDefaultSAXHandler;
627  */
628
629 /*
630  * Entity substitution default behavior.
631  */
632
633 #if 0
634 LIBXML_DLL_IMPORT extern int xmlSubstituteEntitiesDefaultValue;
635 LIBXML_DLL_IMPORT extern int xmlGetWarningsDefaultValue;
636 #endif
637
638 #ifdef __cplusplus
639 }
640 #endif
641 #include <libxml/encoding.h>
642 #include <libxml/xmlIO.h>
643 #include <libxml/globals.h>
644 #ifdef __cplusplus
645 extern "C" {
646 #endif
647
648
649 /*
650  * Init/Cleanup
651  */
652 void            xmlInitParser           (void);
653 void            xmlCleanupParser        (void);
654
655 /*
656  * Input functions
657  */
658 int             xmlParserInputRead      (xmlParserInputPtr in,
659                                          int len);
660 int             xmlParserInputGrow      (xmlParserInputPtr in,
661                                          int len);
662
663 /*
664  * xmlChar handling
665  */
666 xmlChar *       xmlStrdup               (const xmlChar *cur);
667 xmlChar *       xmlStrndup              (const xmlChar *cur,
668                                          int len);
669 xmlChar *       xmlCharStrndup          (const char *cur,
670                                          int len);
671 xmlChar *       xmlCharStrdup           (const char *cur);
672 xmlChar *       xmlStrsub               (const xmlChar *str,
673                                          int start,
674                                          int len);
675 const xmlChar * xmlStrchr               (const xmlChar *str,
676                                          xmlChar val);
677 const xmlChar * xmlStrstr               (const xmlChar *str,
678                                          const xmlChar *val);
679 const xmlChar * xmlStrcasestr           (const xmlChar *str,
680                                          xmlChar *val);
681 int             xmlStrcmp               (const xmlChar *str1,
682                                          const xmlChar *str2);
683 int             xmlStrncmp              (const xmlChar *str1,
684                                          const xmlChar *str2,
685                                          int len);
686 int             xmlStrcasecmp           (const xmlChar *str1,
687                                          const xmlChar *str2);
688 int             xmlStrncasecmp          (const xmlChar *str1,
689                                          const xmlChar *str2,
690                                          int len);
691 int             xmlStrEqual             (const xmlChar *str1,
692                                          const xmlChar *str2);
693 int             xmlStrlen               (const xmlChar *str);
694 xmlChar *       xmlStrcat               (xmlChar *cur,
695                                          const xmlChar *add);
696 xmlChar *       xmlStrncat              (xmlChar *cur,
697                                          const xmlChar *add,
698                                          int len);
699
700 /*
701  * Basic parsing Interfaces
702  */
703 xmlDocPtr       xmlParseDoc             (xmlChar *cur);
704 xmlDocPtr       xmlParseMemory          (const char *buffer,
705                                          int size);
706 xmlDocPtr       xmlParseFile            (const char *filename);
707 int             xmlSubstituteEntitiesDefault(int val);
708 int             xmlKeepBlanksDefault    (int val);
709 void            xmlStopParser           (xmlParserCtxtPtr ctxt);
710 int             xmlPedanticParserDefault(int val);
711 int             xmlLineNumbersDefault   (int val);
712
713 /*
714  * Recovery mode 
715  */
716 xmlDocPtr       xmlRecoverDoc           (xmlChar *cur);
717 xmlDocPtr       xmlRecoverMemory        (const char *buffer,
718                                          int size);
719 xmlDocPtr       xmlRecoverFile          (const char *filename);
720
721 /*
722  * Less common routines and SAX interfaces
723  */
724 int             xmlParseDocument        (xmlParserCtxtPtr ctxt);
725 int             xmlParseExtParsedEnt    (xmlParserCtxtPtr ctxt);
726 xmlDocPtr       xmlSAXParseDoc          (xmlSAXHandlerPtr sax,
727                                          xmlChar *cur,
728                                          int recovery);
729 int             xmlSAXUserParseFile     (xmlSAXHandlerPtr sax,
730                                          void *user_data,
731                                          const char *filename);
732 int             xmlSAXUserParseMemory   (xmlSAXHandlerPtr sax,
733                                          void *user_data,
734                                          const char *buffer,
735                                          int size);
736 xmlDocPtr       xmlSAXParseMemory       (xmlSAXHandlerPtr sax,
737                                          const char *buffer,
738                                          int size,
739                                          int recovery);
740 xmlDocPtr       xmlSAXParseMemoryWithData (xmlSAXHandlerPtr sax,
741                                          const char *buffer,
742                                          int size,
743                                          int recovery,
744                                          void *data);
745 xmlDocPtr       xmlSAXParseFile         (xmlSAXHandlerPtr sax,
746                                          const char *filename,
747                                          int recovery);
748 xmlDocPtr       xmlSAXParseFileWithData (xmlSAXHandlerPtr sax,
749                                          const char *filename,
750                                          int recovery,
751                                          void *data);
752 xmlDocPtr       xmlSAXParseEntity       (xmlSAXHandlerPtr sax,
753                                          const char *filename);
754 xmlDocPtr       xmlParseEntity          (const char *filename);
755 xmlDtdPtr       xmlParseDTD             (const xmlChar *ExternalID,
756                                          const xmlChar *SystemID);
757 xmlDtdPtr       xmlSAXParseDTD          (xmlSAXHandlerPtr sax,
758                                          const xmlChar *ExternalID,
759                                          const xmlChar *SystemID);
760 xmlDtdPtr       xmlIOParseDTD           (xmlSAXHandlerPtr sax,
761                                          xmlParserInputBufferPtr input,
762                                          xmlCharEncoding enc);
763 int             xmlParseBalancedChunkMemory(xmlDocPtr doc,
764                                          xmlSAXHandlerPtr sax,
765                                          void *user_data,
766                                          int depth,
767                                          const xmlChar *string,
768                                          xmlNodePtr *lst);
769 int           xmlParseBalancedChunkMemoryRecover(xmlDocPtr doc,
770                      xmlSAXHandlerPtr sax,
771                      void *user_data,
772                      int depth,
773                      const xmlChar *string,
774                      xmlNodePtr *lst,
775                      int recover);
776 int             xmlParseExternalEntity  (xmlDocPtr doc,
777                                          xmlSAXHandlerPtr sax,
778                                          void *user_data,
779                                          int depth,
780                                          const xmlChar *URL,
781                                          const xmlChar *ID,
782                                          xmlNodePtr *lst);
783 int             xmlParseCtxtExternalEntity(xmlParserCtxtPtr ctx,
784                                          const xmlChar *URL,
785                                          const xmlChar *ID,
786                                          xmlNodePtr *lst);
787
788 /*
789  * Parser contexts handling.
790  */
791 void            xmlInitParserCtxt       (xmlParserCtxtPtr ctxt);
792 void            xmlClearParserCtxt      (xmlParserCtxtPtr ctxt);
793 void            xmlFreeParserCtxt       (xmlParserCtxtPtr ctxt);
794 void            xmlSetupParserForBuffer (xmlParserCtxtPtr ctxt,
795                                          const xmlChar* buffer,
796                                          const char *filename);
797 xmlParserCtxtPtr xmlCreateDocParserCtxt (xmlChar *cur);
798
799 /*
800  * Reading/setting optional parsing features.
801  */
802
803 int             xmlGetFeaturesList      (int *len,
804                                          const char **result);
805 int             xmlGetFeature           (xmlParserCtxtPtr ctxt,
806                                          const char *name,
807                                          void *result);
808 int             xmlSetFeature           (xmlParserCtxtPtr ctxt,
809                                          const char *name,
810                                          void *value);
811
812 /*
813  * Interfaces for the Push mode.
814  */
815 xmlParserCtxtPtr xmlCreatePushParserCtxt(xmlSAXHandlerPtr sax,
816                                          void *user_data,
817                                          const char *chunk,
818                                          int size,
819                                          const char *filename);
820 int              xmlParseChunk          (xmlParserCtxtPtr ctxt,
821                                          const char *chunk,
822                                          int size,
823                                          int terminate);
824
825 /*
826  * Special I/O mode.
827  */
828
829 xmlParserCtxtPtr xmlCreateIOParserCtxt  (xmlSAXHandlerPtr sax,
830                                          void *user_data,
831                                          xmlInputReadCallback   ioread,
832                                          xmlInputCloseCallback  ioclose,
833                                          void *ioctx,
834                                          xmlCharEncoding enc);
835
836 xmlParserInputPtr xmlNewIOInputStream   (xmlParserCtxtPtr ctxt,
837                                          xmlParserInputBufferPtr input,
838                                          xmlCharEncoding enc);
839
840 /*
841  * Node infos.
842  */
843 const xmlParserNodeInfo*
844                 xmlParserFindNodeInfo   (const xmlParserCtxtPtr ctxt,
845                                          const xmlNodePtr node);
846 void            xmlInitNodeInfoSeq      (xmlParserNodeInfoSeqPtr seq);
847 void            xmlClearNodeInfoSeq     (xmlParserNodeInfoSeqPtr seq);
848 unsigned long xmlParserFindNodeInfoIndex(const xmlParserNodeInfoSeqPtr seq,
849                                          const xmlNodePtr node);
850 void            xmlParserAddNodeInfo    (xmlParserCtxtPtr ctxt,
851                                          const xmlParserNodeInfoPtr info);
852
853 /*
854  * External entities handling actually implemented in xmlIO.
855  */
856
857 void            xmlSetExternalEntityLoader(xmlExternalEntityLoader f);
858 xmlExternalEntityLoader
859                 xmlGetExternalEntityLoader(void);
860 xmlParserInputPtr
861                 xmlLoadExternalEntity   (const char *URL,
862                                          const char *ID,
863                                          xmlParserCtxtPtr ctxt);
864
865 #ifdef __cplusplus
866 }
867 #endif
868 #endif /* __XML_PARSER_H__ */
869