/*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 <libxml/xmlversion.h>13#define XML_TREE_INTERNALS14#include <libxml/tree.h>15#undef XML_TREE_INTERNALS16#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>22#include <libxml/xmlmemory.h>23#include <libxml/encoding.h>24#include <libxml/xmlIO.h>25/* for compatibility */26#include <libxml/SAX2.h>27#include <libxml/threads.h>2829#ifdef __cplusplus30extern "C" {31#endif3233/**34* XML_DEFAULT_VERSION:35*36* The default version of XML used: 1.037*/38#define XML_DEFAULT_VERSION "1.0"3940/**41* xmlParserInput:42*43* An xmlParserInput is an input flow for the XML processor.44* Each entity parsed is associated an xmlParserInput (except the45* few predefined ones). This is the case both for internal entities46* - in which case the flow is already completely in memory - or47* external entities - in which case we use the buf structure for48* progressive reading and I18N conversions to the internal UTF-8 format.49*/5051/**52* xmlParserInputDeallocate:53* @str: the string to deallocate54*55* Callback for freeing some parser input allocations.56*/57typedef void (* xmlParserInputDeallocate)(xmlChar *str);5859struct _xmlParserInput {60/* Input buffer */61xmlParserInputBufferPtr buf; /* UTF-8 encoded buffer */6263const char *filename; /* The file analyzed, if any */64const char *directory; /* the directory/base of the file */65const xmlChar *base; /* Base of the array to parse */66const xmlChar *cur; /* Current char being parsed */67const xmlChar *end; /* end of the array to parse */68int length; /* length if known */69int line; /* Current line */70int col; /* Current column */71unsigned long consumed; /* How many xmlChars already consumed */72xmlParserInputDeallocate free; /* function to deallocate the base */73const xmlChar *encoding; /* unused */74const xmlChar *version; /* the version string for entity */75int flags; /* Flags */76int id; /* an unique identifier for the entity */77unsigned long parentConsumed; /* consumed bytes from parents */78xmlEntityPtr entity; /* entity, if any */79};8081/**82* xmlParserNodeInfo:83*84* The parser can be asked to collect Node information, i.e. at what85* place in the file they were detected.86* NOTE: This is off by default and not very well tested.87*/88typedef struct _xmlParserNodeInfo xmlParserNodeInfo;89typedef xmlParserNodeInfo *xmlParserNodeInfoPtr;9091struct _xmlParserNodeInfo {92const struct _xmlNode* node;93/* Position & line # that text that created the node begins & ends on */94unsigned long begin_pos;95unsigned long begin_line;96unsigned long end_pos;97unsigned long end_line;98};99100typedef struct _xmlParserNodeInfoSeq xmlParserNodeInfoSeq;101typedef xmlParserNodeInfoSeq *xmlParserNodeInfoSeqPtr;102struct _xmlParserNodeInfoSeq {103unsigned long maximum;104unsigned long length;105xmlParserNodeInfo* buffer;106};107108/**109* xmlParserInputState:110*111* The parser is now working also as a state based parser.112* The recursive one use the state info for entities processing.113*/114typedef enum {115XML_PARSER_EOF = -1, /* nothing is to be parsed */116XML_PARSER_START = 0, /* nothing has been parsed */117XML_PARSER_MISC, /* Misc* before int subset */118XML_PARSER_PI, /* Within a processing instruction */119XML_PARSER_DTD, /* within some DTD content */120XML_PARSER_PROLOG, /* Misc* after internal subset */121XML_PARSER_COMMENT, /* within a comment */122XML_PARSER_START_TAG, /* within a start tag */123XML_PARSER_CONTENT, /* within the content */124XML_PARSER_CDATA_SECTION, /* within a CDATA section */125XML_PARSER_END_TAG, /* within a closing tag */126XML_PARSER_ENTITY_DECL, /* within an entity declaration */127XML_PARSER_ENTITY_VALUE, /* within an entity value in a decl */128XML_PARSER_ATTRIBUTE_VALUE, /* within an attribute value */129XML_PARSER_SYSTEM_LITERAL, /* within a SYSTEM value */130XML_PARSER_EPILOG, /* the Misc* after the last end tag */131XML_PARSER_IGNORE, /* within an IGNORED section */132XML_PARSER_PUBLIC_LITERAL, /* within a PUBLIC value */133XML_PARSER_XML_DECL /* before XML decl (but after BOM) */134} xmlParserInputState;135136/**137* XML_DETECT_IDS:138*139* Bit in the loadsubset context field to tell to do ID/REFs lookups.140* Use it to initialize xmlLoadExtDtdDefaultValue.141*/142#define XML_DETECT_IDS 2143144/**145* XML_COMPLETE_ATTRS:146*147* Bit in the loadsubset context field to tell to do complete the148* elements attributes lists with the ones defaulted from the DTDs.149* Use it to initialize xmlLoadExtDtdDefaultValue.150*/151#define XML_COMPLETE_ATTRS 4152153/**154* XML_SKIP_IDS:155*156* Bit in the loadsubset context field to tell to not do ID/REFs registration.157* Used to initialize xmlLoadExtDtdDefaultValue in some special cases.158*/159#define XML_SKIP_IDS 8160161/**162* xmlParserMode:163*164* A parser can operate in various modes165*/166typedef enum {167XML_PARSE_UNKNOWN = 0,168XML_PARSE_DOM = 1,169XML_PARSE_SAX = 2,170XML_PARSE_PUSH_DOM = 3,171XML_PARSE_PUSH_SAX = 4,172XML_PARSE_READER = 5173} xmlParserMode;174175typedef struct _xmlStartTag xmlStartTag;176typedef struct _xmlParserNsData xmlParserNsData;177typedef struct _xmlAttrHashBucket xmlAttrHashBucket;178179/**180* xmlParserCtxt:181*182* The parser context.183* NOTE This doesn't completely define the parser state, the (current ?)184* design of the parser uses recursive function calls since this allow185* and easy mapping from the production rules of the specification186* to the actual code. The drawback is that the actual function call187* also reflect the parser state. However most of the parsing routines188* takes as the only argument the parser context pointer, so migrating189* to a state based parser for progressive parsing shouldn't be too hard.190*/191struct _xmlParserCtxt {192struct _xmlSAXHandler *sax; /* The SAX handler */193void *userData; /* For SAX interface only, used by DOM build */194xmlDocPtr myDoc; /* the document being built */195int wellFormed; /* is the document well formed */196int replaceEntities; /* shall we replace entities ? */197const xmlChar *version; /* the XML version string */198const xmlChar *encoding; /* the declared encoding, if any */199int standalone; /* standalone document */200int html; /* an HTML(1) document201* 3 is HTML after <head>202* 10 is HTML after <body>203*/204205/* Input stream stack */206xmlParserInputPtr input; /* Current input stream */207int inputNr; /* Number of current input streams */208int inputMax; /* Max number of input streams */209xmlParserInputPtr *inputTab; /* stack of inputs */210211/* Node analysis stack only used for DOM building */212xmlNodePtr node; /* Current parsed Node */213int nodeNr; /* Depth of the parsing stack */214int nodeMax; /* Max depth of the parsing stack */215xmlNodePtr *nodeTab; /* array of nodes */216217int record_info; /* Whether node info should be kept */218xmlParserNodeInfoSeq node_seq; /* info about each node parsed */219220int errNo; /* error code */221222int hasExternalSubset; /* reference and external subset */223int hasPErefs; /* the internal subset has PE refs */224int external; /* are we parsing an external entity */225226int valid; /* is the document valid */227int validate; /* shall we try to validate ? */228xmlValidCtxt vctxt; /* The validity context */229230xmlParserInputState instate; /* current type of input */231int token; /* next char look-ahead */232233char *directory; /* the data directory */234235/* Node name stack */236const xmlChar *name; /* Current parsed Node */237int nameNr; /* Depth of the parsing stack */238int nameMax; /* Max depth of the parsing stack */239const xmlChar * *nameTab; /* array of nodes */240241long nbChars; /* unused */242long checkIndex; /* used by progressive parsing lookup */243int keepBlanks; /* ugly but ... */244int disableSAX; /* SAX callbacks are disabled */245int inSubset; /* Parsing is in int 1/ext 2 subset */246const xmlChar * intSubName; /* name of subset */247xmlChar * extSubURI; /* URI of external subset */248xmlChar * extSubSystem; /* SYSTEM ID of external subset */249250/* xml:space values */251int * space; /* Should the parser preserve spaces */252int spaceNr; /* Depth of the parsing stack */253int spaceMax; /* Max depth of the parsing stack */254int * spaceTab; /* array of space infos */255256int depth; /* to prevent entity substitution loops */257xmlParserInputPtr entity; /* used to check entities boundaries */258int charset; /* unused */259int nodelen; /* Those two fields are there to */260int nodemem; /* Speed up large node parsing */261int pedantic; /* signal pedantic warnings */262void *_private; /* For user data, libxml won't touch it */263264int loadsubset; /* should the external subset be loaded */265int linenumbers; /* set line number in element content */266void *catalogs; /* document's own catalog */267int recovery; /* run in recovery mode */268int progressive; /* is this a progressive parsing */269xmlDictPtr dict; /* dictionary for the parser */270const xmlChar * *atts; /* array for the attributes callbacks */271int maxatts; /* the size of the array */272int docdict; /* use strings from dict to build tree */273274/*275* pre-interned strings276*/277const xmlChar *str_xml;278const xmlChar *str_xmlns;279const xmlChar *str_xml_ns;280281/*282* Everything below is used only by the new SAX mode283*/284int sax2; /* operating in the new SAX mode */285int nsNr; /* the number of inherited namespaces */286int nsMax; /* the size of the arrays */287const xmlChar * *nsTab; /* the array of prefix/namespace name */288unsigned *attallocs; /* which attribute were allocated */289xmlStartTag *pushTab; /* array of data for push */290xmlHashTablePtr attsDefault; /* defaulted attributes if any */291xmlHashTablePtr attsSpecial; /* non-CDATA attributes if any */292int nsWellFormed; /* is the document XML Namespace okay */293int options; /* Extra options */294295/*296* Those fields are needed only for streaming parsing so far297*/298int dictNames; /* Use dictionary names for the tree */299int freeElemsNr; /* number of freed element nodes */300xmlNodePtr freeElems; /* List of freed element nodes */301int freeAttrsNr; /* number of freed attributes nodes */302xmlAttrPtr freeAttrs; /* List of freed attributes nodes */303304/*305* the complete error information for the last error.306*/307xmlError lastError;308xmlParserMode parseMode; /* the parser mode */309unsigned long nbentities; /* unused */310unsigned long sizeentities; /* size of parsed entities */311312/* for use by HTML non-recursive parser */313xmlParserNodeInfo *nodeInfo; /* Current NodeInfo */314int nodeInfoNr; /* Depth of the parsing stack */315int nodeInfoMax; /* Max depth of the parsing stack */316xmlParserNodeInfo *nodeInfoTab; /* array of nodeInfos */317318int input_id; /* we need to label inputs */319unsigned long sizeentcopy; /* volume of entity copy */320321int endCheckState; /* quote state for push parser */322unsigned short nbErrors; /* number of errors */323unsigned short nbWarnings; /* number of warnings */324unsigned maxAmpl; /* maximum amplification factor */325326xmlParserNsData *nsdb; /* namespace database */327unsigned attrHashMax; /* allocated size */328xmlAttrHashBucket *attrHash; /* atttribute hash table */329};330331/**332* xmlSAXLocator:333*334* A SAX Locator.335*/336struct _xmlSAXLocator {337const xmlChar *(*getPublicId)(void *ctx);338const xmlChar *(*getSystemId)(void *ctx);339int (*getLineNumber)(void *ctx);340int (*getColumnNumber)(void *ctx);341};342343/**344* xmlSAXHandler:345*346* A SAX handler is bunch of callbacks called by the parser when processing347* of the input generate data or structure information.348*/349350/**351* resolveEntitySAXFunc:352* @ctx: the user data (XML parser context)353* @publicId: The public ID of the entity354* @systemId: The system ID of the entity355*356* Callback:357* The entity loader, to control the loading of external entities,358* the application can either:359* - override this resolveEntity() callback in the SAX block360* - or better use the xmlSetExternalEntityLoader() function to361* set up it's own entity resolution routine362*363* Returns the xmlParserInputPtr if inlined or NULL for DOM behaviour.364*/365typedef xmlParserInputPtr (*resolveEntitySAXFunc) (void *ctx,366const xmlChar *publicId,367const xmlChar *systemId);368/**369* internalSubsetSAXFunc:370* @ctx: the user data (XML parser context)371* @name: the root element name372* @ExternalID: the external ID373* @SystemID: the SYSTEM ID (e.g. filename or URL)374*375* Callback on internal subset declaration.376*/377typedef void (*internalSubsetSAXFunc) (void *ctx,378const xmlChar *name,379const xmlChar *ExternalID,380const xmlChar *SystemID);381/**382* externalSubsetSAXFunc:383* @ctx: the user data (XML parser context)384* @name: the root element name385* @ExternalID: the external ID386* @SystemID: the SYSTEM ID (e.g. filename or URL)387*388* Callback on external subset declaration.389*/390typedef void (*externalSubsetSAXFunc) (void *ctx,391const xmlChar *name,392const xmlChar *ExternalID,393const xmlChar *SystemID);394/**395* getEntitySAXFunc:396* @ctx: the user data (XML parser context)397* @name: The entity name398*399* Get an entity by name.400*401* Returns the xmlEntityPtr if found.402*/403typedef xmlEntityPtr (*getEntitySAXFunc) (void *ctx,404const xmlChar *name);405/**406* getParameterEntitySAXFunc:407* @ctx: the user data (XML parser context)408* @name: The entity name409*410* Get a parameter entity by name.411*412* Returns the xmlEntityPtr if found.413*/414typedef xmlEntityPtr (*getParameterEntitySAXFunc) (void *ctx,415const xmlChar *name);416/**417* entityDeclSAXFunc:418* @ctx: the user data (XML parser context)419* @name: the entity name420* @type: the entity type421* @publicId: The public ID of the entity422* @systemId: The system ID of the entity423* @content: the entity value (without processing).424*425* An entity definition has been parsed.426*/427typedef void (*entityDeclSAXFunc) (void *ctx,428const xmlChar *name,429int type,430const xmlChar *publicId,431const xmlChar *systemId,432xmlChar *content);433/**434* notationDeclSAXFunc:435* @ctx: the user data (XML parser context)436* @name: The name of the notation437* @publicId: The public ID of the entity438* @systemId: The system ID of the entity439*440* What to do when a notation declaration has been parsed.441*/442typedef void (*notationDeclSAXFunc)(void *ctx,443const xmlChar *name,444const xmlChar *publicId,445const xmlChar *systemId);446/**447* attributeDeclSAXFunc:448* @ctx: the user data (XML parser context)449* @elem: the name of the element450* @fullname: the attribute name451* @type: the attribute type452* @def: the type of default value453* @defaultValue: the attribute default value454* @tree: the tree of enumerated value set455*456* An attribute definition has been parsed.457*/458typedef void (*attributeDeclSAXFunc)(void *ctx,459const xmlChar *elem,460const xmlChar *fullname,461int type,462int def,463const xmlChar *defaultValue,464xmlEnumerationPtr tree);465/**466* elementDeclSAXFunc:467* @ctx: the user data (XML parser context)468* @name: the element name469* @type: the element type470* @content: the element value tree471*472* An element definition has been parsed.473*/474typedef void (*elementDeclSAXFunc)(void *ctx,475const xmlChar *name,476int type,477xmlElementContentPtr content);478/**479* unparsedEntityDeclSAXFunc:480* @ctx: the user data (XML parser context)481* @name: The name of the entity482* @publicId: The public ID of the entity483* @systemId: The system ID of the entity484* @notationName: the name of the notation485*486* What to do when an unparsed entity declaration is parsed.487*/488typedef void (*unparsedEntityDeclSAXFunc)(void *ctx,489const xmlChar *name,490const xmlChar *publicId,491const xmlChar *systemId,492const xmlChar *notationName);493/**494* setDocumentLocatorSAXFunc:495* @ctx: the user data (XML parser context)496* @loc: A SAX Locator497*498* Receive the document locator at startup, actually xmlDefaultSAXLocator.499* Everything is available on the context, so this is useless in our case.500*/501typedef void (*setDocumentLocatorSAXFunc) (void *ctx,502xmlSAXLocatorPtr loc);503/**504* startDocumentSAXFunc:505* @ctx: the user data (XML parser context)506*507* Called when the document start being processed.508*/509typedef void (*startDocumentSAXFunc) (void *ctx);510/**511* endDocumentSAXFunc:512* @ctx: the user data (XML parser context)513*514* Called when the document end has been detected.515*/516typedef void (*endDocumentSAXFunc) (void *ctx);517/**518* startElementSAXFunc:519* @ctx: the user data (XML parser context)520* @name: The element name, including namespace prefix521* @atts: An array of name/value attributes pairs, NULL terminated522*523* Called when an opening tag has been processed.524*/525typedef void (*startElementSAXFunc) (void *ctx,526const xmlChar *name,527const xmlChar **atts);528/**529* endElementSAXFunc:530* @ctx: the user data (XML parser context)531* @name: The element name532*533* Called when the end of an element has been detected.534*/535typedef void (*endElementSAXFunc) (void *ctx,536const xmlChar *name);537/**538* attributeSAXFunc:539* @ctx: the user data (XML parser context)540* @name: The attribute name, including namespace prefix541* @value: The attribute value542*543* Handle an attribute that has been read by the parser.544* The default handling is to convert the attribute into an545* DOM subtree and past it in a new xmlAttr element added to546* the element.547*/548typedef void (*attributeSAXFunc) (void *ctx,549const xmlChar *name,550const xmlChar *value);551/**552* referenceSAXFunc:553* @ctx: the user data (XML parser context)554* @name: The entity name555*556* Called when an entity reference is detected.557*/558typedef void (*referenceSAXFunc) (void *ctx,559const xmlChar *name);560/**561* charactersSAXFunc:562* @ctx: the user data (XML parser context)563* @ch: a xmlChar string564* @len: the number of xmlChar565*566* Receiving some chars from the parser.567*/568typedef void (*charactersSAXFunc) (void *ctx,569const xmlChar *ch,570int len);571/**572* ignorableWhitespaceSAXFunc:573* @ctx: the user data (XML parser context)574* @ch: a xmlChar string575* @len: the number of xmlChar576*577* Receiving some ignorable whitespaces from the parser.578* UNUSED: by default the DOM building will use characters.579*/580typedef void (*ignorableWhitespaceSAXFunc) (void *ctx,581const xmlChar *ch,582int len);583/**584* processingInstructionSAXFunc:585* @ctx: the user data (XML parser context)586* @target: the target name587* @data: the PI data's588*589* A processing instruction has been parsed.590*/591typedef void (*processingInstructionSAXFunc) (void *ctx,592const xmlChar *target,593const xmlChar *data);594/**595* commentSAXFunc:596* @ctx: the user data (XML parser context)597* @value: the comment content598*599* A comment has been parsed.600*/601typedef void (*commentSAXFunc) (void *ctx,602const xmlChar *value);603/**604* cdataBlockSAXFunc:605* @ctx: the user data (XML parser context)606* @value: The pcdata content607* @len: the block length608*609* Called when a pcdata block has been parsed.610*/611typedef void (*cdataBlockSAXFunc) (612void *ctx,613const xmlChar *value,614int len);615/**616* warningSAXFunc:617* @ctx: an XML parser context618* @msg: the message to display/transmit619* @...: extra parameters for the message display620*621* Display and format a warning messages, callback.622*/623typedef void (*warningSAXFunc) (void *ctx,624const char *msg, ...) LIBXML_ATTR_FORMAT(2,3);625/**626* errorSAXFunc:627* @ctx: an XML parser context628* @msg: the message to display/transmit629* @...: extra parameters for the message display630*631* Display and format an error messages, callback.632*/633typedef void (*errorSAXFunc) (void *ctx,634const char *msg, ...) LIBXML_ATTR_FORMAT(2,3);635/**636* fatalErrorSAXFunc:637* @ctx: an XML parser context638* @msg: the message to display/transmit639* @...: extra parameters for the message display640*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.644*/645typedef void (*fatalErrorSAXFunc) (void *ctx,646const char *msg, ...) LIBXML_ATTR_FORMAT(2,3);647/**648* isStandaloneSAXFunc:649* @ctx: the user data (XML parser context)650*651* Is this document tagged standalone?652*653* Returns 1 if true654*/655typedef int (*isStandaloneSAXFunc) (void *ctx);656/**657* hasInternalSubsetSAXFunc:658* @ctx: the user data (XML parser context)659*660* Does this document has an internal subset.661*662* Returns 1 if true663*/664typedef int (*hasInternalSubsetSAXFunc) (void *ctx);665666/**667* hasExternalSubsetSAXFunc:668* @ctx: the user data (XML parser context)669*670* Does this document has an external subset?671*672* Returns 1 if true673*/674typedef int (*hasExternalSubsetSAXFunc) (void *ctx);675676/************************************************************************677* *678* The SAX version 2 API extensions *679* *680************************************************************************/681/**682* XML_SAX2_MAGIC:683*684* Special constant found in SAX2 blocks initialized fields685*/686#define XML_SAX2_MAGIC 0xDEEDBEAF687688/**689* startElementNsSAX2Func:690* @ctx: the user data (XML parser context)691* @localname: the local name of the element692* @prefix: the element namespace prefix if available693* @URI: the element namespace name if available694* @nb_namespaces: number of namespace definitions on that node695* @namespaces: pointer to the array of prefix/URI pairs namespace definitions696* @nb_attributes: the number of attributes on that node697* @nb_defaulted: the number of defaulted attributes. The defaulted698* ones are at the end of the array699* @attributes: pointer to the array of (localname/prefix/URI/value/end)700* attribute values.701*702* SAX2 callback when an element start has been detected by the parser.703* It provides the namespace information for the element, as well as704* the new namespace declarations on the element.705*/706707typedef void (*startElementNsSAX2Func) (void *ctx,708const xmlChar *localname,709const xmlChar *prefix,710const xmlChar *URI,711int nb_namespaces,712const xmlChar **namespaces,713int nb_attributes,714int nb_defaulted,715const xmlChar **attributes);716717/**718* endElementNsSAX2Func:719* @ctx: the user data (XML parser context)720* @localname: the local name of the element721* @prefix: the element namespace prefix if available722* @URI: the element namespace name if available723*724* SAX2 callback when an element end has been detected by the parser.725* It provides the namespace information for the element.726*/727728typedef void (*endElementNsSAX2Func) (void *ctx,729const xmlChar *localname,730const xmlChar *prefix,731const xmlChar *URI);732733734struct _xmlSAXHandler {735internalSubsetSAXFunc internalSubset;736isStandaloneSAXFunc isStandalone;737hasInternalSubsetSAXFunc hasInternalSubset;738hasExternalSubsetSAXFunc hasExternalSubset;739resolveEntitySAXFunc resolveEntity;740getEntitySAXFunc getEntity;741entityDeclSAXFunc entityDecl;742notationDeclSAXFunc notationDecl;743attributeDeclSAXFunc attributeDecl;744elementDeclSAXFunc elementDecl;745unparsedEntityDeclSAXFunc unparsedEntityDecl;746setDocumentLocatorSAXFunc setDocumentLocator;747startDocumentSAXFunc startDocument;748endDocumentSAXFunc endDocument;749/*750* `startElement` and `endElement` are only used by the legacy SAX1751* interface and should not be used in new software. If you really752* have to enable SAX1, the preferred way is set the `initialized`753* member to 1 instead of XML_SAX2_MAGIC.754*755* For backward compatibility, it's also possible to set the756* `startElementNs` and `endElementNs` handlers to NULL.757*758* You can also set the XML_PARSE_SAX1 parser option, but versions759* older than 2.12.0 will probably crash if this option is provided760* together with custom SAX callbacks.761*/762startElementSAXFunc startElement;763endElementSAXFunc endElement;764referenceSAXFunc reference;765charactersSAXFunc characters;766ignorableWhitespaceSAXFunc ignorableWhitespace;767processingInstructionSAXFunc processingInstruction;768commentSAXFunc comment;769warningSAXFunc warning;770errorSAXFunc error;771fatalErrorSAXFunc fatalError; /* unused error() get all the errors */772getParameterEntitySAXFunc getParameterEntity;773cdataBlockSAXFunc cdataBlock;774externalSubsetSAXFunc externalSubset;775/*776* `initialized` should always be set to XML_SAX2_MAGIC to enable the777* modern SAX2 interface.778*/779unsigned int initialized;780/*781* The following members are only used by the SAX2 interface.782*/783void *_private;784startElementNsSAX2Func startElementNs;785endElementNsSAX2Func endElementNs;786xmlStructuredErrorFunc serror;787};788789/*790* SAX Version 1791*/792typedef struct _xmlSAXHandlerV1 xmlSAXHandlerV1;793typedef xmlSAXHandlerV1 *xmlSAXHandlerV1Ptr;794struct _xmlSAXHandlerV1 {795internalSubsetSAXFunc internalSubset;796isStandaloneSAXFunc isStandalone;797hasInternalSubsetSAXFunc hasInternalSubset;798hasExternalSubsetSAXFunc hasExternalSubset;799resolveEntitySAXFunc resolveEntity;800getEntitySAXFunc getEntity;801entityDeclSAXFunc entityDecl;802notationDeclSAXFunc notationDecl;803attributeDeclSAXFunc attributeDecl;804elementDeclSAXFunc elementDecl;805unparsedEntityDeclSAXFunc unparsedEntityDecl;806setDocumentLocatorSAXFunc setDocumentLocator;807startDocumentSAXFunc startDocument;808endDocumentSAXFunc endDocument;809startElementSAXFunc startElement;810endElementSAXFunc endElement;811referenceSAXFunc reference;812charactersSAXFunc characters;813ignorableWhitespaceSAXFunc ignorableWhitespace;814processingInstructionSAXFunc processingInstruction;815commentSAXFunc comment;816warningSAXFunc warning;817errorSAXFunc error;818fatalErrorSAXFunc fatalError; /* unused error() get all the errors */819getParameterEntitySAXFunc getParameterEntity;820cdataBlockSAXFunc cdataBlock;821externalSubsetSAXFunc externalSubset;822unsigned int initialized;823};824825826/**827* xmlExternalEntityLoader:828* @URL: The System ID of the resource requested829* @ID: The Public ID of the resource requested830* @context: the XML parser context831*832* External entity loaders types.833*834* Returns the entity input parser.835*/836typedef xmlParserInputPtr (*xmlExternalEntityLoader) (const char *URL,837const char *ID,838xmlParserCtxtPtr context);839840/*841* Variables842*/843844XMLPUBVAR const char *const xmlParserVersion;845#ifdef LIBXML_THREAD_ENABLED846/* backward compatibility */847XMLPUBFUN const char *const *__xmlParserVersion(void);848#endif849850/** DOC_DISABLE */851#define XML_GLOBALS_PARSER_CORE \852XML_OP(oldXMLWDcompatibility, int, XML_DEPRECATED) \853XML_OP(xmlDefaultSAXLocator, xmlSAXLocator, XML_DEPRECATED) \854XML_OP(xmlDoValidityCheckingDefaultValue, int, XML_DEPRECATED) \855XML_OP(xmlGetWarningsDefaultValue, int, XML_DEPRECATED) \856XML_OP(xmlKeepBlanksDefaultValue, int, XML_DEPRECATED) \857XML_OP(xmlLineNumbersDefaultValue, int, XML_DEPRECATED) \858XML_OP(xmlLoadExtDtdDefaultValue, int, XML_DEPRECATED) \859XML_OP(xmlParserDebugEntities, int, XML_DEPRECATED) \860XML_OP(xmlPedanticParserDefaultValue, int, XML_DEPRECATED) \861XML_OP(xmlSubstituteEntitiesDefaultValue, int, XML_DEPRECATED)862863#ifdef LIBXML_OUTPUT_ENABLED864#define XML_GLOBALS_PARSER_OUTPUT \865XML_OP(xmlIndentTreeOutput, int, XML_NO_ATTR) \866XML_OP(xmlTreeIndentString, const char *, XML_NO_ATTR) \867XML_OP(xmlSaveNoEmptyTags, int, XML_NO_ATTR)868#else869#define XML_GLOBALS_PARSER_OUTPUT870#endif871872#ifdef LIBXML_SAX1_ENABLED873#define XML_GLOBALS_PARSER_SAX1 \874XML_OP(xmlDefaultSAXHandler, xmlSAXHandlerV1, XML_DEPRECATED)875#else876#define XML_GLOBALS_PARSER_SAX1877#endif878879#define XML_GLOBALS_PARSER \880XML_GLOBALS_PARSER_CORE \881XML_GLOBALS_PARSER_OUTPUT \882XML_GLOBALS_PARSER_SAX1883884#define XML_OP XML_DECLARE_GLOBAL885XML_GLOBALS_PARSER886#undef XML_OP887888#if defined(LIBXML_THREAD_ENABLED) && !defined(XML_GLOBALS_NO_REDEFINITION)889#define oldXMLWDcompatibility XML_GLOBAL_MACRO(oldXMLWDcompatibility)890#define xmlDefaultSAXHandler XML_GLOBAL_MACRO(xmlDefaultSAXHandler)891#define xmlDefaultSAXLocator XML_GLOBAL_MACRO(xmlDefaultSAXLocator)892#define xmlDoValidityCheckingDefaultValue \893XML_GLOBAL_MACRO(xmlDoValidityCheckingDefaultValue)894#define xmlGetWarningsDefaultValue \895XML_GLOBAL_MACRO(xmlGetWarningsDefaultValue)896#define xmlKeepBlanksDefaultValue XML_GLOBAL_MACRO(xmlKeepBlanksDefaultValue)897#define xmlLineNumbersDefaultValue \898XML_GLOBAL_MACRO(xmlLineNumbersDefaultValue)899#define xmlLoadExtDtdDefaultValue XML_GLOBAL_MACRO(xmlLoadExtDtdDefaultValue)900#define xmlParserDebugEntities XML_GLOBAL_MACRO(xmlParserDebugEntities)901#define xmlPedanticParserDefaultValue \902XML_GLOBAL_MACRO(xmlPedanticParserDefaultValue)903#define xmlSubstituteEntitiesDefaultValue \904XML_GLOBAL_MACRO(xmlSubstituteEntitiesDefaultValue)905#ifdef LIBXML_OUTPUT_ENABLED906#define xmlIndentTreeOutput XML_GLOBAL_MACRO(xmlIndentTreeOutput)907#define xmlTreeIndentString XML_GLOBAL_MACRO(xmlTreeIndentString)908#define xmlSaveNoEmptyTags XML_GLOBAL_MACRO(xmlSaveNoEmptyTags)909#endif910#endif911/** DOC_ENABLE */912913/*914* Init/Cleanup915*/916XMLPUBFUN void917xmlInitParser (void);918XMLPUBFUN void919xmlCleanupParser (void);920XML_DEPRECATED921XMLPUBFUN void922xmlInitGlobals (void);923XML_DEPRECATED924XMLPUBFUN void925xmlCleanupGlobals (void);926927/*928* Input functions929*/930XML_DEPRECATED931XMLPUBFUN int932xmlParserInputRead (xmlParserInputPtr in,933int len);934XML_DEPRECATED935XMLPUBFUN int936xmlParserInputGrow (xmlParserInputPtr in,937int len);938939/*940* Basic parsing Interfaces941*/942#ifdef LIBXML_SAX1_ENABLED943XMLPUBFUN xmlDocPtr944xmlParseDoc (const xmlChar *cur);945XMLPUBFUN xmlDocPtr946xmlParseFile (const char *filename);947XMLPUBFUN xmlDocPtr948xmlParseMemory (const char *buffer,949int size);950#endif /* LIBXML_SAX1_ENABLED */951XML_DEPRECATED XMLPUBFUN int952xmlSubstituteEntitiesDefault(int val);953XML_DEPRECATED XMLPUBFUN int954xmlThrDefSubstituteEntitiesDefaultValue(int v);955XMLPUBFUN int956xmlKeepBlanksDefault (int val);957XML_DEPRECATED XMLPUBFUN int958xmlThrDefKeepBlanksDefaultValue(int v);959XMLPUBFUN void960xmlStopParser (xmlParserCtxtPtr ctxt);961XML_DEPRECATED XMLPUBFUN int962xmlPedanticParserDefault(int val);963XML_DEPRECATED XMLPUBFUN int964xmlThrDefPedanticParserDefaultValue(int v);965XML_DEPRECATED XMLPUBFUN int966xmlLineNumbersDefault (int val);967XML_DEPRECATED XMLPUBFUN int968xmlThrDefLineNumbersDefaultValue(int v);969XML_DEPRECATED XMLPUBFUN int970xmlThrDefDoValidityCheckingDefaultValue(int v);971XML_DEPRECATED XMLPUBFUN int972xmlThrDefGetWarningsDefaultValue(int v);973XML_DEPRECATED XMLPUBFUN int974xmlThrDefLoadExtDtdDefaultValue(int v);975XML_DEPRECATED XMLPUBFUN int976xmlThrDefParserDebugEntities(int v);977978#ifdef LIBXML_SAX1_ENABLED979/*980* Recovery mode981*/982XML_DEPRECATED983XMLPUBFUN xmlDocPtr984xmlRecoverDoc (const xmlChar *cur);985XML_DEPRECATED986XMLPUBFUN xmlDocPtr987xmlRecoverMemory (const char *buffer,988int size);989XML_DEPRECATED990XMLPUBFUN xmlDocPtr991xmlRecoverFile (const char *filename);992#endif /* LIBXML_SAX1_ENABLED */993994/*995* Less common routines and SAX interfaces996*/997XMLPUBFUN int998xmlParseDocument (xmlParserCtxtPtr ctxt);999XMLPUBFUN int1000xmlParseExtParsedEnt (xmlParserCtxtPtr ctxt);1001#ifdef LIBXML_SAX1_ENABLED1002XML_DEPRECATED1003XMLPUBFUN int1004xmlSAXUserParseFile (xmlSAXHandlerPtr sax,1005void *user_data,1006const char *filename);1007XML_DEPRECATED1008XMLPUBFUN int1009xmlSAXUserParseMemory (xmlSAXHandlerPtr sax,1010void *user_data,1011const char *buffer,1012int size);1013XML_DEPRECATED1014XMLPUBFUN xmlDocPtr1015xmlSAXParseDoc (xmlSAXHandlerPtr sax,1016const xmlChar *cur,1017int recovery);1018XML_DEPRECATED1019XMLPUBFUN xmlDocPtr1020xmlSAXParseMemory (xmlSAXHandlerPtr sax,1021const char *buffer,1022int size,1023int recovery);1024XML_DEPRECATED1025XMLPUBFUN xmlDocPtr1026xmlSAXParseMemoryWithData (xmlSAXHandlerPtr sax,1027const char *buffer,1028int size,1029int recovery,1030void *data);1031XML_DEPRECATED1032XMLPUBFUN xmlDocPtr1033xmlSAXParseFile (xmlSAXHandlerPtr sax,1034const char *filename,1035int recovery);1036XML_DEPRECATED1037XMLPUBFUN xmlDocPtr1038xmlSAXParseFileWithData (xmlSAXHandlerPtr sax,1039const char *filename,1040int recovery,1041void *data);1042XML_DEPRECATED1043XMLPUBFUN xmlDocPtr1044xmlSAXParseEntity (xmlSAXHandlerPtr sax,1045const char *filename);1046XML_DEPRECATED1047XMLPUBFUN xmlDocPtr1048xmlParseEntity (const char *filename);1049#endif /* LIBXML_SAX1_ENABLED */10501051#ifdef LIBXML_VALID_ENABLED1052XML_DEPRECATED1053XMLPUBFUN xmlDtdPtr1054xmlSAXParseDTD (xmlSAXHandlerPtr sax,1055const xmlChar *ExternalID,1056const xmlChar *SystemID);1057XMLPUBFUN xmlDtdPtr1058xmlParseDTD (const xmlChar *ExternalID,1059const xmlChar *SystemID);1060XMLPUBFUN xmlDtdPtr1061xmlIOParseDTD (xmlSAXHandlerPtr sax,1062xmlParserInputBufferPtr input,1063xmlCharEncoding enc);1064#endif /* LIBXML_VALID_ENABLE */1065#ifdef LIBXML_SAX1_ENABLED1066XMLPUBFUN int1067xmlParseBalancedChunkMemory(xmlDocPtr doc,1068xmlSAXHandlerPtr sax,1069void *user_data,1070int depth,1071const xmlChar *string,1072xmlNodePtr *lst);1073#endif /* LIBXML_SAX1_ENABLED */1074XMLPUBFUN xmlParserErrors1075xmlParseInNodeContext (xmlNodePtr node,1076const char *data,1077int datalen,1078int options,1079xmlNodePtr *lst);1080#ifdef LIBXML_SAX1_ENABLED1081XMLPUBFUN int1082xmlParseBalancedChunkMemoryRecover(xmlDocPtr doc,1083xmlSAXHandlerPtr sax,1084void *user_data,1085int depth,1086const xmlChar *string,1087xmlNodePtr *lst,1088int recover);1089XML_DEPRECATED1090XMLPUBFUN int1091xmlParseExternalEntity (xmlDocPtr doc,1092xmlSAXHandlerPtr sax,1093void *user_data,1094int depth,1095const xmlChar *URL,1096const xmlChar *ID,1097xmlNodePtr *lst);1098#endif /* LIBXML_SAX1_ENABLED */1099XMLPUBFUN int1100xmlParseCtxtExternalEntity(xmlParserCtxtPtr ctx,1101const xmlChar *URL,1102const xmlChar *ID,1103xmlNodePtr *lst);11041105/*1106* Parser contexts handling.1107*/1108XMLPUBFUN xmlParserCtxtPtr1109xmlNewParserCtxt (void);1110XMLPUBFUN xmlParserCtxtPtr1111xmlNewSAXParserCtxt (const xmlSAXHandler *sax,1112void *userData);1113XMLPUBFUN int1114xmlInitParserCtxt (xmlParserCtxtPtr ctxt);1115XMLPUBFUN void1116xmlClearParserCtxt (xmlParserCtxtPtr ctxt);1117XMLPUBFUN void1118xmlFreeParserCtxt (xmlParserCtxtPtr ctxt);1119#ifdef LIBXML_SAX1_ENABLED1120XML_DEPRECATED1121XMLPUBFUN void1122xmlSetupParserForBuffer (xmlParserCtxtPtr ctxt,1123const xmlChar* buffer,1124const char *filename);1125#endif /* LIBXML_SAX1_ENABLED */1126XMLPUBFUN xmlParserCtxtPtr1127xmlCreateDocParserCtxt (const xmlChar *cur);11281129#ifdef LIBXML_LEGACY_ENABLED1130/*1131* Reading/setting optional parsing features.1132*/1133XML_DEPRECATED1134XMLPUBFUN int1135xmlGetFeaturesList (int *len,1136const char **result);1137XML_DEPRECATED1138XMLPUBFUN int1139xmlGetFeature (xmlParserCtxtPtr ctxt,1140const char *name,1141void *result);1142XML_DEPRECATED1143XMLPUBFUN int1144xmlSetFeature (xmlParserCtxtPtr ctxt,1145const char *name,1146void *value);1147#endif /* LIBXML_LEGACY_ENABLED */11481149#ifdef LIBXML_PUSH_ENABLED1150/*1151* Interfaces for the Push mode.1152*/1153XMLPUBFUN xmlParserCtxtPtr1154xmlCreatePushParserCtxt(xmlSAXHandlerPtr sax,1155void *user_data,1156const char *chunk,1157int size,1158const char *filename);1159XMLPUBFUN int1160xmlParseChunk (xmlParserCtxtPtr ctxt,1161const char *chunk,1162int size,1163int terminate);1164#endif /* LIBXML_PUSH_ENABLED */11651166/*1167* Special I/O mode.1168*/11691170XMLPUBFUN xmlParserCtxtPtr1171xmlCreateIOParserCtxt (xmlSAXHandlerPtr sax,1172void *user_data,1173xmlInputReadCallback ioread,1174xmlInputCloseCallback ioclose,1175void *ioctx,1176xmlCharEncoding enc);11771178XMLPUBFUN xmlParserInputPtr1179xmlNewIOInputStream (xmlParserCtxtPtr ctxt,1180xmlParserInputBufferPtr input,1181xmlCharEncoding enc);11821183/*1184* Node infos.1185*/1186XMLPUBFUN const xmlParserNodeInfo*1187xmlParserFindNodeInfo (const xmlParserCtxtPtr ctxt,1188const xmlNodePtr node);1189XMLPUBFUN void1190xmlInitNodeInfoSeq (xmlParserNodeInfoSeqPtr seq);1191XMLPUBFUN void1192xmlClearNodeInfoSeq (xmlParserNodeInfoSeqPtr seq);1193XMLPUBFUN unsigned long1194xmlParserFindNodeInfoIndex(const xmlParserNodeInfoSeqPtr seq,1195const xmlNodePtr node);1196XMLPUBFUN void1197xmlParserAddNodeInfo (xmlParserCtxtPtr ctxt,1198const xmlParserNodeInfoPtr info);11991200/*1201* External entities handling actually implemented in xmlIO.1202*/12031204XMLPUBFUN void1205xmlSetExternalEntityLoader(xmlExternalEntityLoader f);1206XMLPUBFUN xmlExternalEntityLoader1207xmlGetExternalEntityLoader(void);1208XMLPUBFUN xmlParserInputPtr1209xmlLoadExternalEntity (const char *URL,1210const char *ID,1211xmlParserCtxtPtr ctxt);12121213/*1214* Index lookup, actually implemented in the encoding module1215*/1216XMLPUBFUN long1217xmlByteConsumed (xmlParserCtxtPtr ctxt);12181219/*1220* New set of simpler/more flexible APIs1221*/1222/**1223* xmlParserOption:1224*1225* This is the set of XML parser options that can be passed down1226* to the xmlReadDoc() and similar calls.1227*/1228typedef enum {1229XML_PARSE_RECOVER = 1<<0, /* recover on errors */1230XML_PARSE_NOENT = 1<<1, /* substitute entities */1231XML_PARSE_DTDLOAD = 1<<2, /* load the external subset */1232XML_PARSE_DTDATTR = 1<<3, /* default DTD attributes */1233XML_PARSE_DTDVALID = 1<<4, /* validate with the DTD */1234XML_PARSE_NOERROR = 1<<5, /* suppress error reports */1235XML_PARSE_NOWARNING = 1<<6, /* suppress warning reports */1236XML_PARSE_PEDANTIC = 1<<7, /* pedantic error reporting */1237XML_PARSE_NOBLANKS = 1<<8, /* remove blank nodes */1238XML_PARSE_SAX1 = 1<<9, /* use the SAX1 interface internally */1239XML_PARSE_XINCLUDE = 1<<10,/* Implement XInclude substitution */1240XML_PARSE_NONET = 1<<11,/* Forbid network access */1241XML_PARSE_NODICT = 1<<12,/* Do not reuse the context dictionary */1242XML_PARSE_NSCLEAN = 1<<13,/* remove redundant namespaces declarations */1243XML_PARSE_NOCDATA = 1<<14,/* merge CDATA as text nodes */1244XML_PARSE_NOXINCNODE= 1<<15,/* do not generate XINCLUDE START/END nodes */1245XML_PARSE_COMPACT = 1<<16,/* compact small text nodes; no modification of1246the tree allowed afterwards (will possibly1247crash if you try to modify the tree) */1248XML_PARSE_OLD10 = 1<<17,/* parse using XML-1.0 before update 5 */1249XML_PARSE_NOBASEFIX = 1<<18,/* do not fixup XINCLUDE xml:base uris */1250XML_PARSE_HUGE = 1<<19,/* relax any hardcoded limit from the parser */1251XML_PARSE_OLDSAX = 1<<20,/* parse using SAX2 interface before 2.7.0 */1252XML_PARSE_IGNORE_ENC= 1<<21,/* ignore internal document encoding hint */1253XML_PARSE_BIG_LINES = 1<<22 /* Store big lines numbers in text PSVI field */1254} xmlParserOption;12551256XMLPUBFUN void1257xmlCtxtReset (xmlParserCtxtPtr ctxt);1258XMLPUBFUN int1259xmlCtxtResetPush (xmlParserCtxtPtr ctxt,1260const char *chunk,1261int size,1262const char *filename,1263const char *encoding);1264XMLPUBFUN int1265xmlCtxtUseOptions (xmlParserCtxtPtr ctxt,1266int options);1267XMLPUBFUN void1268xmlCtxtSetMaxAmplification(xmlParserCtxtPtr ctxt,1269unsigned maxAmpl);1270XMLPUBFUN xmlDocPtr1271xmlReadDoc (const xmlChar *cur,1272const char *URL,1273const char *encoding,1274int options);1275XMLPUBFUN xmlDocPtr1276xmlReadFile (const char *URL,1277const char *encoding,1278int options);1279XMLPUBFUN xmlDocPtr1280xmlReadMemory (const char *buffer,1281int size,1282const char *URL,1283const char *encoding,1284int options);1285XMLPUBFUN xmlDocPtr1286xmlReadFd (int fd,1287const char *URL,1288const char *encoding,1289int options);1290XMLPUBFUN xmlDocPtr1291xmlReadIO (xmlInputReadCallback ioread,1292xmlInputCloseCallback ioclose,1293void *ioctx,1294const char *URL,1295const char *encoding,1296int options);1297XMLPUBFUN xmlDocPtr1298xmlCtxtReadDoc (xmlParserCtxtPtr ctxt,1299const xmlChar *cur,1300const char *URL,1301const char *encoding,1302int options);1303XMLPUBFUN xmlDocPtr1304xmlCtxtReadFile (xmlParserCtxtPtr ctxt,1305const char *filename,1306const char *encoding,1307int options);1308XMLPUBFUN xmlDocPtr1309xmlCtxtReadMemory (xmlParserCtxtPtr ctxt,1310const char *buffer,1311int size,1312const char *URL,1313const char *encoding,1314int options);1315XMLPUBFUN xmlDocPtr1316xmlCtxtReadFd (xmlParserCtxtPtr ctxt,1317int fd,1318const char *URL,1319const char *encoding,1320int options);1321XMLPUBFUN xmlDocPtr1322xmlCtxtReadIO (xmlParserCtxtPtr ctxt,1323xmlInputReadCallback ioread,1324xmlInputCloseCallback ioclose,1325void *ioctx,1326const char *URL,1327const char *encoding,1328int options);13291330/*1331* Library wide options1332*/1333/**1334* xmlFeature:1335*1336* Used to examine the existence of features that can be enabled1337* or disabled at compile-time.1338* They used to be called XML_FEATURE_xxx but this clashed with Expat1339*/1340typedef enum {1341XML_WITH_THREAD = 1,1342XML_WITH_TREE = 2,1343XML_WITH_OUTPUT = 3,1344XML_WITH_PUSH = 4,1345XML_WITH_READER = 5,1346XML_WITH_PATTERN = 6,1347XML_WITH_WRITER = 7,1348XML_WITH_SAX1 = 8,1349XML_WITH_FTP = 9,1350XML_WITH_HTTP = 10,1351XML_WITH_VALID = 11,1352XML_WITH_HTML = 12,1353XML_WITH_LEGACY = 13,1354XML_WITH_C14N = 14,1355XML_WITH_CATALOG = 15,1356XML_WITH_XPATH = 16,1357XML_WITH_XPTR = 17,1358XML_WITH_XINCLUDE = 18,1359XML_WITH_ICONV = 19,1360XML_WITH_ISO8859X = 20,1361XML_WITH_UNICODE = 21,1362XML_WITH_REGEXP = 22,1363XML_WITH_AUTOMATA = 23,1364XML_WITH_EXPR = 24,1365XML_WITH_SCHEMAS = 25,1366XML_WITH_SCHEMATRON = 26,1367XML_WITH_MODULES = 27,1368XML_WITH_DEBUG = 28,1369XML_WITH_DEBUG_MEM = 29,1370XML_WITH_DEBUG_RUN = 30,1371XML_WITH_ZLIB = 31,1372XML_WITH_ICU = 32,1373XML_WITH_LZMA = 33,1374XML_WITH_NONE = 99999 /* just to be sure of allocation size */1375} xmlFeature;13761377XMLPUBFUN int1378xmlHasFeature (xmlFeature feature);13791380#ifdef __cplusplus1381}1382#endif1383#endif /* __XML_PARSER_H__ */138413851386