VirtualBox

source: vbox/trunk/src/libs/libxml2-2.6.30/include/libxml/parser.h@ 31566

Last change on this file since 31566 was 16778, checked in by vboxsync, 16 years ago

libxml2: some fixes from upstream

  • Property svn:eol-style set to native
  • Property svn:keywords set to Date Revision Author Id
File size: 37.7 KB
Line 
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#include <stdarg.h>
14
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>
23
24#ifdef __cplusplus
25extern "C" {
26#endif
27
28/**
29 * XML_DEFAULT_VERSION:
30 *
31 * The default version of XML used: 1.0
32 */
33#define XML_DEFAULT_VERSION "1.0"
34
35/**
36 * xmlParserInput:
37 *
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.
44 */
45
46/**
47 * xmlParserInputDeallocate:
48 * @str: the string to deallocate
49 *
50 * Callback for freeing some parser input allocations.
51 */
52typedef void (* xmlParserInputDeallocate)(xmlChar *str);
53
54struct _xmlParserInput {
55 /* Input buffer */
56 xmlParserInputBufferPtr buf; /* UTF-8 encoded buffer */
57
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 */
66 /*
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.
70 */
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 */
77};
78
79/**
80 * xmlParserNodeInfo:
81 *
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.
85 */
86typedef struct _xmlParserNodeInfo xmlParserNodeInfo;
87typedef xmlParserNodeInfo *xmlParserNodeInfoPtr;
88
89struct _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;
96};
97
98typedef struct _xmlParserNodeInfoSeq xmlParserNodeInfoSeq;
99typedef xmlParserNodeInfoSeq *xmlParserNodeInfoSeqPtr;
100struct _xmlParserNodeInfoSeq {
101 unsigned long maximum;
102 unsigned long length;
103 xmlParserNodeInfo* buffer;
104};
105
106/**
107 * xmlParserInputState:
108 *
109 * The parser is now working also as a state based parser.
110 * The recursive one use the state info for entities processing.
111 */
112typedef enum {
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;
132
133/**
134 * XML_DETECT_IDS:
135 *
136 * Bit in the loadsubset context field to tell to do ID/REFs lookups.
137 * Use it to initialize xmlLoadExtDtdDefaultValue.
138 */
139#define XML_DETECT_IDS 2
140
141/**
142 * XML_COMPLETE_ATTRS:
143 *
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.
147 */
148#define XML_COMPLETE_ATTRS 4
149
150/**
151 * XML_SKIP_IDS:
152 *
153 * Bit in the loadsubset context field to tell to not do ID/REFs registration.
154 * Used to initialize xmlLoadExtDtdDefaultValue in some special cases.
155 */
156#define XML_SKIP_IDS 8
157
158/**
159 * xmlParserMode:
160 *
161 * A parser can operate in various modes
162 */
163typedef enum {
164 XML_PARSE_UNKNOWN = 0,
165 XML_PARSE_DOM = 1,
166 XML_PARSE_SAX = 2,
167 XML_PARSE_PUSH_DOM = 3,
168 XML_PARSE_PUSH_SAX = 4,
169 XML_PARSE_READER = 5
170} xmlParserMode;
171
172/**
173 * xmlParserCtxt:
174 *
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.
183 */
184struct _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
195 /* Input stream stack */
196 xmlParserInputPtr input; /* Current input stream */
197 int inputNr; /* Number of current input streams */
198 int inputMax; /* Max number of input streams */
199 xmlParserInputPtr *inputTab; /* stack of inputs */
200
201 /* Node analysis stack only used for DOM building */
202 xmlNodePtr node; /* Current parsed Node */
203 int nodeNr; /* Depth of the parsing stack */
204 int nodeMax; /* Max depth of the parsing stack */
205 xmlNodePtr *nodeTab; /* array of nodes */
206
207 int record_info; /* Whether node info should be kept */
208 xmlParserNodeInfoSeq node_seq; /* info about each node parsed */
209
210 int errNo; /* error code */
211
212 int hasExternalSubset; /* reference and external subset */
213 int hasPErefs; /* the internal subset has PE refs */
214 int external; /* are we parsing an external entity */
215
216 int valid; /* is the document valid */
217 int validate; /* shall we try to validate ? */
218 xmlValidCtxt vctxt; /* The validity context */
219
220 xmlParserInputState instate; /* current type of input */
221 int token; /* next char look-ahead */
222
223 char *directory; /* the data directory */
224
225 /* Node name stack */
226 const xmlChar *name; /* Current parsed Node */
227 int nameNr; /* Depth of the parsing stack */
228 int nameMax; /* Max depth of the parsing stack */
229 const xmlChar * *nameTab; /* array of nodes */
230
231 long nbChars; /* number of xmlChar processed */
232 long checkIndex; /* used by progressive parsing lookup */
233 int keepBlanks; /* ugly but ... */
234 int disableSAX; /* SAX callbacks are disabled */
235 int inSubset; /* Parsing is in int 1/ext 2 subset */
236 const xmlChar * intSubName; /* name of subset */
237 xmlChar * extSubURI; /* URI of external subset */
238 xmlChar * extSubSystem; /* SYSTEM ID of external subset */
239
240 /* xml:space values */
241 int * space; /* Should the parser preserve spaces */
242 int spaceNr; /* Depth of the parsing stack */
243 int spaceMax; /* Max depth of the parsing stack */
244 int * spaceTab; /* array of space infos */
245
246 int depth; /* to prevent entity substitution loops */
247 xmlParserInputPtr entity; /* used to check entities boundaries */
248 int charset; /* encoding of the in-memory content
249 actually an xmlCharEncoding */
250 int nodelen; /* Those two fields are there to */
251 int nodemem; /* Speed up large node parsing */
252 int pedantic; /* signal pedantic warnings */
253 void *_private; /* For user data, libxml won't touch it */
254
255 int loadsubset; /* should the external subset be loaded */
256 int linenumbers; /* set line number in element content */
257 void *catalogs; /* document's own catalog */
258 int recovery; /* run in recovery mode */
259 int progressive; /* is this a progressive parsing */
260 xmlDictPtr dict; /* dictionnary for the parser */
261 const xmlChar * *atts; /* array for the attributes callbacks */
262 int maxatts; /* the size of the array */
263 int docdict; /* use strings from dict to build tree */
264
265 /*
266 * pre-interned strings
267 */
268 const xmlChar *str_xml;
269 const xmlChar *str_xmlns;
270 const xmlChar *str_xml_ns;
271
272 /*
273 * Everything below is used only by the new SAX mode
274 */
275 int sax2; /* operating in the new SAX mode */
276 int nsNr; /* the number of inherited namespaces */
277 int nsMax; /* the size of the arrays */
278 const xmlChar * *nsTab; /* the array of prefix/namespace name */
279 int *attallocs; /* which attribute were allocated */
280 void * *pushTab; /* array of data for push */
281 xmlHashTablePtr attsDefault; /* defaulted attributes if any */
282 xmlHashTablePtr attsSpecial; /* non-CDATA attributes if any */
283 int nsWellFormed; /* is the document XML Nanespace okay */
284 int options; /* Extra options */
285
286 /*
287 * Those fields are needed only for treaming parsing so far
288 */
289 int dictNames; /* Use dictionary names for the tree */
290 int freeElemsNr; /* number of freed element nodes */
291 xmlNodePtr freeElems; /* List of freed element nodes */
292 int freeAttrsNr; /* number of freed attributes nodes */
293 xmlAttrPtr freeAttrs; /* List of freed attributes nodes */
294
295 /*
296 * the complete error informations for the last error.
297 */
298 xmlError lastError;
299 xmlParserMode parseMode; /* the parser mode */
300 unsigned long nbentities; /* number of entities references */
301};
302
303/**
304 * xmlSAXLocator:
305 *
306 * A SAX Locator.
307 */
308struct _xmlSAXLocator {
309 const xmlChar *(*getPublicId)(void *ctx);
310 const xmlChar *(*getSystemId)(void *ctx);
311 int (*getLineNumber)(void *ctx);
312 int (*getColumnNumber)(void *ctx);
313};
314
315/**
316 * xmlSAXHandler:
317 *
318 * A SAX handler is bunch of callbacks called by the parser when processing
319 * of the input generate data or structure informations.
320 */
321
322/**
323 * resolveEntitySAXFunc:
324 * @ctx: the user data (XML parser context)
325 * @publicId: The public ID of the entity
326 * @systemId: The system ID of the entity
327 *
328 * Callback:
329 * The entity loader, to control the loading of external entities,
330 * the application can either:
331 * - override this resolveEntity() callback in the SAX block
332 * - or better use the xmlSetExternalEntityLoader() function to
333 * set up it's own entity resolution routine
334 *
335 * Returns the xmlParserInputPtr if inlined or NULL for DOM behaviour.
336 */
337typedef xmlParserInputPtr (*resolveEntitySAXFunc) (void *ctx,
338 const xmlChar *publicId,
339 const xmlChar *systemId);
340/**
341 * internalSubsetSAXFunc:
342 * @ctx: the user data (XML parser context)
343 * @name: the root element name
344 * @ExternalID: the external ID
345 * @SystemID: the SYSTEM ID (e.g. filename or URL)
346 *
347 * Callback on internal subset declaration.
348 */
349typedef void (*internalSubsetSAXFunc) (void *ctx,
350 const xmlChar *name,
351 const xmlChar *ExternalID,
352 const xmlChar *SystemID);
353/**
354 * externalSubsetSAXFunc:
355 * @ctx: the user data (XML parser context)
356 * @name: the root element name
357 * @ExternalID: the external ID
358 * @SystemID: the SYSTEM ID (e.g. filename or URL)
359 *
360 * Callback on external subset declaration.
361 */
362typedef void (*externalSubsetSAXFunc) (void *ctx,
363 const xmlChar *name,
364 const xmlChar *ExternalID,
365 const xmlChar *SystemID);
366/**
367 * getEntitySAXFunc:
368 * @ctx: the user data (XML parser context)
369 * @name: The entity name
370 *
371 * Get an entity by name.
372 *
373 * Returns the xmlEntityPtr if found.
374 */
375typedef xmlEntityPtr (*getEntitySAXFunc) (void *ctx,
376 const xmlChar *name);
377/**
378 * getParameterEntitySAXFunc:
379 * @ctx: the user data (XML parser context)
380 * @name: The entity name
381 *
382 * Get a parameter entity by name.
383 *
384 * Returns the xmlEntityPtr if found.
385 */
386typedef xmlEntityPtr (*getParameterEntitySAXFunc) (void *ctx,
387 const xmlChar *name);
388/**
389 * entityDeclSAXFunc:
390 * @ctx: the user data (XML parser context)
391 * @name: the entity name
392 * @type: the entity type
393 * @publicId: The public ID of the entity
394 * @systemId: The system ID of the entity
395 * @content: the entity value (without processing).
396 *
397 * An entity definition has been parsed.
398 */
399typedef void (*entityDeclSAXFunc) (void *ctx,
400 const xmlChar *name,
401 int type,
402 const xmlChar *publicId,
403 const xmlChar *systemId,
404 xmlChar *content);
405/**
406 * notationDeclSAXFunc:
407 * @ctx: the user data (XML parser context)
408 * @name: The name of the notation
409 * @publicId: The public ID of the entity
410 * @systemId: The system ID of the entity
411 *
412 * What to do when a notation declaration has been parsed.
413 */
414typedef void (*notationDeclSAXFunc)(void *ctx,
415 const xmlChar *name,
416 const xmlChar *publicId,
417 const xmlChar *systemId);
418/**
419 * attributeDeclSAXFunc:
420 * @ctx: the user data (XML parser context)
421 * @elem: the name of the element
422 * @fullname: the attribute name
423 * @type: the attribute type
424 * @def: the type of default value
425 * @defaultValue: the attribute default value
426 * @tree: the tree of enumerated value set
427 *
428 * An attribute definition has been parsed.
429 */
430typedef void (*attributeDeclSAXFunc)(void *ctx,
431 const xmlChar *elem,
432 const xmlChar *fullname,
433 int type,
434 int def,
435 const xmlChar *defaultValue,
436 xmlEnumerationPtr tree);
437/**
438 * elementDeclSAXFunc:
439 * @ctx: the user data (XML parser context)
440 * @name: the element name
441 * @type: the element type
442 * @content: the element value tree
443 *
444 * An element definition has been parsed.
445 */
446typedef void (*elementDeclSAXFunc)(void *ctx,
447 const xmlChar *name,
448 int type,
449 xmlElementContentPtr content);
450/**
451 * unparsedEntityDeclSAXFunc:
452 * @ctx: the user data (XML parser context)
453 * @name: The name of the entity
454 * @publicId: The public ID of the entity
455 * @systemId: The system ID of the entity
456 * @notationName: the name of the notation
457 *
458 * What to do when an unparsed entity declaration is parsed.
459 */
460typedef void (*unparsedEntityDeclSAXFunc)(void *ctx,
461 const xmlChar *name,
462 const xmlChar *publicId,
463 const xmlChar *systemId,
464 const xmlChar *notationName);
465/**
466 * setDocumentLocatorSAXFunc:
467 * @ctx: the user data (XML parser context)
468 * @loc: A SAX Locator
469 *
470 * Receive the document locator at startup, actually xmlDefaultSAXLocator.
471 * Everything is available on the context, so this is useless in our case.
472 */
473typedef void (*setDocumentLocatorSAXFunc) (void *ctx,
474 xmlSAXLocatorPtr loc);
475/**
476 * startDocumentSAXFunc:
477 * @ctx: the user data (XML parser context)
478 *
479 * Called when the document start being processed.
480 */
481typedef void (*startDocumentSAXFunc) (void *ctx);
482/**
483 * endDocumentSAXFunc:
484 * @ctx: the user data (XML parser context)
485 *
486 * Called when the document end has been detected.
487 */
488typedef void (*endDocumentSAXFunc) (void *ctx);
489/**
490 * startElementSAXFunc:
491 * @ctx: the user data (XML parser context)
492 * @name: The element name, including namespace prefix
493 * @atts: An array of name/value attributes pairs, NULL terminated
494 *
495 * Called when an opening tag has been processed.
496 */
497typedef void (*startElementSAXFunc) (void *ctx,
498 const xmlChar *name,
499 const xmlChar **atts);
500/**
501 * endElementSAXFunc:
502 * @ctx: the user data (XML parser context)
503 * @name: The element name
504 *
505 * Called when the end of an element has been detected.
506 */
507typedef void (*endElementSAXFunc) (void *ctx,
508 const xmlChar *name);
509/**
510 * attributeSAXFunc:
511 * @ctx: the user data (XML parser context)
512 * @name: The attribute name, including namespace prefix
513 * @value: The attribute value
514 *
515 * Handle an attribute that has been read by the parser.
516 * The default handling is to convert the attribute into an
517 * DOM subtree and past it in a new xmlAttr element added to
518 * the element.
519 */
520typedef void (*attributeSAXFunc) (void *ctx,
521 const xmlChar *name,
522 const xmlChar *value);
523/**
524 * referenceSAXFunc:
525 * @ctx: the user data (XML parser context)
526 * @name: The entity name
527 *
528 * Called when an entity reference is detected.
529 */
530typedef void (*referenceSAXFunc) (void *ctx,
531 const xmlChar *name);
532/**
533 * charactersSAXFunc:
534 * @ctx: the user data (XML parser context)
535 * @ch: a xmlChar string
536 * @len: the number of xmlChar
537 *
538 * Receiving some chars from the parser.
539 */
540typedef void (*charactersSAXFunc) (void *ctx,
541 const xmlChar *ch,
542 int len);
543/**
544 * ignorableWhitespaceSAXFunc:
545 * @ctx: the user data (XML parser context)
546 * @ch: a xmlChar string
547 * @len: the number of xmlChar
548 *
549 * Receiving some ignorable whitespaces from the parser.
550 * UNUSED: by default the DOM building will use characters.
551 */
552typedef void (*ignorableWhitespaceSAXFunc) (void *ctx,
553 const xmlChar *ch,
554 int len);
555/**
556 * processingInstructionSAXFunc:
557 * @ctx: the user data (XML parser context)
558 * @target: the target name
559 * @data: the PI data's
560 *
561 * A processing instruction has been parsed.
562 */
563typedef void (*processingInstructionSAXFunc) (void *ctx,
564 const xmlChar *target,
565 const xmlChar *data);
566/**
567 * commentSAXFunc:
568 * @ctx: the user data (XML parser context)
569 * @value: the comment content
570 *
571 * A comment has been parsed.
572 */
573typedef void (*commentSAXFunc) (void *ctx,
574 const xmlChar *value);
575/**
576 * cdataBlockSAXFunc:
577 * @ctx: the user data (XML parser context)
578 * @value: The pcdata content
579 * @len: the block length
580 *
581 * Called when a pcdata block has been parsed.
582 */
583typedef void (*cdataBlockSAXFunc) (
584 void *ctx,
585 const xmlChar *value,
586 int len);
587/**
588 * warningSAXFunc:
589 * @ctx: an XML parser context
590 * @msg: the message to display/transmit
591 * @...: extra parameters for the message display
592 *
593 * Display and format a warning messages, callback.
594 */
595typedef void (XMLCDECL *warningSAXFunc) (void *ctx,
596 const char *msg, ...);
597/**
598 * errorSAXFunc:
599 * @ctx: an XML parser context
600 * @msg: the message to display/transmit
601 * @...: extra parameters for the message display
602 *
603 * Display and format an error messages, callback.
604 */
605typedef void (XMLCDECL *errorSAXFunc) (void *ctx,
606 const char *msg, ...);
607/**
608 * fatalErrorSAXFunc:
609 * @ctx: an XML parser context
610 * @msg: the message to display/transmit
611 * @...: extra parameters for the message display
612 *
613 * Display and format fatal error messages, callback.
614 * Note: so far fatalError() SAX callbacks are not used, error()
615 * get all the callbacks for errors.
616 */
617typedef void (XMLCDECL *fatalErrorSAXFunc) (void *ctx,
618 const char *msg, ...);
619/**
620 * isStandaloneSAXFunc:
621 * @ctx: the user data (XML parser context)
622 *
623 * Is this document tagged standalone?
624 *
625 * Returns 1 if true
626 */
627typedef int (*isStandaloneSAXFunc) (void *ctx);
628/**
629 * hasInternalSubsetSAXFunc:
630 * @ctx: the user data (XML parser context)
631 *
632 * Does this document has an internal subset.
633 *
634 * Returns 1 if true
635 */
636typedef int (*hasInternalSubsetSAXFunc) (void *ctx);
637
638/**
639 * hasExternalSubsetSAXFunc:
640 * @ctx: the user data (XML parser context)
641 *
642 * Does this document has an external subset?
643 *
644 * Returns 1 if true
645 */
646typedef int (*hasExternalSubsetSAXFunc) (void *ctx);
647
648/************************************************************************
649 * *
650 * The SAX version 2 API extensions *
651 * *
652 ************************************************************************/
653/**
654 * XML_SAX2_MAGIC:
655 *
656 * Special constant found in SAX2 blocks initialized fields
657 */
658#define XML_SAX2_MAGIC 0xDEEDBEAF
659
660/**
661 * startElementNsSAX2Func:
662 * @ctx: the user data (XML parser context)
663 * @localname: the local name of the element
664 * @prefix: the element namespace prefix if available
665 * @URI: the element namespace name if available
666 * @nb_namespaces: number of namespace definitions on that node
667 * @namespaces: pointer to the array of prefix/URI pairs namespace definitions
668 * @nb_attributes: the number of attributes on that node
669 * @nb_defaulted: the number of defaulted attributes. The defaulted
670 * ones are at the end of the array
671 * @attributes: pointer to the array of (localname/prefix/URI/value/end)
672 * attribute values.
673 *
674 * SAX2 callback when an element start has been detected by the parser.
675 * It provides the namespace informations for the element, as well as
676 * the new namespace declarations on the element.
677 */
678
679typedef void (*startElementNsSAX2Func) (void *ctx,
680 const xmlChar *localname,
681 const xmlChar *prefix,
682 const xmlChar *URI,
683 int nb_namespaces,
684 const xmlChar **namespaces,
685 int nb_attributes,
686 int nb_defaulted,
687 const xmlChar **attributes);
688
689/**
690 * endElementNsSAX2Func:
691 * @ctx: the user data (XML parser context)
692 * @localname: the local name of the element
693 * @prefix: the element namespace prefix if available
694 * @URI: the element namespace name if available
695 *
696 * SAX2 callback when an element end has been detected by the parser.
697 * It provides the namespace informations for the element.
698 */
699
700typedef void (*endElementNsSAX2Func) (void *ctx,
701 const xmlChar *localname,
702 const xmlChar *prefix,
703 const xmlChar *URI);
704
705
706struct _xmlSAXHandler {
707 internalSubsetSAXFunc internalSubset;
708 isStandaloneSAXFunc isStandalone;
709 hasInternalSubsetSAXFunc hasInternalSubset;
710 hasExternalSubsetSAXFunc hasExternalSubset;
711 resolveEntitySAXFunc resolveEntity;
712 getEntitySAXFunc getEntity;
713 entityDeclSAXFunc entityDecl;
714 notationDeclSAXFunc notationDecl;
715 attributeDeclSAXFunc attributeDecl;
716 elementDeclSAXFunc elementDecl;
717 unparsedEntityDeclSAXFunc unparsedEntityDecl;
718 setDocumentLocatorSAXFunc setDocumentLocator;
719 startDocumentSAXFunc startDocument;
720 endDocumentSAXFunc endDocument;
721 startElementSAXFunc startElement;
722 endElementSAXFunc endElement;
723 referenceSAXFunc reference;
724 charactersSAXFunc characters;
725 ignorableWhitespaceSAXFunc ignorableWhitespace;
726 processingInstructionSAXFunc processingInstruction;
727 commentSAXFunc comment;
728 warningSAXFunc warning;
729 errorSAXFunc error;
730 fatalErrorSAXFunc fatalError; /* unused error() get all the errors */
731 getParameterEntitySAXFunc getParameterEntity;
732 cdataBlockSAXFunc cdataBlock;
733 externalSubsetSAXFunc externalSubset;
734 unsigned int initialized;
735 /* The following fields are extensions available only on version 2 */
736 void *_private;
737 startElementNsSAX2Func startElementNs;
738 endElementNsSAX2Func endElementNs;
739 xmlStructuredErrorFunc serror;
740};
741
742/*
743 * SAX Version 1
744 */
745typedef struct _xmlSAXHandlerV1 xmlSAXHandlerV1;
746typedef xmlSAXHandlerV1 *xmlSAXHandlerV1Ptr;
747struct _xmlSAXHandlerV1 {
748 internalSubsetSAXFunc internalSubset;
749 isStandaloneSAXFunc isStandalone;
750 hasInternalSubsetSAXFunc hasInternalSubset;
751 hasExternalSubsetSAXFunc hasExternalSubset;
752 resolveEntitySAXFunc resolveEntity;
753 getEntitySAXFunc getEntity;
754 entityDeclSAXFunc entityDecl;
755 notationDeclSAXFunc notationDecl;
756 attributeDeclSAXFunc attributeDecl;
757 elementDeclSAXFunc elementDecl;
758 unparsedEntityDeclSAXFunc unparsedEntityDecl;
759 setDocumentLocatorSAXFunc setDocumentLocator;
760 startDocumentSAXFunc startDocument;
761 endDocumentSAXFunc endDocument;
762 startElementSAXFunc startElement;
763 endElementSAXFunc endElement;
764 referenceSAXFunc reference;
765 charactersSAXFunc characters;
766 ignorableWhitespaceSAXFunc ignorableWhitespace;
767 processingInstructionSAXFunc processingInstruction;
768 commentSAXFunc comment;
769 warningSAXFunc warning;
770 errorSAXFunc error;
771 fatalErrorSAXFunc fatalError; /* unused error() get all the errors */
772 getParameterEntitySAXFunc getParameterEntity;
773 cdataBlockSAXFunc cdataBlock;
774 externalSubsetSAXFunc externalSubset;
775 unsigned int initialized;
776};
777
778
779/**
780 * xmlExternalEntityLoader:
781 * @URL: The System ID of the resource requested
782 * @ID: The Public ID of the resource requested
783 * @context: the XML parser context
784 *
785 * External entity loaders types.
786 *
787 * Returns the entity input parser.
788 */
789typedef xmlParserInputPtr (*xmlExternalEntityLoader) (const char *URL,
790 const char *ID,
791 xmlParserCtxtPtr context);
792
793#ifdef __cplusplus
794}
795#endif
796
797#include <libxml/encoding.h>
798#include <libxml/xmlIO.h>
799#include <libxml/globals.h>
800
801#ifdef __cplusplus
802extern "C" {
803#endif
804
805
806/*
807 * Init/Cleanup
808 */
809XMLPUBFUN void XMLCALL
810 xmlInitParser (void);
811XMLPUBFUN void XMLCALL
812 xmlCleanupParser (void);
813
814/*
815 * Input functions
816 */
817XMLPUBFUN int XMLCALL
818 xmlParserInputRead (xmlParserInputPtr in,
819 int len);
820XMLPUBFUN int XMLCALL
821 xmlParserInputGrow (xmlParserInputPtr in,
822 int len);
823
824/*
825 * Basic parsing Interfaces
826 */
827#ifdef LIBXML_SAX1_ENABLED
828XMLPUBFUN xmlDocPtr XMLCALL
829 xmlParseDoc (const xmlChar *cur);
830XMLPUBFUN xmlDocPtr XMLCALL
831 xmlParseFile (const char *filename);
832XMLPUBFUN xmlDocPtr XMLCALL
833 xmlParseMemory (const char *buffer,
834 int size);
835#endif /* LIBXML_SAX1_ENABLED */
836XMLPUBFUN int XMLCALL
837 xmlSubstituteEntitiesDefault(int val);
838XMLPUBFUN int XMLCALL
839 xmlKeepBlanksDefault (int val);
840XMLPUBFUN void XMLCALL
841 xmlStopParser (xmlParserCtxtPtr ctxt);
842XMLPUBFUN int XMLCALL
843 xmlPedanticParserDefault(int val);
844XMLPUBFUN int XMLCALL
845 xmlLineNumbersDefault (int val);
846
847#ifdef LIBXML_SAX1_ENABLED
848/*
849 * Recovery mode
850 */
851XMLPUBFUN xmlDocPtr XMLCALL
852 xmlRecoverDoc (xmlChar *cur);
853XMLPUBFUN xmlDocPtr XMLCALL
854 xmlRecoverMemory (const char *buffer,
855 int size);
856XMLPUBFUN xmlDocPtr XMLCALL
857 xmlRecoverFile (const char *filename);
858#endif /* LIBXML_SAX1_ENABLED */
859
860/*
861 * Less common routines and SAX interfaces
862 */
863XMLPUBFUN int XMLCALL
864 xmlParseDocument (xmlParserCtxtPtr ctxt);
865XMLPUBFUN int XMLCALL
866 xmlParseExtParsedEnt (xmlParserCtxtPtr ctxt);
867#ifdef LIBXML_SAX1_ENABLED
868XMLPUBFUN int XMLCALL
869 xmlSAXUserParseFile (xmlSAXHandlerPtr sax,
870 void *user_data,
871 const char *filename);
872XMLPUBFUN int XMLCALL
873 xmlSAXUserParseMemory (xmlSAXHandlerPtr sax,
874 void *user_data,
875 const char *buffer,
876 int size);
877XMLPUBFUN xmlDocPtr XMLCALL
878 xmlSAXParseDoc (xmlSAXHandlerPtr sax,
879 const xmlChar *cur,
880 int recovery);
881XMLPUBFUN xmlDocPtr XMLCALL
882 xmlSAXParseMemory (xmlSAXHandlerPtr sax,
883 const char *buffer,
884 int size,
885 int recovery);
886XMLPUBFUN xmlDocPtr XMLCALL
887 xmlSAXParseMemoryWithData (xmlSAXHandlerPtr sax,
888 const char *buffer,
889 int size,
890 int recovery,
891 void *data);
892XMLPUBFUN xmlDocPtr XMLCALL
893 xmlSAXParseFile (xmlSAXHandlerPtr sax,
894 const char *filename,
895 int recovery);
896XMLPUBFUN xmlDocPtr XMLCALL
897 xmlSAXParseFileWithData (xmlSAXHandlerPtr sax,
898 const char *filename,
899 int recovery,
900 void *data);
901XMLPUBFUN xmlDocPtr XMLCALL
902 xmlSAXParseEntity (xmlSAXHandlerPtr sax,
903 const char *filename);
904XMLPUBFUN xmlDocPtr XMLCALL
905 xmlParseEntity (const char *filename);
906#endif /* LIBXML_SAX1_ENABLED */
907
908#ifdef LIBXML_VALID_ENABLED
909XMLPUBFUN xmlDtdPtr XMLCALL
910 xmlSAXParseDTD (xmlSAXHandlerPtr sax,
911 const xmlChar *ExternalID,
912 const xmlChar *SystemID);
913XMLPUBFUN xmlDtdPtr XMLCALL
914 xmlParseDTD (const xmlChar *ExternalID,
915 const xmlChar *SystemID);
916XMLPUBFUN xmlDtdPtr XMLCALL
917 xmlIOParseDTD (xmlSAXHandlerPtr sax,
918 xmlParserInputBufferPtr input,
919 xmlCharEncoding enc);
920#endif /* LIBXML_VALID_ENABLE */
921#ifdef LIBXML_SAX1_ENABLED
922XMLPUBFUN int XMLCALL
923 xmlParseBalancedChunkMemory(xmlDocPtr doc,
924 xmlSAXHandlerPtr sax,
925 void *user_data,
926 int depth,
927 const xmlChar *string,
928 xmlNodePtr *lst);
929#endif /* LIBXML_SAX1_ENABLED */
930XMLPUBFUN xmlParserErrors XMLCALL
931 xmlParseInNodeContext (xmlNodePtr node,
932 const char *data,
933 int datalen,
934 int options,
935 xmlNodePtr *lst);
936#ifdef LIBXML_SAX1_ENABLED
937XMLPUBFUN int XMLCALL
938 xmlParseBalancedChunkMemoryRecover(xmlDocPtr doc,
939 xmlSAXHandlerPtr sax,
940 void *user_data,
941 int depth,
942 const xmlChar *string,
943 xmlNodePtr *lst,
944 int recover);
945XMLPUBFUN int XMLCALL
946 xmlParseExternalEntity (xmlDocPtr doc,
947 xmlSAXHandlerPtr sax,
948 void *user_data,
949 int depth,
950 const xmlChar *URL,
951 const xmlChar *ID,
952 xmlNodePtr *lst);
953#endif /* LIBXML_SAX1_ENABLED */
954XMLPUBFUN int XMLCALL
955 xmlParseCtxtExternalEntity(xmlParserCtxtPtr ctx,
956 const xmlChar *URL,
957 const xmlChar *ID,
958 xmlNodePtr *lst);
959
960/*
961 * Parser contexts handling.
962 */
963XMLPUBFUN xmlParserCtxtPtr XMLCALL
964 xmlNewParserCtxt (void);
965XMLPUBFUN int XMLCALL
966 xmlInitParserCtxt (xmlParserCtxtPtr ctxt);
967XMLPUBFUN void XMLCALL
968 xmlClearParserCtxt (xmlParserCtxtPtr ctxt);
969XMLPUBFUN void XMLCALL
970 xmlFreeParserCtxt (xmlParserCtxtPtr ctxt);
971#ifdef LIBXML_SAX1_ENABLED
972XMLPUBFUN void XMLCALL
973 xmlSetupParserForBuffer (xmlParserCtxtPtr ctxt,
974 const xmlChar* buffer,
975 const char *filename);
976#endif /* LIBXML_SAX1_ENABLED */
977XMLPUBFUN xmlParserCtxtPtr XMLCALL
978 xmlCreateDocParserCtxt (const xmlChar *cur);
979
980#ifdef LIBXML_LEGACY_ENABLED
981/*
982 * Reading/setting optional parsing features.
983 */
984XMLPUBFUN int XMLCALL
985 xmlGetFeaturesList (int *len,
986 const char **result);
987XMLPUBFUN int XMLCALL
988 xmlGetFeature (xmlParserCtxtPtr ctxt,
989 const char *name,
990 void *result);
991XMLPUBFUN int XMLCALL
992 xmlSetFeature (xmlParserCtxtPtr ctxt,
993 const char *name,
994 void *value);
995#endif /* LIBXML_LEGACY_ENABLED */
996
997#ifdef LIBXML_PUSH_ENABLED
998/*
999 * Interfaces for the Push mode.
1000 */
1001XMLPUBFUN xmlParserCtxtPtr XMLCALL
1002 xmlCreatePushParserCtxt(xmlSAXHandlerPtr sax,
1003 void *user_data,
1004 const char *chunk,
1005 int size,
1006 const char *filename);
1007XMLPUBFUN int XMLCALL
1008 xmlParseChunk (xmlParserCtxtPtr ctxt,
1009 const char *chunk,
1010 int size,
1011 int terminate);
1012#endif /* LIBXML_PUSH_ENABLED */
1013
1014/*
1015 * Special I/O mode.
1016 */
1017
1018XMLPUBFUN xmlParserCtxtPtr XMLCALL
1019 xmlCreateIOParserCtxt (xmlSAXHandlerPtr sax,
1020 void *user_data,
1021 xmlInputReadCallback ioread,
1022 xmlInputCloseCallback ioclose,
1023 void *ioctx,
1024 xmlCharEncoding enc);
1025
1026XMLPUBFUN xmlParserInputPtr XMLCALL
1027 xmlNewIOInputStream (xmlParserCtxtPtr ctxt,
1028 xmlParserInputBufferPtr input,
1029 xmlCharEncoding enc);
1030
1031/*
1032 * Node infos.
1033 */
1034XMLPUBFUN const xmlParserNodeInfo* XMLCALL
1035 xmlParserFindNodeInfo (const xmlParserCtxtPtr ctxt,
1036 const xmlNodePtr node);
1037XMLPUBFUN void XMLCALL
1038 xmlInitNodeInfoSeq (xmlParserNodeInfoSeqPtr seq);
1039XMLPUBFUN void XMLCALL
1040 xmlClearNodeInfoSeq (xmlParserNodeInfoSeqPtr seq);
1041XMLPUBFUN unsigned long XMLCALL
1042 xmlParserFindNodeInfoIndex(const xmlParserNodeInfoSeqPtr seq,
1043 const xmlNodePtr node);
1044XMLPUBFUN void XMLCALL
1045 xmlParserAddNodeInfo (xmlParserCtxtPtr ctxt,
1046 const xmlParserNodeInfoPtr info);
1047
1048/*
1049 * External entities handling actually implemented in xmlIO.
1050 */
1051
1052XMLPUBFUN void XMLCALL
1053 xmlSetExternalEntityLoader(xmlExternalEntityLoader f);
1054XMLPUBFUN xmlExternalEntityLoader XMLCALL
1055 xmlGetExternalEntityLoader(void);
1056XMLPUBFUN xmlParserInputPtr XMLCALL
1057 xmlLoadExternalEntity (const char *URL,
1058 const char *ID,
1059 xmlParserCtxtPtr ctxt);
1060
1061/*
1062 * Index lookup, actually implemented in the encoding module
1063 */
1064XMLPUBFUN long XMLCALL
1065 xmlByteConsumed (xmlParserCtxtPtr ctxt);
1066
1067/*
1068 * New set of simpler/more flexible APIs
1069 */
1070/**
1071 * xmlParserOption:
1072 *
1073 * This is the set of XML parser options that can be passed down
1074 * to the xmlReadDoc() and similar calls.
1075 */
1076typedef enum {
1077 XML_PARSE_RECOVER = 1<<0, /* recover on errors */
1078 XML_PARSE_NOENT = 1<<1, /* substitute entities */
1079 XML_PARSE_DTDLOAD = 1<<2, /* load the external subset */
1080 XML_PARSE_DTDATTR = 1<<3, /* default DTD attributes */
1081 XML_PARSE_DTDVALID = 1<<4, /* validate with the DTD */
1082 XML_PARSE_NOERROR = 1<<5, /* suppress error reports */
1083 XML_PARSE_NOWARNING = 1<<6, /* suppress warning reports */
1084 XML_PARSE_PEDANTIC = 1<<7, /* pedantic error reporting */
1085 XML_PARSE_NOBLANKS = 1<<8, /* remove blank nodes */
1086 XML_PARSE_SAX1 = 1<<9, /* use the SAX1 interface internally */
1087 XML_PARSE_XINCLUDE = 1<<10,/* Implement XInclude substitition */
1088 XML_PARSE_NONET = 1<<11,/* Forbid network access */
1089 XML_PARSE_NODICT = 1<<12,/* Do not reuse the context dictionnary */
1090 XML_PARSE_NSCLEAN = 1<<13,/* remove redundant namespaces declarations */
1091 XML_PARSE_NOCDATA = 1<<14,/* merge CDATA as text nodes */
1092 XML_PARSE_NOXINCNODE= 1<<15,/* do not generate XINCLUDE START/END nodes */
1093 XML_PARSE_COMPACT = 1<<16 /* compact small text nodes; no modification of
1094 the tree allowed afterwards (will possibly
1095 crash if you try to modify the tree) */
1096} xmlParserOption;
1097
1098XMLPUBFUN void XMLCALL
1099 xmlCtxtReset (xmlParserCtxtPtr ctxt);
1100XMLPUBFUN int XMLCALL
1101 xmlCtxtResetPush (xmlParserCtxtPtr ctxt,
1102 const char *chunk,
1103 int size,
1104 const char *filename,
1105 const char *encoding);
1106XMLPUBFUN int XMLCALL
1107 xmlCtxtUseOptions (xmlParserCtxtPtr ctxt,
1108 int options);
1109XMLPUBFUN xmlDocPtr XMLCALL
1110 xmlReadDoc (const xmlChar *cur,
1111 const char *URL,
1112 const char *encoding,
1113 int options);
1114XMLPUBFUN xmlDocPtr XMLCALL
1115 xmlReadFile (const char *URL,
1116 const char *encoding,
1117 int options);
1118XMLPUBFUN xmlDocPtr XMLCALL
1119 xmlReadMemory (const char *buffer,
1120 int size,
1121 const char *URL,
1122 const char *encoding,
1123 int options);
1124XMLPUBFUN xmlDocPtr XMLCALL
1125 xmlReadFd (int fd,
1126 const char *URL,
1127 const char *encoding,
1128 int options);
1129XMLPUBFUN xmlDocPtr XMLCALL
1130 xmlReadIO (xmlInputReadCallback ioread,
1131 xmlInputCloseCallback ioclose,
1132 void *ioctx,
1133 const char *URL,
1134 const char *encoding,
1135 int options);
1136XMLPUBFUN xmlDocPtr XMLCALL
1137 xmlCtxtReadDoc (xmlParserCtxtPtr ctxt,
1138 const xmlChar *cur,
1139 const char *URL,
1140 const char *encoding,
1141 int options);
1142XMLPUBFUN xmlDocPtr XMLCALL
1143 xmlCtxtReadFile (xmlParserCtxtPtr ctxt,
1144 const char *filename,
1145 const char *encoding,
1146 int options);
1147XMLPUBFUN xmlDocPtr XMLCALL
1148 xmlCtxtReadMemory (xmlParserCtxtPtr ctxt,
1149 const char *buffer,
1150 int size,
1151 const char *URL,
1152 const char *encoding,
1153 int options);
1154XMLPUBFUN xmlDocPtr XMLCALL
1155 xmlCtxtReadFd (xmlParserCtxtPtr ctxt,
1156 int fd,
1157 const char *URL,
1158 const char *encoding,
1159 int options);
1160XMLPUBFUN xmlDocPtr XMLCALL
1161 xmlCtxtReadIO (xmlParserCtxtPtr ctxt,
1162 xmlInputReadCallback ioread,
1163 xmlInputCloseCallback ioclose,
1164 void *ioctx,
1165 const char *URL,
1166 const char *encoding,
1167 int options);
1168
1169/*
1170 * Library wide options
1171 */
1172/**
1173 * xmlFeature:
1174 *
1175 * Used to examine the existance of features that can be enabled
1176 * or disabled at compile-time.
1177 * They used to be called XML_FEATURE_xxx but this clashed with Expat
1178 */
1179typedef enum {
1180 XML_WITH_THREAD = 1,
1181 XML_WITH_TREE = 2,
1182 XML_WITH_OUTPUT = 3,
1183 XML_WITH_PUSH = 4,
1184 XML_WITH_READER = 5,
1185 XML_WITH_PATTERN = 6,
1186 XML_WITH_WRITER = 7,
1187 XML_WITH_SAX1 = 8,
1188 XML_WITH_FTP = 9,
1189 XML_WITH_HTTP = 10,
1190 XML_WITH_VALID = 11,
1191 XML_WITH_HTML = 12,
1192 XML_WITH_LEGACY = 13,
1193 XML_WITH_C14N = 14,
1194 XML_WITH_CATALOG = 15,
1195 XML_WITH_XPATH = 16,
1196 XML_WITH_XPTR = 17,
1197 XML_WITH_XINCLUDE = 18,
1198 XML_WITH_ICONV = 19,
1199 XML_WITH_ISO8859X = 20,
1200 XML_WITH_UNICODE = 21,
1201 XML_WITH_REGEXP = 22,
1202 XML_WITH_AUTOMATA = 23,
1203 XML_WITH_EXPR = 24,
1204 XML_WITH_SCHEMAS = 25,
1205 XML_WITH_SCHEMATRON = 26,
1206 XML_WITH_MODULES = 27,
1207 XML_WITH_DEBUG = 28,
1208 XML_WITH_DEBUG_MEM = 29,
1209 XML_WITH_DEBUG_RUN = 30,
1210 XML_WITH_ZLIB = 31,
1211 XML_WITH_NONE = 99999 /* just to be sure of allocation size */
1212} xmlFeature;
1213
1214XMLPUBFUN int XMLCALL
1215 xmlHasFeature (xmlFeature feature);
1216
1217#ifdef __cplusplus
1218}
1219#endif
1220#endif /* __XML_PARSER_H__ */
1221
Note: See TracBrowser for help on using the repository browser.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette