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>
33 #define XML_DEFAULT_VERSION "1.0"
52 typedef void (* xmlParserInputDeallocate)(xmlChar *str);
54 struct _xmlParserInput {
56 xmlParserInputBufferPtr buf;
59 const char *directory;
71 unsigned long consumed;
72 xmlParserInputDeallocate free;
73 const xmlChar *encoding;
74 const xmlChar *version;
86 typedef struct _xmlParserNodeInfo xmlParserNodeInfo;
87 typedef xmlParserNodeInfo *xmlParserNodeInfoPtr;
89 struct _xmlParserNodeInfo {
90 const struct _xmlNode* node;
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;
114 XML_PARSER_START = 0,
120 XML_PARSER_START_TAG,
122 XML_PARSER_CDATA_SECTION,
124 XML_PARSER_ENTITY_DECL,
125 XML_PARSER_ENTITY_VALUE,
126 XML_PARSER_ATTRIBUTE_VALUE,
127 XML_PARSER_SYSTEM_LITERAL,
130 XML_PARSER_PUBLIC_LITERAL
131 } xmlParserInputState;
139 #define XML_DETECT_IDS 2
148 #define XML_COMPLETE_ATTRS 4
156 #define XML_SKIP_IDS 8
164 XML_PARSE_UNKNOWN = 0,
167 XML_PARSE_PUSH_DOM = 3,
168 XML_PARSE_PUSH_SAX = 4,
185 struct _xmlSAXHandler *sax;
190 const xmlChar *version;
191 const xmlChar *encoding;
199 xmlParserInputPtr input;
202 xmlParserInputPtr *inputTab;
211 xmlParserNodeInfoSeq node_seq;
215 int hasExternalSubset;
223 xmlParserInputState instate;
232 const xmlChar * *nameTab;
239 const xmlChar * intSubName;
241 xmlChar * extSubSystem;
250 xmlParserInputPtr entity;
264 const xmlChar * *atts;
271 const xmlChar *str_xml;
272 const xmlChar *str_xmlns;
273 const xmlChar *str_xml_ns;
281 const xmlChar * *nsTab;
284 xmlHashTablePtr attsDefault;
285 xmlHashTablePtr attsSpecial;
294 xmlNodePtr freeElems;
296 xmlAttrPtr freeAttrs;
302 xmlParserMode parseMode;
303 unsigned long nbentities;
304 unsigned long sizeentities;
313 const xmlChar *(*getPublicId)(
void *ctx);
314 const xmlChar *(*getSystemId)(
void *ctx);
315 int (*getLineNumber)(
void *ctx);
316 int (*getColumnNumber)(
void *ctx);
341 typedef xmlParserInputPtr (*resolveEntitySAXFunc) (
void *ctx,
342 const xmlChar *publicId,
343 const xmlChar *systemId);
353 typedef void (*internalSubsetSAXFunc) (
void *ctx,
355 const xmlChar *ExternalID,
356 const xmlChar *SystemID);
366 typedef void (*externalSubsetSAXFunc) (
void *ctx,
368 const xmlChar *ExternalID,
369 const xmlChar *SystemID);
379 typedef xmlEntityPtr (*getEntitySAXFunc) (
void *ctx,
380 const xmlChar *name);
390 typedef xmlEntityPtr (*getParameterEntitySAXFunc) (
void *ctx,
391 const xmlChar *name);
403 typedef void (*entityDeclSAXFunc) (
void *ctx,
406 const xmlChar *publicId,
407 const xmlChar *systemId,
418 typedef void (*notationDeclSAXFunc)(
void *ctx,
420 const xmlChar *publicId,
421 const xmlChar *systemId);
434 typedef void (*attributeDeclSAXFunc)(
void *ctx,
436 const xmlChar *fullname,
439 const xmlChar *defaultValue,
440 xmlEnumerationPtr tree);
450 typedef void (*elementDeclSAXFunc)(
void *ctx,
453 xmlElementContentPtr content);
464 typedef void (*unparsedEntityDeclSAXFunc)(
void *ctx,
466 const xmlChar *publicId,
467 const xmlChar *systemId,
468 const xmlChar *notationName);
477 typedef void (*setDocumentLocatorSAXFunc) (
void *ctx,
485 typedef void (*startDocumentSAXFunc) (
void *ctx);
492 typedef void (*endDocumentSAXFunc) (
void *ctx);
501 typedef void (*startElementSAXFunc) (
void *ctx,
503 const xmlChar **atts);
511 typedef void (*endElementSAXFunc) (
void *ctx,
512 const xmlChar *name);
524 typedef void (*attributeSAXFunc) (
void *ctx,
526 const xmlChar *value);
534 typedef void (*referenceSAXFunc) (
void *ctx,
535 const xmlChar *name);
544 typedef void (*charactersSAXFunc) (
void *ctx,
556 typedef void (*ignorableWhitespaceSAXFunc) (
void *ctx,
567 typedef void (*processingInstructionSAXFunc) (
void *ctx,
568 const xmlChar *target,
569 const xmlChar *data);
577 typedef void (*commentSAXFunc) (
void *ctx,
578 const xmlChar *value);
587 typedef void (*cdataBlockSAXFunc) (
589 const xmlChar *value,
599 typedef void (XMLCDECL *warningSAXFunc) (
void *ctx,
600 const char *msg, ...) LIBXML_ATTR_FORMAT(2,3);
609 typedef void (XMLCDECL *errorSAXFunc) (
void *ctx,
610 const char *msg, ...) LIBXML_ATTR_FORMAT(2,3);
621 typedef void (XMLCDECL *fatalErrorSAXFunc) (
void *ctx,
622 const char *msg, ...) LIBXML_ATTR_FORMAT(2,3);
631 typedef int (*isStandaloneSAXFunc) (
void *ctx);
640 typedef int (*hasInternalSubsetSAXFunc) (
void *ctx);
650 typedef int (*hasExternalSubsetSAXFunc) (
void *ctx);
662 #define XML_SAX2_MAGIC 0xDEEDBEAF
683 typedef void (*startElementNsSAX2Func) (
void *ctx,
684 const xmlChar *localname,
685 const xmlChar *prefix,
688 const xmlChar **namespaces,
691 const xmlChar **attributes);
704 typedef void (*endElementNsSAX2Func) (
void *ctx,
705 const xmlChar *localname,
706 const xmlChar *prefix,
710 struct _xmlSAXHandler {
711 internalSubsetSAXFunc internalSubset;
712 isStandaloneSAXFunc isStandalone;
713 hasInternalSubsetSAXFunc hasInternalSubset;
714 hasExternalSubsetSAXFunc hasExternalSubset;
715 resolveEntitySAXFunc resolveEntity;
716 getEntitySAXFunc getEntity;
717 entityDeclSAXFunc entityDecl;
718 notationDeclSAXFunc notationDecl;
719 attributeDeclSAXFunc attributeDecl;
720 elementDeclSAXFunc elementDecl;
721 unparsedEntityDeclSAXFunc unparsedEntityDecl;
722 setDocumentLocatorSAXFunc setDocumentLocator;
723 startDocumentSAXFunc startDocument;
724 endDocumentSAXFunc endDocument;
725 startElementSAXFunc startElement;
726 endElementSAXFunc endElement;
727 referenceSAXFunc reference;
728 charactersSAXFunc characters;
729 ignorableWhitespaceSAXFunc ignorableWhitespace;
730 processingInstructionSAXFunc processingInstruction;
731 commentSAXFunc comment;
732 warningSAXFunc warning;
734 fatalErrorSAXFunc fatalError;
735 getParameterEntitySAXFunc getParameterEntity;
736 cdataBlockSAXFunc cdataBlock;
737 externalSubsetSAXFunc externalSubset;
738 unsigned int initialized;
741 startElementNsSAX2Func startElementNs;
742 endElementNsSAX2Func endElementNs;
743 xmlStructuredErrorFunc serror;
749 typedef struct _xmlSAXHandlerV1 xmlSAXHandlerV1;
750 typedef xmlSAXHandlerV1 *xmlSAXHandlerV1Ptr;
751 struct _xmlSAXHandlerV1 {
752 internalSubsetSAXFunc internalSubset;
753 isStandaloneSAXFunc isStandalone;
754 hasInternalSubsetSAXFunc hasInternalSubset;
755 hasExternalSubsetSAXFunc hasExternalSubset;
756 resolveEntitySAXFunc resolveEntity;
757 getEntitySAXFunc getEntity;
758 entityDeclSAXFunc entityDecl;
759 notationDeclSAXFunc notationDecl;
760 attributeDeclSAXFunc attributeDecl;
761 elementDeclSAXFunc elementDecl;
762 unparsedEntityDeclSAXFunc unparsedEntityDecl;
763 setDocumentLocatorSAXFunc setDocumentLocator;
764 startDocumentSAXFunc startDocument;
765 endDocumentSAXFunc endDocument;
766 startElementSAXFunc startElement;
767 endElementSAXFunc endElement;
768 referenceSAXFunc reference;
769 charactersSAXFunc characters;
770 ignorableWhitespaceSAXFunc ignorableWhitespace;
771 processingInstructionSAXFunc processingInstruction;
772 commentSAXFunc comment;
773 warningSAXFunc warning;
775 fatalErrorSAXFunc fatalError;
776 getParameterEntitySAXFunc getParameterEntity;
777 cdataBlockSAXFunc cdataBlock;
778 externalSubsetSAXFunc externalSubset;
779 unsigned int initialized;
793 typedef xmlParserInputPtr (*xmlExternalEntityLoader) (
const char *URL,
801 #include <libxml/encoding.h>
802 #include <libxml/xmlIO.h>
803 #include <libxml/globals.h>
813 XMLPUBFUN
void XMLCALL
814 xmlInitParser (
void);
815 XMLPUBFUN
void XMLCALL
816 xmlCleanupParser (
void);
821 XMLPUBFUN
int XMLCALL
822 xmlParserInputRead (xmlParserInputPtr in,
824 XMLPUBFUN
int XMLCALL
825 xmlParserInputGrow (xmlParserInputPtr in,
831 #ifdef LIBXML_SAX1_ENABLED
832 XMLPUBFUN xmlDocPtr XMLCALL
833 xmlParseDoc (
const xmlChar *cur);
834 XMLPUBFUN xmlDocPtr XMLCALL
835 xmlParseFile (
const char *filename);
836 XMLPUBFUN xmlDocPtr XMLCALL
837 xmlParseMemory (
const char *buffer,
840 XMLPUBFUN
int XMLCALL
841 xmlSubstituteEntitiesDefault(
int val);
842 XMLPUBFUN
int XMLCALL
843 xmlKeepBlanksDefault (
int val);
844 XMLPUBFUN
void XMLCALL
846 XMLPUBFUN
int XMLCALL
847 xmlPedanticParserDefault(
int val);
848 XMLPUBFUN
int XMLCALL
849 xmlLineNumbersDefault (
int val);
851 #ifdef LIBXML_SAX1_ENABLED
855 XMLPUBFUN xmlDocPtr XMLCALL
856 xmlRecoverDoc (
const xmlChar *cur);
857 XMLPUBFUN xmlDocPtr XMLCALL
858 xmlRecoverMemory (
const char *buffer,
860 XMLPUBFUN xmlDocPtr XMLCALL
861 xmlRecoverFile (
const char *filename);
867 XMLPUBFUN
int XMLCALL
869 XMLPUBFUN
int XMLCALL
871 #ifdef LIBXML_SAX1_ENABLED
872 XMLPUBFUN
int XMLCALL
873 xmlSAXUserParseFile (xmlSAXHandlerPtr sax,
875 const char *filename);
876 XMLPUBFUN
int XMLCALL
877 xmlSAXUserParseMemory (xmlSAXHandlerPtr sax,
881 XMLPUBFUN xmlDocPtr XMLCALL
882 xmlSAXParseDoc (xmlSAXHandlerPtr sax,
885 XMLPUBFUN xmlDocPtr XMLCALL
886 xmlSAXParseMemory (xmlSAXHandlerPtr sax,
890 XMLPUBFUN xmlDocPtr XMLCALL
891 xmlSAXParseMemoryWithData (xmlSAXHandlerPtr sax,
896 XMLPUBFUN xmlDocPtr XMLCALL
897 xmlSAXParseFile (xmlSAXHandlerPtr sax,
898 const char *filename,
900 XMLPUBFUN xmlDocPtr XMLCALL
901 xmlSAXParseFileWithData (xmlSAXHandlerPtr sax,
902 const char *filename,
905 XMLPUBFUN xmlDocPtr XMLCALL
906 xmlSAXParseEntity (xmlSAXHandlerPtr sax,
907 const char *filename);
908 XMLPUBFUN xmlDocPtr XMLCALL
909 xmlParseEntity (
const char *filename);
912 #ifdef LIBXML_VALID_ENABLED
913 XMLPUBFUN xmlDtdPtr XMLCALL
914 xmlSAXParseDTD (xmlSAXHandlerPtr sax,
915 const xmlChar *ExternalID,
916 const xmlChar *SystemID);
917 XMLPUBFUN xmlDtdPtr XMLCALL
918 xmlParseDTD (
const xmlChar *ExternalID,
919 const xmlChar *SystemID);
920 XMLPUBFUN xmlDtdPtr XMLCALL
921 xmlIOParseDTD (xmlSAXHandlerPtr sax,
922 xmlParserInputBufferPtr input,
923 xmlCharEncoding enc);
925 #ifdef LIBXML_SAX1_ENABLED
926 XMLPUBFUN
int XMLCALL
927 xmlParseBalancedChunkMemory(xmlDocPtr doc,
928 xmlSAXHandlerPtr sax,
931 const xmlChar *
string,
934 XMLPUBFUN xmlParserErrors XMLCALL
935 xmlParseInNodeContext (xmlNodePtr node,
940 #ifdef LIBXML_SAX1_ENABLED
941 XMLPUBFUN
int XMLCALL
942 xmlParseBalancedChunkMemoryRecover(xmlDocPtr doc,
943 xmlSAXHandlerPtr sax,
946 const xmlChar *
string,
949 XMLPUBFUN
int XMLCALL
950 xmlParseExternalEntity (xmlDocPtr doc,
951 xmlSAXHandlerPtr sax,
958 XMLPUBFUN
int XMLCALL
968 xmlNewParserCtxt (
void);
969 XMLPUBFUN
int XMLCALL
971 XMLPUBFUN
void XMLCALL
973 XMLPUBFUN
void XMLCALL
975 #ifdef LIBXML_SAX1_ENABLED
976 XMLPUBFUN
void XMLCALL
978 const xmlChar* buffer,
979 const char *filename);
982 xmlCreateDocParserCtxt (
const xmlChar *cur);
984 #ifdef LIBXML_LEGACY_ENABLED
988 XMLPUBFUN
int XMLCALL
989 xmlGetFeaturesList (
int *len,
990 const char **result);
991 XMLPUBFUN
int XMLCALL
995 XMLPUBFUN
int XMLCALL
1001 #ifdef LIBXML_PUSH_ENABLED
1006 xmlCreatePushParserCtxt(xmlSAXHandlerPtr sax,
1010 const char *filename);
1011 XMLPUBFUN
int XMLCALL
1023 xmlCreateIOParserCtxt (xmlSAXHandlerPtr sax,
1025 xmlInputReadCallback ioread,
1026 xmlInputCloseCallback ioclose,
1028 xmlCharEncoding enc);
1030 XMLPUBFUN xmlParserInputPtr XMLCALL
1032 xmlParserInputBufferPtr input,
1033 xmlCharEncoding enc);
1038 XMLPUBFUN
const xmlParserNodeInfo* XMLCALL
1040 const xmlNodePtr node);
1041 XMLPUBFUN
void XMLCALL
1042 xmlInitNodeInfoSeq (xmlParserNodeInfoSeqPtr seq);
1043 XMLPUBFUN
void XMLCALL
1044 xmlClearNodeInfoSeq (xmlParserNodeInfoSeqPtr seq);
1045 XMLPUBFUN
unsigned long XMLCALL
1046 xmlParserFindNodeInfoIndex(
const xmlParserNodeInfoSeqPtr seq,
1047 const xmlNodePtr node);
1048 XMLPUBFUN
void XMLCALL
1050 const xmlParserNodeInfoPtr info);
1056 XMLPUBFUN
void XMLCALL
1057 xmlSetExternalEntityLoader(xmlExternalEntityLoader f);
1058 XMLPUBFUN xmlExternalEntityLoader XMLCALL
1059 xmlGetExternalEntityLoader(
void);
1060 XMLPUBFUN xmlParserInputPtr XMLCALL
1061 xmlLoadExternalEntity (
const char *URL,
1068 XMLPUBFUN
long XMLCALL
1081 XML_PARSE_RECOVER = 1<<0,
1082 XML_PARSE_NOENT = 1<<1,
1083 XML_PARSE_DTDLOAD = 1<<2,
1084 XML_PARSE_DTDATTR = 1<<3,
1085 XML_PARSE_DTDVALID = 1<<4,
1086 XML_PARSE_NOERROR = 1<<5,
1087 XML_PARSE_NOWARNING = 1<<6,
1088 XML_PARSE_PEDANTIC = 1<<7,
1089 XML_PARSE_NOBLANKS = 1<<8,
1090 XML_PARSE_SAX1 = 1<<9,
1091 XML_PARSE_XINCLUDE = 1<<10,
1092 XML_PARSE_NONET = 1<<11,
1093 XML_PARSE_NODICT = 1<<12,
1094 XML_PARSE_NSCLEAN = 1<<13,
1095 XML_PARSE_NOCDATA = 1<<14,
1096 XML_PARSE_NOXINCNODE= 1<<15,
1097 XML_PARSE_COMPACT = 1<<16,
1100 XML_PARSE_OLD10 = 1<<17,
1101 XML_PARSE_NOBASEFIX = 1<<18,
1102 XML_PARSE_HUGE = 1<<19,
1103 XML_PARSE_OLDSAX = 1<<20
1106 XMLPUBFUN
void XMLCALL
1108 XMLPUBFUN
int XMLCALL
1112 const char *filename,
1113 const char *encoding);
1114 XMLPUBFUN
int XMLCALL
1117 XMLPUBFUN xmlDocPtr XMLCALL
1118 xmlReadDoc (
const xmlChar *cur,
1120 const char *encoding,
1122 XMLPUBFUN xmlDocPtr XMLCALL
1123 xmlReadFile (
const char *URL,
1124 const char *encoding,
1126 XMLPUBFUN xmlDocPtr XMLCALL
1127 xmlReadMemory (
const char *buffer,
1130 const char *encoding,
1132 XMLPUBFUN xmlDocPtr XMLCALL
1135 const char *encoding,
1137 XMLPUBFUN xmlDocPtr XMLCALL
1138 xmlReadIO (xmlInputReadCallback ioread,
1139 xmlInputCloseCallback ioclose,
1142 const char *encoding,
1144 XMLPUBFUN xmlDocPtr XMLCALL
1148 const char *encoding,
1150 XMLPUBFUN xmlDocPtr XMLCALL
1152 const char *filename,
1153 const char *encoding,
1155 XMLPUBFUN xmlDocPtr XMLCALL
1160 const char *encoding,
1162 XMLPUBFUN xmlDocPtr XMLCALL
1166 const char *encoding,
1168 XMLPUBFUN xmlDocPtr XMLCALL
1170 xmlInputReadCallback ioread,
1171 xmlInputCloseCallback ioclose,
1174 const char *encoding,
1188 XML_WITH_THREAD = 1,
1190 XML_WITH_OUTPUT = 3,
1192 XML_WITH_READER = 5,
1193 XML_WITH_PATTERN = 6,
1194 XML_WITH_WRITER = 7,
1198 XML_WITH_VALID = 11,
1200 XML_WITH_LEGACY = 13,
1202 XML_WITH_CATALOG = 15,
1203 XML_WITH_XPATH = 16,
1205 XML_WITH_XINCLUDE = 18,
1206 XML_WITH_ICONV = 19,
1207 XML_WITH_ISO8859X = 20,
1208 XML_WITH_UNICODE = 21,
1209 XML_WITH_REGEXP = 22,
1210 XML_WITH_AUTOMATA = 23,
1212 XML_WITH_SCHEMAS = 25,
1213 XML_WITH_SCHEMATRON = 26,
1214 XML_WITH_MODULES = 27,
1215 XML_WITH_DEBUG = 28,
1216 XML_WITH_DEBUG_MEM = 29,
1217 XML_WITH_DEBUG_RUN = 30,
1219 XML_WITH_NONE = 99999
1222 XMLPUBFUN
int XMLCALL
1223 xmlHasFeature (xmlFeature feature);