parser.h

Go to the documentation of this file.
00001 /*
00002  * Summary: the core parser module
00003  * Description: Interfaces, constants and types related to the XML parser
00004  *
00005  * Copy: See Copyright for the status of this software.
00006  *
00007  * Author: Daniel Veillard
00008  */
00009 
00010 #ifndef __XML_PARSER_H__
00011 #define __XML_PARSER_H__
00012 
00013 #include <stdarg.h>
00014 
00015 #include <libxml/xmlversion.h>
00016 #include <libxml/tree.h>
00017 #include <libxml/dict.h>
00018 #include <libxml/hash.h>
00019 #include <libxml/valid.h>
00020 #include <libxml/entities.h>
00021 #include <libxml/xmlerror.h>
00022 #include <libxml/xmlstring.h>
00023 
00024 #ifdef __cplusplus
00025 extern "C" {
00026 #endif
00027 
00033 #define XML_DEFAULT_VERSION "1.0"
00034 
00052 typedef void (* xmlParserInputDeallocate)(xmlChar *str);
00053 
00054 struct _xmlParserInput {
00055     /* Input buffer */
00056     xmlParserInputBufferPtr buf;      /* UTF-8 encoded buffer */
00057 
00058     const char *filename;             /* The file analyzed, if any */
00059     const char *directory;            /* the directory/base of the file */
00060     const xmlChar *base;              /* Base of the array to parse */
00061     const xmlChar *cur;               /* Current char being parsed */
00062     const xmlChar *end;               /* end of the array to parse */
00063     int length;                       /* length if known */
00064     int line;                         /* Current line */
00065     int col;                          /* Current column */
00066     /*
00067      * NOTE: consumed is only tested for equality in the parser code,
00068      *       so even if there is an overflow this should not give troubles
00069      *       for parsing very large instances.
00070      */
00071     unsigned long consumed;           /* How many xmlChars already consumed */
00072     xmlParserInputDeallocate free;    /* function to deallocate the base */
00073     const xmlChar *encoding;          /* the encoding string for entity */
00074     const xmlChar *version;           /* the version string for entity */
00075     int standalone;                   /* Was that entity marked standalone */
00076     int id;                           /* an unique identifier for the entity */
00077 };
00078 
00086 typedef struct _xmlParserNodeInfo xmlParserNodeInfo;
00087 typedef xmlParserNodeInfo *xmlParserNodeInfoPtr;
00088 
00089 struct _xmlParserNodeInfo {
00090   const struct _xmlNode* node;
00091   /* Position & line # that text that created the node begins & ends on */
00092   unsigned long begin_pos;
00093   unsigned long begin_line;
00094   unsigned long end_pos;
00095   unsigned long end_line;
00096 };
00097 
00098 typedef struct _xmlParserNodeInfoSeq xmlParserNodeInfoSeq;
00099 typedef xmlParserNodeInfoSeq *xmlParserNodeInfoSeqPtr;
00100 struct _xmlParserNodeInfoSeq {
00101   unsigned long maximum;
00102   unsigned long length;
00103   xmlParserNodeInfo* buffer;
00104 };
00105 
00112 typedef enum {
00113     XML_PARSER_EOF = -1,    /* nothing is to be parsed */
00114     XML_PARSER_START = 0,   /* nothing has been parsed */
00115     XML_PARSER_MISC,        /* Misc* before int subset */
00116     XML_PARSER_PI,      /* Within a processing instruction */
00117     XML_PARSER_DTD,     /* within some DTD content */
00118     XML_PARSER_PROLOG,      /* Misc* after internal subset */
00119     XML_PARSER_COMMENT,     /* within a comment */
00120     XML_PARSER_START_TAG,   /* within a start tag */
00121     XML_PARSER_CONTENT,     /* within the content */
00122     XML_PARSER_CDATA_SECTION,   /* within a CDATA section */
00123     XML_PARSER_END_TAG,     /* within a closing tag */
00124     XML_PARSER_ENTITY_DECL, /* within an entity declaration */
00125     XML_PARSER_ENTITY_VALUE,    /* within an entity value in a decl */
00126     XML_PARSER_ATTRIBUTE_VALUE, /* within an attribute value */
00127     XML_PARSER_SYSTEM_LITERAL,  /* within a SYSTEM value */
00128     XML_PARSER_EPILOG,      /* the Misc* after the last end tag */
00129     XML_PARSER_IGNORE,      /* within an IGNORED section */
00130     XML_PARSER_PUBLIC_LITERAL   /* within a PUBLIC value */
00131 } xmlParserInputState;
00132 
00139 #define XML_DETECT_IDS      2
00140 
00148 #define XML_COMPLETE_ATTRS  4
00149 
00156 #define XML_SKIP_IDS        8
00157 
00163 typedef enum {
00164     XML_PARSE_UNKNOWN = 0,
00165     XML_PARSE_DOM = 1,
00166     XML_PARSE_SAX = 2,
00167     XML_PARSE_PUSH_DOM = 3,
00168     XML_PARSE_PUSH_SAX = 4,
00169     XML_PARSE_READER = 5
00170 } xmlParserMode;
00171 
00184 struct _xmlParserCtxt {
00185     struct _xmlSAXHandler *sax;       /* The SAX handler */
00186     void            *userData;        /* For SAX interface only, used by DOM build */
00187     xmlDocPtr           myDoc;        /* the document being built */
00188     int            wellFormed;        /* is the document well formed */
00189     int       replaceEntities;        /* shall we replace entities ? */
00190     const xmlChar    *version;        /* the XML version string */
00191     const xmlChar   *encoding;        /* the declared encoding, if any */
00192     int            standalone;        /* standalone document */
00193     int                  html;        /* an HTML(1)/Docbook(2) document */
00194 
00195     /* Input stream stack */
00196     xmlParserInputPtr  input;         /* Current input stream */
00197     int                inputNr;       /* Number of current input streams */
00198     int                inputMax;      /* Max number of input streams */
00199     xmlParserInputPtr *inputTab;      /* stack of inputs */
00200 
00201     /* Node analysis stack only used for DOM building */
00202     xmlNodePtr         node;          /* Current parsed Node */
00203     int                nodeNr;        /* Depth of the parsing stack */
00204     int                nodeMax;       /* Max depth of the parsing stack */
00205     xmlNodePtr        *nodeTab;       /* array of nodes */
00206 
00207     int record_info;                  /* Whether node info should be kept */
00208     xmlParserNodeInfoSeq node_seq;    /* info about each node parsed */
00209 
00210     int errNo;                        /* error code */
00211 
00212     int     hasExternalSubset;        /* reference and external subset */
00213     int             hasPErefs;        /* the internal subset has PE refs */
00214     int              external;        /* are we parsing an external entity */
00215 
00216     int                 valid;        /* is the document valid */
00217     int              validate;        /* shall we try to validate ? */
00218     xmlValidCtxt        vctxt;        /* The validity context */
00219 
00220     xmlParserInputState instate;      /* current type of input */
00221     int                 token;        /* next char look-ahead */    
00222 
00223     char           *directory;        /* the data directory */
00224 
00225     /* Node name stack */
00226     const xmlChar     *name;          /* Current parsed Node */
00227     int                nameNr;        /* Depth of the parsing stack */
00228     int                nameMax;       /* Max depth of the parsing stack */
00229     const xmlChar *   *nameTab;       /* array of nodes */
00230 
00231     long               nbChars;       /* number of xmlChar processed */
00232     long            checkIndex;       /* used by progressive parsing lookup */
00233     int             keepBlanks;       /* ugly but ... */
00234     int             disableSAX;       /* SAX callbacks are disabled */
00235     int               inSubset;       /* Parsing is in int 1/ext 2 subset */
00236     const xmlChar *    intSubName;    /* name of subset */
00237     xmlChar *          extSubURI;     /* URI of external subset */
00238     xmlChar *          extSubSystem;  /* SYSTEM ID of external subset */
00239 
00240     /* xml:space values */
00241     int *              space;         /* Should the parser preserve spaces */
00242     int                spaceNr;       /* Depth of the parsing stack */
00243     int                spaceMax;      /* Max depth of the parsing stack */
00244     int *              spaceTab;      /* array of space infos */
00245 
00246     int                depth;         /* to prevent entity substitution loops */
00247     xmlParserInputPtr  entity;        /* used to check entities boundaries */
00248     int                charset;       /* encoding of the in-memory content
00249                          actually an xmlCharEncoding */
00250     int                nodelen;       /* Those two fields are there to */
00251     int                nodemem;       /* Speed up large node parsing */
00252     int                pedantic;      /* signal pedantic warnings */
00253     void              *_private;      /* For user data, libxml won't touch it */
00254 
00255     int                loadsubset;    /* should the external subset be loaded */
00256     int                linenumbers;   /* set line number in element content */
00257     void              *catalogs;      /* document's own catalog */
00258     int                recovery;      /* run in recovery mode */
00259     int                progressive;   /* is this a progressive parsing */
00260     xmlDictPtr         dict;          /* dictionnary for the parser */
00261     const xmlChar *   *atts;          /* array for the attributes callbacks */
00262     int                maxatts;       /* the size of the array */
00263     int                docdict;       /* use strings from dict to build tree */
00264 
00265     /*
00266      * pre-interned strings
00267      */
00268     const xmlChar *str_xml;
00269     const xmlChar *str_xmlns;
00270     const xmlChar *str_xml_ns;
00271 
00272     /*
00273      * Everything below is used only by the new SAX mode
00274      */
00275     int                sax2;          /* operating in the new SAX mode */
00276     int                nsNr;          /* the number of inherited namespaces */
00277     int                nsMax;         /* the size of the arrays */
00278     const xmlChar *   *nsTab;         /* the array of prefix/namespace name */
00279     int               *attallocs;     /* which attribute were allocated */
00280     void *            *pushTab;       /* array of data for push */
00281     xmlHashTablePtr    attsDefault;   /* defaulted attributes if any */
00282     xmlHashTablePtr    attsSpecial;   /* non-CDATA attributes if any */
00283     int                nsWellFormed;  /* is the document XML Nanespace okay */
00284     int                options;       /* Extra options */
00285 
00286     /*
00287      * Those fields are needed only for treaming parsing so far
00288      */
00289     int               dictNames;    /* Use dictionary names for the tree */
00290     int               freeElemsNr;  /* number of freed element nodes */
00291     xmlNodePtr        freeElems;    /* List of freed element nodes */
00292     int               freeAttrsNr;  /* number of freed attributes nodes */
00293     xmlAttrPtr        freeAttrs;    /* List of freed attributes nodes */
00294 
00295     /*
00296      * the complete error informations for the last error.
00297      */
00298     xmlError          lastError;
00299     xmlParserMode     parseMode;    /* the parser mode */
00300 };
00301 
00307 struct _xmlSAXLocator {
00308     const xmlChar *(*getPublicId)(void *ctx);
00309     const xmlChar *(*getSystemId)(void *ctx);
00310     int (*getLineNumber)(void *ctx);
00311     int (*getColumnNumber)(void *ctx);
00312 };
00313 
00336 typedef xmlParserInputPtr (*resolveEntitySAXFunc) (void *ctx,
00337                 const xmlChar *publicId,
00338                 const xmlChar *systemId);
00348 typedef void (*internalSubsetSAXFunc) (void *ctx,
00349                 const xmlChar *name,
00350                 const xmlChar *ExternalID,
00351                 const xmlChar *SystemID);
00361 typedef void (*externalSubsetSAXFunc) (void *ctx,
00362                 const xmlChar *name,
00363                 const xmlChar *ExternalID,
00364                 const xmlChar *SystemID);
00374 typedef xmlEntityPtr (*getEntitySAXFunc) (void *ctx,
00375                 const xmlChar *name);
00385 typedef xmlEntityPtr (*getParameterEntitySAXFunc) (void *ctx,
00386                 const xmlChar *name);
00398 typedef void (*entityDeclSAXFunc) (void *ctx,
00399                 const xmlChar *name,
00400                 int type,
00401                 const xmlChar *publicId,
00402                 const xmlChar *systemId,
00403                 xmlChar *content);
00413 typedef void (*notationDeclSAXFunc)(void *ctx,
00414                 const xmlChar *name,
00415                 const xmlChar *publicId,
00416                 const xmlChar *systemId);
00429 typedef void (*attributeDeclSAXFunc)(void *ctx,
00430                 const xmlChar *elem,
00431                 const xmlChar *fullname,
00432                 int type,
00433                 int def,
00434                 const xmlChar *defaultValue,
00435                 xmlEnumerationPtr tree);
00445 typedef void (*elementDeclSAXFunc)(void *ctx,
00446                 const xmlChar *name,
00447                 int type,
00448                 xmlElementContentPtr content);
00459 typedef void (*unparsedEntityDeclSAXFunc)(void *ctx,
00460                 const xmlChar *name,
00461                 const xmlChar *publicId,
00462                 const xmlChar *systemId,
00463                 const xmlChar *notationName);
00472 typedef void (*setDocumentLocatorSAXFunc) (void *ctx,
00473                 xmlSAXLocatorPtr loc);
00480 typedef void (*startDocumentSAXFunc) (void *ctx);
00487 typedef void (*endDocumentSAXFunc) (void *ctx);
00496 typedef void (*startElementSAXFunc) (void *ctx,
00497                 const xmlChar *name,
00498                 const xmlChar **atts);
00506 typedef void (*endElementSAXFunc) (void *ctx,
00507                 const xmlChar *name);
00519 typedef void (*attributeSAXFunc) (void *ctx,
00520                 const xmlChar *name,
00521                 const xmlChar *value);
00529 typedef void (*referenceSAXFunc) (void *ctx,
00530                 const xmlChar *name);
00539 typedef void (*charactersSAXFunc) (void *ctx,
00540                 const xmlChar *ch,
00541                 int len);
00551 typedef void (*ignorableWhitespaceSAXFunc) (void *ctx,
00552                 const xmlChar *ch,
00553                 int len);
00562 typedef void (*processingInstructionSAXFunc) (void *ctx,
00563                 const xmlChar *target,
00564                 const xmlChar *data);
00572 typedef void (*commentSAXFunc) (void *ctx,
00573                 const xmlChar *value);
00582 typedef void (*cdataBlockSAXFunc) (
00583                             void *ctx,
00584                 const xmlChar *value,
00585                 int len);
00594 typedef void (XMLCDECL *warningSAXFunc) (void *ctx,
00595                 const char *msg, ...);
00604 typedef void (XMLCDECL *errorSAXFunc) (void *ctx,
00605                 const char *msg, ...);
00616 typedef void (XMLCDECL *fatalErrorSAXFunc) (void *ctx,
00617                 const char *msg, ...);
00626 typedef int (*isStandaloneSAXFunc) (void *ctx);
00635 typedef int (*hasInternalSubsetSAXFunc) (void *ctx);
00636 
00645 typedef int (*hasExternalSubsetSAXFunc) (void *ctx);
00646 
00647 /************************************************************************
00648  *                                  *
00649  *          The SAX version 2 API extensions        *
00650  *                                  *
00651  ************************************************************************/
00657 #define XML_SAX2_MAGIC 0xDEEDBEAF
00658 
00678 typedef void (*startElementNsSAX2Func) (void *ctx,
00679                     const xmlChar *localname,
00680                     const xmlChar *prefix,
00681                     const xmlChar *URI,
00682                     int nb_namespaces,
00683                     const xmlChar **namespaces,
00684                     int nb_attributes,
00685                     int nb_defaulted,
00686                     const xmlChar **attributes);
00687  
00699 typedef void (*endElementNsSAX2Func)   (void *ctx,
00700                     const xmlChar *localname,
00701                     const xmlChar *prefix,
00702                     const xmlChar *URI);
00703 
00704 
00705 struct _xmlSAXHandler {
00706     internalSubsetSAXFunc internalSubset;
00707     isStandaloneSAXFunc isStandalone;
00708     hasInternalSubsetSAXFunc hasInternalSubset;
00709     hasExternalSubsetSAXFunc hasExternalSubset;
00710     resolveEntitySAXFunc resolveEntity;
00711     getEntitySAXFunc getEntity;
00712     entityDeclSAXFunc entityDecl;
00713     notationDeclSAXFunc notationDecl;
00714     attributeDeclSAXFunc attributeDecl;
00715     elementDeclSAXFunc elementDecl;
00716     unparsedEntityDeclSAXFunc unparsedEntityDecl;
00717     setDocumentLocatorSAXFunc setDocumentLocator;
00718     startDocumentSAXFunc startDocument;
00719     endDocumentSAXFunc endDocument;
00720     startElementSAXFunc startElement;
00721     endElementSAXFunc endElement;
00722     referenceSAXFunc reference;
00723     charactersSAXFunc characters;
00724     ignorableWhitespaceSAXFunc ignorableWhitespace;
00725     processingInstructionSAXFunc processingInstruction;
00726     commentSAXFunc comment;
00727     warningSAXFunc warning;
00728     errorSAXFunc error;
00729     fatalErrorSAXFunc fatalError; /* unused error() get all the errors */
00730     getParameterEntitySAXFunc getParameterEntity;
00731     cdataBlockSAXFunc cdataBlock;
00732     externalSubsetSAXFunc externalSubset;
00733     unsigned int initialized;
00734     /* The following fields are extensions available only on version 2 */
00735     void *_private;
00736     startElementNsSAX2Func startElementNs;
00737     endElementNsSAX2Func endElementNs;
00738     xmlStructuredErrorFunc serror;
00739 };
00740 
00741 /*
00742  * SAX Version 1
00743  */
00744 typedef struct _xmlSAXHandlerV1 xmlSAXHandlerV1;
00745 typedef xmlSAXHandlerV1 *xmlSAXHandlerV1Ptr;
00746 struct _xmlSAXHandlerV1 {
00747     internalSubsetSAXFunc internalSubset;
00748     isStandaloneSAXFunc isStandalone;
00749     hasInternalSubsetSAXFunc hasInternalSubset;
00750     hasExternalSubsetSAXFunc hasExternalSubset;
00751     resolveEntitySAXFunc resolveEntity;
00752     getEntitySAXFunc getEntity;
00753     entityDeclSAXFunc entityDecl;
00754     notationDeclSAXFunc notationDecl;
00755     attributeDeclSAXFunc attributeDecl;
00756     elementDeclSAXFunc elementDecl;
00757     unparsedEntityDeclSAXFunc unparsedEntityDecl;
00758     setDocumentLocatorSAXFunc setDocumentLocator;
00759     startDocumentSAXFunc startDocument;
00760     endDocumentSAXFunc endDocument;
00761     startElementSAXFunc startElement;
00762     endElementSAXFunc endElement;
00763     referenceSAXFunc reference;
00764     charactersSAXFunc characters;
00765     ignorableWhitespaceSAXFunc ignorableWhitespace;
00766     processingInstructionSAXFunc processingInstruction;
00767     commentSAXFunc comment;
00768     warningSAXFunc warning;
00769     errorSAXFunc error;
00770     fatalErrorSAXFunc fatalError; /* unused error() get all the errors */
00771     getParameterEntitySAXFunc getParameterEntity;
00772     cdataBlockSAXFunc cdataBlock;
00773     externalSubsetSAXFunc externalSubset;
00774     unsigned int initialized;
00775 };
00776 
00777 
00788 typedef xmlParserInputPtr (*xmlExternalEntityLoader) (const char *URL,
00789                      const char *ID,
00790                      xmlParserCtxtPtr context);
00791 
00792 #ifdef __cplusplus
00793 }
00794 #endif
00795 
00796 #include <libxml/encoding.h>
00797 #include <libxml/xmlIO.h>
00798 #include <libxml/globals.h>
00799 
00800 #ifdef __cplusplus
00801 extern "C" {
00802 #endif
00803 
00804 
00805 /*
00806  * Init/Cleanup
00807  */
00808 XMLPUBFUN void XMLCALL      
00809         xmlInitParser       (void);
00810 XMLPUBFUN void XMLCALL      
00811         xmlCleanupParser    (void);
00812 
00813 /*
00814  * Input functions
00815  */
00816 XMLPUBFUN int XMLCALL       
00817         xmlParserInputRead  (xmlParserInputPtr in,
00818                      int len);
00819 XMLPUBFUN int XMLCALL       
00820         xmlParserInputGrow  (xmlParserInputPtr in,
00821                      int len);
00822 
00823 /*
00824  * Basic parsing Interfaces
00825  */
00826 #ifdef LIBXML_SAX1_ENABLED
00827 XMLPUBFUN xmlDocPtr XMLCALL 
00828         xmlParseDoc     (const xmlChar *cur);
00829 XMLPUBFUN xmlDocPtr XMLCALL 
00830         xmlParseFile        (const char *filename);
00831 XMLPUBFUN xmlDocPtr XMLCALL 
00832         xmlParseMemory      (const char *buffer,
00833                      int size);
00834 #endif /* LIBXML_SAX1_ENABLED */
00835 XMLPUBFUN int XMLCALL       
00836         xmlSubstituteEntitiesDefault(int val);
00837 XMLPUBFUN int XMLCALL       
00838         xmlKeepBlanksDefault    (int val);
00839 XMLPUBFUN void XMLCALL      
00840         xmlStopParser       (xmlParserCtxtPtr ctxt);
00841 XMLPUBFUN int XMLCALL       
00842         xmlPedanticParserDefault(int val);
00843 XMLPUBFUN int XMLCALL       
00844         xmlLineNumbersDefault   (int val);
00845 
00846 #ifdef LIBXML_SAX1_ENABLED
00847 /*
00848  * Recovery mode 
00849  */
00850 XMLPUBFUN xmlDocPtr XMLCALL 
00851         xmlRecoverDoc       (xmlChar *cur);
00852 XMLPUBFUN xmlDocPtr XMLCALL 
00853         xmlRecoverMemory    (const char *buffer,
00854                      int size);
00855 XMLPUBFUN xmlDocPtr XMLCALL 
00856         xmlRecoverFile      (const char *filename);
00857 #endif /* LIBXML_SAX1_ENABLED */
00858 
00859 /*
00860  * Less common routines and SAX interfaces
00861  */
00862 XMLPUBFUN int XMLCALL       
00863         xmlParseDocument    (xmlParserCtxtPtr ctxt);
00864 XMLPUBFUN int XMLCALL       
00865         xmlParseExtParsedEnt    (xmlParserCtxtPtr ctxt);
00866 #ifdef LIBXML_SAX1_ENABLED
00867 XMLPUBFUN int XMLCALL       
00868         xmlSAXUserParseFile (xmlSAXHandlerPtr sax,
00869                      void *user_data,
00870                      const char *filename);
00871 XMLPUBFUN int XMLCALL       
00872         xmlSAXUserParseMemory   (xmlSAXHandlerPtr sax,
00873                      void *user_data,
00874                      const char *buffer,
00875                      int size);
00876 XMLPUBFUN xmlDocPtr XMLCALL 
00877         xmlSAXParseDoc      (xmlSAXHandlerPtr sax,
00878                      const xmlChar *cur,
00879                      int recovery);
00880 XMLPUBFUN xmlDocPtr XMLCALL 
00881         xmlSAXParseMemory   (xmlSAXHandlerPtr sax,
00882                      const char *buffer,
00883                                      int size,
00884                      int recovery);
00885 XMLPUBFUN xmlDocPtr XMLCALL 
00886         xmlSAXParseMemoryWithData (xmlSAXHandlerPtr sax,
00887                      const char *buffer,
00888                                      int size,
00889                      int recovery,
00890                      void *data);
00891 XMLPUBFUN xmlDocPtr XMLCALL 
00892         xmlSAXParseFile     (xmlSAXHandlerPtr sax,
00893                      const char *filename,
00894                      int recovery);
00895 XMLPUBFUN xmlDocPtr XMLCALL 
00896         xmlSAXParseFileWithData (xmlSAXHandlerPtr sax,
00897                      const char *filename,
00898                      int recovery,
00899                      void *data);
00900 XMLPUBFUN xmlDocPtr XMLCALL 
00901         xmlSAXParseEntity   (xmlSAXHandlerPtr sax,
00902                      const char *filename);
00903 XMLPUBFUN xmlDocPtr XMLCALL 
00904         xmlParseEntity      (const char *filename);
00905 #endif /* LIBXML_SAX1_ENABLED */
00906 
00907 #ifdef LIBXML_VALID_ENABLED
00908 XMLPUBFUN xmlDtdPtr XMLCALL 
00909         xmlSAXParseDTD      (xmlSAXHandlerPtr sax,
00910                      const xmlChar *ExternalID,
00911                      const xmlChar *SystemID);
00912 XMLPUBFUN xmlDtdPtr XMLCALL 
00913         xmlParseDTD     (const xmlChar *ExternalID,
00914                      const xmlChar *SystemID);
00915 XMLPUBFUN xmlDtdPtr XMLCALL 
00916         xmlIOParseDTD       (xmlSAXHandlerPtr sax,
00917                      xmlParserInputBufferPtr input,
00918                      xmlCharEncoding enc);
00919 #endif /* LIBXML_VALID_ENABLE */
00920 #ifdef LIBXML_SAX1_ENABLED
00921 XMLPUBFUN int XMLCALL   
00922         xmlParseBalancedChunkMemory(xmlDocPtr doc,
00923                      xmlSAXHandlerPtr sax,
00924                      void *user_data,
00925                      int depth,
00926                      const xmlChar *string,
00927                      xmlNodePtr *lst);
00928 #endif /* LIBXML_SAX1_ENABLED */
00929 XMLPUBFUN xmlParserErrors XMLCALL
00930         xmlParseInNodeContext   (xmlNodePtr node,
00931                      const char *data,
00932                      int datalen,
00933                      int options,
00934                      xmlNodePtr *lst);
00935 #ifdef LIBXML_SAX1_ENABLED
00936 XMLPUBFUN int XMLCALL          
00937         xmlParseBalancedChunkMemoryRecover(xmlDocPtr doc,
00938                      xmlSAXHandlerPtr sax,
00939                      void *user_data,
00940                      int depth,
00941                      const xmlChar *string,
00942                      xmlNodePtr *lst,
00943                      int recover);
00944 XMLPUBFUN int XMLCALL       
00945         xmlParseExternalEntity  (xmlDocPtr doc,
00946                      xmlSAXHandlerPtr sax,
00947                      void *user_data,
00948                      int depth,
00949                      const xmlChar *URL,
00950                      const xmlChar *ID,
00951                      xmlNodePtr *lst);
00952 #endif /* LIBXML_SAX1_ENABLED */
00953 XMLPUBFUN int XMLCALL       
00954         xmlParseCtxtExternalEntity(xmlParserCtxtPtr ctx,
00955                      const xmlChar *URL,
00956                      const xmlChar *ID,
00957                      xmlNodePtr *lst);
00958 
00959 /*
00960  * Parser contexts handling.
00961  */
00962 XMLPUBFUN xmlParserCtxtPtr XMLCALL  
00963         xmlNewParserCtxt    (void);
00964 XMLPUBFUN int XMLCALL       
00965         xmlInitParserCtxt   (xmlParserCtxtPtr ctxt);
00966 XMLPUBFUN void XMLCALL      
00967         xmlClearParserCtxt  (xmlParserCtxtPtr ctxt);
00968 XMLPUBFUN void XMLCALL      
00969         xmlFreeParserCtxt   (xmlParserCtxtPtr ctxt);
00970 #ifdef LIBXML_SAX1_ENABLED
00971 XMLPUBFUN void XMLCALL      
00972         xmlSetupParserForBuffer (xmlParserCtxtPtr ctxt,
00973                      const xmlChar* buffer,
00974                      const char *filename);
00975 #endif /* LIBXML_SAX1_ENABLED */
00976 XMLPUBFUN xmlParserCtxtPtr XMLCALL 
00977         xmlCreateDocParserCtxt  (const xmlChar *cur);
00978 
00979 #ifdef LIBXML_LEGACY_ENABLED
00980 /*
00981  * Reading/setting optional parsing features.
00982  */
00983 XMLPUBFUN int XMLCALL       
00984         xmlGetFeaturesList  (int *len,
00985                      const char **result);
00986 XMLPUBFUN int XMLCALL       
00987         xmlGetFeature       (xmlParserCtxtPtr ctxt,
00988                      const char *name,
00989                      void *result);
00990 XMLPUBFUN int XMLCALL       
00991         xmlSetFeature       (xmlParserCtxtPtr ctxt,
00992                      const char *name,
00993                      void *value);
00994 #endif /* LIBXML_LEGACY_ENABLED */
00995 
00996 #ifdef LIBXML_PUSH_ENABLED
00997 /*
00998  * Interfaces for the Push mode.
00999  */
01000 XMLPUBFUN xmlParserCtxtPtr XMLCALL 
01001         xmlCreatePushParserCtxt(xmlSAXHandlerPtr sax,
01002                      void *user_data,
01003                      const char *chunk,
01004                      int size,
01005                      const char *filename);
01006 XMLPUBFUN int XMLCALL        
01007         xmlParseChunk       (xmlParserCtxtPtr ctxt,
01008                      const char *chunk,
01009                      int size,
01010                      int terminate);
01011 #endif /* LIBXML_PUSH_ENABLED */
01012 
01013 /*
01014  * Special I/O mode.
01015  */
01016 
01017 XMLPUBFUN xmlParserCtxtPtr XMLCALL 
01018         xmlCreateIOParserCtxt   (xmlSAXHandlerPtr sax,
01019                      void *user_data,
01020                      xmlInputReadCallback   ioread,
01021                      xmlInputCloseCallback  ioclose,
01022                      void *ioctx,
01023                      xmlCharEncoding enc);
01024 
01025 XMLPUBFUN xmlParserInputPtr XMLCALL 
01026         xmlNewIOInputStream (xmlParserCtxtPtr ctxt,
01027                      xmlParserInputBufferPtr input,
01028                      xmlCharEncoding enc);
01029 
01030 /*
01031  * Node infos.
01032  */
01033 XMLPUBFUN const xmlParserNodeInfo* XMLCALL
01034         xmlParserFindNodeInfo   (const xmlParserCtxtPtr ctxt,
01035                          const xmlNodePtr node);
01036 XMLPUBFUN void XMLCALL      
01037         xmlInitNodeInfoSeq  (xmlParserNodeInfoSeqPtr seq);
01038 XMLPUBFUN void XMLCALL      
01039         xmlClearNodeInfoSeq (xmlParserNodeInfoSeqPtr seq);
01040 XMLPUBFUN unsigned long XMLCALL 
01041         xmlParserFindNodeInfoIndex(const xmlParserNodeInfoSeqPtr seq,
01042                                          const xmlNodePtr node);
01043 XMLPUBFUN void XMLCALL      
01044         xmlParserAddNodeInfo    (xmlParserCtxtPtr ctxt,
01045                      const xmlParserNodeInfoPtr info);
01046 
01047 /*
01048  * External entities handling actually implemented in xmlIO.
01049  */
01050 
01051 XMLPUBFUN void XMLCALL      
01052         xmlSetExternalEntityLoader(xmlExternalEntityLoader f);
01053 XMLPUBFUN xmlExternalEntityLoader XMLCALL
01054         xmlGetExternalEntityLoader(void);
01055 XMLPUBFUN xmlParserInputPtr XMLCALL
01056         xmlLoadExternalEntity   (const char *URL,
01057                      const char *ID,
01058                      xmlParserCtxtPtr ctxt);
01059 
01060 /*
01061  * Index lookup, actually implemented in the encoding module
01062  */
01063 XMLPUBFUN long XMLCALL
01064         xmlByteConsumed     (xmlParserCtxtPtr ctxt);
01065 
01066 /*
01067  * New set of simpler/more flexible APIs
01068  */
01075 typedef enum {
01076     XML_PARSE_RECOVER   = 1<<0, /* recover on errors */
01077     XML_PARSE_NOENT = 1<<1, /* substitute entities */
01078     XML_PARSE_DTDLOAD   = 1<<2, /* load the external subset */
01079     XML_PARSE_DTDATTR   = 1<<3, /* default DTD attributes */
01080     XML_PARSE_DTDVALID  = 1<<4, /* validate with the DTD */
01081     XML_PARSE_NOERROR   = 1<<5, /* suppress error reports */
01082     XML_PARSE_NOWARNING = 1<<6, /* suppress warning reports */
01083     XML_PARSE_PEDANTIC  = 1<<7, /* pedantic error reporting */
01084     XML_PARSE_NOBLANKS  = 1<<8, /* remove blank nodes */
01085     XML_PARSE_SAX1  = 1<<9, /* use the SAX1 interface internally */
01086     XML_PARSE_XINCLUDE  = 1<<10,/* Implement XInclude substitition  */
01087     XML_PARSE_NONET = 1<<11,/* Forbid network access */
01088     XML_PARSE_NODICT    = 1<<12,/* Do not reuse the context dictionnary */
01089     XML_PARSE_NSCLEAN   = 1<<13,/* remove redundant namespaces declarations */
01090     XML_PARSE_NOCDATA   = 1<<14,/* merge CDATA as text nodes */
01091     XML_PARSE_NOXINCNODE= 1<<15,/* do not generate XINCLUDE START/END nodes */
01092     XML_PARSE_COMPACT   = 1<<16 /* compact small text nodes; no modification of
01093                                    the tree allowed afterwards (will possibly
01094                    crash if you try to modify the tree) */
01095 } xmlParserOption;
01096 
01097 XMLPUBFUN void XMLCALL
01098         xmlCtxtReset        (xmlParserCtxtPtr ctxt);
01099 XMLPUBFUN int XMLCALL
01100         xmlCtxtResetPush    (xmlParserCtxtPtr ctxt,
01101                      const char *chunk,
01102                      int size,
01103                      const char *filename,
01104                      const char *encoding);
01105 XMLPUBFUN int XMLCALL
01106         xmlCtxtUseOptions   (xmlParserCtxtPtr ctxt,
01107                      int options);
01108 XMLPUBFUN xmlDocPtr XMLCALL
01109         xmlReadDoc      (const xmlChar *cur,
01110                      const char *URL,
01111                      const char *encoding,
01112                      int options);
01113 XMLPUBFUN xmlDocPtr XMLCALL
01114         xmlReadFile     (const char *URL,
01115                      const char *encoding,
01116                      int options);
01117 XMLPUBFUN xmlDocPtr XMLCALL
01118         xmlReadMemory       (const char *buffer,
01119                      int size,
01120                      const char *URL,
01121                      const char *encoding,
01122                      int options);
01123 XMLPUBFUN xmlDocPtr XMLCALL
01124         xmlReadFd       (int fd,
01125                      const char *URL,
01126                      const char *encoding,
01127                      int options);
01128 XMLPUBFUN xmlDocPtr XMLCALL
01129         xmlReadIO       (xmlInputReadCallback ioread,
01130                      xmlInputCloseCallback ioclose,
01131                      void *ioctx,
01132                      const char *URL,
01133                      const char *encoding,
01134                      int options);
01135 XMLPUBFUN xmlDocPtr XMLCALL
01136         xmlCtxtReadDoc      (xmlParserCtxtPtr ctxt,
01137                      const xmlChar *cur,
01138                      const char *URL,
01139                      const char *encoding,
01140                      int options);
01141 XMLPUBFUN xmlDocPtr XMLCALL
01142         xmlCtxtReadFile     (xmlParserCtxtPtr ctxt,
01143                      const char *filename,
01144                      const char *encoding,
01145                      int options);
01146 XMLPUBFUN xmlDocPtr XMLCALL
01147         xmlCtxtReadMemory       (xmlParserCtxtPtr ctxt,
01148                      const char *buffer,
01149                      int size,
01150                      const char *URL,
01151                      const char *encoding,
01152                      int options);
01153 XMLPUBFUN xmlDocPtr XMLCALL
01154         xmlCtxtReadFd       (xmlParserCtxtPtr ctxt,
01155                      int fd,
01156                      const char *URL,
01157                      const char *encoding,
01158                      int options);
01159 XMLPUBFUN xmlDocPtr XMLCALL
01160         xmlCtxtReadIO       (xmlParserCtxtPtr ctxt,
01161                      xmlInputReadCallback ioread,
01162                      xmlInputCloseCallback ioclose,
01163                      void *ioctx,
01164                      const char *URL,
01165                      const char *encoding,
01166                      int options);
01167 
01168 /*
01169  * Library wide options
01170  */
01178 typedef enum {
01179     XML_WITH_THREAD = 1,
01180     XML_WITH_TREE = 2,
01181     XML_WITH_OUTPUT = 3,
01182     XML_WITH_PUSH = 4,
01183     XML_WITH_READER = 5,
01184     XML_WITH_PATTERN = 6,
01185     XML_WITH_WRITER = 7,
01186     XML_WITH_SAX1 = 8,
01187     XML_WITH_FTP = 9,
01188     XML_WITH_HTTP = 10,
01189     XML_WITH_VALID = 11,
01190     XML_WITH_HTML = 12,
01191     XML_WITH_LEGACY = 13,
01192     XML_WITH_C14N = 14,
01193     XML_WITH_CATALOG = 15,
01194     XML_WITH_XPATH = 16,
01195     XML_WITH_XPTR = 17,
01196     XML_WITH_XINCLUDE = 18,
01197     XML_WITH_ICONV = 19,
01198     XML_WITH_ISO8859X = 20,
01199     XML_WITH_UNICODE = 21,
01200     XML_WITH_REGEXP = 22,
01201     XML_WITH_AUTOMATA = 23,
01202     XML_WITH_EXPR = 24,
01203     XML_WITH_SCHEMAS = 25,
01204     XML_WITH_SCHEMATRON = 26,
01205     XML_WITH_MODULES = 27,
01206     XML_WITH_DEBUG = 28,
01207     XML_WITH_DEBUG_MEM = 29,
01208     XML_WITH_DEBUG_RUN = 30,
01209     XML_WITH_ZLIB = 31,
01210     XML_WITH_NONE = 99999 /* just to be sure of allocation size */
01211 } xmlFeature;
01212 
01213 XMLPUBFUN int XMLCALL
01214         xmlHasFeature       (xmlFeature feature);
01215 
01216 #ifdef __cplusplus
01217 }
01218 #endif
01219 #endif /* __XML_PARSER_H__ */
01220 
footer
 SourceForge.net Logo