2
* Summary: the core parser module
3
* Description: Interfaces, constants and types related to the XML parser
5
* Copy: See Copyright for the status of this software.
7
* Author: Daniel Veillard
10
#ifndef __XML_PARSER_H__
11
#define __XML_PARSER_H__
15
#include <libxml/xmlversion.h>
16
#include <libxml/tree.h>
17
#include <libxml/dict.h>
18
#include <libxml/hash.h>
19
#include <libxml/valid.h>
20
#include <libxml/entities.h>
21
#include <libxml/xmlerror.h>
22
#include <libxml/xmlstring.h>
29
* XML_DEFAULT_VERSION:
31
* The default version of XML used: 1.0
33
#define XML_DEFAULT_VERSION "1.0"
38
* An xmlParserInput is an input flow for the XML processor.
39
* Each entity parsed is associated an xmlParserInput (except the
40
* few predefined ones). This is the case both for internal entities
41
* - in which case the flow is already completely in memory - or
42
* external entities - in which case we use the buf structure for
43
* progressive reading and I18N conversions to the internal UTF-8 format.
47
* xmlParserInputDeallocate:
48
* @str: the string to deallocate
50
* Callback for freeing some parser input allocations.
52
typedef void (* xmlParserInputDeallocate)(xmlChar *str);
54
struct _xmlParserInput {
56
xmlParserInputBufferPtr buf; /* UTF-8 encoded buffer */
58
const char *filename; /* The file analyzed, if any */
59
const char *directory; /* the directory/base of the file */
60
const xmlChar *base; /* Base of the array to parse */
61
const xmlChar *cur; /* Current char being parsed */
62
const xmlChar *end; /* end of the array to parse */
63
int length; /* length if known */
64
int line; /* Current line */
65
int col; /* Current column */
67
* NOTE: consumed is only tested for equality in the parser code,
68
* so even if there is an overflow this should not give troubles
69
* for parsing very large instances.
71
unsigned long consumed; /* How many xmlChars already consumed */
72
xmlParserInputDeallocate free; /* function to deallocate the base */
73
const xmlChar *encoding; /* the encoding string for entity */
74
const xmlChar *version; /* the version string for entity */
75
int standalone; /* Was that entity marked standalone */
76
int id; /* an unique identifier for the entity */
82
* The parser can be asked to collect Node informations, i.e. at what
83
* place in the file they were detected.
84
* NOTE: This is off by default and not very well tested.
86
typedef struct _xmlParserNodeInfo xmlParserNodeInfo;
87
typedef xmlParserNodeInfo *xmlParserNodeInfoPtr;
89
struct _xmlParserNodeInfo {
90
const struct _xmlNode* node;
91
/* Position & line # that text that created the node begins & ends on */
92
unsigned long begin_pos;
93
unsigned long begin_line;
94
unsigned long end_pos;
95
unsigned long end_line;
98
typedef struct _xmlParserNodeInfoSeq xmlParserNodeInfoSeq;
99
typedef xmlParserNodeInfoSeq *xmlParserNodeInfoSeqPtr;
100
struct _xmlParserNodeInfoSeq {
101
unsigned long maximum;
102
unsigned long length;
103
xmlParserNodeInfo* buffer;
107
* xmlParserInputState:
109
* The parser is now working also as a state based parser.
110
* The recursive one use the state info for entities processing.
113
XML_PARSER_EOF = -1, /* nothing is to be parsed */
114
XML_PARSER_START = 0, /* nothing has been parsed */
115
XML_PARSER_MISC, /* Misc* before int subset */
116
XML_PARSER_PI, /* Within a processing instruction */
117
XML_PARSER_DTD, /* within some DTD content */
118
XML_PARSER_PROLOG, /* Misc* after internal subset */
119
XML_PARSER_COMMENT, /* within a comment */
120
XML_PARSER_START_TAG, /* within a start tag */
121
XML_PARSER_CONTENT, /* within the content */
122
XML_PARSER_CDATA_SECTION, /* within a CDATA section */
123
XML_PARSER_END_TAG, /* within a closing tag */
124
XML_PARSER_ENTITY_DECL, /* within an entity declaration */
125
XML_PARSER_ENTITY_VALUE, /* within an entity value in a decl */
126
XML_PARSER_ATTRIBUTE_VALUE, /* within an attribute value */
127
XML_PARSER_SYSTEM_LITERAL, /* within a SYSTEM value */
128
XML_PARSER_EPILOG, /* the Misc* after the last end tag */
129
XML_PARSER_IGNORE, /* within an IGNORED section */
130
XML_PARSER_PUBLIC_LITERAL /* within a PUBLIC value */
131
} xmlParserInputState;
136
* Bit in the loadsubset context field to tell to do ID/REFs lookups.
137
* Use it to initialize xmlLoadExtDtdDefaultValue.
139
#define XML_DETECT_IDS 2
142
* XML_COMPLETE_ATTRS:
144
* Bit in the loadsubset context field to tell to do complete the
145
* elements attributes lists with the ones defaulted from the DTDs.
146
* Use it to initialize xmlLoadExtDtdDefaultValue.
148
#define XML_COMPLETE_ATTRS 4
153
* Bit in the loadsubset context field to tell to not do ID/REFs registration.
154
* Used to initialize xmlLoadExtDtdDefaultValue in some special cases.
156
#define XML_SKIP_IDS 8
161
* A parser can operate in various modes
164
XML_PARSE_UNKNOWN = 0,
167
XML_PARSE_PUSH_DOM = 3,
168
XML_PARSE_PUSH_SAX = 4,
175
* The parser context.
176
* NOTE This doesn't completely define the parser state, the (current ?)
177
* design of the parser uses recursive function calls since this allow
178
* and easy mapping from the production rules of the specification
179
* to the actual code. The drawback is that the actual function call
180
* also reflect the parser state. However most of the parsing routines
181
* takes as the only argument the parser context pointer, so migrating
182
* to a state based parser for progressive parsing shouldn't be too hard.
184
struct _xmlParserCtxt {
185
struct _xmlSAXHandler *sax; /* The SAX handler */
186
void *userData; /* For SAX interface only, used by DOM build */
187
xmlDocPtr myDoc; /* the document being built */
188
int wellFormed; /* is the document well formed */
189
int replaceEntities; /* shall we replace entities ? */
190
const xmlChar *version; /* the XML version string */
191
const xmlChar *encoding; /* the declared encoding, if any */
192
int standalone; /* standalone document */
193
int html; /* an HTML(1)/Docbook(2) document
194
* 3 is HTML after <head>
195
* 10 is HTML after <body>
198
/* Input stream stack */
199
xmlParserInputPtr input; /* Current input stream */
200
int inputNr; /* Number of current input streams */
201
int inputMax; /* Max number of input streams */
202
xmlParserInputPtr *inputTab; /* stack of inputs */
204
/* Node analysis stack only used for DOM building */
205
xmlNodePtr node; /* Current parsed Node */
206
int nodeNr; /* Depth of the parsing stack */
207
int nodeMax; /* Max depth of the parsing stack */
208
xmlNodePtr *nodeTab; /* array of nodes */
210
int record_info; /* Whether node info should be kept */
211
xmlParserNodeInfoSeq node_seq; /* info about each node parsed */
213
int errNo; /* error code */
215
int hasExternalSubset; /* reference and external subset */
216
int hasPErefs; /* the internal subset has PE refs */
217
int external; /* are we parsing an external entity */
219
int valid; /* is the document valid */
220
int validate; /* shall we try to validate ? */
221
xmlValidCtxt vctxt; /* The validity context */
223
xmlParserInputState instate; /* current type of input */
224
int token; /* next char look-ahead */
226
char *directory; /* the data directory */
228
/* Node name stack */
229
const xmlChar *name; /* Current parsed Node */
230
int nameNr; /* Depth of the parsing stack */
231
int nameMax; /* Max depth of the parsing stack */
232
const xmlChar * *nameTab; /* array of nodes */
234
long nbChars; /* number of xmlChar processed */
235
long checkIndex; /* used by progressive parsing lookup */
236
int keepBlanks; /* ugly but ... */
237
int disableSAX; /* SAX callbacks are disabled */
238
int inSubset; /* Parsing is in int 1/ext 2 subset */
239
const xmlChar * intSubName; /* name of subset */
240
xmlChar * extSubURI; /* URI of external subset */
241
xmlChar * extSubSystem; /* SYSTEM ID of external subset */
243
/* xml:space values */
244
int * space; /* Should the parser preserve spaces */
245
int spaceNr; /* Depth of the parsing stack */
246
int spaceMax; /* Max depth of the parsing stack */
247
int * spaceTab; /* array of space infos */
249
int depth; /* to prevent entity substitution loops */
250
xmlParserInputPtr entity; /* used to check entities boundaries */
251
int charset; /* encoding of the in-memory content
252
actually an xmlCharEncoding */
253
int nodelen; /* Those two fields are there to */
254
int nodemem; /* Speed up large node parsing */
255
int pedantic; /* signal pedantic warnings */
256
void *_private; /* For user data, libxml won't touch it */
258
int loadsubset; /* should the external subset be loaded */
259
int linenumbers; /* set line number in element content */
260
void *catalogs; /* document's own catalog */
261
int recovery; /* run in recovery mode */
262
int progressive; /* is this a progressive parsing */
263
xmlDictPtr dict; /* dictionnary for the parser */
264
const xmlChar * *atts; /* array for the attributes callbacks */
265
int maxatts; /* the size of the array */
266
int docdict; /* use strings from dict to build tree */
269
* pre-interned strings
271
const xmlChar *str_xml;
272
const xmlChar *str_xmlns;
273
const xmlChar *str_xml_ns;
276
* Everything below is used only by the new SAX mode
278
int sax2; /* operating in the new SAX mode */
279
int nsNr; /* the number of inherited namespaces */
280
int nsMax; /* the size of the arrays */
281
const xmlChar * *nsTab; /* the array of prefix/namespace name */
282
int *attallocs; /* which attribute were allocated */
283
void * *pushTab; /* array of data for push */
284
xmlHashTablePtr attsDefault; /* defaulted attributes if any */
285
xmlHashTablePtr attsSpecial; /* non-CDATA attributes if any */
286
int nsWellFormed; /* is the document XML Nanespace okay */
287
int options; /* Extra options */
290
* Those fields are needed only for treaming parsing so far
292
int dictNames; /* Use dictionary names for the tree */
293
int freeElemsNr; /* number of freed element nodes */
294
xmlNodePtr freeElems; /* List of freed element nodes */
295
int freeAttrsNr; /* number of freed attributes nodes */
296
xmlAttrPtr freeAttrs; /* List of freed attributes nodes */
299
* the complete error informations for the last error.
302
xmlParserMode parseMode; /* the parser mode */
303
unsigned long nbentities; /* number of entities references */
304
unsigned long sizeentities; /* size of parsed entities */
306
/* for use by HTML non-recursive parser */
307
xmlParserNodeInfo *nodeInfo; /* Current NodeInfo */
308
int nodeInfoNr; /* Depth of the parsing stack */
309
int nodeInfoMax; /* Max depth of the parsing stack */
310
xmlParserNodeInfo *nodeInfoTab; /* array of nodeInfos */
312
int input_id; /* we need to label inputs */
320
struct _xmlSAXLocator {
321
const xmlChar *(*getPublicId)(void *ctx);
322
const xmlChar *(*getSystemId)(void *ctx);
323
int (*getLineNumber)(void *ctx);
324
int (*getColumnNumber)(void *ctx);
330
* A SAX handler is bunch of callbacks called by the parser when processing
331
* of the input generate data or structure informations.
335
* resolveEntitySAXFunc:
336
* @ctx: the user data (XML parser context)
337
* @publicId: The public ID of the entity
338
* @systemId: The system ID of the entity
341
* The entity loader, to control the loading of external entities,
342
* the application can either:
343
* - override this resolveEntity() callback in the SAX block
344
* - or better use the xmlSetExternalEntityLoader() function to
345
* set up it's own entity resolution routine
347
* Returns the xmlParserInputPtr if inlined or NULL for DOM behaviour.
349
typedef xmlParserInputPtr (*resolveEntitySAXFunc) (void *ctx,
350
const xmlChar *publicId,
351
const xmlChar *systemId);
353
* internalSubsetSAXFunc:
354
* @ctx: the user data (XML parser context)
355
* @name: the root element name
356
* @ExternalID: the external ID
357
* @SystemID: the SYSTEM ID (e.g. filename or URL)
359
* Callback on internal subset declaration.
361
typedef void (*internalSubsetSAXFunc) (void *ctx,
363
const xmlChar *ExternalID,
364
const xmlChar *SystemID);
366
* externalSubsetSAXFunc:
367
* @ctx: the user data (XML parser context)
368
* @name: the root element name
369
* @ExternalID: the external ID
370
* @SystemID: the SYSTEM ID (e.g. filename or URL)
372
* Callback on external subset declaration.
374
typedef void (*externalSubsetSAXFunc) (void *ctx,
376
const xmlChar *ExternalID,
377
const xmlChar *SystemID);
380
* @ctx: the user data (XML parser context)
381
* @name: The entity name
383
* Get an entity by name.
385
* Returns the xmlEntityPtr if found.
387
typedef xmlEntityPtr (*getEntitySAXFunc) (void *ctx,
388
const xmlChar *name);
390
* getParameterEntitySAXFunc:
391
* @ctx: the user data (XML parser context)
392
* @name: The entity name
394
* Get a parameter entity by name.
396
* Returns the xmlEntityPtr if found.
398
typedef xmlEntityPtr (*getParameterEntitySAXFunc) (void *ctx,
399
const xmlChar *name);
402
* @ctx: the user data (XML parser context)
403
* @name: the entity name
404
* @type: the entity type
405
* @publicId: The public ID of the entity
406
* @systemId: The system ID of the entity
407
* @content: the entity value (without processing).
409
* An entity definition has been parsed.
411
typedef void (*entityDeclSAXFunc) (void *ctx,
414
const xmlChar *publicId,
415
const xmlChar *systemId,
418
* notationDeclSAXFunc:
419
* @ctx: the user data (XML parser context)
420
* @name: The name of the notation
421
* @publicId: The public ID of the entity
422
* @systemId: The system ID of the entity
424
* What to do when a notation declaration has been parsed.
426
typedef void (*notationDeclSAXFunc)(void *ctx,
428
const xmlChar *publicId,
429
const xmlChar *systemId);
431
* attributeDeclSAXFunc:
432
* @ctx: the user data (XML parser context)
433
* @elem: the name of the element
434
* @fullname: the attribute name
435
* @type: the attribute type
436
* @def: the type of default value
437
* @defaultValue: the attribute default value
438
* @tree: the tree of enumerated value set
440
* An attribute definition has been parsed.
442
typedef void (*attributeDeclSAXFunc)(void *ctx,
444
const xmlChar *fullname,
447
const xmlChar *defaultValue,
448
xmlEnumerationPtr tree);
450
* elementDeclSAXFunc:
451
* @ctx: the user data (XML parser context)
452
* @name: the element name
453
* @type: the element type
454
* @content: the element value tree
456
* An element definition has been parsed.
458
typedef void (*elementDeclSAXFunc)(void *ctx,
461
xmlElementContentPtr content);
463
* unparsedEntityDeclSAXFunc:
464
* @ctx: the user data (XML parser context)
465
* @name: The name of the entity
466
* @publicId: The public ID of the entity
467
* @systemId: The system ID of the entity
468
* @notationName: the name of the notation
470
* What to do when an unparsed entity declaration is parsed.
472
typedef void (*unparsedEntityDeclSAXFunc)(void *ctx,
474
const xmlChar *publicId,
475
const xmlChar *systemId,
476
const xmlChar *notationName);
478
* setDocumentLocatorSAXFunc:
479
* @ctx: the user data (XML parser context)
480
* @loc: A SAX Locator
482
* Receive the document locator at startup, actually xmlDefaultSAXLocator.
483
* Everything is available on the context, so this is useless in our case.
485
typedef void (*setDocumentLocatorSAXFunc) (void *ctx,
486
xmlSAXLocatorPtr loc);
488
* startDocumentSAXFunc:
489
* @ctx: the user data (XML parser context)
491
* Called when the document start being processed.
493
typedef void (*startDocumentSAXFunc) (void *ctx);
495
* endDocumentSAXFunc:
496
* @ctx: the user data (XML parser context)
498
* Called when the document end has been detected.
500
typedef void (*endDocumentSAXFunc) (void *ctx);
502
* startElementSAXFunc:
503
* @ctx: the user data (XML parser context)
504
* @name: The element name, including namespace prefix
505
* @atts: An array of name/value attributes pairs, NULL terminated
507
* Called when an opening tag has been processed.
509
typedef void (*startElementSAXFunc) (void *ctx,
511
const xmlChar **atts);
514
* @ctx: the user data (XML parser context)
515
* @name: The element name
517
* Called when the end of an element has been detected.
519
typedef void (*endElementSAXFunc) (void *ctx,
520
const xmlChar *name);
523
* @ctx: the user data (XML parser context)
524
* @name: The attribute name, including namespace prefix
525
* @value: The attribute value
527
* Handle an attribute that has been read by the parser.
528
* The default handling is to convert the attribute into an
529
* DOM subtree and past it in a new xmlAttr element added to
532
typedef void (*attributeSAXFunc) (void *ctx,
534
const xmlChar *value);
537
* @ctx: the user data (XML parser context)
538
* @name: The entity name
540
* Called when an entity reference is detected.
542
typedef void (*referenceSAXFunc) (void *ctx,
543
const xmlChar *name);
546
* @ctx: the user data (XML parser context)
547
* @ch: a xmlChar string
548
* @len: the number of xmlChar
550
* Receiving some chars from the parser.
552
typedef void (*charactersSAXFunc) (void *ctx,
556
* ignorableWhitespaceSAXFunc:
557
* @ctx: the user data (XML parser context)
558
* @ch: a xmlChar string
559
* @len: the number of xmlChar
561
* Receiving some ignorable whitespaces from the parser.
562
* UNUSED: by default the DOM building will use characters.
564
typedef void (*ignorableWhitespaceSAXFunc) (void *ctx,
568
* processingInstructionSAXFunc:
569
* @ctx: the user data (XML parser context)
570
* @target: the target name
571
* @data: the PI data's
573
* A processing instruction has been parsed.
575
typedef void (*processingInstructionSAXFunc) (void *ctx,
576
const xmlChar *target,
577
const xmlChar *data);
580
* @ctx: the user data (XML parser context)
581
* @value: the comment content
583
* A comment has been parsed.
585
typedef void (*commentSAXFunc) (void *ctx,
586
const xmlChar *value);
589
* @ctx: the user data (XML parser context)
590
* @value: The pcdata content
591
* @len: the block length
593
* Called when a pcdata block has been parsed.
595
typedef void (*cdataBlockSAXFunc) (
597
const xmlChar *value,
601
* @ctx: an XML parser context
602
* @msg: the message to display/transmit
603
* @...: extra parameters for the message display
605
* Display and format a warning messages, callback.
607
typedef void (XMLCDECL *warningSAXFunc) (void *ctx,
608
const char *msg, ...) LIBXML_ATTR_FORMAT(2,3);
611
* @ctx: an XML parser context
612
* @msg: the message to display/transmit
613
* @...: extra parameters for the message display
615
* Display and format an error messages, callback.
617
typedef void (XMLCDECL *errorSAXFunc) (void *ctx,
618
const char *msg, ...) LIBXML_ATTR_FORMAT(2,3);
621
* @ctx: an XML parser context
622
* @msg: the message to display/transmit
623
* @...: extra parameters for the message display
625
* Display and format fatal error messages, callback.
626
* Note: so far fatalError() SAX callbacks are not used, error()
627
* get all the callbacks for errors.
629
typedef void (XMLCDECL *fatalErrorSAXFunc) (void *ctx,
630
const char *msg, ...) LIBXML_ATTR_FORMAT(2,3);
632
* isStandaloneSAXFunc:
633
* @ctx: the user data (XML parser context)
635
* Is this document tagged standalone?
639
typedef int (*isStandaloneSAXFunc) (void *ctx);
641
* hasInternalSubsetSAXFunc:
642
* @ctx: the user data (XML parser context)
644
* Does this document has an internal subset.
648
typedef int (*hasInternalSubsetSAXFunc) (void *ctx);
651
* hasExternalSubsetSAXFunc:
652
* @ctx: the user data (XML parser context)
654
* Does this document has an external subset?
658
typedef int (*hasExternalSubsetSAXFunc) (void *ctx);
660
/************************************************************************
662
* The SAX version 2 API extensions *
664
************************************************************************/
668
* Special constant found in SAX2 blocks initialized fields
670
#define XML_SAX2_MAGIC 0xDEEDBEAF
673
* startElementNsSAX2Func:
674
* @ctx: the user data (XML parser context)
675
* @localname: the local name of the element
676
* @prefix: the element namespace prefix if available
677
* @URI: the element namespace name if available
678
* @nb_namespaces: number of namespace definitions on that node
679
* @namespaces: pointer to the array of prefix/URI pairs namespace definitions
680
* @nb_attributes: the number of attributes on that node
681
* @nb_defaulted: the number of defaulted attributes. The defaulted
682
* ones are at the end of the array
683
* @attributes: pointer to the array of (localname/prefix/URI/value/end)
686
* SAX2 callback when an element start has been detected by the parser.
687
* It provides the namespace informations for the element, as well as
688
* the new namespace declarations on the element.
691
typedef void (*startElementNsSAX2Func) (void *ctx,
692
const xmlChar *localname,
693
const xmlChar *prefix,
696
const xmlChar **namespaces,
699
const xmlChar **attributes);
702
* endElementNsSAX2Func:
703
* @ctx: the user data (XML parser context)
704
* @localname: the local name of the element
705
* @prefix: the element namespace prefix if available
706
* @URI: the element namespace name if available
708
* SAX2 callback when an element end has been detected by the parser.
709
* It provides the namespace informations for the element.
712
typedef void (*endElementNsSAX2Func) (void *ctx,
713
const xmlChar *localname,
714
const xmlChar *prefix,
718
struct _xmlSAXHandler {
719
internalSubsetSAXFunc internalSubset;
720
isStandaloneSAXFunc isStandalone;
721
hasInternalSubsetSAXFunc hasInternalSubset;
722
hasExternalSubsetSAXFunc hasExternalSubset;
723
resolveEntitySAXFunc resolveEntity;
724
getEntitySAXFunc getEntity;
725
entityDeclSAXFunc entityDecl;
726
notationDeclSAXFunc notationDecl;
727
attributeDeclSAXFunc attributeDecl;
728
elementDeclSAXFunc elementDecl;
729
unparsedEntityDeclSAXFunc unparsedEntityDecl;
730
setDocumentLocatorSAXFunc setDocumentLocator;
731
startDocumentSAXFunc startDocument;
732
endDocumentSAXFunc endDocument;
733
startElementSAXFunc startElement;
734
endElementSAXFunc endElement;
735
referenceSAXFunc reference;
736
charactersSAXFunc characters;
737
ignorableWhitespaceSAXFunc ignorableWhitespace;
738
processingInstructionSAXFunc processingInstruction;
739
commentSAXFunc comment;
740
warningSAXFunc warning;
742
fatalErrorSAXFunc fatalError; /* unused error() get all the errors */
743
getParameterEntitySAXFunc getParameterEntity;
744
cdataBlockSAXFunc cdataBlock;
745
externalSubsetSAXFunc externalSubset;
746
unsigned int initialized;
747
/* The following fields are extensions available only on version 2 */
749
startElementNsSAX2Func startElementNs;
750
endElementNsSAX2Func endElementNs;
751
xmlStructuredErrorFunc serror;
757
typedef struct _xmlSAXHandlerV1 xmlSAXHandlerV1;
758
typedef xmlSAXHandlerV1 *xmlSAXHandlerV1Ptr;
759
struct _xmlSAXHandlerV1 {
760
internalSubsetSAXFunc internalSubset;
761
isStandaloneSAXFunc isStandalone;
762
hasInternalSubsetSAXFunc hasInternalSubset;
763
hasExternalSubsetSAXFunc hasExternalSubset;
764
resolveEntitySAXFunc resolveEntity;
765
getEntitySAXFunc getEntity;
766
entityDeclSAXFunc entityDecl;
767
notationDeclSAXFunc notationDecl;
768
attributeDeclSAXFunc attributeDecl;
769
elementDeclSAXFunc elementDecl;
770
unparsedEntityDeclSAXFunc unparsedEntityDecl;
771
setDocumentLocatorSAXFunc setDocumentLocator;
772
startDocumentSAXFunc startDocument;
773
endDocumentSAXFunc endDocument;
774
startElementSAXFunc startElement;
775
endElementSAXFunc endElement;
776
referenceSAXFunc reference;
777
charactersSAXFunc characters;
778
ignorableWhitespaceSAXFunc ignorableWhitespace;
779
processingInstructionSAXFunc processingInstruction;
780
commentSAXFunc comment;
781
warningSAXFunc warning;
783
fatalErrorSAXFunc fatalError; /* unused error() get all the errors */
784
getParameterEntitySAXFunc getParameterEntity;
785
cdataBlockSAXFunc cdataBlock;
786
externalSubsetSAXFunc externalSubset;
787
unsigned int initialized;
792
* xmlExternalEntityLoader:
793
* @URL: The System ID of the resource requested
794
* @ID: The Public ID of the resource requested
795
* @context: the XML parser context
797
* External entity loaders types.
799
* Returns the entity input parser.
801
typedef xmlParserInputPtr (*xmlExternalEntityLoader) (const char *URL,
803
xmlParserCtxtPtr context);
809
#include <libxml/encoding.h>
810
#include <libxml/xmlIO.h>
811
#include <libxml/globals.h>
821
XMLPUBFUN void XMLCALL
822
xmlInitParser (void);
823
XMLPUBFUN void XMLCALL
824
xmlCleanupParser (void);
829
XMLPUBFUN int XMLCALL
830
xmlParserInputRead (xmlParserInputPtr in,
832
XMLPUBFUN int XMLCALL
833
xmlParserInputGrow (xmlParserInputPtr in,
837
* Basic parsing Interfaces
839
#ifdef LIBXML_SAX1_ENABLED
840
XMLPUBFUN xmlDocPtr XMLCALL
841
xmlParseDoc (const xmlChar *cur);
842
XMLPUBFUN xmlDocPtr XMLCALL
843
xmlParseFile (const char *filename);
844
XMLPUBFUN xmlDocPtr XMLCALL
845
xmlParseMemory (const char *buffer,
847
#endif /* LIBXML_SAX1_ENABLED */
848
XMLPUBFUN int XMLCALL
849
xmlSubstituteEntitiesDefault(int val);
850
XMLPUBFUN int XMLCALL
851
xmlKeepBlanksDefault (int val);
852
XMLPUBFUN void XMLCALL
853
xmlStopParser (xmlParserCtxtPtr ctxt);
854
XMLPUBFUN int XMLCALL
855
xmlPedanticParserDefault(int val);
856
XMLPUBFUN int XMLCALL
857
xmlLineNumbersDefault (int val);
859
#ifdef LIBXML_SAX1_ENABLED
863
XMLPUBFUN xmlDocPtr XMLCALL
864
xmlRecoverDoc (const xmlChar *cur);
865
XMLPUBFUN xmlDocPtr XMLCALL
866
xmlRecoverMemory (const char *buffer,
868
XMLPUBFUN xmlDocPtr XMLCALL
869
xmlRecoverFile (const char *filename);
870
#endif /* LIBXML_SAX1_ENABLED */
873
* Less common routines and SAX interfaces
875
XMLPUBFUN int XMLCALL
876
xmlParseDocument (xmlParserCtxtPtr ctxt);
877
XMLPUBFUN int XMLCALL
878
xmlParseExtParsedEnt (xmlParserCtxtPtr ctxt);
879
#ifdef LIBXML_SAX1_ENABLED
880
XMLPUBFUN int XMLCALL
881
xmlSAXUserParseFile (xmlSAXHandlerPtr sax,
883
const char *filename);
884
XMLPUBFUN int XMLCALL
885
xmlSAXUserParseMemory (xmlSAXHandlerPtr sax,
889
XMLPUBFUN xmlDocPtr XMLCALL
890
xmlSAXParseDoc (xmlSAXHandlerPtr sax,
893
XMLPUBFUN xmlDocPtr XMLCALL
894
xmlSAXParseMemory (xmlSAXHandlerPtr sax,
898
XMLPUBFUN xmlDocPtr XMLCALL
899
xmlSAXParseMemoryWithData (xmlSAXHandlerPtr sax,
904
XMLPUBFUN xmlDocPtr XMLCALL
905
xmlSAXParseFile (xmlSAXHandlerPtr sax,
906
const char *filename,
908
XMLPUBFUN xmlDocPtr XMLCALL
909
xmlSAXParseFileWithData (xmlSAXHandlerPtr sax,
910
const char *filename,
913
XMLPUBFUN xmlDocPtr XMLCALL
914
xmlSAXParseEntity (xmlSAXHandlerPtr sax,
915
const char *filename);
916
XMLPUBFUN xmlDocPtr XMLCALL
917
xmlParseEntity (const char *filename);
918
#endif /* LIBXML_SAX1_ENABLED */
920
#ifdef LIBXML_VALID_ENABLED
921
XMLPUBFUN xmlDtdPtr XMLCALL
922
xmlSAXParseDTD (xmlSAXHandlerPtr sax,
923
const xmlChar *ExternalID,
924
const xmlChar *SystemID);
925
XMLPUBFUN xmlDtdPtr XMLCALL
926
xmlParseDTD (const xmlChar *ExternalID,
927
const xmlChar *SystemID);
928
XMLPUBFUN xmlDtdPtr XMLCALL
929
xmlIOParseDTD (xmlSAXHandlerPtr sax,
930
xmlParserInputBufferPtr input,
931
xmlCharEncoding enc);
932
#endif /* LIBXML_VALID_ENABLE */
933
#ifdef LIBXML_SAX1_ENABLED
934
XMLPUBFUN int XMLCALL
935
xmlParseBalancedChunkMemory(xmlDocPtr doc,
936
xmlSAXHandlerPtr sax,
939
const xmlChar *string,
941
#endif /* LIBXML_SAX1_ENABLED */
942
XMLPUBFUN xmlParserErrors XMLCALL
943
xmlParseInNodeContext (xmlNodePtr node,
948
#ifdef LIBXML_SAX1_ENABLED
949
XMLPUBFUN int XMLCALL
950
xmlParseBalancedChunkMemoryRecover(xmlDocPtr doc,
951
xmlSAXHandlerPtr sax,
954
const xmlChar *string,
957
XMLPUBFUN int XMLCALL
958
xmlParseExternalEntity (xmlDocPtr doc,
959
xmlSAXHandlerPtr sax,
965
#endif /* LIBXML_SAX1_ENABLED */
966
XMLPUBFUN int XMLCALL
967
xmlParseCtxtExternalEntity(xmlParserCtxtPtr ctx,
973
* Parser contexts handling.
975
XMLPUBFUN xmlParserCtxtPtr XMLCALL
976
xmlNewParserCtxt (void);
977
XMLPUBFUN int XMLCALL
978
xmlInitParserCtxt (xmlParserCtxtPtr ctxt);
979
XMLPUBFUN void XMLCALL
980
xmlClearParserCtxt (xmlParserCtxtPtr ctxt);
981
XMLPUBFUN void XMLCALL
982
xmlFreeParserCtxt (xmlParserCtxtPtr ctxt);
983
#ifdef LIBXML_SAX1_ENABLED
984
XMLPUBFUN void XMLCALL
985
xmlSetupParserForBuffer (xmlParserCtxtPtr ctxt,
986
const xmlChar* buffer,
987
const char *filename);
988
#endif /* LIBXML_SAX1_ENABLED */
989
XMLPUBFUN xmlParserCtxtPtr XMLCALL
990
xmlCreateDocParserCtxt (const xmlChar *cur);
992
#ifdef LIBXML_LEGACY_ENABLED
994
* Reading/setting optional parsing features.
996
XMLPUBFUN int XMLCALL
997
xmlGetFeaturesList (int *len,
998
const char **result);
999
XMLPUBFUN int XMLCALL
1000
xmlGetFeature (xmlParserCtxtPtr ctxt,
1003
XMLPUBFUN int XMLCALL
1004
xmlSetFeature (xmlParserCtxtPtr ctxt,
1007
#endif /* LIBXML_LEGACY_ENABLED */
1009
#ifdef LIBXML_PUSH_ENABLED
1011
* Interfaces for the Push mode.
1013
XMLPUBFUN xmlParserCtxtPtr XMLCALL
1014
xmlCreatePushParserCtxt(xmlSAXHandlerPtr sax,
1018
const char *filename);
1019
XMLPUBFUN int XMLCALL
1020
xmlParseChunk (xmlParserCtxtPtr ctxt,
1024
#endif /* LIBXML_PUSH_ENABLED */
1030
XMLPUBFUN xmlParserCtxtPtr XMLCALL
1031
xmlCreateIOParserCtxt (xmlSAXHandlerPtr sax,
1033
xmlInputReadCallback ioread,
1034
xmlInputCloseCallback ioclose,
1036
xmlCharEncoding enc);
1038
XMLPUBFUN xmlParserInputPtr XMLCALL
1039
xmlNewIOInputStream (xmlParserCtxtPtr ctxt,
1040
xmlParserInputBufferPtr input,
1041
xmlCharEncoding enc);
1046
XMLPUBFUN const xmlParserNodeInfo* XMLCALL
1047
xmlParserFindNodeInfo (const xmlParserCtxtPtr ctxt,
1048
const xmlNodePtr node);
1049
XMLPUBFUN void XMLCALL
1050
xmlInitNodeInfoSeq (xmlParserNodeInfoSeqPtr seq);
1051
XMLPUBFUN void XMLCALL
1052
xmlClearNodeInfoSeq (xmlParserNodeInfoSeqPtr seq);
1053
XMLPUBFUN unsigned long XMLCALL
1054
xmlParserFindNodeInfoIndex(const xmlParserNodeInfoSeqPtr seq,
1055
const xmlNodePtr node);
1056
XMLPUBFUN void XMLCALL
1057
xmlParserAddNodeInfo (xmlParserCtxtPtr ctxt,
1058
const xmlParserNodeInfoPtr info);
1061
* External entities handling actually implemented in xmlIO.
1064
XMLPUBFUN void XMLCALL
1065
xmlSetExternalEntityLoader(xmlExternalEntityLoader f);
1066
XMLPUBFUN xmlExternalEntityLoader XMLCALL
1067
xmlGetExternalEntityLoader(void);
1068
XMLPUBFUN xmlParserInputPtr XMLCALL
1069
xmlLoadExternalEntity (const char *URL,
1071
xmlParserCtxtPtr ctxt);
1074
* Index lookup, actually implemented in the encoding module
1076
XMLPUBFUN long XMLCALL
1077
xmlByteConsumed (xmlParserCtxtPtr ctxt);
1080
* New set of simpler/more flexible APIs
1085
* This is the set of XML parser options that can be passed down
1086
* to the xmlReadDoc() and similar calls.
1089
XML_PARSE_RECOVER = 1<<0, /* recover on errors */
1090
XML_PARSE_NOENT = 1<<1, /* substitute entities */
1091
XML_PARSE_DTDLOAD = 1<<2, /* load the external subset */
1092
XML_PARSE_DTDATTR = 1<<3, /* default DTD attributes */
1093
XML_PARSE_DTDVALID = 1<<4, /* validate with the DTD */
1094
XML_PARSE_NOERROR = 1<<5, /* suppress error reports */
1095
XML_PARSE_NOWARNING = 1<<6, /* suppress warning reports */
1096
XML_PARSE_PEDANTIC = 1<<7, /* pedantic error reporting */
1097
XML_PARSE_NOBLANKS = 1<<8, /* remove blank nodes */
1098
XML_PARSE_SAX1 = 1<<9, /* use the SAX1 interface internally */
1099
XML_PARSE_XINCLUDE = 1<<10,/* Implement XInclude substitition */
1100
XML_PARSE_NONET = 1<<11,/* Forbid network access */
1101
XML_PARSE_NODICT = 1<<12,/* Do not reuse the context dictionnary */
1102
XML_PARSE_NSCLEAN = 1<<13,/* remove redundant namespaces declarations */
1103
XML_PARSE_NOCDATA = 1<<14,/* merge CDATA as text nodes */
1104
XML_PARSE_NOXINCNODE= 1<<15,/* do not generate XINCLUDE START/END nodes */
1105
XML_PARSE_COMPACT = 1<<16,/* compact small text nodes; no modification of
1106
the tree allowed afterwards (will possibly
1107
crash if you try to modify the tree) */
1108
XML_PARSE_OLD10 = 1<<17,/* parse using XML-1.0 before update 5 */
1109
XML_PARSE_NOBASEFIX = 1<<18,/* do not fixup XINCLUDE xml:base uris */
1110
XML_PARSE_HUGE = 1<<19,/* relax any hardcoded limit from the parser */
1111
XML_PARSE_OLDSAX = 1<<20,/* parse using SAX2 interface before 2.7.0 */
1112
XML_PARSE_IGNORE_ENC= 1<<21,/* ignore internal document encoding hint */
1113
XML_PARSE_BIG_LINES = 1<<22 /* Store big lines numbers in text PSVI field */
1116
XMLPUBFUN void XMLCALL
1117
xmlCtxtReset (xmlParserCtxtPtr ctxt);
1118
XMLPUBFUN int XMLCALL
1119
xmlCtxtResetPush (xmlParserCtxtPtr ctxt,
1122
const char *filename,
1123
const char *encoding);
1124
XMLPUBFUN int XMLCALL
1125
xmlCtxtUseOptions (xmlParserCtxtPtr ctxt,
1127
XMLPUBFUN xmlDocPtr XMLCALL
1128
xmlReadDoc (const xmlChar *cur,
1130
const char *encoding,
1132
XMLPUBFUN xmlDocPtr XMLCALL
1133
xmlReadFile (const char *URL,
1134
const char *encoding,
1136
XMLPUBFUN xmlDocPtr XMLCALL
1137
xmlReadMemory (const char *buffer,
1140
const char *encoding,
1142
XMLPUBFUN xmlDocPtr XMLCALL
1145
const char *encoding,
1147
XMLPUBFUN xmlDocPtr XMLCALL
1148
xmlReadIO (xmlInputReadCallback ioread,
1149
xmlInputCloseCallback ioclose,
1152
const char *encoding,
1154
XMLPUBFUN xmlDocPtr XMLCALL
1155
xmlCtxtReadDoc (xmlParserCtxtPtr ctxt,
1158
const char *encoding,
1160
XMLPUBFUN xmlDocPtr XMLCALL
1161
xmlCtxtReadFile (xmlParserCtxtPtr ctxt,
1162
const char *filename,
1163
const char *encoding,
1165
XMLPUBFUN xmlDocPtr XMLCALL
1166
xmlCtxtReadMemory (xmlParserCtxtPtr ctxt,
1170
const char *encoding,
1172
XMLPUBFUN xmlDocPtr XMLCALL
1173
xmlCtxtReadFd (xmlParserCtxtPtr ctxt,
1176
const char *encoding,
1178
XMLPUBFUN xmlDocPtr XMLCALL
1179
xmlCtxtReadIO (xmlParserCtxtPtr ctxt,
1180
xmlInputReadCallback ioread,
1181
xmlInputCloseCallback ioclose,
1184
const char *encoding,
1188
* Library wide options
1193
* Used to examine the existance of features that can be enabled
1194
* or disabled at compile-time.
1195
* They used to be called XML_FEATURE_xxx but this clashed with Expat
1198
XML_WITH_THREAD = 1,
1200
XML_WITH_OUTPUT = 3,
1202
XML_WITH_READER = 5,
1203
XML_WITH_PATTERN = 6,
1204
XML_WITH_WRITER = 7,
1208
XML_WITH_VALID = 11,
1210
XML_WITH_LEGACY = 13,
1212
XML_WITH_CATALOG = 15,
1213
XML_WITH_XPATH = 16,
1215
XML_WITH_XINCLUDE = 18,
1216
XML_WITH_ICONV = 19,
1217
XML_WITH_ISO8859X = 20,
1218
XML_WITH_UNICODE = 21,
1219
XML_WITH_REGEXP = 22,
1220
XML_WITH_AUTOMATA = 23,
1222
XML_WITH_SCHEMAS = 25,
1223
XML_WITH_SCHEMATRON = 26,
1224
XML_WITH_MODULES = 27,
1225
XML_WITH_DEBUG = 28,
1226
XML_WITH_DEBUG_MEM = 29,
1227
XML_WITH_DEBUG_RUN = 30,
1231
XML_WITH_NONE = 99999 /* just to be sure of allocation size */
1234
XMLPUBFUN int XMLCALL
1235
xmlHasFeature (xmlFeature feature);
1240
#endif /* __XML_PARSER_H__ */