xref: /aosp_15_r20/external/libxml2/include/libxml/parser.h (revision 7c5688314b92172186c154356a6374bf7684c3ca)
1 /*
2  * Summary: the core parser module
3  * Description: Interfaces, constants and types related to the XML parser
4  *
5  * Copy: See Copyright for the status of this software.
6  *
7  * Author: Daniel Veillard
8  */
9 
10 #ifndef __XML_PARSER_H__
11 #define __XML_PARSER_H__
12 
13 /** DOC_DISABLE */
14 #include <libxml/xmlversion.h>
15 #define XML_TREE_INTERNALS
16 #include <libxml/tree.h>
17 #undef XML_TREE_INTERNALS
18 #include <libxml/dict.h>
19 #include <libxml/hash.h>
20 #include <libxml/valid.h>
21 #include <libxml/entities.h>
22 #include <libxml/xmlerror.h>
23 #include <libxml/xmlstring.h>
24 #include <libxml/xmlmemory.h>
25 #include <libxml/encoding.h>
26 #include <libxml/xmlIO.h>
27 /* for compatibility */
28 #include <libxml/SAX2.h>
29 #include <libxml/threads.h>
30 /** DOC_ENABLE */
31 
32 #ifdef __cplusplus
33 extern "C" {
34 #endif
35 
36 /**
37  * XML_DEFAULT_VERSION:
38  *
39  * The default version of XML used: 1.0
40  */
41 #define XML_DEFAULT_VERSION	"1.0"
42 
43 #define XML_STATUS_NOT_WELL_FORMED          (1 << 0)
44 #define XML_STATUS_NOT_NS_WELL_FORMED       (1 << 1)
45 #define XML_STATUS_DTD_VALIDATION_FAILED    (1 << 2)
46 #define XML_STATUS_CATASTROPHIC_ERROR       (1 << 3)
47 
48 typedef enum {
49     XML_RESOURCE_UNKNOWN = 0,
50     XML_RESOURCE_MAIN_DOCUMENT,
51     XML_RESOURCE_DTD,
52     XML_RESOURCE_GENERAL_ENTITY,
53     XML_RESOURCE_PARAMETER_ENTITY,
54     XML_RESOURCE_XINCLUDE,
55     XML_RESOURCE_XINCLUDE_TEXT
56 } xmlResourceType;
57 
58 /**
59  * xmlParserInput:
60  *
61  * An xmlParserInput is an input flow for the XML processor.
62  * Each entity parsed is associated an xmlParserInput (except the
63  * few predefined ones). This is the case both for internal entities
64  * - in which case the flow is already completely in memory - or
65  * external entities - in which case we use the buf structure for
66  * progressive reading and I18N conversions to the internal UTF-8 format.
67  */
68 
69 /**
70  * xmlParserInputDeallocate:
71  * @str:  the string to deallocate
72  *
73  * Callback for freeing some parser input allocations.
74  */
75 typedef void (* xmlParserInputDeallocate)(xmlChar *str);
76 
77 struct _xmlParserInput {
78     /* Input buffer */
79     xmlParserInputBufferPtr buf;
80     /* The file analyzed, if any */
81     const char *filename;
82     /* unused */
83     const char *directory XML_DEPRECATED_MEMBER;
84     /* Base of the array to parse */
85     const xmlChar *base;
86     /* Current char being parsed */
87     const xmlChar *cur;
88     /* end of the array to parse */
89     const xmlChar *end;
90     /* unused */
91     int length XML_DEPRECATED_MEMBER;
92     /* Current line */
93     int line;
94     /* Current column */
95     int col;
96     /* How many xmlChars already consumed */
97     unsigned long consumed XML_DEPRECATED_MEMBER;
98     /* function to deallocate the base */
99     xmlParserInputDeallocate free XML_DEPRECATED_MEMBER;
100     /* unused */
101     const xmlChar *encoding XML_DEPRECATED_MEMBER;
102     /* the version string for entity */
103     const xmlChar *version XML_DEPRECATED_MEMBER;
104     /* Flags */
105     int flags XML_DEPRECATED_MEMBER;
106     /* an unique identifier for the entity */
107     int id XML_DEPRECATED_MEMBER;
108     /* unused */
109     unsigned long parentConsumed XML_DEPRECATED_MEMBER;
110     /* entity, if any */
111     xmlEntityPtr entity XML_DEPRECATED_MEMBER;
112 };
113 
114 /**
115  * xmlParserNodeInfo:
116  *
117  * The parser can be asked to collect Node information, i.e. at what
118  * place in the file they were detected.
119  * NOTE: This is off by default and not very well tested.
120  */
121 typedef struct _xmlParserNodeInfo xmlParserNodeInfo;
122 typedef xmlParserNodeInfo *xmlParserNodeInfoPtr;
123 
124 struct _xmlParserNodeInfo {
125   const struct _xmlNode* node;
126   /* Position & line # that text that created the node begins & ends on */
127   unsigned long begin_pos;
128   unsigned long begin_line;
129   unsigned long end_pos;
130   unsigned long end_line;
131 };
132 
133 typedef struct _xmlParserNodeInfoSeq xmlParserNodeInfoSeq;
134 typedef xmlParserNodeInfoSeq *xmlParserNodeInfoSeqPtr;
135 struct _xmlParserNodeInfoSeq {
136   unsigned long maximum;
137   unsigned long length;
138   xmlParserNodeInfo* buffer;
139 };
140 
141 /**
142  * xmlParserInputState:
143  *
144  * The parser is now working also as a state based parser.
145  * The recursive one use the state info for entities processing.
146  */
147 typedef enum {
148     XML_PARSER_EOF = -1,	/* nothing is to be parsed */
149     XML_PARSER_START = 0,	/* nothing has been parsed */
150     XML_PARSER_MISC,		/* Misc* before int subset */
151     XML_PARSER_PI,		/* Within a processing instruction */
152     XML_PARSER_DTD,		/* within some DTD content */
153     XML_PARSER_PROLOG,		/* Misc* after internal subset */
154     XML_PARSER_COMMENT,		/* within a comment */
155     XML_PARSER_START_TAG,	/* within a start tag */
156     XML_PARSER_CONTENT,		/* within the content */
157     XML_PARSER_CDATA_SECTION,	/* within a CDATA section */
158     XML_PARSER_END_TAG,		/* within a closing tag */
159     XML_PARSER_ENTITY_DECL,	/* within an entity declaration */
160     XML_PARSER_ENTITY_VALUE,	/* within an entity value in a decl */
161     XML_PARSER_ATTRIBUTE_VALUE,	/* within an attribute value */
162     XML_PARSER_SYSTEM_LITERAL,	/* within a SYSTEM value */
163     XML_PARSER_EPILOG,		/* the Misc* after the last end tag */
164     XML_PARSER_IGNORE,		/* within an IGNORED section */
165     XML_PARSER_PUBLIC_LITERAL,	/* within a PUBLIC value */
166     XML_PARSER_XML_DECL         /* before XML decl (but after BOM) */
167 } xmlParserInputState;
168 
169 /** DOC_DISABLE */
170 /*
171  * Internal bits in the 'loadsubset' context member
172  */
173 #define XML_DETECT_IDS		2
174 #define XML_COMPLETE_ATTRS	4
175 #define XML_SKIP_IDS		8
176 /** DOC_ENABLE */
177 
178 /**
179  * xmlParserMode:
180  *
181  * A parser can operate in various modes
182  */
183 typedef enum {
184     XML_PARSE_UNKNOWN = 0,
185     XML_PARSE_DOM = 1,
186     XML_PARSE_SAX = 2,
187     XML_PARSE_PUSH_DOM = 3,
188     XML_PARSE_PUSH_SAX = 4,
189     XML_PARSE_READER = 5
190 } xmlParserMode;
191 
192 typedef struct _xmlStartTag xmlStartTag;
193 typedef struct _xmlParserNsData xmlParserNsData;
194 typedef struct _xmlAttrHashBucket xmlAttrHashBucket;
195 
196 typedef int
197 (*xmlResourceLoader)(void *ctxt, const char *url, const char *publicId,
198                      xmlResourceType type, int flags, xmlParserInputPtr *out);
199 
200 /**
201  * xmlParserCtxt:
202  *
203  * The parser context.
204  * NOTE This doesn't completely define the parser state, the (current ?)
205  *      design of the parser uses recursive function calls since this allow
206  *      and easy mapping from the production rules of the specification
207  *      to the actual code. The drawback is that the actual function call
208  *      also reflect the parser state. However most of the parsing routines
209  *      takes as the only argument the parser context pointer, so migrating
210  *      to a state based parser for progressive parsing shouldn't be too hard.
211  */
212 struct _xmlParserCtxt {
213     /* The SAX handler */
214     struct _xmlSAXHandler *sax;
215     /* For SAX interface only, used by DOM build */
216     void *userData;
217     /* the document being built */
218     xmlDocPtr myDoc;
219     /* is the document well formed */
220     int wellFormed;
221     /* shall we replace entities ? */
222     int replaceEntities XML_DEPRECATED_MEMBER;
223     /* the XML version string */
224     const xmlChar *version;
225     /* the declared encoding, if any */
226     const xmlChar *encoding;
227     /* standalone document */
228     int standalone;
229 
230     /* an HTML(1) document
231      * 3 is HTML after <head>
232      * 10 is HTML after <body>
233      */
234     int html;
235 
236     /* Input stream stack */
237 
238     /* Current input stream */
239     xmlParserInputPtr input;
240     /* Number of current input streams */
241     int inputNr;
242     /* Max number of input streams */
243     int inputMax XML_DEPRECATED_MEMBER;
244     /* stack of inputs */
245     xmlParserInputPtr *inputTab;
246 
247     /* Node analysis stack only used for DOM building */
248 
249     /* Current parsed Node */
250     xmlNodePtr node XML_DEPRECATED_MEMBER;
251     /* Depth of the parsing stack */
252     int nodeNr XML_DEPRECATED_MEMBER;
253     /* Max depth of the parsing stack */
254     int nodeMax XML_DEPRECATED_MEMBER;
255     /* array of nodes */
256     xmlNodePtr *nodeTab XML_DEPRECATED_MEMBER;
257 
258     /* Whether node info should be kept */
259     int record_info;
260     /* info about each node parsed */
261     xmlParserNodeInfoSeq node_seq XML_DEPRECATED_MEMBER;
262 
263     /* error code */
264     int errNo;
265 
266     /* reference and external subset */
267     int hasExternalSubset XML_DEPRECATED_MEMBER;
268     /* the internal subset has PE refs */
269     int hasPErefs XML_DEPRECATED_MEMBER;
270     /* unused */
271     int external XML_DEPRECATED_MEMBER;
272 
273     /* is the document valid */
274     int valid;
275     /* shall we try to validate ? */
276     int validate XML_DEPRECATED_MEMBER;
277     /* The validity context */
278     xmlValidCtxt vctxt;
279 
280     /* push parser state */
281     xmlParserInputState instate XML_DEPRECATED_MEMBER;
282     /* unused */
283     int token XML_DEPRECATED_MEMBER;
284 
285     /* unused internally, still used downstream */
286     char *directory;
287 
288     /* Node name stack */
289 
290     /* Current parsed Node */
291     const xmlChar *name XML_DEPRECATED_MEMBER;
292     /* Depth of the parsing stack */
293     int nameNr XML_DEPRECATED_MEMBER;
294     /* Max depth of the parsing stack */
295     int nameMax XML_DEPRECATED_MEMBER;
296     /* array of nodes */
297     const xmlChar **nameTab XML_DEPRECATED_MEMBER;
298 
299     /* unused */
300     long nbChars XML_DEPRECATED_MEMBER;
301     /* used by progressive parsing lookup */
302     long checkIndex XML_DEPRECATED_MEMBER;
303     /* ugly but ... */
304     int keepBlanks XML_DEPRECATED_MEMBER;
305     /* SAX callbacks are disabled */
306     int disableSAX XML_DEPRECATED_MEMBER;
307     /* Parsing is in int 1/ext 2 subset */
308     int inSubset;
309     /* name of subset */
310     const xmlChar *intSubName;
311     /* URI of external subset */
312     xmlChar *extSubURI;
313     /* SYSTEM ID of external subset */
314     xmlChar *extSubSystem;
315 
316     /* xml:space values */
317 
318     /* Should the parser preserve spaces */
319     int *space XML_DEPRECATED_MEMBER;
320     /* Depth of the parsing stack */
321     int spaceNr XML_DEPRECATED_MEMBER;
322     /* Max depth of the parsing stack */
323     int spaceMax XML_DEPRECATED_MEMBER;
324     /* array of space infos */
325     int *spaceTab XML_DEPRECATED_MEMBER;
326 
327     /* to prevent entity substitution loops */
328     int depth XML_DEPRECATED_MEMBER;
329     /* unused */
330     xmlParserInputPtr entity XML_DEPRECATED_MEMBER;
331     /* unused */
332     int charset XML_DEPRECATED_MEMBER;
333     /* Those two fields are there to */
334     int nodelen XML_DEPRECATED_MEMBER;
335     /* Speed up large node parsing */
336     int nodemem XML_DEPRECATED_MEMBER;
337     /* signal pedantic warnings */
338     int pedantic XML_DEPRECATED_MEMBER;
339     /* For user data, libxml won't touch it */
340     void *_private;
341 
342     /* should the external subset be loaded */
343     int loadsubset XML_DEPRECATED_MEMBER;
344     /* set line number in element content */
345     int linenumbers XML_DEPRECATED_MEMBER;
346     /* document's own catalog */
347     void *catalogs XML_DEPRECATED_MEMBER;
348     /* run in recovery mode */
349     int recovery XML_DEPRECATED_MEMBER;
350     /* unused */
351     int progressive XML_DEPRECATED_MEMBER;
352     /* dictionary for the parser */
353     xmlDictPtr dict;
354     /* array for the attributes callbacks */
355     const xmlChar **atts XML_DEPRECATED_MEMBER;
356     /* the size of the array */
357     int maxatts XML_DEPRECATED_MEMBER;
358     /* unused */
359     int docdict XML_DEPRECATED_MEMBER;
360 
361     /*
362      * pre-interned strings
363      */
364     const xmlChar *str_xml XML_DEPRECATED_MEMBER;
365     const xmlChar *str_xmlns XML_DEPRECATED_MEMBER;
366     const xmlChar *str_xml_ns XML_DEPRECATED_MEMBER;
367 
368     /*
369      * Everything below is used only by the new SAX mode
370      */
371 
372     /* operating in the new SAX mode */
373     int sax2 XML_DEPRECATED_MEMBER;
374     /* the number of inherited namespaces */
375     int nsNr XML_DEPRECATED_MEMBER;
376     /* the size of the arrays */
377     int nsMax XML_DEPRECATED_MEMBER;
378     /* the array of prefix/namespace name */
379     const xmlChar **nsTab XML_DEPRECATED_MEMBER;
380     /* which attribute were allocated */
381     unsigned *attallocs XML_DEPRECATED_MEMBER;
382     /* array of data for push */
383     xmlStartTag *pushTab XML_DEPRECATED_MEMBER;
384     /* defaulted attributes if any */
385     xmlHashTablePtr attsDefault XML_DEPRECATED_MEMBER;
386     /* non-CDATA attributes if any */
387     xmlHashTablePtr attsSpecial XML_DEPRECATED_MEMBER;
388     /* is the document XML Namespace okay */
389     int nsWellFormed;
390     /* Extra options */
391     int options;
392 
393     /*
394      * Those fields are needed only for streaming parsing so far
395      */
396 
397     /* Use dictionary names for the tree */
398     int dictNames XML_DEPRECATED_MEMBER;
399     /* number of freed element nodes */
400     int freeElemsNr XML_DEPRECATED_MEMBER;
401     /* List of freed element nodes */
402     xmlNodePtr freeElems XML_DEPRECATED_MEMBER;
403     /* number of freed attributes nodes */
404     int freeAttrsNr XML_DEPRECATED_MEMBER;
405     /* List of freed attributes nodes */
406     xmlAttrPtr freeAttrs XML_DEPRECATED_MEMBER;
407 
408     /*
409      * the complete error information for the last error.
410      */
411     xmlError lastError XML_DEPRECATED_MEMBER;
412     /* the parser mode */
413     xmlParserMode parseMode XML_DEPRECATED_MEMBER;
414     /* unused */
415     unsigned long nbentities XML_DEPRECATED_MEMBER;
416     /* size of external entities */
417     unsigned long sizeentities XML_DEPRECATED_MEMBER;
418 
419     /* for use by HTML non-recursive parser */
420     /* Current NodeInfo */
421     xmlParserNodeInfo *nodeInfo XML_DEPRECATED_MEMBER;
422     /* Depth of the parsing stack */
423     int nodeInfoNr XML_DEPRECATED_MEMBER;
424     /* Max depth of the parsing stack */
425     int nodeInfoMax XML_DEPRECATED_MEMBER;
426     /* array of nodeInfos */
427     xmlParserNodeInfo *nodeInfoTab XML_DEPRECATED_MEMBER;
428 
429     /* we need to label inputs */
430     int input_id XML_DEPRECATED_MEMBER;
431     /* volume of entity copy */
432     unsigned long sizeentcopy XML_DEPRECATED_MEMBER;
433 
434     /* quote state for push parser */
435     int endCheckState XML_DEPRECATED_MEMBER;
436     /* number of errors */
437     unsigned short nbErrors XML_DEPRECATED_MEMBER;
438     /* number of warnings */
439     unsigned short nbWarnings XML_DEPRECATED_MEMBER;
440     /* maximum amplification factor */
441     unsigned maxAmpl XML_DEPRECATED_MEMBER;
442 
443     /* namespace database */
444     xmlParserNsData *nsdb XML_DEPRECATED_MEMBER;
445     /* allocated size */
446     unsigned attrHashMax XML_DEPRECATED_MEMBER;
447     /* atttribute hash table */
448     xmlAttrHashBucket *attrHash XML_DEPRECATED_MEMBER;
449 
450     xmlStructuredErrorFunc errorHandler XML_DEPRECATED_MEMBER;
451     void *errorCtxt XML_DEPRECATED_MEMBER;
452 
453     xmlResourceLoader resourceLoader XML_DEPRECATED_MEMBER;
454     void *resourceCtxt XML_DEPRECATED_MEMBER;
455 
456     xmlCharEncConvImpl convImpl XML_DEPRECATED_MEMBER;
457     void *convCtxt XML_DEPRECATED_MEMBER;
458 };
459 
460 /**
461  * xmlSAXLocator:
462  *
463  * A SAX Locator.
464  */
465 struct _xmlSAXLocator {
466     const xmlChar *(*getPublicId)(void *ctx);
467     const xmlChar *(*getSystemId)(void *ctx);
468     int (*getLineNumber)(void *ctx);
469     int (*getColumnNumber)(void *ctx);
470 };
471 
472 /**
473  * xmlSAXHandler:
474  *
475  * A SAX handler is bunch of callbacks called by the parser when processing
476  * of the input generate data or structure information.
477  */
478 
479 /**
480  * resolveEntitySAXFunc:
481  * @ctx:  the user data (XML parser context)
482  * @publicId: The public ID of the entity
483  * @systemId: The system ID of the entity
484  *
485  * Callback:
486  * The entity loader, to control the loading of external entities,
487  * the application can either:
488  *    - override this resolveEntity() callback in the SAX block
489  *    - or better use the xmlSetExternalEntityLoader() function to
490  *      set up it's own entity resolution routine
491  *
492  * Returns the xmlParserInputPtr if inlined or NULL for DOM behaviour.
493  */
494 typedef xmlParserInputPtr (*resolveEntitySAXFunc) (void *ctx,
495 				const xmlChar *publicId,
496 				const xmlChar *systemId);
497 /**
498  * internalSubsetSAXFunc:
499  * @ctx:  the user data (XML parser context)
500  * @name:  the root element name
501  * @ExternalID:  the external ID
502  * @SystemID:  the SYSTEM ID (e.g. filename or URL)
503  *
504  * Callback on internal subset declaration.
505  */
506 typedef void (*internalSubsetSAXFunc) (void *ctx,
507 				const xmlChar *name,
508 				const xmlChar *ExternalID,
509 				const xmlChar *SystemID);
510 /**
511  * externalSubsetSAXFunc:
512  * @ctx:  the user data (XML parser context)
513  * @name:  the root element name
514  * @ExternalID:  the external ID
515  * @SystemID:  the SYSTEM ID (e.g. filename or URL)
516  *
517  * Callback on external subset declaration.
518  */
519 typedef void (*externalSubsetSAXFunc) (void *ctx,
520 				const xmlChar *name,
521 				const xmlChar *ExternalID,
522 				const xmlChar *SystemID);
523 /**
524  * getEntitySAXFunc:
525  * @ctx:  the user data (XML parser context)
526  * @name: The entity name
527  *
528  * Get an entity by name.
529  *
530  * Returns the xmlEntityPtr if found.
531  */
532 typedef xmlEntityPtr (*getEntitySAXFunc) (void *ctx,
533 				const xmlChar *name);
534 /**
535  * getParameterEntitySAXFunc:
536  * @ctx:  the user data (XML parser context)
537  * @name: The entity name
538  *
539  * Get a parameter entity by name.
540  *
541  * Returns the xmlEntityPtr if found.
542  */
543 typedef xmlEntityPtr (*getParameterEntitySAXFunc) (void *ctx,
544 				const xmlChar *name);
545 /**
546  * entityDeclSAXFunc:
547  * @ctx:  the user data (XML parser context)
548  * @name:  the entity name
549  * @type:  the entity type
550  * @publicId: The public ID of the entity
551  * @systemId: The system ID of the entity
552  * @content: the entity value (without processing).
553  *
554  * An entity definition has been parsed.
555  */
556 typedef void (*entityDeclSAXFunc) (void *ctx,
557 				const xmlChar *name,
558 				int type,
559 				const xmlChar *publicId,
560 				const xmlChar *systemId,
561 				xmlChar *content);
562 /**
563  * notationDeclSAXFunc:
564  * @ctx:  the user data (XML parser context)
565  * @name: The name of the notation
566  * @publicId: The public ID of the entity
567  * @systemId: The system ID of the entity
568  *
569  * What to do when a notation declaration has been parsed.
570  */
571 typedef void (*notationDeclSAXFunc)(void *ctx,
572 				const xmlChar *name,
573 				const xmlChar *publicId,
574 				const xmlChar *systemId);
575 /**
576  * attributeDeclSAXFunc:
577  * @ctx:  the user data (XML parser context)
578  * @elem:  the name of the element
579  * @fullname:  the attribute name
580  * @type:  the attribute type
581  * @def:  the type of default value
582  * @defaultValue: the attribute default value
583  * @tree:  the tree of enumerated value set
584  *
585  * An attribute definition has been parsed.
586  */
587 typedef void (*attributeDeclSAXFunc)(void *ctx,
588 				const xmlChar *elem,
589 				const xmlChar *fullname,
590 				int type,
591 				int def,
592 				const xmlChar *defaultValue,
593 				xmlEnumerationPtr tree);
594 /**
595  * elementDeclSAXFunc:
596  * @ctx:  the user data (XML parser context)
597  * @name:  the element name
598  * @type:  the element type
599  * @content: the element value tree
600  *
601  * An element definition has been parsed.
602  */
603 typedef void (*elementDeclSAXFunc)(void *ctx,
604 				const xmlChar *name,
605 				int type,
606 				xmlElementContentPtr content);
607 /**
608  * unparsedEntityDeclSAXFunc:
609  * @ctx:  the user data (XML parser context)
610  * @name: The name of the entity
611  * @publicId: The public ID of the entity
612  * @systemId: The system ID of the entity
613  * @notationName: the name of the notation
614  *
615  * What to do when an unparsed entity declaration is parsed.
616  */
617 typedef void (*unparsedEntityDeclSAXFunc)(void *ctx,
618 				const xmlChar *name,
619 				const xmlChar *publicId,
620 				const xmlChar *systemId,
621 				const xmlChar *notationName);
622 /**
623  * setDocumentLocatorSAXFunc:
624  * @ctx:  the user data (XML parser context)
625  * @loc: A SAX Locator
626  *
627  * Receive the document locator at startup, actually xmlDefaultSAXLocator.
628  * Everything is available on the context, so this is useless in our case.
629  */
630 typedef void (*setDocumentLocatorSAXFunc) (void *ctx,
631 				xmlSAXLocatorPtr loc);
632 /**
633  * startDocumentSAXFunc:
634  * @ctx:  the user data (XML parser context)
635  *
636  * Called when the document start being processed.
637  */
638 typedef void (*startDocumentSAXFunc) (void *ctx);
639 /**
640  * endDocumentSAXFunc:
641  * @ctx:  the user data (XML parser context)
642  *
643  * Called when the document end has been detected.
644  */
645 typedef void (*endDocumentSAXFunc) (void *ctx);
646 /**
647  * startElementSAXFunc:
648  * @ctx:  the user data (XML parser context)
649  * @name:  The element name, including namespace prefix
650  * @atts:  An array of name/value attributes pairs, NULL terminated
651  *
652  * Called when an opening tag has been processed.
653  */
654 typedef void (*startElementSAXFunc) (void *ctx,
655 				const xmlChar *name,
656 				const xmlChar **atts);
657 /**
658  * endElementSAXFunc:
659  * @ctx:  the user data (XML parser context)
660  * @name:  The element name
661  *
662  * Called when the end of an element has been detected.
663  */
664 typedef void (*endElementSAXFunc) (void *ctx,
665 				const xmlChar *name);
666 /**
667  * attributeSAXFunc:
668  * @ctx:  the user data (XML parser context)
669  * @name:  The attribute name, including namespace prefix
670  * @value:  The attribute value
671  *
672  * Handle an attribute that has been read by the parser.
673  * The default handling is to convert the attribute into an
674  * DOM subtree and past it in a new xmlAttr element added to
675  * the element.
676  */
677 typedef void (*attributeSAXFunc) (void *ctx,
678 				const xmlChar *name,
679 				const xmlChar *value);
680 /**
681  * referenceSAXFunc:
682  * @ctx:  the user data (XML parser context)
683  * @name:  The entity name
684  *
685  * Called when an entity reference is detected.
686  */
687 typedef void (*referenceSAXFunc) (void *ctx,
688 				const xmlChar *name);
689 /**
690  * charactersSAXFunc:
691  * @ctx:  the user data (XML parser context)
692  * @ch:  a xmlChar string
693  * @len: the number of xmlChar
694  *
695  * Receiving some chars from the parser.
696  */
697 typedef void (*charactersSAXFunc) (void *ctx,
698 				const xmlChar *ch,
699 				int len);
700 /**
701  * ignorableWhitespaceSAXFunc:
702  * @ctx:  the user data (XML parser context)
703  * @ch:  a xmlChar string
704  * @len: the number of xmlChar
705  *
706  * Receiving some ignorable whitespaces from the parser.
707  * UNUSED: by default the DOM building will use characters.
708  */
709 typedef void (*ignorableWhitespaceSAXFunc) (void *ctx,
710 				const xmlChar *ch,
711 				int len);
712 /**
713  * processingInstructionSAXFunc:
714  * @ctx:  the user data (XML parser context)
715  * @target:  the target name
716  * @data: the PI data's
717  *
718  * A processing instruction has been parsed.
719  */
720 typedef void (*processingInstructionSAXFunc) (void *ctx,
721 				const xmlChar *target,
722 				const xmlChar *data);
723 /**
724  * commentSAXFunc:
725  * @ctx:  the user data (XML parser context)
726  * @value:  the comment content
727  *
728  * A comment has been parsed.
729  */
730 typedef void (*commentSAXFunc) (void *ctx,
731 				const xmlChar *value);
732 /**
733  * cdataBlockSAXFunc:
734  * @ctx:  the user data (XML parser context)
735  * @value:  The pcdata content
736  * @len:  the block length
737  *
738  * Called when a pcdata block has been parsed.
739  */
740 typedef void (*cdataBlockSAXFunc) (
741 	                        void *ctx,
742 				const xmlChar *value,
743 				int len);
744 /**
745  * warningSAXFunc:
746  * @ctx:  an XML parser context
747  * @msg:  the message to display/transmit
748  * @...:  extra parameters for the message display
749  *
750  * Display and format a warning messages, callback.
751  */
752 typedef void (*warningSAXFunc) (void *ctx,
753 				const char *msg, ...) LIBXML_ATTR_FORMAT(2,3);
754 /**
755  * errorSAXFunc:
756  * @ctx:  an XML parser context
757  * @msg:  the message to display/transmit
758  * @...:  extra parameters for the message display
759  *
760  * Display and format an error messages, callback.
761  */
762 typedef void (*errorSAXFunc) (void *ctx,
763 				const char *msg, ...) LIBXML_ATTR_FORMAT(2,3);
764 /**
765  * fatalErrorSAXFunc:
766  * @ctx:  an XML parser context
767  * @msg:  the message to display/transmit
768  * @...:  extra parameters for the message display
769  *
770  * Display and format fatal error messages, callback.
771  * Note: so far fatalError() SAX callbacks are not used, error()
772  *       get all the callbacks for errors.
773  */
774 typedef void (*fatalErrorSAXFunc) (void *ctx,
775 				const char *msg, ...) LIBXML_ATTR_FORMAT(2,3);
776 /**
777  * isStandaloneSAXFunc:
778  * @ctx:  the user data (XML parser context)
779  *
780  * Is this document tagged standalone?
781  *
782  * Returns 1 if true
783  */
784 typedef int (*isStandaloneSAXFunc) (void *ctx);
785 /**
786  * hasInternalSubsetSAXFunc:
787  * @ctx:  the user data (XML parser context)
788  *
789  * Does this document has an internal subset.
790  *
791  * Returns 1 if true
792  */
793 typedef int (*hasInternalSubsetSAXFunc) (void *ctx);
794 
795 /**
796  * hasExternalSubsetSAXFunc:
797  * @ctx:  the user data (XML parser context)
798  *
799  * Does this document has an external subset?
800  *
801  * Returns 1 if true
802  */
803 typedef int (*hasExternalSubsetSAXFunc) (void *ctx);
804 
805 /************************************************************************
806  *									*
807  *			The SAX version 2 API extensions		*
808  *									*
809  ************************************************************************/
810 /**
811  * XML_SAX2_MAGIC:
812  *
813  * Special constant found in SAX2 blocks initialized fields
814  */
815 #define XML_SAX2_MAGIC 0xDEEDBEAF
816 
817 /**
818  * startElementNsSAX2Func:
819  * @ctx:  the user data (XML parser context)
820  * @localname:  the local name of the element
821  * @prefix:  the element namespace prefix if available
822  * @URI:  the element namespace name if available
823  * @nb_namespaces:  number of namespace definitions on that node
824  * @namespaces:  pointer to the array of prefix/URI pairs namespace definitions
825  * @nb_attributes:  the number of attributes on that node
826  * @nb_defaulted:  the number of defaulted attributes. The defaulted
827  *                  ones are at the end of the array
828  * @attributes:  pointer to the array of (localname/prefix/URI/value/end)
829  *               attribute values.
830  *
831  * SAX2 callback when an element start has been detected by the parser.
832  * It provides the namespace information for the element, as well as
833  * the new namespace declarations on the element.
834  */
835 
836 typedef void (*startElementNsSAX2Func) (void *ctx,
837 					const xmlChar *localname,
838 					const xmlChar *prefix,
839 					const xmlChar *URI,
840 					int nb_namespaces,
841 					const xmlChar **namespaces,
842 					int nb_attributes,
843 					int nb_defaulted,
844 					const xmlChar **attributes);
845 
846 /**
847  * endElementNsSAX2Func:
848  * @ctx:  the user data (XML parser context)
849  * @localname:  the local name of the element
850  * @prefix:  the element namespace prefix if available
851  * @URI:  the element namespace name if available
852  *
853  * SAX2 callback when an element end has been detected by the parser.
854  * It provides the namespace information for the element.
855  */
856 
857 typedef void (*endElementNsSAX2Func)   (void *ctx,
858 					const xmlChar *localname,
859 					const xmlChar *prefix,
860 					const xmlChar *URI);
861 
862 
863 struct _xmlSAXHandler {
864     internalSubsetSAXFunc internalSubset;
865     isStandaloneSAXFunc isStandalone;
866     hasInternalSubsetSAXFunc hasInternalSubset;
867     hasExternalSubsetSAXFunc hasExternalSubset;
868     resolveEntitySAXFunc resolveEntity;
869     getEntitySAXFunc getEntity;
870     entityDeclSAXFunc entityDecl;
871     notationDeclSAXFunc notationDecl;
872     attributeDeclSAXFunc attributeDecl;
873     elementDeclSAXFunc elementDecl;
874     unparsedEntityDeclSAXFunc unparsedEntityDecl;
875     setDocumentLocatorSAXFunc setDocumentLocator;
876     startDocumentSAXFunc startDocument;
877     endDocumentSAXFunc endDocument;
878     /*
879      * `startElement` and `endElement` are only used by the legacy SAX1
880      * interface and should not be used in new software. If you really
881      * have to enable SAX1, the preferred way is set the `initialized`
882      * member to 1 instead of XML_SAX2_MAGIC.
883      *
884      * For backward compatibility, it's also possible to set the
885      * `startElementNs` and `endElementNs` handlers to NULL.
886      *
887      * You can also set the XML_PARSE_SAX1 parser option, but versions
888      * older than 2.12.0 will probably crash if this option is provided
889      * together with custom SAX callbacks.
890      */
891     startElementSAXFunc startElement;
892     endElementSAXFunc endElement;
893     referenceSAXFunc reference;
894     charactersSAXFunc characters;
895     ignorableWhitespaceSAXFunc ignorableWhitespace;
896     processingInstructionSAXFunc processingInstruction;
897     commentSAXFunc comment;
898     warningSAXFunc warning;
899     errorSAXFunc error;
900     fatalErrorSAXFunc fatalError; /* unused error() get all the errors */
901     getParameterEntitySAXFunc getParameterEntity;
902     cdataBlockSAXFunc cdataBlock;
903     externalSubsetSAXFunc externalSubset;
904     /*
905      * `initialized` should always be set to XML_SAX2_MAGIC to enable the
906      * modern SAX2 interface.
907      */
908     unsigned int initialized;
909     /*
910      * The following members are only used by the SAX2 interface.
911      */
912     void *_private;
913     startElementNsSAX2Func startElementNs;
914     endElementNsSAX2Func endElementNs;
915     xmlStructuredErrorFunc serror;
916 };
917 
918 /*
919  * SAX Version 1
920  */
921 typedef struct _xmlSAXHandlerV1 xmlSAXHandlerV1;
922 typedef xmlSAXHandlerV1 *xmlSAXHandlerV1Ptr;
923 struct _xmlSAXHandlerV1 {
924     internalSubsetSAXFunc internalSubset;
925     isStandaloneSAXFunc isStandalone;
926     hasInternalSubsetSAXFunc hasInternalSubset;
927     hasExternalSubsetSAXFunc hasExternalSubset;
928     resolveEntitySAXFunc resolveEntity;
929     getEntitySAXFunc getEntity;
930     entityDeclSAXFunc entityDecl;
931     notationDeclSAXFunc notationDecl;
932     attributeDeclSAXFunc attributeDecl;
933     elementDeclSAXFunc elementDecl;
934     unparsedEntityDeclSAXFunc unparsedEntityDecl;
935     setDocumentLocatorSAXFunc setDocumentLocator;
936     startDocumentSAXFunc startDocument;
937     endDocumentSAXFunc endDocument;
938     startElementSAXFunc startElement;
939     endElementSAXFunc endElement;
940     referenceSAXFunc reference;
941     charactersSAXFunc characters;
942     ignorableWhitespaceSAXFunc ignorableWhitespace;
943     processingInstructionSAXFunc processingInstruction;
944     commentSAXFunc comment;
945     warningSAXFunc warning;
946     errorSAXFunc error;
947     fatalErrorSAXFunc fatalError; /* unused error() get all the errors */
948     getParameterEntitySAXFunc getParameterEntity;
949     cdataBlockSAXFunc cdataBlock;
950     externalSubsetSAXFunc externalSubset;
951     unsigned int initialized;
952 };
953 
954 
955 /**
956  * xmlExternalEntityLoader:
957  * @URL: The System ID of the resource requested
958  * @ID: The Public ID of the resource requested
959  * @context: the XML parser context
960  *
961  * External entity loaders types.
962  *
963  * Returns the entity input parser.
964  */
965 typedef xmlParserInputPtr (*xmlExternalEntityLoader) (const char *URL,
966 					 const char *ID,
967 					 xmlParserCtxtPtr context);
968 
969 /*
970  * Variables
971  */
972 
973 XMLPUBVAR const char *const xmlParserVersion;
974 XML_DEPRECATED
975 XMLPUBVAR const int oldXMLWDcompatibility;
976 XML_DEPRECATED
977 XMLPUBVAR const int xmlParserDebugEntities;
978 XML_DEPRECATED
979 XMLPUBVAR const xmlSAXLocator xmlDefaultSAXLocator;
980 #ifdef LIBXML_SAX1_ENABLED
981 XML_DEPRECATED
982 XMLPUBVAR const xmlSAXHandlerV1 xmlDefaultSAXHandler;
983 #endif
984 
985 #ifdef LIBXML_THREAD_ENABLED
986 /* backward compatibility */
987 XMLPUBFUN const char *const *__xmlParserVersion(void);
988 XML_DEPRECATED
989 XMLPUBFUN const int *__oldXMLWDcompatibility(void);
990 XML_DEPRECATED
991 XMLPUBFUN const int *__xmlParserDebugEntities(void);
992 XML_DEPRECATED
993 XMLPUBFUN const xmlSAXLocator *__xmlDefaultSAXLocator(void);
994 #ifdef LIBXML_SAX1_ENABLED
995 XML_DEPRECATED
996 XMLPUBFUN const xmlSAXHandlerV1 *__xmlDefaultSAXHandler(void);
997 #endif
998 #endif
999 
1000 /** DOC_DISABLE */
1001 #define XML_GLOBALS_PARSER_CORE \
1002   XML_OP(xmlDoValidityCheckingDefaultValue, int, XML_DEPRECATED) \
1003   XML_OP(xmlGetWarningsDefaultValue, int, XML_DEPRECATED) \
1004   XML_OP(xmlKeepBlanksDefaultValue, int, XML_DEPRECATED) \
1005   XML_OP(xmlLineNumbersDefaultValue, int, XML_DEPRECATED) \
1006   XML_OP(xmlLoadExtDtdDefaultValue, int, XML_DEPRECATED) \
1007   XML_OP(xmlPedanticParserDefaultValue, int, XML_DEPRECATED) \
1008   XML_OP(xmlSubstituteEntitiesDefaultValue, int, XML_DEPRECATED)
1009 
1010 #ifdef LIBXML_OUTPUT_ENABLED
1011   #define XML_GLOBALS_PARSER_OUTPUT \
1012     XML_OP(xmlIndentTreeOutput, int, XML_NO_ATTR) \
1013     XML_OP(xmlTreeIndentString, const char *, XML_NO_ATTR) \
1014     XML_OP(xmlSaveNoEmptyTags, int, XML_NO_ATTR)
1015 #else
1016   #define XML_GLOBALS_PARSER_OUTPUT
1017 #endif
1018 
1019 #define XML_GLOBALS_PARSER \
1020   XML_GLOBALS_PARSER_CORE \
1021   XML_GLOBALS_PARSER_OUTPUT
1022 
1023 #define XML_OP XML_DECLARE_GLOBAL
1024 XML_GLOBALS_PARSER
1025 #undef XML_OP
1026 
1027 #if defined(LIBXML_THREAD_ENABLED) && !defined(XML_GLOBALS_NO_REDEFINITION)
1028   #define xmlDoValidityCheckingDefaultValue \
1029     XML_GLOBAL_MACRO(xmlDoValidityCheckingDefaultValue)
1030   #define xmlGetWarningsDefaultValue \
1031     XML_GLOBAL_MACRO(xmlGetWarningsDefaultValue)
1032   #define xmlKeepBlanksDefaultValue XML_GLOBAL_MACRO(xmlKeepBlanksDefaultValue)
1033   #define xmlLineNumbersDefaultValue \
1034     XML_GLOBAL_MACRO(xmlLineNumbersDefaultValue)
1035   #define xmlLoadExtDtdDefaultValue XML_GLOBAL_MACRO(xmlLoadExtDtdDefaultValue)
1036   #define xmlPedanticParserDefaultValue \
1037     XML_GLOBAL_MACRO(xmlPedanticParserDefaultValue)
1038   #define xmlSubstituteEntitiesDefaultValue \
1039     XML_GLOBAL_MACRO(xmlSubstituteEntitiesDefaultValue)
1040   #ifdef LIBXML_OUTPUT_ENABLED
1041     #define xmlIndentTreeOutput XML_GLOBAL_MACRO(xmlIndentTreeOutput)
1042     #define xmlTreeIndentString XML_GLOBAL_MACRO(xmlTreeIndentString)
1043     #define xmlSaveNoEmptyTags XML_GLOBAL_MACRO(xmlSaveNoEmptyTags)
1044   #endif
1045 #endif
1046 /** DOC_ENABLE */
1047 
1048 /*
1049  * Init/Cleanup
1050  */
1051 XMLPUBFUN void
1052 		xmlInitParser		(void);
1053 XMLPUBFUN void
1054 		xmlCleanupParser	(void);
1055 XML_DEPRECATED
1056 XMLPUBFUN void
1057 		xmlInitGlobals		(void);
1058 XML_DEPRECATED
1059 XMLPUBFUN void
1060 		xmlCleanupGlobals	(void);
1061 
1062 /*
1063  * Input functions
1064  */
1065 XML_DEPRECATED
1066 XMLPUBFUN int
1067 		xmlParserInputRead	(xmlParserInputPtr in,
1068 					 int len);
1069 XMLPUBFUN int
1070 		xmlParserInputGrow	(xmlParserInputPtr in,
1071 					 int len);
1072 
1073 /*
1074  * Basic parsing Interfaces
1075  */
1076 #ifdef LIBXML_SAX1_ENABLED
1077 XMLPUBFUN xmlDocPtr
1078 		xmlParseDoc		(const xmlChar *cur);
1079 XMLPUBFUN xmlDocPtr
1080 		xmlParseFile		(const char *filename);
1081 XMLPUBFUN xmlDocPtr
1082 		xmlParseMemory		(const char *buffer,
1083 					 int size);
1084 #endif /* LIBXML_SAX1_ENABLED */
1085 XML_DEPRECATED XMLPUBFUN int
1086 		xmlSubstituteEntitiesDefault(int val);
1087 XML_DEPRECATED XMLPUBFUN int
1088                 xmlThrDefSubstituteEntitiesDefaultValue(int v);
1089 XMLPUBFUN int
1090 		xmlKeepBlanksDefault	(int val);
1091 XML_DEPRECATED XMLPUBFUN int
1092 		xmlThrDefKeepBlanksDefaultValue(int v);
1093 XMLPUBFUN void
1094 		xmlStopParser		(xmlParserCtxtPtr ctxt);
1095 XML_DEPRECATED XMLPUBFUN int
1096 		xmlPedanticParserDefault(int val);
1097 XML_DEPRECATED XMLPUBFUN int
1098                 xmlThrDefPedanticParserDefaultValue(int v);
1099 XML_DEPRECATED XMLPUBFUN int
1100 		xmlLineNumbersDefault	(int val);
1101 XML_DEPRECATED XMLPUBFUN int
1102                 xmlThrDefLineNumbersDefaultValue(int v);
1103 XML_DEPRECATED XMLPUBFUN int
1104                 xmlThrDefDoValidityCheckingDefaultValue(int v);
1105 XML_DEPRECATED XMLPUBFUN int
1106                 xmlThrDefGetWarningsDefaultValue(int v);
1107 XML_DEPRECATED XMLPUBFUN int
1108                 xmlThrDefLoadExtDtdDefaultValue(int v);
1109 XML_DEPRECATED XMLPUBFUN int
1110                 xmlThrDefParserDebugEntities(int v);
1111 
1112 #ifdef LIBXML_SAX1_ENABLED
1113 /*
1114  * Recovery mode
1115  */
1116 XML_DEPRECATED
1117 XMLPUBFUN xmlDocPtr
1118 		xmlRecoverDoc		(const xmlChar *cur);
1119 XML_DEPRECATED
1120 XMLPUBFUN xmlDocPtr
1121 		xmlRecoverMemory	(const char *buffer,
1122 					 int size);
1123 XML_DEPRECATED
1124 XMLPUBFUN xmlDocPtr
1125 		xmlRecoverFile		(const char *filename);
1126 #endif /* LIBXML_SAX1_ENABLED */
1127 
1128 /*
1129  * Less common routines and SAX interfaces
1130  */
1131 XMLPUBFUN int
1132 		xmlParseDocument	(xmlParserCtxtPtr ctxt);
1133 XMLPUBFUN int
1134 		xmlParseExtParsedEnt	(xmlParserCtxtPtr ctxt);
1135 #ifdef LIBXML_SAX1_ENABLED
1136 XML_DEPRECATED
1137 XMLPUBFUN int
1138 		xmlSAXUserParseFile	(xmlSAXHandlerPtr sax,
1139 					 void *user_data,
1140 					 const char *filename);
1141 XML_DEPRECATED
1142 XMLPUBFUN int
1143 		xmlSAXUserParseMemory	(xmlSAXHandlerPtr sax,
1144 					 void *user_data,
1145 					 const char *buffer,
1146 					 int size);
1147 XML_DEPRECATED
1148 XMLPUBFUN xmlDocPtr
1149 		xmlSAXParseDoc		(xmlSAXHandlerPtr sax,
1150 					 const xmlChar *cur,
1151 					 int recovery);
1152 XML_DEPRECATED
1153 XMLPUBFUN xmlDocPtr
1154 		xmlSAXParseMemory	(xmlSAXHandlerPtr sax,
1155 					 const char *buffer,
1156 					 int size,
1157 					 int recovery);
1158 XML_DEPRECATED
1159 XMLPUBFUN xmlDocPtr
1160 		xmlSAXParseMemoryWithData (xmlSAXHandlerPtr sax,
1161 					 const char *buffer,
1162 					 int size,
1163 					 int recovery,
1164 					 void *data);
1165 XML_DEPRECATED
1166 XMLPUBFUN xmlDocPtr
1167 		xmlSAXParseFile		(xmlSAXHandlerPtr sax,
1168 					 const char *filename,
1169 					 int recovery);
1170 XML_DEPRECATED
1171 XMLPUBFUN xmlDocPtr
1172 		xmlSAXParseFileWithData	(xmlSAXHandlerPtr sax,
1173 					 const char *filename,
1174 					 int recovery,
1175 					 void *data);
1176 XML_DEPRECATED
1177 XMLPUBFUN xmlDocPtr
1178 		xmlSAXParseEntity	(xmlSAXHandlerPtr sax,
1179 					 const char *filename);
1180 XML_DEPRECATED
1181 XMLPUBFUN xmlDocPtr
1182 		xmlParseEntity		(const char *filename);
1183 #endif /* LIBXML_SAX1_ENABLED */
1184 
1185 #ifdef LIBXML_VALID_ENABLED
1186 XML_DEPRECATED
1187 XMLPUBFUN xmlDtdPtr
1188 		xmlSAXParseDTD		(xmlSAXHandlerPtr sax,
1189 					 const xmlChar *ExternalID,
1190 					 const xmlChar *SystemID);
1191 XMLPUBFUN xmlDtdPtr
1192 		xmlParseDTD		(const xmlChar *ExternalID,
1193 					 const xmlChar *SystemID);
1194 XMLPUBFUN xmlDtdPtr
1195 		xmlIOParseDTD		(xmlSAXHandlerPtr sax,
1196 					 xmlParserInputBufferPtr input,
1197 					 xmlCharEncoding enc);
1198 #endif /* LIBXML_VALID_ENABLE */
1199 #ifdef LIBXML_SAX1_ENABLED
1200 XMLPUBFUN int
1201 		xmlParseBalancedChunkMemory(xmlDocPtr doc,
1202 					 xmlSAXHandlerPtr sax,
1203 					 void *user_data,
1204 					 int depth,
1205 					 const xmlChar *string,
1206 					 xmlNodePtr *lst);
1207 #endif /* LIBXML_SAX1_ENABLED */
1208 XMLPUBFUN xmlParserErrors
1209 		xmlParseInNodeContext	(xmlNodePtr node,
1210 					 const char *data,
1211 					 int datalen,
1212 					 int options,
1213 					 xmlNodePtr *lst);
1214 #ifdef LIBXML_SAX1_ENABLED
1215 XMLPUBFUN int
1216 		xmlParseBalancedChunkMemoryRecover(xmlDocPtr doc,
1217                      xmlSAXHandlerPtr sax,
1218                      void *user_data,
1219                      int depth,
1220                      const xmlChar *string,
1221                      xmlNodePtr *lst,
1222                      int recover);
1223 XML_DEPRECATED
1224 XMLPUBFUN int
1225 		xmlParseExternalEntity	(xmlDocPtr doc,
1226 					 xmlSAXHandlerPtr sax,
1227 					 void *user_data,
1228 					 int depth,
1229 					 const xmlChar *URL,
1230 					 const xmlChar *ID,
1231 					 xmlNodePtr *lst);
1232 #endif /* LIBXML_SAX1_ENABLED */
1233 XMLPUBFUN int
1234 		xmlParseCtxtExternalEntity(xmlParserCtxtPtr ctx,
1235 					 const xmlChar *URL,
1236 					 const xmlChar *ID,
1237 					 xmlNodePtr *lst);
1238 
1239 /*
1240  * Parser contexts handling.
1241  */
1242 XMLPUBFUN xmlParserCtxtPtr
1243 		xmlNewParserCtxt	(void);
1244 XMLPUBFUN xmlParserCtxtPtr
1245 		xmlNewSAXParserCtxt	(const xmlSAXHandler *sax,
1246 					 void *userData);
1247 XMLPUBFUN int
1248 		xmlInitParserCtxt	(xmlParserCtxtPtr ctxt);
1249 XMLPUBFUN void
1250 		xmlClearParserCtxt	(xmlParserCtxtPtr ctxt);
1251 XMLPUBFUN void
1252 		xmlFreeParserCtxt	(xmlParserCtxtPtr ctxt);
1253 #ifdef LIBXML_SAX1_ENABLED
1254 XML_DEPRECATED
1255 XMLPUBFUN void
1256 		xmlSetupParserForBuffer	(xmlParserCtxtPtr ctxt,
1257 					 const xmlChar* buffer,
1258 					 const char *filename);
1259 #endif /* LIBXML_SAX1_ENABLED */
1260 XMLPUBFUN xmlParserCtxtPtr
1261 		xmlCreateDocParserCtxt	(const xmlChar *cur);
1262 
1263 #ifdef LIBXML_LEGACY_ENABLED
1264 /** DOC_DISABLE */
1265 /*
1266  * Reading/setting optional parsing features.
1267  */
1268 XML_DEPRECATED
1269 XMLPUBFUN int
1270 		xmlGetFeaturesList	(int *len,
1271 					 const char **result);
1272 XML_DEPRECATED
1273 XMLPUBFUN int
1274 		xmlGetFeature		(xmlParserCtxtPtr ctxt,
1275 					 const char *name,
1276 					 void *result);
1277 XML_DEPRECATED
1278 XMLPUBFUN int
1279 		xmlSetFeature		(xmlParserCtxtPtr ctxt,
1280 					 const char *name,
1281 					 void *value);
1282 /** DOC_ENABLE */
1283 #endif /* LIBXML_LEGACY_ENABLED */
1284 
1285 #ifdef LIBXML_PUSH_ENABLED
1286 /*
1287  * Interfaces for the Push mode.
1288  */
1289 XMLPUBFUN xmlParserCtxtPtr
1290 		xmlCreatePushParserCtxt(xmlSAXHandlerPtr sax,
1291 					 void *user_data,
1292 					 const char *chunk,
1293 					 int size,
1294 					 const char *filename);
1295 XMLPUBFUN int
1296 		xmlParseChunk		(xmlParserCtxtPtr ctxt,
1297 					 const char *chunk,
1298 					 int size,
1299 					 int terminate);
1300 #endif /* LIBXML_PUSH_ENABLED */
1301 
1302 /*
1303  * Special I/O mode.
1304  */
1305 
1306 XMLPUBFUN xmlParserCtxtPtr
1307 		xmlCreateIOParserCtxt	(xmlSAXHandlerPtr sax,
1308 					 void *user_data,
1309 					 xmlInputReadCallback   ioread,
1310 					 xmlInputCloseCallback  ioclose,
1311 					 void *ioctx,
1312 					 xmlCharEncoding enc);
1313 
1314 XMLPUBFUN xmlParserInputPtr
1315 		xmlNewIOInputStream	(xmlParserCtxtPtr ctxt,
1316 					 xmlParserInputBufferPtr input,
1317 					 xmlCharEncoding enc);
1318 
1319 /*
1320  * Node infos.
1321  */
1322 XMLPUBFUN const xmlParserNodeInfo*
1323 		xmlParserFindNodeInfo	(xmlParserCtxtPtr ctxt,
1324 				         xmlNodePtr node);
1325 XMLPUBFUN void
1326 		xmlInitNodeInfoSeq	(xmlParserNodeInfoSeqPtr seq);
1327 XMLPUBFUN void
1328 		xmlClearNodeInfoSeq	(xmlParserNodeInfoSeqPtr seq);
1329 XMLPUBFUN unsigned long
1330 		xmlParserFindNodeInfoIndex(xmlParserNodeInfoSeqPtr seq,
1331                                          xmlNodePtr node);
1332 XMLPUBFUN void
1333 		xmlParserAddNodeInfo	(xmlParserCtxtPtr ctxt,
1334 					 xmlParserNodeInfoPtr info);
1335 
1336 /*
1337  * External entities handling actually implemented in xmlIO.
1338  */
1339 
1340 XMLPUBFUN void
1341 		xmlSetExternalEntityLoader(xmlExternalEntityLoader f);
1342 XMLPUBFUN xmlExternalEntityLoader
1343 		xmlGetExternalEntityLoader(void);
1344 XMLPUBFUN xmlParserInputPtr
1345 		xmlLoadExternalEntity	(const char *URL,
1346 					 const char *ID,
1347 					 xmlParserCtxtPtr ctxt);
1348 
1349 XML_DEPRECATED
1350 XMLPUBFUN long
1351 		xmlByteConsumed		(xmlParserCtxtPtr ctxt);
1352 
1353 /*
1354  * New set of simpler/more flexible APIs
1355  */
1356 /**
1357  * xmlParserOption:
1358  *
1359  * This is the set of XML parser options that can be passed down
1360  * to the xmlReadDoc() and similar calls.
1361  */
1362 typedef enum {
1363     XML_PARSE_RECOVER	= 1<<0,	/* recover on errors */
1364     XML_PARSE_NOENT	= 1<<1,	/* substitute entities */
1365     XML_PARSE_DTDLOAD	= 1<<2,	/* load the external subset */
1366     XML_PARSE_DTDATTR	= 1<<3,	/* default DTD attributes */
1367     XML_PARSE_DTDVALID	= 1<<4,	/* validate with the DTD */
1368     XML_PARSE_NOERROR	= 1<<5,	/* suppress error reports */
1369     XML_PARSE_NOWARNING	= 1<<6,	/* suppress warning reports */
1370     XML_PARSE_PEDANTIC	= 1<<7,	/* pedantic error reporting */
1371     XML_PARSE_NOBLANKS	= 1<<8,	/* remove blank nodes */
1372     XML_PARSE_SAX1	= 1<<9,	/* use the SAX1 interface internally */
1373     XML_PARSE_XINCLUDE	= 1<<10,/* Implement XInclude substitution  */
1374     XML_PARSE_NONET	= 1<<11,/* Forbid network access */
1375     XML_PARSE_NODICT	= 1<<12,/* Do not reuse the context dictionary */
1376     XML_PARSE_NSCLEAN	= 1<<13,/* remove redundant namespaces declarations */
1377     XML_PARSE_NOCDATA	= 1<<14,/* merge CDATA as text nodes */
1378     XML_PARSE_NOXINCNODE= 1<<15,/* do not generate XINCLUDE START/END nodes */
1379     XML_PARSE_COMPACT   = 1<<16,/* compact small text nodes; no modification of
1380                                    the tree allowed afterwards (will possibly
1381 				   crash if you try to modify the tree) */
1382     XML_PARSE_OLD10	= 1<<17,/* parse using XML-1.0 before update 5 */
1383     XML_PARSE_NOBASEFIX = 1<<18,/* do not fixup XINCLUDE xml:base uris */
1384     XML_PARSE_HUGE      = 1<<19,/* relax any hardcoded limit from the parser */
1385     XML_PARSE_OLDSAX    = 1<<20,/* parse using SAX2 interface before 2.7.0 */
1386     XML_PARSE_IGNORE_ENC= 1<<21,/* ignore internal document encoding hint */
1387     XML_PARSE_BIG_LINES = 1<<22,/* Store big lines numbers in text PSVI field */
1388     /* since 2.13.0 */
1389     XML_PARSE_NO_XXE    = 1<<23,/* disable loading of external content */
1390     /* since 2.14.0 */
1391     XML_PARSE_NO_UNZIP       = 1<<24,/* disable compressed content */
1392     XML_PARSE_NO_SYS_CATALOG = 1<<25,/* disable global system catalog */
1393     XML_PARSE_NO_CATALOG_PI  = 1<<26 /* ignore catalog PIs */
1394 } xmlParserOption;
1395 
1396 XMLPUBFUN void
1397 		xmlCtxtReset		(xmlParserCtxtPtr ctxt);
1398 XMLPUBFUN int
1399 		xmlCtxtResetPush	(xmlParserCtxtPtr ctxt,
1400 					 const char *chunk,
1401 					 int size,
1402 					 const char *filename,
1403 					 const char *encoding);
1404 XMLPUBFUN int
1405 		xmlCtxtGetOptions	(xmlParserCtxtPtr ctxt);
1406 XMLPUBFUN int
1407 		xmlCtxtSetOptions	(xmlParserCtxtPtr ctxt,
1408 					 int options);
1409 XMLPUBFUN int
1410 		xmlCtxtUseOptions	(xmlParserCtxtPtr ctxt,
1411 					 int options);
1412 XMLPUBFUN void *
1413 		xmlCtxtGetPrivate	(xmlParserCtxtPtr ctxt);
1414 XMLPUBFUN void
1415 		xmlCtxtSetPrivate	(xmlParserCtxtPtr ctxt,
1416 					 void *priv);
1417 XMLPUBFUN void *
1418 		xmlCtxtGetCatalogs	(xmlParserCtxtPtr ctxt);
1419 XMLPUBFUN void
1420 		xmlCtxtSetCatalogs	(xmlParserCtxtPtr ctxt,
1421 					 void *catalogs);
1422 XMLPUBFUN xmlDictPtr
1423 		xmlCtxtGetDict		(xmlParserCtxtPtr ctxt);
1424 XMLPUBFUN void
1425 		xmlCtxtSetDict		(xmlParserCtxtPtr ctxt,
1426 					 xmlDictPtr);
1427 XMLPUBFUN const xmlChar *
1428 		xmlCtxtGetVersion	(xmlParserCtxtPtr ctxt);
1429 XMLPUBFUN const xmlChar *
1430 		xmlCtxtGetDeclaredEncoding(xmlParserCtxtPtr ctxt);
1431 XMLPUBFUN int
1432 		xmlCtxtGetStandalone	(xmlParserCtxtPtr ctxt);
1433 XMLPUBFUN int
1434 		xmlCtxtGetStatus	(xmlParserCtxtPtr ctxt);
1435 XMLPUBFUN void
1436 		xmlCtxtSetErrorHandler	(xmlParserCtxtPtr ctxt,
1437 					 xmlStructuredErrorFunc handler,
1438 					 void *data);
1439 XMLPUBFUN void
1440 		xmlCtxtSetResourceLoader(xmlParserCtxtPtr ctxt,
1441 					 xmlResourceLoader loader,
1442 					 void *vctxt);
1443 XMLPUBFUN void
1444 		xmlCtxtSetCharEncConvImpl(xmlParserCtxtPtr ctxt,
1445 					 xmlCharEncConvImpl impl,
1446 					 void *vctxt);
1447 XMLPUBFUN void
1448 		xmlCtxtSetMaxAmplification(xmlParserCtxtPtr ctxt,
1449 					 unsigned maxAmpl);
1450 XMLPUBFUN xmlDocPtr
1451 		xmlReadDoc		(const xmlChar *cur,
1452 					 const char *URL,
1453 					 const char *encoding,
1454 					 int options);
1455 XMLPUBFUN xmlDocPtr
1456 		xmlReadFile		(const char *URL,
1457 					 const char *encoding,
1458 					 int options);
1459 XMLPUBFUN xmlDocPtr
1460 		xmlReadMemory		(const char *buffer,
1461 					 int size,
1462 					 const char *URL,
1463 					 const char *encoding,
1464 					 int options);
1465 XMLPUBFUN xmlDocPtr
1466 		xmlReadFd		(int fd,
1467 					 const char *URL,
1468 					 const char *encoding,
1469 					 int options);
1470 XMLPUBFUN xmlDocPtr
1471 		xmlReadIO		(xmlInputReadCallback ioread,
1472 					 xmlInputCloseCallback ioclose,
1473 					 void *ioctx,
1474 					 const char *URL,
1475 					 const char *encoding,
1476 					 int options);
1477 XMLPUBFUN xmlDocPtr
1478 		xmlCtxtParseDocument	(xmlParserCtxtPtr ctxt,
1479 					 xmlParserInputPtr input);
1480 XMLPUBFUN xmlNodePtr
1481 		xmlCtxtParseContent	(xmlParserCtxtPtr ctxt,
1482 					 xmlParserInputPtr input,
1483 					 xmlNodePtr node,
1484 					 int hasTextDecl);
1485 XMLPUBFUN xmlDocPtr
1486 		xmlCtxtReadDoc		(xmlParserCtxtPtr ctxt,
1487 					 const xmlChar *cur,
1488 					 const char *URL,
1489 					 const char *encoding,
1490 					 int options);
1491 XMLPUBFUN xmlDocPtr
1492 		xmlCtxtReadFile		(xmlParserCtxtPtr ctxt,
1493 					 const char *filename,
1494 					 const char *encoding,
1495 					 int options);
1496 XMLPUBFUN xmlDocPtr
1497 		xmlCtxtReadMemory		(xmlParserCtxtPtr ctxt,
1498 					 const char *buffer,
1499 					 int size,
1500 					 const char *URL,
1501 					 const char *encoding,
1502 					 int options);
1503 XMLPUBFUN xmlDocPtr
1504 		xmlCtxtReadFd		(xmlParserCtxtPtr ctxt,
1505 					 int fd,
1506 					 const char *URL,
1507 					 const char *encoding,
1508 					 int options);
1509 XMLPUBFUN xmlDocPtr
1510 		xmlCtxtReadIO		(xmlParserCtxtPtr ctxt,
1511 					 xmlInputReadCallback ioread,
1512 					 xmlInputCloseCallback ioclose,
1513 					 void *ioctx,
1514 					 const char *URL,
1515 					 const char *encoding,
1516 					 int options);
1517 
1518 /**
1519  * New input API
1520  */
1521 
1522 #define XML_INPUT_BUF_STATIC		(1 << 1)
1523 #define XML_INPUT_BUF_ZERO_TERMINATED	(1 << 2)
1524 #define XML_INPUT_UNZIP                 (1 << 3)
1525 #define XML_INPUT_NETWORK               (1 << 4)
1526 
1527 XMLPUBFUN int
1528 xmlNewInputFromUrl(const char *url, int flags, xmlParserInputPtr *out);
1529 XMLPUBFUN xmlParserInputPtr
1530 xmlNewInputFromMemory(const char *url, const void *mem, size_t size,
1531                       int flags);
1532 XMLPUBFUN xmlParserInputPtr
1533 xmlNewInputFromString(const char *url, const char *str, int flags);
1534 XMLPUBFUN xmlParserInputPtr
1535 xmlNewInputFromFd(const char *url, int fd, int flags);
1536 XMLPUBFUN xmlParserInputPtr
1537 xmlNewInputFromIO(const char *url, xmlInputReadCallback ioRead,
1538                   xmlInputCloseCallback ioClose, void *ioCtxt, int flags);
1539 XMLPUBFUN int
1540 xmlInputSetEncodingHandler(xmlParserInputPtr input,
1541                            xmlCharEncodingHandlerPtr handler);
1542 
1543 /*
1544  * Library wide options
1545  */
1546 /**
1547  * xmlFeature:
1548  *
1549  * Used to examine the existence of features that can be enabled
1550  * or disabled at compile-time.
1551  * They used to be called XML_FEATURE_xxx but this clashed with Expat
1552  */
1553 typedef enum {
1554     XML_WITH_THREAD = 1,
1555     XML_WITH_TREE = 2,
1556     XML_WITH_OUTPUT = 3,
1557     XML_WITH_PUSH = 4,
1558     XML_WITH_READER = 5,
1559     XML_WITH_PATTERN = 6,
1560     XML_WITH_WRITER = 7,
1561     XML_WITH_SAX1 = 8,
1562     XML_WITH_FTP = 9,
1563     XML_WITH_HTTP = 10,
1564     XML_WITH_VALID = 11,
1565     XML_WITH_HTML = 12,
1566     XML_WITH_LEGACY = 13,
1567     XML_WITH_C14N = 14,
1568     XML_WITH_CATALOG = 15,
1569     XML_WITH_XPATH = 16,
1570     XML_WITH_XPTR = 17,
1571     XML_WITH_XINCLUDE = 18,
1572     XML_WITH_ICONV = 19,
1573     XML_WITH_ISO8859X = 20,
1574     XML_WITH_UNICODE = 21,
1575     XML_WITH_REGEXP = 22,
1576     XML_WITH_AUTOMATA = 23,
1577     XML_WITH_EXPR = 24,
1578     XML_WITH_SCHEMAS = 25,
1579     XML_WITH_SCHEMATRON = 26,
1580     XML_WITH_MODULES = 27,
1581     XML_WITH_DEBUG = 28,
1582     XML_WITH_DEBUG_MEM = 29,
1583     XML_WITH_DEBUG_RUN = 30, /* unused */
1584     XML_WITH_ZLIB = 31,
1585     XML_WITH_ICU = 32,
1586     XML_WITH_LZMA = 33,
1587     XML_WITH_NONE = 99999 /* just to be sure of allocation size */
1588 } xmlFeature;
1589 
1590 XMLPUBFUN int
1591 		xmlHasFeature		(xmlFeature feature);
1592 
1593 #ifdef __cplusplus
1594 }
1595 #endif
1596 #endif /* __XML_PARSER_H__ */
1597