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
8 * Portion Copyright © 2009 Nokia Corporation and/or its subsidiary(-ies). All rights reserved.
19 #include <stdapis/libxml2/libxml2_dict.h>
20 #include <stdapis/libxml2/libxml2_hash.h>
21 #include <stdapis/libxml2/libxml2_valid.h>
22 #include <stdapis/libxml2/libxml2_entities.h>
23 #include <stdapis/libxml2/libxml2_encoding.h>
25 //typedef struct _xmlParserInput xmlParserInput;
26 //typedef xmlParserInput *xmlParserInputPtr;
28 #include <stdapis/libxml2/libxml2_xmlio.h>
35 * XML_DEFAULT_VERSION:
37 * The default version of XML used: 1.0
39 #define XML_DEFAULT_VERSION "1.0"
44 * An xmlParserInput is an input flow for the XML processor.
45 * Each entity parsed is associated an xmlParserInput (except the
46 * few predefined ones). This is the case both for internal entities
47 * - in which case the flow is already completely in memory - or
48 * external entities - in which case we use the buf structure for
49 * progressive reading and I18N conversions to the internal UTF-8 format.
53 * xmlParserInputDeallocate:
54 * @param str the string to deallocate
56 * Callback for freeing some parser input allocations.
58 typedef void (* xmlParserInputDeallocate)(xmlChar *str);
60 struct _xmlParserInput {
62 xmlParserInputBufferPtr buf; /* UTF-8 encoded buffer */
64 const char *filename; /* The file analyzed, if any */
65 const char *directory; /* the directory/base of the file */
66 const xmlChar *base; /* Base of the array to parse */
67 const xmlChar *cur; /* Current char being parsed */
68 const xmlChar *end; /* end of the array to parse */
69 int length; /* length if known */
70 int line; /* Current line */
71 int col; /* Current column */
73 * NOTE: consumed is only tested for equality in the parser code,
74 * so even if there is an overflow this should not give troubles
75 * for parsing very large instances.
77 unsigned long consumed; /* How many xmlChars already consumed */
78 xmlParserInputDeallocate free; /* function to deallocate the base */
79 const xmlChar *encoding; /* the encoding string for entity */
80 const xmlChar *version; /* the version string for entity */
81 int standalone; /* Was that entity marked standalone */
82 int id; /* an unique identifier for the entity */
88 * The parser can be asked to collect Node informations, i.e. at what
89 * place in the file they were detected.
90 * NOTE: This is off by default and not very well tested.
92 typedef struct _xmlParserNodeInfo xmlParserNodeInfo;
93 typedef xmlParserNodeInfo *xmlParserNodeInfoPtr;
95 struct _xmlParserNodeInfo {
96 const struct _xmlNode* node;
97 /* Position & line # that text that created the node begins & ends on */
98 unsigned long begin_pos;
99 unsigned long begin_line;
100 unsigned long end_pos;
101 unsigned long end_line;
104 typedef struct _xmlParserNodeInfoSeq xmlParserNodeInfoSeq;
105 typedef xmlParserNodeInfoSeq *xmlParserNodeInfoSeqPtr;
106 struct _xmlParserNodeInfoSeq {
107 unsigned long maximum;
108 unsigned long length;
109 xmlParserNodeInfo* buffer;
113 * xmlParserInputState:
115 * The parser is now working also as a state based parser.
116 * The recursive one use the state info for entities processing.
119 XML_PARSER_EOF = -1, /* nothing is to be parsed */
120 XML_PARSER_START = 0, /* nothing has been parsed */
121 XML_PARSER_MISC, /* Misc* before int subset */
122 XML_PARSER_PI, /* Within a processing instruction */
123 XML_PARSER_DTD, /* within some DTD content */
124 XML_PARSER_PROLOG, /* Misc* after internal subset */
125 XML_PARSER_COMMENT, /* within a comment */
126 XML_PARSER_START_TAG, /* within a start tag */
127 XML_PARSER_CONTENT, /* within the content */
128 XML_PARSER_CDATA_SECTION, /* within a CDATA section */
129 XML_PARSER_END_TAG, /* within a closing tag */
130 XML_PARSER_ENTITY_DECL, /* within an entity declaration */
131 XML_PARSER_ENTITY_VALUE, /* within an entity value in a decl */
132 XML_PARSER_ATTRIBUTE_VALUE, /* within an attribute value */
133 XML_PARSER_SYSTEM_LITERAL, /* within a SYSTEM value */
134 XML_PARSER_EPILOG, /* the Misc* after the last end tag */
135 XML_PARSER_IGNORE, /* within an IGNORED section */
136 XML_PARSER_PUBLIC_LITERAL /* within a PUBLIC value */
137 } xmlParserInputState;
142 * Bit in the loadsubset context field to tell to do ID/REFs lookups.
143 * Use it to initialize xmlLoadExtDtdDefaultValue.
145 #define XML_DETECT_IDS 2
148 * XML_COMPLETE_ATTRS:
150 * Bit in the loadsubset context field to tell to do complete the
151 * elements attributes lists with the ones defaulted from the DTDs.
152 * Use it to initialize xmlLoadExtDtdDefaultValue.
154 #define XML_COMPLETE_ATTRS 4
159 * Bit in the loadsubset context field to tell to not do ID/REFs registration.
160 * Used to initialize xmlLoadExtDtdDefaultValue in some special cases.
162 #define XML_SKIP_IDS 8
167 * The parser context.
168 * NOTE This doesn't completely define the parser state, the (current ?)
169 * design of the parser uses recursive function calls since this allow
170 * and easy mapping from the production rules of the specification
171 * to the actual code. The drawback is that the actual function call
172 * also reflect the parser state. However most of the parsing routines
173 * takes as the only argument the parser context pointer, so migrating
174 * to a state based parser for progressive parsing shouldn't be too hard.
176 struct _xmlParserCtxt {
177 struct _xmlSAXHandler *sax; /* The SAX handler */
178 void* userData; /* For SAX interface only, used by DOM build */
179 xmlDocPtr myDoc; /* the document being built */
180 int wellFormed; /* is the document well formed */
181 int replaceEntities; /* shall we replace entities ? */
182 const xmlChar* encoding; /* the declared encoding, if any */
183 int standalone; /* standalone document */
184 int html; /* an HTML(1)/Docbook(2) document */
186 /* Input stream stack */
187 xmlParserInputPtr input; /* Current input stream */
188 int inputNr; /* Number of current input streams */
189 int inputMax; /* Max number of input streams */
190 xmlParserInputPtr* inputTab; /* stack of inputs */
192 #ifdef LIBXML_ENABLE_GS_CACHING_IN_CTXT
193 // Note: location is chosen trying to get GS pointer into proximity to
194 // the data often referred to (to avoid cache misses)
195 //XMLENGINE: NEW CODE
196 void* cachedGs; /* cached GS pointer */
198 /* Node analysis stack only used for DOM building */
199 xmlNodePtr node; /* Current parsed Node */
200 int nodeNr; /* Depth of the parsing stack */
201 int nodeMax; /* Max depth of the parsing stack */
202 xmlNodePtr* nodeTab; /* array of nodes */
204 int errNo; /* error code */
206 int hasExternalSubset; /* reference and external subset */
207 int hasPErefs; /* the internal subset has PE refs */
208 int external; /* are we parsing an external entity */
210 int valid; /* is the document valid */
211 int validate; /* shall we try to validate ? */
213 xmlParserInputState instate; /* current type of input */
214 int token; /* next char look-ahead */
216 char* directory; /* the data directory */
218 /* Node name stack */
219 const xmlChar* name; /* Current parsed Node */
220 int nameNr; /* Depth of the parsing stack */
221 int nameMax; /* Max depth of the parsing stack */
222 const xmlChar** nameTab; /* array of nodes */
224 long nbChars; /* number of xmlChar processed */
225 long checkIndex; /* used by progressive parsing lookup */
226 int keepBlanks; /* ugly but ... */
227 int disableSAX; /* SAX callbacks are disabled */
228 int inSubset; /* Parsing is in int 1/ext 2 subset */
229 int stackLowThreshold; /* minimum amount of thread's stack left */
231 /* xml:space values */
232 int* space; /* Should the parser preserve spaces */
233 int spaceNr; /* Depth of the parsing stack */
234 int spaceMax; /* Max depth of the parsing stack */
235 int* spaceTab; /* array of space infos */
237 int depth; /* to prevent entity substitution loops */
238 int charset; /* encoding of the in-memory content
239 actually an xmlCharEncoding */
240 int nodelen; /* Those two fields are there to */
241 int nodemem; /* Speed up large node parsing */
242 int pedantic; /* signal pedantic warnings */
243 void* _private; /* For user data, libxml won't touch it */
245 int loadsubset; /* should the external subset be loaded */
247 void* catalogs; /* document's own catalog */
248 int progressive; /* is this a progressive parsing */
249 xmlDictPtr dict; /* dictionnary for the parser */
250 const xmlChar** atts; /* array for the attributes callbacks */
251 int maxatts; /* the size of the array */
254 * pre-interned strings
256 const xmlChar* str_xml;
257 const xmlChar* str_xmlns;
258 const xmlChar* str_xml_ns;
261 * Everything below is used only by the new SAX mode
263 int sax2; /* operating in the new SAX mode */
264 int nsNr; /* the number of inherited namespaces */
265 int nsMax; /* the size of the arrays */
266 const xmlChar** nsTab; /* the array of prefix/namespace name */
267 int* attallocs; /* which attribute were allocated */
268 void** pushTab; /* array of data for push */
269 xmlHashTablePtr attsDefault; /* defaulted attributes if any */
270 xmlHashTablePtr attsSpecial; /* non-CDATA attributes if any */
271 int nsWellFormed; /* is the document XML Nanespace okay */
272 int options; /* Extra options */
275 * Those fields are needed only for streaming parsing so far
277 int dictNames; /* Use dictionary names for the tree */
278 int freeElemsNr; /* number of freed element nodes */
279 xmlNodePtr freeElems; /* List of freed element nodes */
280 int freeAttrsNr; /* number of freed attributes nodes */
281 xmlAttrPtr freeAttrs; /* List of freed attributes nodes */
284 * the complete error informations for the last error.
288 // XMLENGINE: BEGIN NEW CODE - lastNsNr attribute in parser context
289 int lastNsNr; /* temporarily contains number of new namespaces in element*/
290 // XMLENGINE: END NEW CODE
292 //== Fields less used in libxml2, so put in the end of the structure (offset is > 255)
294 // Note: these fields were move from their original place in the structure
296 const xmlChar* version; /* the XML version string */
297 const xmlChar* intSubName; /* name of subset */
298 xmlChar* extSubURI; /* URI of external subset */
299 xmlChar* extSubSystem; /* SYSTEM ID of external subset */
300 int recovery; /* run in recovery mode */
301 int docdict; /* use strings from dict to build tree */
302 xmlParserInputPtr entity; /* used to check entities boundaries */
304 xmlValidCtxt vctxt; /* The validity context */
306 //== Fields below are likely to stay disabled forever in XML ENGINE
308 #ifdef LIBXML_ENABLE_NODE_LINEINFO
309 int linenumbers; /* set line number in element content */
312 #ifdef XMLENGINE_ENABLE_PARSER_RECORD_INFO
313 int record_info; /* Whether node info should be kept */
314 xmlParserNodeInfoSeq node_seq; /* info about each node parsed */
318 }; // struct _xmlParserCtxt
327 struct _xmlSAXLocator {
328 const xmlChar* (*getPublicId)(void* ctx);
329 const xmlChar* (*getSystemId)(void* ctx);
330 int (*getLineNumber)(void* ctx);
331 int (*getColumnNumber)(void* ctx);
337 * A SAX handler is bunch of callbacks called by the parser when processing
338 * of the input generate data or structure informations.
342 * resolveEntitySAXFunc:
343 * @param ctx the user data (XML parser context)
344 * @param publicId The public ID of the entity
345 * @param systemId The system ID of the entity
348 * The entity loader, to control the loading of external entities,
349 * the application can either:
350 * - override this resolveEntity() callback in the SAX block
351 * - or better use the xmlSetExternalEntityLoader() function to
352 * set up it's own entity resolution routine
354 * Returns the xmlParserInputPtr if inlined or NULL for DOM behaviour.
356 typedef xmlParserInputPtr (*resolveEntitySAXFunc) (
358 const xmlChar* publicId,
359 const xmlChar* systemId);
361 * internalSubsetSAXFunc:
362 * @param ctx the user data (XML parser context)
363 * @param name the root element name
364 * @param ExternalID the external ID
365 * @param SystemID the SYSTEM ID (e.g. filename or URL)
367 * Callback on internal subset declaration.
369 typedef void (*internalSubsetSAXFunc) (
372 const xmlChar* ExternalID,
373 const xmlChar* SystemID);
375 * externalSubsetSAXFunc:
376 * @param ctx the user data (XML parser context)
377 * @param name the root element name
378 * @param ExternalID the external ID
379 * @param SystemID the SYSTEM ID (e.g. filename or URL)
381 * Callback on external subset declaration.
383 typedef void (*externalSubsetSAXFunc) (
386 const xmlChar* ExternalID,
387 const xmlChar* SystemID);
390 * @param ctx the user data (XML parser context)
391 * @param name The entity name
393 * Get an entity by name.
395 * Returns the xmlEntityPtr if found.
397 typedef xmlEntityPtr (*getEntitySAXFunc) (
399 const xmlChar* name);
401 * getParameterEntitySAXFunc:
402 * @param ctx the user data (XML parser context)
403 * @param name The entity name
405 * Get a parameter entity by name.
407 * Returns the xmlEntityPtr if found.
409 typedef xmlEntityPtr (*getParameterEntitySAXFunc) (
411 const xmlChar* name);
414 * @param ctx the user data (XML parser context)
415 * @param name the entity name
416 * @param type the entity type
417 * @param publicId The public ID of the entity
418 * @param systemId The system ID of the entity
419 * @param content the entity value (without processing).
421 * An entity definition has been parsed.
423 typedef void (*entityDeclSAXFunc) (
427 const xmlChar* publicId,
428 const xmlChar* systemId,
431 * notationDeclSAXFunc:
432 * @param ctx the user data (XML parser context)
433 * @param name The name of the notation
434 * @param publicId The public ID of the entity
435 * @param systemId The system ID of the entity
437 * What to do when a notation declaration has been parsed.
439 typedef void (*notationDeclSAXFunc)(
442 const xmlChar* publicId,
443 const xmlChar* systemId);
445 * attributeDeclSAXFunc:
446 * @param ctx the user data (XML parser context)
447 * @param elem the name of the element
448 * @param fullname the attribute name
449 * @param type the attribute type
450 * @param def the type of default value
451 * @param defaultValue the attribute default value
452 * @param tree the tree of enumerated value set
454 * An attribute definition has been parsed.
456 typedef void (*attributeDeclSAXFunc)(
459 const xmlChar* fullname,
462 const xmlChar* defaultValue,
463 xmlEnumerationPtr tree);
465 * elementDeclSAXFunc:
466 * @param ctx the user data (XML parser context)
467 * @param name the element name
468 * @param type the element type
469 * @param content the element value tree
471 * An element definition has been parsed.
473 typedef void (*elementDeclSAXFunc)(
477 xmlElementContentPtr content);
479 * unparsedEntityDeclSAXFunc:
480 * @param ctx the user data (XML parser context)
481 * @param name The name of the entity
482 * @param publicId The public ID of the entity
483 * @param systemId The system ID of the entity
484 * @param notationName the name of the notation
486 * What to do when an unparsed entity declaration is parsed.
488 typedef void (*unparsedEntityDeclSAXFunc)(void *ctx,
490 const xmlChar *publicId,
491 const xmlChar *systemId,
492 const xmlChar *notationName);
494 * setDocumentLocatorSAXFunc:
495 * @param ctx the user data (XML parser context)
496 * @param loc A SAX Locator
498 * Receive the document locator at startup, actually xmlDefaultSAXLocator.
499 * Everything is available on the context, so this is useless in our case.
501 typedef void (*setDocumentLocatorSAXFunc) (void *ctx,
502 xmlSAXLocatorPtr loc);
504 * startDocumentSAXFunc:
505 * @param ctx the user data (XML parser context)
507 * Called when the document start being processed.
509 typedef void (*startDocumentSAXFunc) (void *ctx);
511 * endDocumentSAXFunc:
512 * @param ctx the user data (XML parser context)
514 * Called when the document end has been detected.
516 typedef void (*endDocumentSAXFunc) (void *ctx);
518 * startElementSAXFunc:
519 * @param ctx the user data (XML parser context)
520 * @param name The element name, including namespace prefix
521 * @param atts An array of name/value attributes pairs, NULL terminated
523 * Called when an opening tag has been processed.
525 typedef void (*startElementSAXFunc) (void *ctx,
527 const xmlChar **atts);
530 * @param ctx the user data (XML parser context)
531 * @param name The element name
533 * Called when the end of an element has been detected.
535 typedef void (*endElementSAXFunc) (void *ctx,
536 const xmlChar *name);
539 * @param ctx the user data (XML parser context)
540 * @param name The attribute name, including namespace prefix
541 * @param value The attribute value
543 * Handle an attribute that has been read by the parser.
544 * The default handling is to convert the attribute into an
545 * DOM subtree and past it in a new xmlAttr element added to
548 typedef void (*attributeSAXFunc) (void *ctx,
550 const xmlChar *value);
553 * @param ctx the user data (XML parser context)
554 * @param name The entity name
556 * Called when an entity reference is detected.
558 typedef void (*referenceSAXFunc) (void *ctx,
559 const xmlChar *name);
562 * @param ctx the user data (XML parser context)
563 * @param ch a xmlChar string
564 * @param len the number of xmlChar
566 * Receiving some chars from the parser.
568 typedef void (*charactersSAXFunc) (void *ctx,
572 * ignorableWhitespaceSAXFunc:
573 * @param ctx the user data (XML parser context)
574 * @param ch a xmlChar string
575 * @param len the number of xmlChar
577 * Receiving some ignorable whitespaces from the parser.
578 * UNUSED: by default the DOM building will use characters.
580 typedef void (*ignorableWhitespaceSAXFunc) (void *ctx,
584 * processingInstructionSAXFunc:
585 * @param ctx the user data (XML parser context)
586 * @param target the target name
587 * @param data the PI data's
589 * A processing instruction has been parsed.
591 typedef void (*processingInstructionSAXFunc) (void *ctx,
592 const xmlChar *target,
593 const xmlChar *data);
596 * @param ctx the user data (XML parser context)
597 * @param value the comment content
599 * A comment has been parsed.
601 typedef void (*commentSAXFunc) (void *ctx,
602 const xmlChar *value);
605 * @param ctx the user data (XML parser context)
606 * @param value The pcdata content
607 * @param len the block length
609 * Called when a pcdata block has been parsed.
611 typedef void (*cdataBlockSAXFunc) (
613 const xmlChar *value,
617 * @param ctx an XML parser context
618 * @param msg the message to display/transmit
619 * @param # extra parameters for the message display
621 * Display and format a warning messages, callback.
623 typedef void (*warningSAXFunc) (void *ctx,
624 const char *msg, ...);
627 * @param ctx an XML parser context
628 * @param msg the message to display/transmit
629 * @param # extra parameters for the message display
631 * Display and format an error messages, callback.
633 typedef void (*errorSAXFunc) (void *ctx,
634 const char *msg, ...);
637 * @param ctx an XML parser context
638 * @param msg the message to display/transmit
639 * @param # extra parameters for the message display
641 * Display and format fatal error messages, callback.
642 * Note: so far fatalError() SAX callbacks are not used, error()
643 * get all the callbacks for errors.
645 typedef void (*fatalErrorSAXFunc) (void *ctx,
646 const char *msg, ...);
648 * isStandaloneSAXFunc:
649 * @param ctx the user data (XML parser context)
651 * Is this document tagged standalone?
655 typedef int (*isStandaloneSAXFunc) (void *ctx);
657 * hasInternalSubsetSAXFunc:
658 * @param ctx the user data (XML parser context)
660 * Does this document has an internal subset.
664 typedef int (*hasInternalSubsetSAXFunc) (void *ctx);
667 * hasExternalSubsetSAXFunc:
668 * @param ctx the user data (XML parser context)
670 * Does this document has an external subset?
674 typedef int (*hasExternalSubsetSAXFunc) (void *ctx);
676 /************************************************************************
678 * The SAX version 2 API extensions *
680 ************************************************************************/
684 * Special constant found in SAX2 blocks initialized fields
686 #define XML_SAX2_MAGIC 0xDEEDBEAF
689 * startElementNsSAX2Func:
690 * @param ctx the user data (XML parser context)
691 * @param localname the local name of the element
692 * @param prefix the element namespace prefix if available
693 * @param URI the element namespace name if available
694 * @param nb_namespaces number of namespace definitions on that node
695 * @param namespaces pointer to the array of prefix/URI pairs namespace definitions
696 * @param nb_attributes the number of attributes on that node
697 * @param nb_defaulted the number of defaulted attributes. The defaulted
698 * ones are at the end of the array
699 * @param attributes pointer to the array of (localname/prefix/URI/value/end)
702 * SAX2 callback when an element start has been detected by the parser.
703 * It provides the namespace informations for the element, as well as
704 * the new namespace declarations on the element.
707 typedef void (*startElementNsSAX2Func) (void *ctx,
708 const xmlChar *localname,
709 const xmlChar *prefix,
712 const xmlChar **namespaces,
715 const xmlChar **attributes);
718 * endElementNsSAX2Func:
719 * @param ctx the user data (XML parser context)
720 * @param localname the local name of the element
721 * @param prefix the element namespace prefix if available
722 * @param URI the element namespace name if available
724 * SAX2 callback when an element end has been detected by the parser.
725 * It provides the namespace informations for the element.
728 typedef void (*endElementNsSAX2Func) (void *ctx,
729 const xmlChar *localname,
730 const xmlChar *prefix,
733 // XE: BEGIN new code
735 * startPrefixMappingSAX2Func:
736 * @param ctx the user data (XML parser context)
737 * @param prefix the element namespace prefix if available, NULL if default namespace
738 * @param URI the element namespace name if available
740 * SAX2 callback when namespace prefix mapping is done.
743 typedef void (*startPrefixMappingSAX2Func) (void *ctx,
744 const xmlChar *prefix,
749 * endPrefixMappingSAX2Func:
750 * @param ctx the user data (XML parser context)
751 * @param prefix the element namespace prefix if available, NULL otherwise
753 * SAX2 callback when namespace prefix mapping is getting out of scope.
756 typedef void (*endPrefixMappingSAX2Func) (void *ctx,
757 const xmlChar *prefix);
761 struct _xmlSAXHandler {
762 internalSubsetSAXFunc internalSubset;
763 isStandaloneSAXFunc isStandalone;
764 hasInternalSubsetSAXFunc hasInternalSubset;
765 hasExternalSubsetSAXFunc hasExternalSubset;
766 resolveEntitySAXFunc resolveEntity;
767 getEntitySAXFunc getEntity;
768 entityDeclSAXFunc entityDecl;
769 notationDeclSAXFunc notationDecl;
770 attributeDeclSAXFunc attributeDecl;
771 elementDeclSAXFunc elementDecl;
772 unparsedEntityDeclSAXFunc unparsedEntityDecl;
773 setDocumentLocatorSAXFunc setDocumentLocator;
774 startDocumentSAXFunc startDocument;
775 endDocumentSAXFunc endDocument;
776 startElementSAXFunc startElement;
777 endElementSAXFunc endElement;
778 referenceSAXFunc reference;
779 charactersSAXFunc characters;
780 ignorableWhitespaceSAXFunc ignorableWhitespace;
781 processingInstructionSAXFunc processingInstruction;
782 commentSAXFunc comment;
783 warningSAXFunc warning;
785 fatalErrorSAXFunc fatalError; /* unused - error() get all the errors */
786 getParameterEntitySAXFunc getParameterEntity;
787 cdataBlockSAXFunc cdataBlock;
788 externalSubsetSAXFunc externalSubset;
789 unsigned int initialized;
790 /* The following fields are extensions available only on version 2 */
792 startElementNsSAX2Func startElementNs;
793 endElementNsSAX2Func endElementNs;
794 xmlStructuredErrorFunc serror;
795 startPrefixMappingSAX2Func startPrefixMapping;
796 endPrefixMappingSAX2Func endPrefixMapping;
802 typedef struct _xmlSAXHandlerV1 xmlSAXHandlerV1;
803 typedef xmlSAXHandlerV1 *xmlSAXHandlerV1Ptr;
804 struct _xmlSAXHandlerV1 {
805 internalSubsetSAXFunc internalSubset;
806 isStandaloneSAXFunc isStandalone;
807 hasInternalSubsetSAXFunc hasInternalSubset;
808 hasExternalSubsetSAXFunc hasExternalSubset;
809 resolveEntitySAXFunc resolveEntity;
810 getEntitySAXFunc getEntity;
811 entityDeclSAXFunc entityDecl;
812 notationDeclSAXFunc notationDecl;
813 attributeDeclSAXFunc attributeDecl;
814 elementDeclSAXFunc elementDecl;
815 unparsedEntityDeclSAXFunc unparsedEntityDecl;
816 setDocumentLocatorSAXFunc setDocumentLocator;
817 startDocumentSAXFunc startDocument;
818 endDocumentSAXFunc endDocument;
819 startElementSAXFunc startElement;
820 endElementSAXFunc endElement;
821 referenceSAXFunc reference;
822 charactersSAXFunc characters;
823 ignorableWhitespaceSAXFunc ignorableWhitespace;
824 processingInstructionSAXFunc processingInstruction;
825 commentSAXFunc comment;
826 warningSAXFunc warning;
828 fatalErrorSAXFunc fatalError; /* unused error() get all the errors */
829 getParameterEntitySAXFunc getParameterEntity;
830 cdataBlockSAXFunc cdataBlock;
831 externalSubsetSAXFunc externalSubset;
832 unsigned int initialized;
837 * xmlExternalEntityLoader:
838 * @param URL The System ID of the resource requested
839 * @param ID The Public ID of the resource requested
840 * @param context the XML parser context
842 * External entity loaders types.
844 * Returns the entity input parser.
846 typedef xmlParserInputPtr (*xmlExternalEntityLoader) (const char *URL,
848 xmlParserCtxtPtr context);
862 XMLPUBFUN void XMLCALL
863 xmlInitParser (void);
864 XMLPUBFUN void XMLCALL
865 xmlCleanupParser (void);
870 XMLPUBFUN int XMLCALL
871 xmlParserInputRead (xmlParserInputPtr in,
873 XMLPUBFUN int XMLCALL
874 xmlParserInputGrow (xmlParserInputPtr in,
878 * Basic parsing Interfaces
880 XMLPUBFUN xmlDocPtr XMLCALL
881 xmlParseDoc (xmlChar *cur);
882 XMLPUBFUN xmlDocPtr XMLCALL
883 xmlParseMemory (const char *buffer,
885 XMLPUBFUN xmlDocPtr XMLCALL
886 xmlParseFile (const char *filename);
887 XMLPUBFUN int XMLCALL
888 xmlSubstituteEntitiesDefault(int val);
890 #ifndef XMLENGINE_EXCLUDE_UNUSED
891 XMLPUBFUN int XMLCALL xmlKeepBlanksDefault (int val);
892 XMLPUBFUN int XMLCALL xmlLineNumbersDefault (int val);
893 #endif /* ifndef XMLENGINE_EXCLUDE_UNUSED */
895 XMLPUBFUN void XMLCALL
896 xmlStopParser (xmlParserCtxtPtr ctxt);
897 XMLPUBFUN int XMLCALL
898 xmlPedanticParserDefault(int val);
903 XMLPUBFUN xmlDocPtr XMLCALL
904 xmlRecoverDoc (xmlChar *cur);
905 XMLPUBFUN xmlDocPtr XMLCALL
906 xmlRecoverMemory (const char *buffer, int size);
907 XMLPUBFUN xmlDocPtr XMLCALL
908 xmlRecoverFile (const char *filename);
911 * Less common routines and SAX interfaces
913 XMLPUBFUN int XMLCALL
914 xmlParseDocument (xmlParserCtxtPtr ctxt);
915 XMLPUBFUN int XMLCALL
916 xmlParseExtParsedEnt(xmlParserCtxtPtr ctxt);
917 XMLPUBFUN xmlDocPtr XMLCALL
918 xmlSAXParseDoc (xmlSAXHandlerPtr sax,
922 int* /* out if !NULL */ errorCode);
923 XMLPUBFUN int XMLCALL
924 xmlSAXUserParseFile (xmlSAXHandlerPtr sax,
926 const char *filename);
927 XMLPUBFUN int XMLCALL
928 xmlSAXUserParseMemory (xmlSAXHandlerPtr sax,
932 XMLPUBFUN xmlDocPtr XMLCALL
933 xmlSAXParseMemory (xmlSAXHandlerPtr sax,
937 XMLPUBFUN xmlDocPtr XMLCALL
938 xmlSAXParseMemoryWithData (xmlSAXHandlerPtr sax,
943 XMLPUBFUN xmlDocPtr XMLCALL
944 xmlSAXParseFile (xmlSAXHandlerPtr sax,
945 const char *filename,
947 XMLPUBFUN xmlDocPtr XMLCALL
948 xmlSAXParseFileWithData (xmlSAXHandlerPtr sax,
949 const char *filename,
952 XMLPUBFUN xmlDocPtr XMLCALL
953 xmlSAXParseEntity (xmlSAXHandlerPtr sax,
954 const char *filename);
955 XMLPUBFUN xmlDocPtr XMLCALL
956 xmlParseEntity (const char *filename);
957 XMLPUBFUN xmlDtdPtr XMLCALL
958 xmlParseDTD (const xmlChar *ExternalID,
959 const xmlChar *SystemID);
960 XMLPUBFUN xmlDtdPtr XMLCALL
961 xmlSAXParseDTD (xmlSAXHandlerPtr sax,
962 const xmlChar *ExternalID,
963 const xmlChar *SystemID);
964 XMLPUBFUN xmlDtdPtr XMLCALL
965 xmlIOParseDTD (xmlSAXHandlerPtr sax,
966 xmlParserInputBufferPtr input,
967 xmlCharEncoding enc);
968 XMLPUBFUN int XMLCALL
969 xmlParseBalancedChunkMemory(xmlDocPtr doc,
970 xmlSAXHandlerPtr sax,
973 const xmlChar *string,
975 // XMLENGINE: added from v2.6.21
976 XMLPUBFUN xmlParserErrors XMLCALL
977 xmlParseInNodeContext (xmlNodePtr node,
983 XMLPUBFUN int XMLCALL
984 xmlParseBalancedChunkMemoryRecover(xmlDocPtr doc,
985 xmlSAXHandlerPtr sax,
988 const xmlChar *string,
991 XMLPUBFUN int XMLCALL
992 xmlParseExternalEntity (xmlDocPtr doc,
993 xmlSAXHandlerPtr sax,
999 XMLPUBFUN int XMLCALL
1000 xmlParseCtxtExternalEntity(xmlParserCtxtPtr ctx,
1006 * Parser contexts handling.
1008 XMLPUBFUN xmlParserCtxtPtr XMLCALL
1009 xmlNewParserCtxt (void);
1010 XMLPUBFUN int XMLCALL
1011 xmlInitParserCtxt (xmlParserCtxtPtr ctxt);
1012 XMLPUBFUN void XMLCALL
1013 xmlClearParserCtxt (xmlParserCtxtPtr ctxt);
1014 XMLPUBFUN void XMLCALL
1015 xmlFreeParserCtxt (xmlParserCtxtPtr ctxt);
1016 XMLPUBFUN void XMLCALL
1017 xmlSetupParserForBuffer (xmlParserCtxtPtr ctxt,
1018 const xmlChar* buffer,
1019 const char *filename);
1020 XMLPUBFUN xmlParserCtxtPtr XMLCALL
1021 xmlCreateDocParserCtxt (const xmlChar *cur, int length);
1024 * Reading/setting optional parsing features.
1027 XMLPUBFUN int XMLCALL
1028 xmlGetFeaturesList (int *len,
1029 const char **result);
1030 XMLPUBFUN int XMLCALL
1031 xmlGetFeature (xmlParserCtxtPtr ctxt,
1034 XMLPUBFUN int XMLCALL
1035 xmlSetFeature (xmlParserCtxtPtr ctxt,
1039 #ifdef LIBXML_PUSH_ENABLED
1041 * Interfaces for the Push mode.
1043 XMLPUBFUN xmlParserCtxtPtr XMLCALL
1044 xmlCreatePushParserCtxt(xmlSAXHandlerPtr sax,
1048 const char *filename);
1049 XMLPUBFUN int XMLCALL
1050 xmlParseChunk (xmlParserCtxtPtr ctxt,
1054 #endif /* LIBXML_PUSH_ENABLED */
1059 #ifndef XMLENGINE_EXCLUDE_UNUSED
1060 XMLPUBFUN xmlParserCtxtPtr XMLCALL
1061 xmlCreateIOParserCtxt (xmlSAXHandlerPtr sax,
1063 xmlInputReadCallback ioread,
1064 xmlInputCloseCallback ioclose,
1066 xmlCharEncoding enc);
1067 #endif /* ifndef XMLENGINE_EXCLUDE_UNUSED */
1070 XMLPUBFUN xmlParserInputPtr XMLCALL
1071 xmlNewIOInputStream (xmlParserCtxtPtr ctxt,
1072 xmlParserInputBufferPtr input,
1073 xmlCharEncoding enc);
1075 #ifdef XMLENGINE_ENABLE_PARSER_RECORD_INFO
1079 XMLPUBFUN const xmlParserNodeInfo* XMLCALL
1080 xmlParserFindNodeInfo (const xmlParserCtxtPtr ctxt,
1081 const xmlNodePtr node);
1082 XMLPUBFUN void XMLCALL
1083 xmlInitNodeInfoSeq (xmlParserNodeInfoSeqPtr seq);
1084 XMLPUBFUN void XMLCALL
1085 xmlClearNodeInfoSeq (xmlParserNodeInfoSeqPtr seq);
1086 XMLPUBFUN unsigned long XMLCALL
1087 xmlParserFindNodeInfoIndex(const xmlParserNodeInfoSeqPtr seq,
1088 const xmlNodePtr node);
1089 XMLPUBFUN void XMLCALL
1090 xmlParserAddNodeInfo (xmlParserCtxtPtr ctxt,
1091 const xmlParserNodeInfoPtr info);
1092 #endif /* XMLENGINE_ENABLE_PARSER_RECORD_INFO */
1095 * External entities handling actually implemented in xmlIO.
1098 #ifndef XMLENGINE_EXCLUDE_UNUSED
1099 XMLPUBFUN void XMLCALL xmlSetExternalEntityLoader(xmlExternalEntityLoader f);
1100 XMLPUBFUN xmlExternalEntityLoader XMLCALL xmlGetExternalEntityLoader(void);
1101 #endif /* ifndef XMLENGINE_EXCLUDE_UNUSED */
1103 XMLPUBFUN xmlParserInputPtr XMLCALL
1104 xmlLoadExternalEntity (const char *URL,
1106 xmlParserCtxtPtr ctxt);
1109 * Index lookup, actually implemented in the encoding module
1112 #ifndef XMLENGINE_EXCLUDE_UNUSED
1113 XMLPUBFUN long XMLCALL xmlByteConsumed (xmlParserCtxtPtr ctxt);
1114 #endif /* ifndef XMLENGINE_EXCLUDE_UNUSED */
1117 * New set of simpler/more flexible APIs
1122 * This is the set of XML parser options that can be passed down
1123 * to the xmlReadDoc() and similar calls.
1126 XML_PARSE_RECOVER = 1<<0, /* recover on errors */
1127 XML_PARSE_NOENT = 1<<1, /* substitute entities */
1128 XML_PARSE_DTDLOAD = 1<<2, /* load the external subset */
1129 XML_PARSE_DTDATTR = 1<<3, /* default DTD attributes */
1130 XML_PARSE_DTDVALID = 1<<4, /* validate with the DTD */
1131 XML_PARSE_NOERROR = 1<<5, /* suppress error reports */
1132 XML_PARSE_NOWARNING = 1<<6, /* suppress warning reports */
1133 XML_PARSE_PEDANTIC = 1<<7, /* pedantic error reporting */
1134 XML_PARSE_NOBLANKS = 1<<8, /* remove blank nodes */
1135 XML_PARSE_SAX1 = 1<<9, /* use the SAX1 interface internally */
1136 XML_PARSE_XINCLUDE = 1<<10,/* Implement XInclude substitition */
1137 XML_PARSE_NONET = 1<<11,/* Forbid network access */
1138 XML_PARSE_NODICT = 1<<12,/* Do not reuse the context dictionnary */
1139 XML_PARSE_NSCLEAN = 1<<13,/* remove redundant namespaces declarations */
1140 XML_PARSE_NOCDATA = 1<<14 /* merge CDATA as text nodes */
1143 XMLPUBFUN void XMLCALL
1144 xmlCtxtReset (xmlParserCtxtPtr ctxt);
1146 #ifndef XMLENGINE_EXCLUDE_UNUSED
1147 XMLPUBFUN int XMLCALL
1148 xmlCtxtResetPush (xmlParserCtxtPtr ctxt,
1151 const char *filename,
1152 const char *encoding);
1153 #endif /* ifndef XMLENGINE_EXCLUDE_UNUSED */
1155 XMLPUBFUN int XMLCALL
1156 xmlCtxtUseOptions (xmlParserCtxtPtr ctxt,
1158 XMLPUBFUN xmlDocPtr XMLCALL
1159 xmlReadDoc (const xmlChar *cur,
1161 const char *encoding,
1164 #ifndef XMLENGINE_EXCLUDE_UNUSED
1165 XMLPUBFUN xmlDocPtr XMLCALL
1166 xmlReadFile (const char *URL,
1167 const char *encoding,
1171 XMLPUBFUN xmlDocPtr XMLCALL
1172 xmlReadMemory (const char *buffer,
1175 const char *encoding,
1177 XMLPUBFUN xmlDocPtr XMLCALL
1180 const char *encoding,
1182 XMLPUBFUN xmlDocPtr XMLCALL
1183 xmlReadIO (xmlInputReadCallback ioread,
1184 xmlInputCloseCallback ioclose,
1187 const char *encoding,
1190 #ifndef XMLENGINE_EXCLUDE_UNUSED
1192 XMLPUBFUN xmlDocPtr XMLCALL
1193 xmlCtxtReadDoc (xmlParserCtxtPtr ctxt,
1196 const char *encoding,
1198 XMLPUBFUN xmlDocPtr XMLCALL
1199 xmlCtxtReadFd (xmlParserCtxtPtr ctxt,
1202 const char *encoding,
1204 XMLPUBFUN xmlDocPtr XMLCALL
1205 xmlCtxtReadFile (xmlParserCtxtPtr ctxt,
1206 const char *filename,
1207 const char *encoding,
1209 XMLPUBFUN xmlDocPtr XMLCALL
1210 xmlCtxtReadMemory (xmlParserCtxtPtr ctxt,
1214 const char *encoding,
1216 XMLPUBFUN xmlDocPtr XMLCALL
1217 xmlCtxtReadIO (xmlParserCtxtPtr ctxt,
1218 xmlInputReadCallback ioread,
1219 xmlInputCloseCallback ioclose,
1222 const char *encoding,
1224 #endif /* ifndef XMLENGINE_EXCLUDE_UNUSED */
1229 #endif /* XML_PARSER_H */