Path: blob/master/venv/Lib/site-packages/lxml/includes/libxml/parser.h
811 views
/*1* Summary: the core parser module2* Description: Interfaces, constants and types related to the XML parser3*4* Copy: See Copyright for the status of this software.5*6* Author: Daniel Veillard7*/89#ifndef __XML_PARSER_H__10#define __XML_PARSER_H__1112#include <stdarg.h>1314#include <libxml/xmlversion.h>15#include <libxml/tree.h>16#include <libxml/dict.h>17#include <libxml/hash.h>18#include <libxml/valid.h>19#include <libxml/entities.h>20#include <libxml/xmlerror.h>21#include <libxml/xmlstring.h>2223#ifdef __cplusplus24extern "C" {25#endif2627/**28* XML_DEFAULT_VERSION:29*30* The default version of XML used: 1.031*/32#define XML_DEFAULT_VERSION "1.0"3334/**35* xmlParserInput:36*37* An xmlParserInput is an input flow for the XML processor.38* Each entity parsed is associated an xmlParserInput (except the39* few predefined ones). This is the case both for internal entities40* - in which case the flow is already completely in memory - or41* external entities - in which case we use the buf structure for42* progressive reading and I18N conversions to the internal UTF-8 format.43*/4445/**46* xmlParserInputDeallocate:47* @str: the string to deallocate48*49* Callback for freeing some parser input allocations.50*/51typedef void (* xmlParserInputDeallocate)(xmlChar *str);5253struct _xmlParserInput {54/* Input buffer */55xmlParserInputBufferPtr buf; /* UTF-8 encoded buffer */5657const char *filename; /* The file analyzed, if any */58const char *directory; /* the directory/base of the file */59const xmlChar *base; /* Base of the array to parse */60const xmlChar *cur; /* Current char being parsed */61const xmlChar *end; /* end of the array to parse */62int length; /* length if known */63int line; /* Current line */64int col; /* Current column */65/*66* NOTE: consumed is only tested for equality in the parser code,67* so even if there is an overflow this should not give troubles68* for parsing very large instances.69*/70unsigned long consumed; /* How many xmlChars already consumed */71xmlParserInputDeallocate free; /* function to deallocate the base */72const xmlChar *encoding; /* the encoding string for entity */73const xmlChar *version; /* the version string for entity */74int standalone; /* Was that entity marked standalone */75int id; /* an unique identifier for the entity */76};7778/**79* xmlParserNodeInfo:80*81* The parser can be asked to collect Node informations, i.e. at what82* place in the file they were detected.83* NOTE: This is off by default and not very well tested.84*/85typedef struct _xmlParserNodeInfo xmlParserNodeInfo;86typedef xmlParserNodeInfo *xmlParserNodeInfoPtr;8788struct _xmlParserNodeInfo {89const struct _xmlNode* node;90/* Position & line # that text that created the node begins & ends on */91unsigned long begin_pos;92unsigned long begin_line;93unsigned long end_pos;94unsigned long end_line;95};9697typedef struct _xmlParserNodeInfoSeq xmlParserNodeInfoSeq;98typedef xmlParserNodeInfoSeq *xmlParserNodeInfoSeqPtr;99struct _xmlParserNodeInfoSeq {100unsigned long maximum;101unsigned long length;102xmlParserNodeInfo* buffer;103};104105/**106* xmlParserInputState:107*108* The parser is now working also as a state based parser.109* The recursive one use the state info for entities processing.110*/111typedef enum {112XML_PARSER_EOF = -1, /* nothing is to be parsed */113XML_PARSER_START = 0, /* nothing has been parsed */114XML_PARSER_MISC, /* Misc* before int subset */115XML_PARSER_PI, /* Within a processing instruction */116XML_PARSER_DTD, /* within some DTD content */117XML_PARSER_PROLOG, /* Misc* after internal subset */118XML_PARSER_COMMENT, /* within a comment */119XML_PARSER_START_TAG, /* within a start tag */120XML_PARSER_CONTENT, /* within the content */121XML_PARSER_CDATA_SECTION, /* within a CDATA section */122XML_PARSER_END_TAG, /* within a closing tag */123XML_PARSER_ENTITY_DECL, /* within an entity declaration */124XML_PARSER_ENTITY_VALUE, /* within an entity value in a decl */125XML_PARSER_ATTRIBUTE_VALUE, /* within an attribute value */126XML_PARSER_SYSTEM_LITERAL, /* within a SYSTEM value */127XML_PARSER_EPILOG, /* the Misc* after the last end tag */128XML_PARSER_IGNORE, /* within an IGNORED section */129XML_PARSER_PUBLIC_LITERAL /* within a PUBLIC value */130} xmlParserInputState;131132/**133* XML_DETECT_IDS:134*135* Bit in the loadsubset context field to tell to do ID/REFs lookups.136* Use it to initialize xmlLoadExtDtdDefaultValue.137*/138#define XML_DETECT_IDS 2139140/**141* XML_COMPLETE_ATTRS:142*143* Bit in the loadsubset context field to tell to do complete the144* elements attributes lists with the ones defaulted from the DTDs.145* Use it to initialize xmlLoadExtDtdDefaultValue.146*/147#define XML_COMPLETE_ATTRS 4148149/**150* XML_SKIP_IDS:151*152* Bit in the loadsubset context field to tell to not do ID/REFs registration.153* Used to initialize xmlLoadExtDtdDefaultValue in some special cases.154*/155#define XML_SKIP_IDS 8156157/**158* xmlParserMode:159*160* A parser can operate in various modes161*/162typedef enum {163XML_PARSE_UNKNOWN = 0,164XML_PARSE_DOM = 1,165XML_PARSE_SAX = 2,166XML_PARSE_PUSH_DOM = 3,167XML_PARSE_PUSH_SAX = 4,168XML_PARSE_READER = 5169} xmlParserMode;170171/**172* xmlParserCtxt:173*174* The parser context.175* NOTE This doesn't completely define the parser state, the (current ?)176* design of the parser uses recursive function calls since this allow177* and easy mapping from the production rules of the specification178* to the actual code. The drawback is that the actual function call179* also reflect the parser state. However most of the parsing routines180* takes as the only argument the parser context pointer, so migrating181* to a state based parser for progressive parsing shouldn't be too hard.182*/183struct _xmlParserCtxt {184struct _xmlSAXHandler *sax; /* The SAX handler */185void *userData; /* For SAX interface only, used by DOM build */186xmlDocPtr myDoc; /* the document being built */187int wellFormed; /* is the document well formed */188int replaceEntities; /* shall we replace entities ? */189const xmlChar *version; /* the XML version string */190const xmlChar *encoding; /* the declared encoding, if any */191int standalone; /* standalone document */192int html; /* an HTML(1)/Docbook(2) document193* 3 is HTML after <head>194* 10 is HTML after <body>195*/196197/* Input stream stack */198xmlParserInputPtr input; /* Current input stream */199int inputNr; /* Number of current input streams */200int inputMax; /* Max number of input streams */201xmlParserInputPtr *inputTab; /* stack of inputs */202203/* Node analysis stack only used for DOM building */204xmlNodePtr node; /* Current parsed Node */205int nodeNr; /* Depth of the parsing stack */206int nodeMax; /* Max depth of the parsing stack */207xmlNodePtr *nodeTab; /* array of nodes */208209int record_info; /* Whether node info should be kept */210xmlParserNodeInfoSeq node_seq; /* info about each node parsed */211212int errNo; /* error code */213214int hasExternalSubset; /* reference and external subset */215int hasPErefs; /* the internal subset has PE refs */216int external; /* are we parsing an external entity */217218int valid; /* is the document valid */219int validate; /* shall we try to validate ? */220xmlValidCtxt vctxt; /* The validity context */221222xmlParserInputState instate; /* current type of input */223int token; /* next char look-ahead */224225char *directory; /* the data directory */226227/* Node name stack */228const xmlChar *name; /* Current parsed Node */229int nameNr; /* Depth of the parsing stack */230int nameMax; /* Max depth of the parsing stack */231const xmlChar * *nameTab; /* array of nodes */232233long nbChars; /* number of xmlChar processed */234long checkIndex; /* used by progressive parsing lookup */235int keepBlanks; /* ugly but ... */236int disableSAX; /* SAX callbacks are disabled */237int inSubset; /* Parsing is in int 1/ext 2 subset */238const xmlChar * intSubName; /* name of subset */239xmlChar * extSubURI; /* URI of external subset */240xmlChar * extSubSystem; /* SYSTEM ID of external subset */241242/* xml:space values */243int * space; /* Should the parser preserve spaces */244int spaceNr; /* Depth of the parsing stack */245int spaceMax; /* Max depth of the parsing stack */246int * spaceTab; /* array of space infos */247248int depth; /* to prevent entity substitution loops */249xmlParserInputPtr entity; /* used to check entities boundaries */250int charset; /* encoding of the in-memory content251actually an xmlCharEncoding */252int nodelen; /* Those two fields are there to */253int nodemem; /* Speed up large node parsing */254int pedantic; /* signal pedantic warnings */255void *_private; /* For user data, libxml won't touch it */256257int loadsubset; /* should the external subset be loaded */258int linenumbers; /* set line number in element content */259void *catalogs; /* document's own catalog */260int recovery; /* run in recovery mode */261int progressive; /* is this a progressive parsing */262xmlDictPtr dict; /* dictionary for the parser */263const xmlChar * *atts; /* array for the attributes callbacks */264int maxatts; /* the size of the array */265int docdict; /* use strings from dict to build tree */266267/*268* pre-interned strings269*/270const xmlChar *str_xml;271const xmlChar *str_xmlns;272const xmlChar *str_xml_ns;273274/*275* Everything below is used only by the new SAX mode276*/277int sax2; /* operating in the new SAX mode */278int nsNr; /* the number of inherited namespaces */279int nsMax; /* the size of the arrays */280const xmlChar * *nsTab; /* the array of prefix/namespace name */281int *attallocs; /* which attribute were allocated */282void * *pushTab; /* array of data for push */283xmlHashTablePtr attsDefault; /* defaulted attributes if any */284xmlHashTablePtr attsSpecial; /* non-CDATA attributes if any */285int nsWellFormed; /* is the document XML Nanespace okay */286int options; /* Extra options */287288/*289* Those fields are needed only for treaming parsing so far290*/291int dictNames; /* Use dictionary names for the tree */292int freeElemsNr; /* number of freed element nodes */293xmlNodePtr freeElems; /* List of freed element nodes */294int freeAttrsNr; /* number of freed attributes nodes */295xmlAttrPtr freeAttrs; /* List of freed attributes nodes */296297/*298* the complete error informations for the last error.299*/300xmlError lastError;301xmlParserMode parseMode; /* the parser mode */302unsigned long nbentities; /* number of entities references */303unsigned long sizeentities; /* size of parsed entities */304305/* for use by HTML non-recursive parser */306xmlParserNodeInfo *nodeInfo; /* Current NodeInfo */307int nodeInfoNr; /* Depth of the parsing stack */308int nodeInfoMax; /* Max depth of the parsing stack */309xmlParserNodeInfo *nodeInfoTab; /* array of nodeInfos */310311int input_id; /* we need to label inputs */312unsigned long sizeentcopy; /* volume of entity copy */313};314315/**316* xmlSAXLocator:317*318* A SAX Locator.319*/320struct _xmlSAXLocator {321const xmlChar *(*getPublicId)(void *ctx);322const xmlChar *(*getSystemId)(void *ctx);323int (*getLineNumber)(void *ctx);324int (*getColumnNumber)(void *ctx);325};326327/**328* xmlSAXHandler:329*330* A SAX handler is bunch of callbacks called by the parser when processing331* of the input generate data or structure informations.332*/333334/**335* resolveEntitySAXFunc:336* @ctx: the user data (XML parser context)337* @publicId: The public ID of the entity338* @systemId: The system ID of the entity339*340* Callback:341* The entity loader, to control the loading of external entities,342* the application can either:343* - override this resolveEntity() callback in the SAX block344* - or better use the xmlSetExternalEntityLoader() function to345* set up it's own entity resolution routine346*347* Returns the xmlParserInputPtr if inlined or NULL for DOM behaviour.348*/349typedef xmlParserInputPtr (*resolveEntitySAXFunc) (void *ctx,350const xmlChar *publicId,351const xmlChar *systemId);352/**353* internalSubsetSAXFunc:354* @ctx: the user data (XML parser context)355* @name: the root element name356* @ExternalID: the external ID357* @SystemID: the SYSTEM ID (e.g. filename or URL)358*359* Callback on internal subset declaration.360*/361typedef void (*internalSubsetSAXFunc) (void *ctx,362const xmlChar *name,363const xmlChar *ExternalID,364const xmlChar *SystemID);365/**366* externalSubsetSAXFunc:367* @ctx: the user data (XML parser context)368* @name: the root element name369* @ExternalID: the external ID370* @SystemID: the SYSTEM ID (e.g. filename or URL)371*372* Callback on external subset declaration.373*/374typedef void (*externalSubsetSAXFunc) (void *ctx,375const xmlChar *name,376const xmlChar *ExternalID,377const xmlChar *SystemID);378/**379* getEntitySAXFunc:380* @ctx: the user data (XML parser context)381* @name: The entity name382*383* Get an entity by name.384*385* Returns the xmlEntityPtr if found.386*/387typedef xmlEntityPtr (*getEntitySAXFunc) (void *ctx,388const xmlChar *name);389/**390* getParameterEntitySAXFunc:391* @ctx: the user data (XML parser context)392* @name: The entity name393*394* Get a parameter entity by name.395*396* Returns the xmlEntityPtr if found.397*/398typedef xmlEntityPtr (*getParameterEntitySAXFunc) (void *ctx,399const xmlChar *name);400/**401* entityDeclSAXFunc:402* @ctx: the user data (XML parser context)403* @name: the entity name404* @type: the entity type405* @publicId: The public ID of the entity406* @systemId: The system ID of the entity407* @content: the entity value (without processing).408*409* An entity definition has been parsed.410*/411typedef void (*entityDeclSAXFunc) (void *ctx,412const xmlChar *name,413int type,414const xmlChar *publicId,415const xmlChar *systemId,416xmlChar *content);417/**418* notationDeclSAXFunc:419* @ctx: the user data (XML parser context)420* @name: The name of the notation421* @publicId: The public ID of the entity422* @systemId: The system ID of the entity423*424* What to do when a notation declaration has been parsed.425*/426typedef void (*notationDeclSAXFunc)(void *ctx,427const xmlChar *name,428const xmlChar *publicId,429const xmlChar *systemId);430/**431* attributeDeclSAXFunc:432* @ctx: the user data (XML parser context)433* @elem: the name of the element434* @fullname: the attribute name435* @type: the attribute type436* @def: the type of default value437* @defaultValue: the attribute default value438* @tree: the tree of enumerated value set439*440* An attribute definition has been parsed.441*/442typedef void (*attributeDeclSAXFunc)(void *ctx,443const xmlChar *elem,444const xmlChar *fullname,445int type,446int def,447const xmlChar *defaultValue,448xmlEnumerationPtr tree);449/**450* elementDeclSAXFunc:451* @ctx: the user data (XML parser context)452* @name: the element name453* @type: the element type454* @content: the element value tree455*456* An element definition has been parsed.457*/458typedef void (*elementDeclSAXFunc)(void *ctx,459const xmlChar *name,460int type,461xmlElementContentPtr content);462/**463* unparsedEntityDeclSAXFunc:464* @ctx: the user data (XML parser context)465* @name: The name of the entity466* @publicId: The public ID of the entity467* @systemId: The system ID of the entity468* @notationName: the name of the notation469*470* What to do when an unparsed entity declaration is parsed.471*/472typedef void (*unparsedEntityDeclSAXFunc)(void *ctx,473const xmlChar *name,474const xmlChar *publicId,475const xmlChar *systemId,476const xmlChar *notationName);477/**478* setDocumentLocatorSAXFunc:479* @ctx: the user data (XML parser context)480* @loc: A SAX Locator481*482* Receive the document locator at startup, actually xmlDefaultSAXLocator.483* Everything is available on the context, so this is useless in our case.484*/485typedef void (*setDocumentLocatorSAXFunc) (void *ctx,486xmlSAXLocatorPtr loc);487/**488* startDocumentSAXFunc:489* @ctx: the user data (XML parser context)490*491* Called when the document start being processed.492*/493typedef void (*startDocumentSAXFunc) (void *ctx);494/**495* endDocumentSAXFunc:496* @ctx: the user data (XML parser context)497*498* Called when the document end has been detected.499*/500typedef void (*endDocumentSAXFunc) (void *ctx);501/**502* startElementSAXFunc:503* @ctx: the user data (XML parser context)504* @name: The element name, including namespace prefix505* @atts: An array of name/value attributes pairs, NULL terminated506*507* Called when an opening tag has been processed.508*/509typedef void (*startElementSAXFunc) (void *ctx,510const xmlChar *name,511const xmlChar **atts);512/**513* endElementSAXFunc:514* @ctx: the user data (XML parser context)515* @name: The element name516*517* Called when the end of an element has been detected.518*/519typedef void (*endElementSAXFunc) (void *ctx,520const xmlChar *name);521/**522* attributeSAXFunc:523* @ctx: the user data (XML parser context)524* @name: The attribute name, including namespace prefix525* @value: The attribute value526*527* Handle an attribute that has been read by the parser.528* The default handling is to convert the attribute into an529* DOM subtree and past it in a new xmlAttr element added to530* the element.531*/532typedef void (*attributeSAXFunc) (void *ctx,533const xmlChar *name,534const xmlChar *value);535/**536* referenceSAXFunc:537* @ctx: the user data (XML parser context)538* @name: The entity name539*540* Called when an entity reference is detected.541*/542typedef void (*referenceSAXFunc) (void *ctx,543const xmlChar *name);544/**545* charactersSAXFunc:546* @ctx: the user data (XML parser context)547* @ch: a xmlChar string548* @len: the number of xmlChar549*550* Receiving some chars from the parser.551*/552typedef void (*charactersSAXFunc) (void *ctx,553const xmlChar *ch,554int len);555/**556* ignorableWhitespaceSAXFunc:557* @ctx: the user data (XML parser context)558* @ch: a xmlChar string559* @len: the number of xmlChar560*561* Receiving some ignorable whitespaces from the parser.562* UNUSED: by default the DOM building will use characters.563*/564typedef void (*ignorableWhitespaceSAXFunc) (void *ctx,565const xmlChar *ch,566int len);567/**568* processingInstructionSAXFunc:569* @ctx: the user data (XML parser context)570* @target: the target name571* @data: the PI data's572*573* A processing instruction has been parsed.574*/575typedef void (*processingInstructionSAXFunc) (void *ctx,576const xmlChar *target,577const xmlChar *data);578/**579* commentSAXFunc:580* @ctx: the user data (XML parser context)581* @value: the comment content582*583* A comment has been parsed.584*/585typedef void (*commentSAXFunc) (void *ctx,586const xmlChar *value);587/**588* cdataBlockSAXFunc:589* @ctx: the user data (XML parser context)590* @value: The pcdata content591* @len: the block length592*593* Called when a pcdata block has been parsed.594*/595typedef void (*cdataBlockSAXFunc) (596void *ctx,597const xmlChar *value,598int len);599/**600* warningSAXFunc:601* @ctx: an XML parser context602* @msg: the message to display/transmit603* @...: extra parameters for the message display604*605* Display and format a warning messages, callback.606*/607typedef void (XMLCDECL *warningSAXFunc) (void *ctx,608const char *msg, ...) LIBXML_ATTR_FORMAT(2,3);609/**610* errorSAXFunc:611* @ctx: an XML parser context612* @msg: the message to display/transmit613* @...: extra parameters for the message display614*615* Display and format an error messages, callback.616*/617typedef void (XMLCDECL *errorSAXFunc) (void *ctx,618const char *msg, ...) LIBXML_ATTR_FORMAT(2,3);619/**620* fatalErrorSAXFunc:621* @ctx: an XML parser context622* @msg: the message to display/transmit623* @...: extra parameters for the message display624*625* Display and format fatal error messages, callback.626* Note: so far fatalError() SAX callbacks are not used, error()627* get all the callbacks for errors.628*/629typedef void (XMLCDECL *fatalErrorSAXFunc) (void *ctx,630const char *msg, ...) LIBXML_ATTR_FORMAT(2,3);631/**632* isStandaloneSAXFunc:633* @ctx: the user data (XML parser context)634*635* Is this document tagged standalone?636*637* Returns 1 if true638*/639typedef int (*isStandaloneSAXFunc) (void *ctx);640/**641* hasInternalSubsetSAXFunc:642* @ctx: the user data (XML parser context)643*644* Does this document has an internal subset.645*646* Returns 1 if true647*/648typedef int (*hasInternalSubsetSAXFunc) (void *ctx);649650/**651* hasExternalSubsetSAXFunc:652* @ctx: the user data (XML parser context)653*654* Does this document has an external subset?655*656* Returns 1 if true657*/658typedef int (*hasExternalSubsetSAXFunc) (void *ctx);659660/************************************************************************661* *662* The SAX version 2 API extensions *663* *664************************************************************************/665/**666* XML_SAX2_MAGIC:667*668* Special constant found in SAX2 blocks initialized fields669*/670#define XML_SAX2_MAGIC 0xDEEDBEAF671672/**673* startElementNsSAX2Func:674* @ctx: the user data (XML parser context)675* @localname: the local name of the element676* @prefix: the element namespace prefix if available677* @URI: the element namespace name if available678* @nb_namespaces: number of namespace definitions on that node679* @namespaces: pointer to the array of prefix/URI pairs namespace definitions680* @nb_attributes: the number of attributes on that node681* @nb_defaulted: the number of defaulted attributes. The defaulted682* ones are at the end of the array683* @attributes: pointer to the array of (localname/prefix/URI/value/end)684* attribute values.685*686* SAX2 callback when an element start has been detected by the parser.687* It provides the namespace informations for the element, as well as688* the new namespace declarations on the element.689*/690691typedef void (*startElementNsSAX2Func) (void *ctx,692const xmlChar *localname,693const xmlChar *prefix,694const xmlChar *URI,695int nb_namespaces,696const xmlChar **namespaces,697int nb_attributes,698int nb_defaulted,699const xmlChar **attributes);700701/**702* endElementNsSAX2Func:703* @ctx: the user data (XML parser context)704* @localname: the local name of the element705* @prefix: the element namespace prefix if available706* @URI: the element namespace name if available707*708* SAX2 callback when an element end has been detected by the parser.709* It provides the namespace informations for the element.710*/711712typedef void (*endElementNsSAX2Func) (void *ctx,713const xmlChar *localname,714const xmlChar *prefix,715const xmlChar *URI);716717718struct _xmlSAXHandler {719internalSubsetSAXFunc internalSubset;720isStandaloneSAXFunc isStandalone;721hasInternalSubsetSAXFunc hasInternalSubset;722hasExternalSubsetSAXFunc hasExternalSubset;723resolveEntitySAXFunc resolveEntity;724getEntitySAXFunc getEntity;725entityDeclSAXFunc entityDecl;726notationDeclSAXFunc notationDecl;727attributeDeclSAXFunc attributeDecl;728elementDeclSAXFunc elementDecl;729unparsedEntityDeclSAXFunc unparsedEntityDecl;730setDocumentLocatorSAXFunc setDocumentLocator;731startDocumentSAXFunc startDocument;732endDocumentSAXFunc endDocument;733startElementSAXFunc startElement;734endElementSAXFunc endElement;735referenceSAXFunc reference;736charactersSAXFunc characters;737ignorableWhitespaceSAXFunc ignorableWhitespace;738processingInstructionSAXFunc processingInstruction;739commentSAXFunc comment;740warningSAXFunc warning;741errorSAXFunc error;742fatalErrorSAXFunc fatalError; /* unused error() get all the errors */743getParameterEntitySAXFunc getParameterEntity;744cdataBlockSAXFunc cdataBlock;745externalSubsetSAXFunc externalSubset;746unsigned int initialized;747/* The following fields are extensions available only on version 2 */748void *_private;749startElementNsSAX2Func startElementNs;750endElementNsSAX2Func endElementNs;751xmlStructuredErrorFunc serror;752};753754/*755* SAX Version 1756*/757typedef struct _xmlSAXHandlerV1 xmlSAXHandlerV1;758typedef xmlSAXHandlerV1 *xmlSAXHandlerV1Ptr;759struct _xmlSAXHandlerV1 {760internalSubsetSAXFunc internalSubset;761isStandaloneSAXFunc isStandalone;762hasInternalSubsetSAXFunc hasInternalSubset;763hasExternalSubsetSAXFunc hasExternalSubset;764resolveEntitySAXFunc resolveEntity;765getEntitySAXFunc getEntity;766entityDeclSAXFunc entityDecl;767notationDeclSAXFunc notationDecl;768attributeDeclSAXFunc attributeDecl;769elementDeclSAXFunc elementDecl;770unparsedEntityDeclSAXFunc unparsedEntityDecl;771setDocumentLocatorSAXFunc setDocumentLocator;772startDocumentSAXFunc startDocument;773endDocumentSAXFunc endDocument;774startElementSAXFunc startElement;775endElementSAXFunc endElement;776referenceSAXFunc reference;777charactersSAXFunc characters;778ignorableWhitespaceSAXFunc ignorableWhitespace;779processingInstructionSAXFunc processingInstruction;780commentSAXFunc comment;781warningSAXFunc warning;782errorSAXFunc error;783fatalErrorSAXFunc fatalError; /* unused error() get all the errors */784getParameterEntitySAXFunc getParameterEntity;785cdataBlockSAXFunc cdataBlock;786externalSubsetSAXFunc externalSubset;787unsigned int initialized;788};789790791/**792* xmlExternalEntityLoader:793* @URL: The System ID of the resource requested794* @ID: The Public ID of the resource requested795* @context: the XML parser context796*797* External entity loaders types.798*799* Returns the entity input parser.800*/801typedef xmlParserInputPtr (*xmlExternalEntityLoader) (const char *URL,802const char *ID,803xmlParserCtxtPtr context);804805#ifdef __cplusplus806}807#endif808809#include <libxml/encoding.h>810#include <libxml/xmlIO.h>811#include <libxml/globals.h>812813#ifdef __cplusplus814extern "C" {815#endif816817818/*819* Init/Cleanup820*/821XMLPUBFUN void XMLCALL822xmlInitParser (void);823XMLPUBFUN void XMLCALL824xmlCleanupParser (void);825826/*827* Input functions828*/829XMLPUBFUN int XMLCALL830xmlParserInputRead (xmlParserInputPtr in,831int len);832XMLPUBFUN int XMLCALL833xmlParserInputGrow (xmlParserInputPtr in,834int len);835836/*837* Basic parsing Interfaces838*/839#ifdef LIBXML_SAX1_ENABLED840XMLPUBFUN xmlDocPtr XMLCALL841xmlParseDoc (const xmlChar *cur);842XMLPUBFUN xmlDocPtr XMLCALL843xmlParseFile (const char *filename);844XMLPUBFUN xmlDocPtr XMLCALL845xmlParseMemory (const char *buffer,846int size);847#endif /* LIBXML_SAX1_ENABLED */848XMLPUBFUN int XMLCALL849xmlSubstituteEntitiesDefault(int val);850XMLPUBFUN int XMLCALL851xmlKeepBlanksDefault (int val);852XMLPUBFUN void XMLCALL853xmlStopParser (xmlParserCtxtPtr ctxt);854XMLPUBFUN int XMLCALL855xmlPedanticParserDefault(int val);856XMLPUBFUN int XMLCALL857xmlLineNumbersDefault (int val);858859#ifdef LIBXML_SAX1_ENABLED860/*861* Recovery mode862*/863XMLPUBFUN xmlDocPtr XMLCALL864xmlRecoverDoc (const xmlChar *cur);865XMLPUBFUN xmlDocPtr XMLCALL866xmlRecoverMemory (const char *buffer,867int size);868XMLPUBFUN xmlDocPtr XMLCALL869xmlRecoverFile (const char *filename);870#endif /* LIBXML_SAX1_ENABLED */871872/*873* Less common routines and SAX interfaces874*/875XMLPUBFUN int XMLCALL876xmlParseDocument (xmlParserCtxtPtr ctxt);877XMLPUBFUN int XMLCALL878xmlParseExtParsedEnt (xmlParserCtxtPtr ctxt);879#ifdef LIBXML_SAX1_ENABLED880XMLPUBFUN int XMLCALL881xmlSAXUserParseFile (xmlSAXHandlerPtr sax,882void *user_data,883const char *filename);884XMLPUBFUN int XMLCALL885xmlSAXUserParseMemory (xmlSAXHandlerPtr sax,886void *user_data,887const char *buffer,888int size);889XMLPUBFUN xmlDocPtr XMLCALL890xmlSAXParseDoc (xmlSAXHandlerPtr sax,891const xmlChar *cur,892int recovery);893XMLPUBFUN xmlDocPtr XMLCALL894xmlSAXParseMemory (xmlSAXHandlerPtr sax,895const char *buffer,896int size,897int recovery);898XMLPUBFUN xmlDocPtr XMLCALL899xmlSAXParseMemoryWithData (xmlSAXHandlerPtr sax,900const char *buffer,901int size,902int recovery,903void *data);904XMLPUBFUN xmlDocPtr XMLCALL905xmlSAXParseFile (xmlSAXHandlerPtr sax,906const char *filename,907int recovery);908XMLPUBFUN xmlDocPtr XMLCALL909xmlSAXParseFileWithData (xmlSAXHandlerPtr sax,910const char *filename,911int recovery,912void *data);913XMLPUBFUN xmlDocPtr XMLCALL914xmlSAXParseEntity (xmlSAXHandlerPtr sax,915const char *filename);916XMLPUBFUN xmlDocPtr XMLCALL917xmlParseEntity (const char *filename);918#endif /* LIBXML_SAX1_ENABLED */919920#ifdef LIBXML_VALID_ENABLED921XMLPUBFUN xmlDtdPtr XMLCALL922xmlSAXParseDTD (xmlSAXHandlerPtr sax,923const xmlChar *ExternalID,924const xmlChar *SystemID);925XMLPUBFUN xmlDtdPtr XMLCALL926xmlParseDTD (const xmlChar *ExternalID,927const xmlChar *SystemID);928XMLPUBFUN xmlDtdPtr XMLCALL929xmlIOParseDTD (xmlSAXHandlerPtr sax,930xmlParserInputBufferPtr input,931xmlCharEncoding enc);932#endif /* LIBXML_VALID_ENABLE */933#ifdef LIBXML_SAX1_ENABLED934XMLPUBFUN int XMLCALL935xmlParseBalancedChunkMemory(xmlDocPtr doc,936xmlSAXHandlerPtr sax,937void *user_data,938int depth,939const xmlChar *string,940xmlNodePtr *lst);941#endif /* LIBXML_SAX1_ENABLED */942XMLPUBFUN xmlParserErrors XMLCALL943xmlParseInNodeContext (xmlNodePtr node,944const char *data,945int datalen,946int options,947xmlNodePtr *lst);948#ifdef LIBXML_SAX1_ENABLED949XMLPUBFUN int XMLCALL950xmlParseBalancedChunkMemoryRecover(xmlDocPtr doc,951xmlSAXHandlerPtr sax,952void *user_data,953int depth,954const xmlChar *string,955xmlNodePtr *lst,956int recover);957XMLPUBFUN int XMLCALL958xmlParseExternalEntity (xmlDocPtr doc,959xmlSAXHandlerPtr sax,960void *user_data,961int depth,962const xmlChar *URL,963const xmlChar *ID,964xmlNodePtr *lst);965#endif /* LIBXML_SAX1_ENABLED */966XMLPUBFUN int XMLCALL967xmlParseCtxtExternalEntity(xmlParserCtxtPtr ctx,968const xmlChar *URL,969const xmlChar *ID,970xmlNodePtr *lst);971972/*973* Parser contexts handling.974*/975XMLPUBFUN xmlParserCtxtPtr XMLCALL976xmlNewParserCtxt (void);977XMLPUBFUN int XMLCALL978xmlInitParserCtxt (xmlParserCtxtPtr ctxt);979XMLPUBFUN void XMLCALL980xmlClearParserCtxt (xmlParserCtxtPtr ctxt);981XMLPUBFUN void XMLCALL982xmlFreeParserCtxt (xmlParserCtxtPtr ctxt);983#ifdef LIBXML_SAX1_ENABLED984XMLPUBFUN void XMLCALL985xmlSetupParserForBuffer (xmlParserCtxtPtr ctxt,986const xmlChar* buffer,987const char *filename);988#endif /* LIBXML_SAX1_ENABLED */989XMLPUBFUN xmlParserCtxtPtr XMLCALL990xmlCreateDocParserCtxt (const xmlChar *cur);991992#ifdef LIBXML_LEGACY_ENABLED993/*994* Reading/setting optional parsing features.995*/996XMLPUBFUN int XMLCALL997xmlGetFeaturesList (int *len,998const char **result);999XMLPUBFUN int XMLCALL1000xmlGetFeature (xmlParserCtxtPtr ctxt,1001const char *name,1002void *result);1003XMLPUBFUN int XMLCALL1004xmlSetFeature (xmlParserCtxtPtr ctxt,1005const char *name,1006void *value);1007#endif /* LIBXML_LEGACY_ENABLED */10081009#ifdef LIBXML_PUSH_ENABLED1010/*1011* Interfaces for the Push mode.1012*/1013XMLPUBFUN xmlParserCtxtPtr XMLCALL1014xmlCreatePushParserCtxt(xmlSAXHandlerPtr sax,1015void *user_data,1016const char *chunk,1017int size,1018const char *filename);1019XMLPUBFUN int XMLCALL1020xmlParseChunk (xmlParserCtxtPtr ctxt,1021const char *chunk,1022int size,1023int terminate);1024#endif /* LIBXML_PUSH_ENABLED */10251026/*1027* Special I/O mode.1028*/10291030XMLPUBFUN xmlParserCtxtPtr XMLCALL1031xmlCreateIOParserCtxt (xmlSAXHandlerPtr sax,1032void *user_data,1033xmlInputReadCallback ioread,1034xmlInputCloseCallback ioclose,1035void *ioctx,1036xmlCharEncoding enc);10371038XMLPUBFUN xmlParserInputPtr XMLCALL1039xmlNewIOInputStream (xmlParserCtxtPtr ctxt,1040xmlParserInputBufferPtr input,1041xmlCharEncoding enc);10421043/*1044* Node infos.1045*/1046XMLPUBFUN const xmlParserNodeInfo* XMLCALL1047xmlParserFindNodeInfo (const xmlParserCtxtPtr ctxt,1048const xmlNodePtr node);1049XMLPUBFUN void XMLCALL1050xmlInitNodeInfoSeq (xmlParserNodeInfoSeqPtr seq);1051XMLPUBFUN void XMLCALL1052xmlClearNodeInfoSeq (xmlParserNodeInfoSeqPtr seq);1053XMLPUBFUN unsigned long XMLCALL1054xmlParserFindNodeInfoIndex(const xmlParserNodeInfoSeqPtr seq,1055const xmlNodePtr node);1056XMLPUBFUN void XMLCALL1057xmlParserAddNodeInfo (xmlParserCtxtPtr ctxt,1058const xmlParserNodeInfoPtr info);10591060/*1061* External entities handling actually implemented in xmlIO.1062*/10631064XMLPUBFUN void XMLCALL1065xmlSetExternalEntityLoader(xmlExternalEntityLoader f);1066XMLPUBFUN xmlExternalEntityLoader XMLCALL1067xmlGetExternalEntityLoader(void);1068XMLPUBFUN xmlParserInputPtr XMLCALL1069xmlLoadExternalEntity (const char *URL,1070const char *ID,1071xmlParserCtxtPtr ctxt);10721073/*1074* Index lookup, actually implemented in the encoding module1075*/1076XMLPUBFUN long XMLCALL1077xmlByteConsumed (xmlParserCtxtPtr ctxt);10781079/*1080* New set of simpler/more flexible APIs1081*/1082/**1083* xmlParserOption:1084*1085* This is the set of XML parser options that can be passed down1086* to the xmlReadDoc() and similar calls.1087*/1088typedef enum {1089XML_PARSE_RECOVER = 1<<0, /* recover on errors */1090XML_PARSE_NOENT = 1<<1, /* substitute entities */1091XML_PARSE_DTDLOAD = 1<<2, /* load the external subset */1092XML_PARSE_DTDATTR = 1<<3, /* default DTD attributes */1093XML_PARSE_DTDVALID = 1<<4, /* validate with the DTD */1094XML_PARSE_NOERROR = 1<<5, /* suppress error reports */1095XML_PARSE_NOWARNING = 1<<6, /* suppress warning reports */1096XML_PARSE_PEDANTIC = 1<<7, /* pedantic error reporting */1097XML_PARSE_NOBLANKS = 1<<8, /* remove blank nodes */1098XML_PARSE_SAX1 = 1<<9, /* use the SAX1 interface internally */1099XML_PARSE_XINCLUDE = 1<<10,/* Implement XInclude substitition */1100XML_PARSE_NONET = 1<<11,/* Forbid network access */1101XML_PARSE_NODICT = 1<<12,/* Do not reuse the context dictionary */1102XML_PARSE_NSCLEAN = 1<<13,/* remove redundant namespaces declarations */1103XML_PARSE_NOCDATA = 1<<14,/* merge CDATA as text nodes */1104XML_PARSE_NOXINCNODE= 1<<15,/* do not generate XINCLUDE START/END nodes */1105XML_PARSE_COMPACT = 1<<16,/* compact small text nodes; no modification of1106the tree allowed afterwards (will possibly1107crash if you try to modify the tree) */1108XML_PARSE_OLD10 = 1<<17,/* parse using XML-1.0 before update 5 */1109XML_PARSE_NOBASEFIX = 1<<18,/* do not fixup XINCLUDE xml:base uris */1110XML_PARSE_HUGE = 1<<19,/* relax any hardcoded limit from the parser */1111XML_PARSE_OLDSAX = 1<<20,/* parse using SAX2 interface before 2.7.0 */1112XML_PARSE_IGNORE_ENC= 1<<21,/* ignore internal document encoding hint */1113XML_PARSE_BIG_LINES = 1<<22 /* Store big lines numbers in text PSVI field */1114} xmlParserOption;11151116XMLPUBFUN void XMLCALL1117xmlCtxtReset (xmlParserCtxtPtr ctxt);1118XMLPUBFUN int XMLCALL1119xmlCtxtResetPush (xmlParserCtxtPtr ctxt,1120const char *chunk,1121int size,1122const char *filename,1123const char *encoding);1124XMLPUBFUN int XMLCALL1125xmlCtxtUseOptions (xmlParserCtxtPtr ctxt,1126int options);1127XMLPUBFUN xmlDocPtr XMLCALL1128xmlReadDoc (const xmlChar *cur,1129const char *URL,1130const char *encoding,1131int options);1132XMLPUBFUN xmlDocPtr XMLCALL1133xmlReadFile (const char *URL,1134const char *encoding,1135int options);1136XMLPUBFUN xmlDocPtr XMLCALL1137xmlReadMemory (const char *buffer,1138int size,1139const char *URL,1140const char *encoding,1141int options);1142XMLPUBFUN xmlDocPtr XMLCALL1143xmlReadFd (int fd,1144const char *URL,1145const char *encoding,1146int options);1147XMLPUBFUN xmlDocPtr XMLCALL1148xmlReadIO (xmlInputReadCallback ioread,1149xmlInputCloseCallback ioclose,1150void *ioctx,1151const char *URL,1152const char *encoding,1153int options);1154XMLPUBFUN xmlDocPtr XMLCALL1155xmlCtxtReadDoc (xmlParserCtxtPtr ctxt,1156const xmlChar *cur,1157const char *URL,1158const char *encoding,1159int options);1160XMLPUBFUN xmlDocPtr XMLCALL1161xmlCtxtReadFile (xmlParserCtxtPtr ctxt,1162const char *filename,1163const char *encoding,1164int options);1165XMLPUBFUN xmlDocPtr XMLCALL1166xmlCtxtReadMemory (xmlParserCtxtPtr ctxt,1167const char *buffer,1168int size,1169const char *URL,1170const char *encoding,1171int options);1172XMLPUBFUN xmlDocPtr XMLCALL1173xmlCtxtReadFd (xmlParserCtxtPtr ctxt,1174int fd,1175const char *URL,1176const char *encoding,1177int options);1178XMLPUBFUN xmlDocPtr XMLCALL1179xmlCtxtReadIO (xmlParserCtxtPtr ctxt,1180xmlInputReadCallback ioread,1181xmlInputCloseCallback ioclose,1182void *ioctx,1183const char *URL,1184const char *encoding,1185int options);11861187/*1188* Library wide options1189*/1190/**1191* xmlFeature:1192*1193* Used to examine the existance of features that can be enabled1194* or disabled at compile-time.1195* They used to be called XML_FEATURE_xxx but this clashed with Expat1196*/1197typedef enum {1198XML_WITH_THREAD = 1,1199XML_WITH_TREE = 2,1200XML_WITH_OUTPUT = 3,1201XML_WITH_PUSH = 4,1202XML_WITH_READER = 5,1203XML_WITH_PATTERN = 6,1204XML_WITH_WRITER = 7,1205XML_WITH_SAX1 = 8,1206XML_WITH_FTP = 9,1207XML_WITH_HTTP = 10,1208XML_WITH_VALID = 11,1209XML_WITH_HTML = 12,1210XML_WITH_LEGACY = 13,1211XML_WITH_C14N = 14,1212XML_WITH_CATALOG = 15,1213XML_WITH_XPATH = 16,1214XML_WITH_XPTR = 17,1215XML_WITH_XINCLUDE = 18,1216XML_WITH_ICONV = 19,1217XML_WITH_ISO8859X = 20,1218XML_WITH_UNICODE = 21,1219XML_WITH_REGEXP = 22,1220XML_WITH_AUTOMATA = 23,1221XML_WITH_EXPR = 24,1222XML_WITH_SCHEMAS = 25,1223XML_WITH_SCHEMATRON = 26,1224XML_WITH_MODULES = 27,1225XML_WITH_DEBUG = 28,1226XML_WITH_DEBUG_MEM = 29,1227XML_WITH_DEBUG_RUN = 30,1228XML_WITH_ZLIB = 31,1229XML_WITH_ICU = 32,1230XML_WITH_LZMA = 33,1231XML_WITH_NONE = 99999 /* just to be sure of allocation size */1232} xmlFeature;12331234XMLPUBFUN int XMLCALL1235xmlHasFeature (xmlFeature feature);12361237#ifdef __cplusplus1238}1239#endif1240#endif /* __XML_PARSER_H__ */124112421243