parser.h 43 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384
  1. /*
  2. * Summary: the core parser module
  3. * Description: Interfaces, constants and types related to the XML parser
  4. *
  5. * Copy: See Copyright for the status of this software.
  6. *
  7. * Author: Daniel Veillard
  8. */
  9. #ifndef __XML_PARSER_H__
  10. #define __XML_PARSER_H__
  11. #include <libxml/xmlversion.h>
  12. #define XML_TREE_INTERNALS
  13. #include <libxml/tree.h>
  14. #undef XML_TREE_INTERNALS
  15. #include <libxml/dict.h>
  16. #include <libxml/hash.h>
  17. #include <libxml/valid.h>
  18. #include <libxml/entities.h>
  19. #include <libxml/xmlerror.h>
  20. #include <libxml/xmlstring.h>
  21. #include <libxml/xmlmemory.h>
  22. #include <libxml/encoding.h>
  23. #include <libxml/xmlIO.h>
  24. /* for compatibility */
  25. #include <libxml/SAX2.h>
  26. #include <libxml/threads.h>
  27. #ifdef __cplusplus
  28. extern "C" {
  29. #endif
  30. /**
  31. * XML_DEFAULT_VERSION:
  32. *
  33. * The default version of XML used: 1.0
  34. */
  35. #define XML_DEFAULT_VERSION "1.0"
  36. /**
  37. * xmlParserInput:
  38. *
  39. * An xmlParserInput is an input flow for the XML processor.
  40. * Each entity parsed is associated an xmlParserInput (except the
  41. * few predefined ones). This is the case both for internal entities
  42. * - in which case the flow is already completely in memory - or
  43. * external entities - in which case we use the buf structure for
  44. * progressive reading and I18N conversions to the internal UTF-8 format.
  45. */
  46. /**
  47. * xmlParserInputDeallocate:
  48. * @str: the string to deallocate
  49. *
  50. * Callback for freeing some parser input allocations.
  51. */
  52. typedef void (* xmlParserInputDeallocate)(xmlChar *str);
  53. struct _xmlParserInput {
  54. /* Input buffer */
  55. xmlParserInputBufferPtr buf; /* UTF-8 encoded buffer */
  56. const char *filename; /* The file analyzed, if any */
  57. const char *directory; /* the directory/base of the file */
  58. const xmlChar *base; /* Base of the array to parse */
  59. const xmlChar *cur; /* Current char being parsed */
  60. const xmlChar *end; /* end of the array to parse */
  61. int length; /* length if known */
  62. int line; /* Current line */
  63. int col; /* Current column */
  64. unsigned long consumed; /* How many xmlChars already consumed */
  65. xmlParserInputDeallocate free; /* function to deallocate the base */
  66. const xmlChar *encoding; /* unused */
  67. const xmlChar *version; /* the version string for entity */
  68. int flags; /* Flags */
  69. int id; /* an unique identifier for the entity */
  70. unsigned long parentConsumed; /* consumed bytes from parents */
  71. xmlEntityPtr entity; /* entity, if any */
  72. };
  73. /**
  74. * xmlParserNodeInfo:
  75. *
  76. * The parser can be asked to collect Node information, i.e. at what
  77. * place in the file they were detected.
  78. * NOTE: This is off by default and not very well tested.
  79. */
  80. typedef struct _xmlParserNodeInfo xmlParserNodeInfo;
  81. typedef xmlParserNodeInfo *xmlParserNodeInfoPtr;
  82. struct _xmlParserNodeInfo {
  83. const struct _xmlNode* node;
  84. /* Position & line # that text that created the node begins & ends on */
  85. unsigned long begin_pos;
  86. unsigned long begin_line;
  87. unsigned long end_pos;
  88. unsigned long end_line;
  89. };
  90. typedef struct _xmlParserNodeInfoSeq xmlParserNodeInfoSeq;
  91. typedef xmlParserNodeInfoSeq *xmlParserNodeInfoSeqPtr;
  92. struct _xmlParserNodeInfoSeq {
  93. unsigned long maximum;
  94. unsigned long length;
  95. xmlParserNodeInfo* buffer;
  96. };
  97. /**
  98. * xmlParserInputState:
  99. *
  100. * The parser is now working also as a state based parser.
  101. * The recursive one use the state info for entities processing.
  102. */
  103. typedef enum {
  104. XML_PARSER_EOF = -1, /* nothing is to be parsed */
  105. XML_PARSER_START = 0, /* nothing has been parsed */
  106. XML_PARSER_MISC, /* Misc* before int subset */
  107. XML_PARSER_PI, /* Within a processing instruction */
  108. XML_PARSER_DTD, /* within some DTD content */
  109. XML_PARSER_PROLOG, /* Misc* after internal subset */
  110. XML_PARSER_COMMENT, /* within a comment */
  111. XML_PARSER_START_TAG, /* within a start tag */
  112. XML_PARSER_CONTENT, /* within the content */
  113. XML_PARSER_CDATA_SECTION, /* within a CDATA section */
  114. XML_PARSER_END_TAG, /* within a closing tag */
  115. XML_PARSER_ENTITY_DECL, /* within an entity declaration */
  116. XML_PARSER_ENTITY_VALUE, /* within an entity value in a decl */
  117. XML_PARSER_ATTRIBUTE_VALUE, /* within an attribute value */
  118. XML_PARSER_SYSTEM_LITERAL, /* within a SYSTEM value */
  119. XML_PARSER_EPILOG, /* the Misc* after the last end tag */
  120. XML_PARSER_IGNORE, /* within an IGNORED section */
  121. XML_PARSER_PUBLIC_LITERAL, /* within a PUBLIC value */
  122. XML_PARSER_XML_DECL /* before XML decl (but after BOM) */
  123. } xmlParserInputState;
  124. /**
  125. * XML_DETECT_IDS:
  126. *
  127. * Bit in the loadsubset context field to tell to do ID/REFs lookups.
  128. * Use it to initialize xmlLoadExtDtdDefaultValue.
  129. */
  130. #define XML_DETECT_IDS 2
  131. /**
  132. * XML_COMPLETE_ATTRS:
  133. *
  134. * Bit in the loadsubset context field to tell to do complete the
  135. * elements attributes lists with the ones defaulted from the DTDs.
  136. * Use it to initialize xmlLoadExtDtdDefaultValue.
  137. */
  138. #define XML_COMPLETE_ATTRS 4
  139. /**
  140. * XML_SKIP_IDS:
  141. *
  142. * Bit in the loadsubset context field to tell to not do ID/REFs registration.
  143. * Used to initialize xmlLoadExtDtdDefaultValue in some special cases.
  144. */
  145. #define XML_SKIP_IDS 8
  146. /**
  147. * xmlParserMode:
  148. *
  149. * A parser can operate in various modes
  150. */
  151. typedef enum {
  152. XML_PARSE_UNKNOWN = 0,
  153. XML_PARSE_DOM = 1,
  154. XML_PARSE_SAX = 2,
  155. XML_PARSE_PUSH_DOM = 3,
  156. XML_PARSE_PUSH_SAX = 4,
  157. XML_PARSE_READER = 5
  158. } xmlParserMode;
  159. typedef struct _xmlStartTag xmlStartTag;
  160. typedef struct _xmlParserNsData xmlParserNsData;
  161. typedef struct _xmlAttrHashBucket xmlAttrHashBucket;
  162. /**
  163. * xmlParserCtxt:
  164. *
  165. * The parser context.
  166. * NOTE This doesn't completely define the parser state, the (current ?)
  167. * design of the parser uses recursive function calls since this allow
  168. * and easy mapping from the production rules of the specification
  169. * to the actual code. The drawback is that the actual function call
  170. * also reflect the parser state. However most of the parsing routines
  171. * takes as the only argument the parser context pointer, so migrating
  172. * to a state based parser for progressive parsing shouldn't be too hard.
  173. */
  174. struct _xmlParserCtxt {
  175. struct _xmlSAXHandler *sax; /* The SAX handler */
  176. void *userData; /* For SAX interface only, used by DOM build */
  177. xmlDocPtr myDoc; /* the document being built */
  178. int wellFormed; /* is the document well formed */
  179. int replaceEntities; /* shall we replace entities ? */
  180. const xmlChar *version; /* the XML version string */
  181. const xmlChar *encoding; /* the declared encoding, if any */
  182. int standalone; /* standalone document */
  183. int html; /* an HTML(1) document
  184. * 3 is HTML after <head>
  185. * 10 is HTML after <body>
  186. */
  187. /* Input stream stack */
  188. xmlParserInputPtr input; /* Current input stream */
  189. int inputNr; /* Number of current input streams */
  190. int inputMax; /* Max number of input streams */
  191. xmlParserInputPtr *inputTab; /* stack of inputs */
  192. /* Node analysis stack only used for DOM building */
  193. xmlNodePtr node; /* Current parsed Node */
  194. int nodeNr; /* Depth of the parsing stack */
  195. int nodeMax; /* Max depth of the parsing stack */
  196. xmlNodePtr *nodeTab; /* array of nodes */
  197. int record_info; /* Whether node info should be kept */
  198. xmlParserNodeInfoSeq node_seq; /* info about each node parsed */
  199. int errNo; /* error code */
  200. int hasExternalSubset; /* reference and external subset */
  201. int hasPErefs; /* the internal subset has PE refs */
  202. int external; /* are we parsing an external entity */
  203. int valid; /* is the document valid */
  204. int validate; /* shall we try to validate ? */
  205. xmlValidCtxt vctxt; /* The validity context */
  206. xmlParserInputState instate; /* current type of input */
  207. int token; /* next char look-ahead */
  208. char *directory; /* the data directory */
  209. /* Node name stack */
  210. const xmlChar *name; /* Current parsed Node */
  211. int nameNr; /* Depth of the parsing stack */
  212. int nameMax; /* Max depth of the parsing stack */
  213. const xmlChar * *nameTab; /* array of nodes */
  214. long nbChars; /* unused */
  215. long checkIndex; /* used by progressive parsing lookup */
  216. int keepBlanks; /* ugly but ... */
  217. int disableSAX; /* SAX callbacks are disabled */
  218. int inSubset; /* Parsing is in int 1/ext 2 subset */
  219. const xmlChar * intSubName; /* name of subset */
  220. xmlChar * extSubURI; /* URI of external subset */
  221. xmlChar * extSubSystem; /* SYSTEM ID of external subset */
  222. /* xml:space values */
  223. int * space; /* Should the parser preserve spaces */
  224. int spaceNr; /* Depth of the parsing stack */
  225. int spaceMax; /* Max depth of the parsing stack */
  226. int * spaceTab; /* array of space infos */
  227. int depth; /* to prevent entity substitution loops */
  228. xmlParserInputPtr entity; /* used to check entities boundaries */
  229. int charset; /* unused */
  230. int nodelen; /* Those two fields are there to */
  231. int nodemem; /* Speed up large node parsing */
  232. int pedantic; /* signal pedantic warnings */
  233. void *_private; /* For user data, libxml won't touch it */
  234. int loadsubset; /* should the external subset be loaded */
  235. int linenumbers; /* set line number in element content */
  236. void *catalogs; /* document's own catalog */
  237. int recovery; /* run in recovery mode */
  238. int progressive; /* is this a progressive parsing */
  239. xmlDictPtr dict; /* dictionary for the parser */
  240. const xmlChar * *atts; /* array for the attributes callbacks */
  241. int maxatts; /* the size of the array */
  242. int docdict; /* use strings from dict to build tree */
  243. /*
  244. * pre-interned strings
  245. */
  246. const xmlChar *str_xml;
  247. const xmlChar *str_xmlns;
  248. const xmlChar *str_xml_ns;
  249. /*
  250. * Everything below is used only by the new SAX mode
  251. */
  252. int sax2; /* operating in the new SAX mode */
  253. int nsNr; /* the number of inherited namespaces */
  254. int nsMax; /* the size of the arrays */
  255. const xmlChar * *nsTab; /* the array of prefix/namespace name */
  256. unsigned *attallocs; /* which attribute were allocated */
  257. xmlStartTag *pushTab; /* array of data for push */
  258. xmlHashTablePtr attsDefault; /* defaulted attributes if any */
  259. xmlHashTablePtr attsSpecial; /* non-CDATA attributes if any */
  260. int nsWellFormed; /* is the document XML Namespace okay */
  261. int options; /* Extra options */
  262. /*
  263. * Those fields are needed only for streaming parsing so far
  264. */
  265. int dictNames; /* Use dictionary names for the tree */
  266. int freeElemsNr; /* number of freed element nodes */
  267. xmlNodePtr freeElems; /* List of freed element nodes */
  268. int freeAttrsNr; /* number of freed attributes nodes */
  269. xmlAttrPtr freeAttrs; /* List of freed attributes nodes */
  270. /*
  271. * the complete error information for the last error.
  272. */
  273. xmlError lastError;
  274. xmlParserMode parseMode; /* the parser mode */
  275. unsigned long nbentities; /* unused */
  276. unsigned long sizeentities; /* size of parsed entities */
  277. /* for use by HTML non-recursive parser */
  278. xmlParserNodeInfo *nodeInfo; /* Current NodeInfo */
  279. int nodeInfoNr; /* Depth of the parsing stack */
  280. int nodeInfoMax; /* Max depth of the parsing stack */
  281. xmlParserNodeInfo *nodeInfoTab; /* array of nodeInfos */
  282. int input_id; /* we need to label inputs */
  283. unsigned long sizeentcopy; /* volume of entity copy */
  284. int endCheckState; /* quote state for push parser */
  285. unsigned short nbErrors; /* number of errors */
  286. unsigned short nbWarnings; /* number of warnings */
  287. unsigned maxAmpl; /* maximum amplification factor */
  288. xmlParserNsData *nsdb; /* namespace database */
  289. unsigned attrHashMax; /* allocated size */
  290. xmlAttrHashBucket *attrHash; /* atttribute hash table */
  291. };
  292. /**
  293. * xmlSAXLocator:
  294. *
  295. * A SAX Locator.
  296. */
  297. struct _xmlSAXLocator {
  298. const xmlChar *(*getPublicId)(void *ctx);
  299. const xmlChar *(*getSystemId)(void *ctx);
  300. int (*getLineNumber)(void *ctx);
  301. int (*getColumnNumber)(void *ctx);
  302. };
  303. /**
  304. * xmlSAXHandler:
  305. *
  306. * A SAX handler is bunch of callbacks called by the parser when processing
  307. * of the input generate data or structure information.
  308. */
  309. /**
  310. * resolveEntitySAXFunc:
  311. * @ctx: the user data (XML parser context)
  312. * @publicId: The public ID of the entity
  313. * @systemId: The system ID of the entity
  314. *
  315. * Callback:
  316. * The entity loader, to control the loading of external entities,
  317. * the application can either:
  318. * - override this resolveEntity() callback in the SAX block
  319. * - or better use the xmlSetExternalEntityLoader() function to
  320. * set up it's own entity resolution routine
  321. *
  322. * Returns the xmlParserInputPtr if inlined or NULL for DOM behaviour.
  323. */
  324. typedef xmlParserInputPtr (*resolveEntitySAXFunc) (void *ctx,
  325. const xmlChar *publicId,
  326. const xmlChar *systemId);
  327. /**
  328. * internalSubsetSAXFunc:
  329. * @ctx: the user data (XML parser context)
  330. * @name: the root element name
  331. * @ExternalID: the external ID
  332. * @SystemID: the SYSTEM ID (e.g. filename or URL)
  333. *
  334. * Callback on internal subset declaration.
  335. */
  336. typedef void (*internalSubsetSAXFunc) (void *ctx,
  337. const xmlChar *name,
  338. const xmlChar *ExternalID,
  339. const xmlChar *SystemID);
  340. /**
  341. * externalSubsetSAXFunc:
  342. * @ctx: the user data (XML parser context)
  343. * @name: the root element name
  344. * @ExternalID: the external ID
  345. * @SystemID: the SYSTEM ID (e.g. filename or URL)
  346. *
  347. * Callback on external subset declaration.
  348. */
  349. typedef void (*externalSubsetSAXFunc) (void *ctx,
  350. const xmlChar *name,
  351. const xmlChar *ExternalID,
  352. const xmlChar *SystemID);
  353. /**
  354. * getEntitySAXFunc:
  355. * @ctx: the user data (XML parser context)
  356. * @name: The entity name
  357. *
  358. * Get an entity by name.
  359. *
  360. * Returns the xmlEntityPtr if found.
  361. */
  362. typedef xmlEntityPtr (*getEntitySAXFunc) (void *ctx,
  363. const xmlChar *name);
  364. /**
  365. * getParameterEntitySAXFunc:
  366. * @ctx: the user data (XML parser context)
  367. * @name: The entity name
  368. *
  369. * Get a parameter entity by name.
  370. *
  371. * Returns the xmlEntityPtr if found.
  372. */
  373. typedef xmlEntityPtr (*getParameterEntitySAXFunc) (void *ctx,
  374. const xmlChar *name);
  375. /**
  376. * entityDeclSAXFunc:
  377. * @ctx: the user data (XML parser context)
  378. * @name: the entity name
  379. * @type: the entity type
  380. * @publicId: The public ID of the entity
  381. * @systemId: The system ID of the entity
  382. * @content: the entity value (without processing).
  383. *
  384. * An entity definition has been parsed.
  385. */
  386. typedef void (*entityDeclSAXFunc) (void *ctx,
  387. const xmlChar *name,
  388. int type,
  389. const xmlChar *publicId,
  390. const xmlChar *systemId,
  391. xmlChar *content);
  392. /**
  393. * notationDeclSAXFunc:
  394. * @ctx: the user data (XML parser context)
  395. * @name: The name of the notation
  396. * @publicId: The public ID of the entity
  397. * @systemId: The system ID of the entity
  398. *
  399. * What to do when a notation declaration has been parsed.
  400. */
  401. typedef void (*notationDeclSAXFunc)(void *ctx,
  402. const xmlChar *name,
  403. const xmlChar *publicId,
  404. const xmlChar *systemId);
  405. /**
  406. * attributeDeclSAXFunc:
  407. * @ctx: the user data (XML parser context)
  408. * @elem: the name of the element
  409. * @fullname: the attribute name
  410. * @type: the attribute type
  411. * @def: the type of default value
  412. * @defaultValue: the attribute default value
  413. * @tree: the tree of enumerated value set
  414. *
  415. * An attribute definition has been parsed.
  416. */
  417. typedef void (*attributeDeclSAXFunc)(void *ctx,
  418. const xmlChar *elem,
  419. const xmlChar *fullname,
  420. int type,
  421. int def,
  422. const xmlChar *defaultValue,
  423. xmlEnumerationPtr tree);
  424. /**
  425. * elementDeclSAXFunc:
  426. * @ctx: the user data (XML parser context)
  427. * @name: the element name
  428. * @type: the element type
  429. * @content: the element value tree
  430. *
  431. * An element definition has been parsed.
  432. */
  433. typedef void (*elementDeclSAXFunc)(void *ctx,
  434. const xmlChar *name,
  435. int type,
  436. xmlElementContentPtr content);
  437. /**
  438. * unparsedEntityDeclSAXFunc:
  439. * @ctx: the user data (XML parser context)
  440. * @name: The name of the entity
  441. * @publicId: The public ID of the entity
  442. * @systemId: The system ID of the entity
  443. * @notationName: the name of the notation
  444. *
  445. * What to do when an unparsed entity declaration is parsed.
  446. */
  447. typedef void (*unparsedEntityDeclSAXFunc)(void *ctx,
  448. const xmlChar *name,
  449. const xmlChar *publicId,
  450. const xmlChar *systemId,
  451. const xmlChar *notationName);
  452. /**
  453. * setDocumentLocatorSAXFunc:
  454. * @ctx: the user data (XML parser context)
  455. * @loc: A SAX Locator
  456. *
  457. * Receive the document locator at startup, actually xmlDefaultSAXLocator.
  458. * Everything is available on the context, so this is useless in our case.
  459. */
  460. typedef void (*setDocumentLocatorSAXFunc) (void *ctx,
  461. xmlSAXLocatorPtr loc);
  462. /**
  463. * startDocumentSAXFunc:
  464. * @ctx: the user data (XML parser context)
  465. *
  466. * Called when the document start being processed.
  467. */
  468. typedef void (*startDocumentSAXFunc) (void *ctx);
  469. /**
  470. * endDocumentSAXFunc:
  471. * @ctx: the user data (XML parser context)
  472. *
  473. * Called when the document end has been detected.
  474. */
  475. typedef void (*endDocumentSAXFunc) (void *ctx);
  476. /**
  477. * startElementSAXFunc:
  478. * @ctx: the user data (XML parser context)
  479. * @name: The element name, including namespace prefix
  480. * @atts: An array of name/value attributes pairs, NULL terminated
  481. *
  482. * Called when an opening tag has been processed.
  483. */
  484. typedef void (*startElementSAXFunc) (void *ctx,
  485. const xmlChar *name,
  486. const xmlChar **atts);
  487. /**
  488. * endElementSAXFunc:
  489. * @ctx: the user data (XML parser context)
  490. * @name: The element name
  491. *
  492. * Called when the end of an element has been detected.
  493. */
  494. typedef void (*endElementSAXFunc) (void *ctx,
  495. const xmlChar *name);
  496. /**
  497. * attributeSAXFunc:
  498. * @ctx: the user data (XML parser context)
  499. * @name: The attribute name, including namespace prefix
  500. * @value: The attribute value
  501. *
  502. * Handle an attribute that has been read by the parser.
  503. * The default handling is to convert the attribute into an
  504. * DOM subtree and past it in a new xmlAttr element added to
  505. * the element.
  506. */
  507. typedef void (*attributeSAXFunc) (void *ctx,
  508. const xmlChar *name,
  509. const xmlChar *value);
  510. /**
  511. * referenceSAXFunc:
  512. * @ctx: the user data (XML parser context)
  513. * @name: The entity name
  514. *
  515. * Called when an entity reference is detected.
  516. */
  517. typedef void (*referenceSAXFunc) (void *ctx,
  518. const xmlChar *name);
  519. /**
  520. * charactersSAXFunc:
  521. * @ctx: the user data (XML parser context)
  522. * @ch: a xmlChar string
  523. * @len: the number of xmlChar
  524. *
  525. * Receiving some chars from the parser.
  526. */
  527. typedef void (*charactersSAXFunc) (void *ctx,
  528. const xmlChar *ch,
  529. int len);
  530. /**
  531. * ignorableWhitespaceSAXFunc:
  532. * @ctx: the user data (XML parser context)
  533. * @ch: a xmlChar string
  534. * @len: the number of xmlChar
  535. *
  536. * Receiving some ignorable whitespaces from the parser.
  537. * UNUSED: by default the DOM building will use characters.
  538. */
  539. typedef void (*ignorableWhitespaceSAXFunc) (void *ctx,
  540. const xmlChar *ch,
  541. int len);
  542. /**
  543. * processingInstructionSAXFunc:
  544. * @ctx: the user data (XML parser context)
  545. * @target: the target name
  546. * @data: the PI data's
  547. *
  548. * A processing instruction has been parsed.
  549. */
  550. typedef void (*processingInstructionSAXFunc) (void *ctx,
  551. const xmlChar *target,
  552. const xmlChar *data);
  553. /**
  554. * commentSAXFunc:
  555. * @ctx: the user data (XML parser context)
  556. * @value: the comment content
  557. *
  558. * A comment has been parsed.
  559. */
  560. typedef void (*commentSAXFunc) (void *ctx,
  561. const xmlChar *value);
  562. /**
  563. * cdataBlockSAXFunc:
  564. * @ctx: the user data (XML parser context)
  565. * @value: The pcdata content
  566. * @len: the block length
  567. *
  568. * Called when a pcdata block has been parsed.
  569. */
  570. typedef void (*cdataBlockSAXFunc) (
  571. void *ctx,
  572. const xmlChar *value,
  573. int len);
  574. /**
  575. * warningSAXFunc:
  576. * @ctx: an XML parser context
  577. * @msg: the message to display/transmit
  578. * @...: extra parameters for the message display
  579. *
  580. * Display and format a warning messages, callback.
  581. */
  582. typedef void (*warningSAXFunc) (void *ctx,
  583. const char *msg, ...) LIBXML_ATTR_FORMAT(2,3);
  584. /**
  585. * errorSAXFunc:
  586. * @ctx: an XML parser context
  587. * @msg: the message to display/transmit
  588. * @...: extra parameters for the message display
  589. *
  590. * Display and format an error messages, callback.
  591. */
  592. typedef void (*errorSAXFunc) (void *ctx,
  593. const char *msg, ...) LIBXML_ATTR_FORMAT(2,3);
  594. /**
  595. * fatalErrorSAXFunc:
  596. * @ctx: an XML parser context
  597. * @msg: the message to display/transmit
  598. * @...: extra parameters for the message display
  599. *
  600. * Display and format fatal error messages, callback.
  601. * Note: so far fatalError() SAX callbacks are not used, error()
  602. * get all the callbacks for errors.
  603. */
  604. typedef void (*fatalErrorSAXFunc) (void *ctx,
  605. const char *msg, ...) LIBXML_ATTR_FORMAT(2,3);
  606. /**
  607. * isStandaloneSAXFunc:
  608. * @ctx: the user data (XML parser context)
  609. *
  610. * Is this document tagged standalone?
  611. *
  612. * Returns 1 if true
  613. */
  614. typedef int (*isStandaloneSAXFunc) (void *ctx);
  615. /**
  616. * hasInternalSubsetSAXFunc:
  617. * @ctx: the user data (XML parser context)
  618. *
  619. * Does this document has an internal subset.
  620. *
  621. * Returns 1 if true
  622. */
  623. typedef int (*hasInternalSubsetSAXFunc) (void *ctx);
  624. /**
  625. * hasExternalSubsetSAXFunc:
  626. * @ctx: the user data (XML parser context)
  627. *
  628. * Does this document has an external subset?
  629. *
  630. * Returns 1 if true
  631. */
  632. typedef int (*hasExternalSubsetSAXFunc) (void *ctx);
  633. /************************************************************************
  634. * *
  635. * The SAX version 2 API extensions *
  636. * *
  637. ************************************************************************/
  638. /**
  639. * XML_SAX2_MAGIC:
  640. *
  641. * Special constant found in SAX2 blocks initialized fields
  642. */
  643. #define XML_SAX2_MAGIC 0xDEEDBEAF
  644. /**
  645. * startElementNsSAX2Func:
  646. * @ctx: the user data (XML parser context)
  647. * @localname: the local name of the element
  648. * @prefix: the element namespace prefix if available
  649. * @URI: the element namespace name if available
  650. * @nb_namespaces: number of namespace definitions on that node
  651. * @namespaces: pointer to the array of prefix/URI pairs namespace definitions
  652. * @nb_attributes: the number of attributes on that node
  653. * @nb_defaulted: the number of defaulted attributes. The defaulted
  654. * ones are at the end of the array
  655. * @attributes: pointer to the array of (localname/prefix/URI/value/end)
  656. * attribute values.
  657. *
  658. * SAX2 callback when an element start has been detected by the parser.
  659. * It provides the namespace information for the element, as well as
  660. * the new namespace declarations on the element.
  661. */
  662. typedef void (*startElementNsSAX2Func) (void *ctx,
  663. const xmlChar *localname,
  664. const xmlChar *prefix,
  665. const xmlChar *URI,
  666. int nb_namespaces,
  667. const xmlChar **namespaces,
  668. int nb_attributes,
  669. int nb_defaulted,
  670. const xmlChar **attributes);
  671. /**
  672. * endElementNsSAX2Func:
  673. * @ctx: the user data (XML parser context)
  674. * @localname: the local name of the element
  675. * @prefix: the element namespace prefix if available
  676. * @URI: the element namespace name if available
  677. *
  678. * SAX2 callback when an element end has been detected by the parser.
  679. * It provides the namespace information for the element.
  680. */
  681. typedef void (*endElementNsSAX2Func) (void *ctx,
  682. const xmlChar *localname,
  683. const xmlChar *prefix,
  684. const xmlChar *URI);
  685. struct _xmlSAXHandler {
  686. internalSubsetSAXFunc internalSubset;
  687. isStandaloneSAXFunc isStandalone;
  688. hasInternalSubsetSAXFunc hasInternalSubset;
  689. hasExternalSubsetSAXFunc hasExternalSubset;
  690. resolveEntitySAXFunc resolveEntity;
  691. getEntitySAXFunc getEntity;
  692. entityDeclSAXFunc entityDecl;
  693. notationDeclSAXFunc notationDecl;
  694. attributeDeclSAXFunc attributeDecl;
  695. elementDeclSAXFunc elementDecl;
  696. unparsedEntityDeclSAXFunc unparsedEntityDecl;
  697. setDocumentLocatorSAXFunc setDocumentLocator;
  698. startDocumentSAXFunc startDocument;
  699. endDocumentSAXFunc endDocument;
  700. /*
  701. * `startElement` and `endElement` are only used by the legacy SAX1
  702. * interface and should not be used in new software. If you really
  703. * have to enable SAX1, the preferred way is set the `initialized`
  704. * member to 1 instead of XML_SAX2_MAGIC.
  705. *
  706. * For backward compatibility, it's also possible to set the
  707. * `startElementNs` and `endElementNs` handlers to NULL.
  708. *
  709. * You can also set the XML_PARSE_SAX1 parser option, but versions
  710. * older than 2.12.0 will probably crash if this option is provided
  711. * together with custom SAX callbacks.
  712. */
  713. startElementSAXFunc startElement;
  714. endElementSAXFunc endElement;
  715. referenceSAXFunc reference;
  716. charactersSAXFunc characters;
  717. ignorableWhitespaceSAXFunc ignorableWhitespace;
  718. processingInstructionSAXFunc processingInstruction;
  719. commentSAXFunc comment;
  720. warningSAXFunc warning;
  721. errorSAXFunc error;
  722. fatalErrorSAXFunc fatalError; /* unused error() get all the errors */
  723. getParameterEntitySAXFunc getParameterEntity;
  724. cdataBlockSAXFunc cdataBlock;
  725. externalSubsetSAXFunc externalSubset;
  726. /*
  727. * `initialized` should always be set to XML_SAX2_MAGIC to enable the
  728. * modern SAX2 interface.
  729. */
  730. unsigned int initialized;
  731. /*
  732. * The following members are only used by the SAX2 interface.
  733. */
  734. void *_private;
  735. startElementNsSAX2Func startElementNs;
  736. endElementNsSAX2Func endElementNs;
  737. xmlStructuredErrorFunc serror;
  738. };
  739. /*
  740. * SAX Version 1
  741. */
  742. typedef struct _xmlSAXHandlerV1 xmlSAXHandlerV1;
  743. typedef xmlSAXHandlerV1 *xmlSAXHandlerV1Ptr;
  744. struct _xmlSAXHandlerV1 {
  745. internalSubsetSAXFunc internalSubset;
  746. isStandaloneSAXFunc isStandalone;
  747. hasInternalSubsetSAXFunc hasInternalSubset;
  748. hasExternalSubsetSAXFunc hasExternalSubset;
  749. resolveEntitySAXFunc resolveEntity;
  750. getEntitySAXFunc getEntity;
  751. entityDeclSAXFunc entityDecl;
  752. notationDeclSAXFunc notationDecl;
  753. attributeDeclSAXFunc attributeDecl;
  754. elementDeclSAXFunc elementDecl;
  755. unparsedEntityDeclSAXFunc unparsedEntityDecl;
  756. setDocumentLocatorSAXFunc setDocumentLocator;
  757. startDocumentSAXFunc startDocument;
  758. endDocumentSAXFunc endDocument;
  759. startElementSAXFunc startElement;
  760. endElementSAXFunc endElement;
  761. referenceSAXFunc reference;
  762. charactersSAXFunc characters;
  763. ignorableWhitespaceSAXFunc ignorableWhitespace;
  764. processingInstructionSAXFunc processingInstruction;
  765. commentSAXFunc comment;
  766. warningSAXFunc warning;
  767. errorSAXFunc error;
  768. fatalErrorSAXFunc fatalError; /* unused error() get all the errors */
  769. getParameterEntitySAXFunc getParameterEntity;
  770. cdataBlockSAXFunc cdataBlock;
  771. externalSubsetSAXFunc externalSubset;
  772. unsigned int initialized;
  773. };
  774. /**
  775. * xmlExternalEntityLoader:
  776. * @URL: The System ID of the resource requested
  777. * @ID: The Public ID of the resource requested
  778. * @context: the XML parser context
  779. *
  780. * External entity loaders types.
  781. *
  782. * Returns the entity input parser.
  783. */
  784. typedef xmlParserInputPtr (*xmlExternalEntityLoader) (const char *URL,
  785. const char *ID,
  786. xmlParserCtxtPtr context);
  787. /*
  788. * Variables
  789. */
  790. XMLPUBVAR const char *const xmlParserVersion;
  791. #ifdef LIBXML_THREAD_ENABLED
  792. /* backward compatibility */
  793. XMLPUBFUN const char *const *__xmlParserVersion(void);
  794. #endif
  795. /** DOC_DISABLE */
  796. #define XML_GLOBALS_PARSER_CORE \
  797. XML_OP(oldXMLWDcompatibility, int, XML_DEPRECATED) \
  798. XML_OP(xmlDefaultSAXLocator, xmlSAXLocator, XML_DEPRECATED) \
  799. XML_OP(xmlDoValidityCheckingDefaultValue, int, XML_DEPRECATED) \
  800. XML_OP(xmlGetWarningsDefaultValue, int, XML_DEPRECATED) \
  801. XML_OP(xmlKeepBlanksDefaultValue, int, XML_DEPRECATED) \
  802. XML_OP(xmlLineNumbersDefaultValue, int, XML_DEPRECATED) \
  803. XML_OP(xmlLoadExtDtdDefaultValue, int, XML_DEPRECATED) \
  804. XML_OP(xmlParserDebugEntities, int, XML_DEPRECATED) \
  805. XML_OP(xmlPedanticParserDefaultValue, int, XML_DEPRECATED) \
  806. XML_OP(xmlSubstituteEntitiesDefaultValue, int, XML_DEPRECATED)
  807. #ifdef LIBXML_OUTPUT_ENABLED
  808. #define XML_GLOBALS_PARSER_OUTPUT \
  809. XML_OP(xmlIndentTreeOutput, int, XML_NO_ATTR) \
  810. XML_OP(xmlTreeIndentString, const char *, XML_NO_ATTR) \
  811. XML_OP(xmlSaveNoEmptyTags, int, XML_NO_ATTR)
  812. #else
  813. #define XML_GLOBALS_PARSER_OUTPUT
  814. #endif
  815. #ifdef LIBXML_SAX1_ENABLED
  816. #define XML_GLOBALS_PARSER_SAX1 \
  817. XML_OP(xmlDefaultSAXHandler, xmlSAXHandlerV1, XML_DEPRECATED)
  818. #else
  819. #define XML_GLOBALS_PARSER_SAX1
  820. #endif
  821. #define XML_GLOBALS_PARSER \
  822. XML_GLOBALS_PARSER_CORE \
  823. XML_GLOBALS_PARSER_OUTPUT \
  824. XML_GLOBALS_PARSER_SAX1
  825. #define XML_OP XML_DECLARE_GLOBAL
  826. XML_GLOBALS_PARSER
  827. #undef XML_OP
  828. #if defined(LIBXML_THREAD_ENABLED) && !defined(XML_GLOBALS_NO_REDEFINITION)
  829. #define oldXMLWDcompatibility XML_GLOBAL_MACRO(oldXMLWDcompatibility)
  830. #define xmlDefaultSAXHandler XML_GLOBAL_MACRO(xmlDefaultSAXHandler)
  831. #define xmlDefaultSAXLocator XML_GLOBAL_MACRO(xmlDefaultSAXLocator)
  832. #define xmlDoValidityCheckingDefaultValue \
  833. XML_GLOBAL_MACRO(xmlDoValidityCheckingDefaultValue)
  834. #define xmlGetWarningsDefaultValue \
  835. XML_GLOBAL_MACRO(xmlGetWarningsDefaultValue)
  836. #define xmlKeepBlanksDefaultValue XML_GLOBAL_MACRO(xmlKeepBlanksDefaultValue)
  837. #define xmlLineNumbersDefaultValue \
  838. XML_GLOBAL_MACRO(xmlLineNumbersDefaultValue)
  839. #define xmlLoadExtDtdDefaultValue XML_GLOBAL_MACRO(xmlLoadExtDtdDefaultValue)
  840. #define xmlParserDebugEntities XML_GLOBAL_MACRO(xmlParserDebugEntities)
  841. #define xmlPedanticParserDefaultValue \
  842. XML_GLOBAL_MACRO(xmlPedanticParserDefaultValue)
  843. #define xmlSubstituteEntitiesDefaultValue \
  844. XML_GLOBAL_MACRO(xmlSubstituteEntitiesDefaultValue)
  845. #ifdef LIBXML_OUTPUT_ENABLED
  846. #define xmlIndentTreeOutput XML_GLOBAL_MACRO(xmlIndentTreeOutput)
  847. #define xmlTreeIndentString XML_GLOBAL_MACRO(xmlTreeIndentString)
  848. #define xmlSaveNoEmptyTags XML_GLOBAL_MACRO(xmlSaveNoEmptyTags)
  849. #endif
  850. #endif
  851. /** DOC_ENABLE */
  852. /*
  853. * Init/Cleanup
  854. */
  855. XMLPUBFUN void
  856. xmlInitParser (void);
  857. XMLPUBFUN void
  858. xmlCleanupParser (void);
  859. XML_DEPRECATED
  860. XMLPUBFUN void
  861. xmlInitGlobals (void);
  862. XML_DEPRECATED
  863. XMLPUBFUN void
  864. xmlCleanupGlobals (void);
  865. /*
  866. * Input functions
  867. */
  868. XML_DEPRECATED
  869. XMLPUBFUN int
  870. xmlParserInputRead (xmlParserInputPtr in,
  871. int len);
  872. XML_DEPRECATED
  873. XMLPUBFUN int
  874. xmlParserInputGrow (xmlParserInputPtr in,
  875. int len);
  876. /*
  877. * Basic parsing Interfaces
  878. */
  879. #ifdef LIBXML_SAX1_ENABLED
  880. XMLPUBFUN xmlDocPtr
  881. xmlParseDoc (const xmlChar *cur);
  882. XMLPUBFUN xmlDocPtr
  883. xmlParseFile (const char *filename);
  884. XMLPUBFUN xmlDocPtr
  885. xmlParseMemory (const char *buffer,
  886. int size);
  887. #endif /* LIBXML_SAX1_ENABLED */
  888. XML_DEPRECATED XMLPUBFUN int
  889. xmlSubstituteEntitiesDefault(int val);
  890. XML_DEPRECATED XMLPUBFUN int
  891. xmlThrDefSubstituteEntitiesDefaultValue(int v);
  892. XMLPUBFUN int
  893. xmlKeepBlanksDefault (int val);
  894. XML_DEPRECATED XMLPUBFUN int
  895. xmlThrDefKeepBlanksDefaultValue(int v);
  896. XMLPUBFUN void
  897. xmlStopParser (xmlParserCtxtPtr ctxt);
  898. XML_DEPRECATED XMLPUBFUN int
  899. xmlPedanticParserDefault(int val);
  900. XML_DEPRECATED XMLPUBFUN int
  901. xmlThrDefPedanticParserDefaultValue(int v);
  902. XML_DEPRECATED XMLPUBFUN int
  903. xmlLineNumbersDefault (int val);
  904. XML_DEPRECATED XMLPUBFUN int
  905. xmlThrDefLineNumbersDefaultValue(int v);
  906. XML_DEPRECATED XMLPUBFUN int
  907. xmlThrDefDoValidityCheckingDefaultValue(int v);
  908. XML_DEPRECATED XMLPUBFUN int
  909. xmlThrDefGetWarningsDefaultValue(int v);
  910. XML_DEPRECATED XMLPUBFUN int
  911. xmlThrDefLoadExtDtdDefaultValue(int v);
  912. XML_DEPRECATED XMLPUBFUN int
  913. xmlThrDefParserDebugEntities(int v);
  914. #ifdef LIBXML_SAX1_ENABLED
  915. /*
  916. * Recovery mode
  917. */
  918. XML_DEPRECATED
  919. XMLPUBFUN xmlDocPtr
  920. xmlRecoverDoc (const xmlChar *cur);
  921. XML_DEPRECATED
  922. XMLPUBFUN xmlDocPtr
  923. xmlRecoverMemory (const char *buffer,
  924. int size);
  925. XML_DEPRECATED
  926. XMLPUBFUN xmlDocPtr
  927. xmlRecoverFile (const char *filename);
  928. #endif /* LIBXML_SAX1_ENABLED */
  929. /*
  930. * Less common routines and SAX interfaces
  931. */
  932. XMLPUBFUN int
  933. xmlParseDocument (xmlParserCtxtPtr ctxt);
  934. XMLPUBFUN int
  935. xmlParseExtParsedEnt (xmlParserCtxtPtr ctxt);
  936. #ifdef LIBXML_SAX1_ENABLED
  937. XML_DEPRECATED
  938. XMLPUBFUN int
  939. xmlSAXUserParseFile (xmlSAXHandlerPtr sax,
  940. void *user_data,
  941. const char *filename);
  942. XML_DEPRECATED
  943. XMLPUBFUN int
  944. xmlSAXUserParseMemory (xmlSAXHandlerPtr sax,
  945. void *user_data,
  946. const char *buffer,
  947. int size);
  948. XML_DEPRECATED
  949. XMLPUBFUN xmlDocPtr
  950. xmlSAXParseDoc (xmlSAXHandlerPtr sax,
  951. const xmlChar *cur,
  952. int recovery);
  953. XML_DEPRECATED
  954. XMLPUBFUN xmlDocPtr
  955. xmlSAXParseMemory (xmlSAXHandlerPtr sax,
  956. const char *buffer,
  957. int size,
  958. int recovery);
  959. XML_DEPRECATED
  960. XMLPUBFUN xmlDocPtr
  961. xmlSAXParseMemoryWithData (xmlSAXHandlerPtr sax,
  962. const char *buffer,
  963. int size,
  964. int recovery,
  965. void *data);
  966. XML_DEPRECATED
  967. XMLPUBFUN xmlDocPtr
  968. xmlSAXParseFile (xmlSAXHandlerPtr sax,
  969. const char *filename,
  970. int recovery);
  971. XML_DEPRECATED
  972. XMLPUBFUN xmlDocPtr
  973. xmlSAXParseFileWithData (xmlSAXHandlerPtr sax,
  974. const char *filename,
  975. int recovery,
  976. void *data);
  977. XML_DEPRECATED
  978. XMLPUBFUN xmlDocPtr
  979. xmlSAXParseEntity (xmlSAXHandlerPtr sax,
  980. const char *filename);
  981. XML_DEPRECATED
  982. XMLPUBFUN xmlDocPtr
  983. xmlParseEntity (const char *filename);
  984. #endif /* LIBXML_SAX1_ENABLED */
  985. #ifdef LIBXML_VALID_ENABLED
  986. XML_DEPRECATED
  987. XMLPUBFUN xmlDtdPtr
  988. xmlSAXParseDTD (xmlSAXHandlerPtr sax,
  989. const xmlChar *ExternalID,
  990. const xmlChar *SystemID);
  991. XMLPUBFUN xmlDtdPtr
  992. xmlParseDTD (const xmlChar *ExternalID,
  993. const xmlChar *SystemID);
  994. XMLPUBFUN xmlDtdPtr
  995. xmlIOParseDTD (xmlSAXHandlerPtr sax,
  996. xmlParserInputBufferPtr input,
  997. xmlCharEncoding enc);
  998. #endif /* LIBXML_VALID_ENABLE */
  999. #ifdef LIBXML_SAX1_ENABLED
  1000. XMLPUBFUN int
  1001. xmlParseBalancedChunkMemory(xmlDocPtr doc,
  1002. xmlSAXHandlerPtr sax,
  1003. void *user_data,
  1004. int depth,
  1005. const xmlChar *string,
  1006. xmlNodePtr *lst);
  1007. #endif /* LIBXML_SAX1_ENABLED */
  1008. XMLPUBFUN xmlParserErrors
  1009. xmlParseInNodeContext (xmlNodePtr node,
  1010. const char *data,
  1011. int datalen,
  1012. int options,
  1013. xmlNodePtr *lst);
  1014. #ifdef LIBXML_SAX1_ENABLED
  1015. XMLPUBFUN int
  1016. xmlParseBalancedChunkMemoryRecover(xmlDocPtr doc,
  1017. xmlSAXHandlerPtr sax,
  1018. void *user_data,
  1019. int depth,
  1020. const xmlChar *string,
  1021. xmlNodePtr *lst,
  1022. int recover);
  1023. XML_DEPRECATED
  1024. XMLPUBFUN int
  1025. xmlParseExternalEntity (xmlDocPtr doc,
  1026. xmlSAXHandlerPtr sax,
  1027. void *user_data,
  1028. int depth,
  1029. const xmlChar *URL,
  1030. const xmlChar *ID,
  1031. xmlNodePtr *lst);
  1032. #endif /* LIBXML_SAX1_ENABLED */
  1033. XMLPUBFUN int
  1034. xmlParseCtxtExternalEntity(xmlParserCtxtPtr ctx,
  1035. const xmlChar *URL,
  1036. const xmlChar *ID,
  1037. xmlNodePtr *lst);
  1038. /*
  1039. * Parser contexts handling.
  1040. */
  1041. XMLPUBFUN xmlParserCtxtPtr
  1042. xmlNewParserCtxt (void);
  1043. XMLPUBFUN xmlParserCtxtPtr
  1044. xmlNewSAXParserCtxt (const xmlSAXHandler *sax,
  1045. void *userData);
  1046. XMLPUBFUN int
  1047. xmlInitParserCtxt (xmlParserCtxtPtr ctxt);
  1048. XMLPUBFUN void
  1049. xmlClearParserCtxt (xmlParserCtxtPtr ctxt);
  1050. XMLPUBFUN void
  1051. xmlFreeParserCtxt (xmlParserCtxtPtr ctxt);
  1052. #ifdef LIBXML_SAX1_ENABLED
  1053. XML_DEPRECATED
  1054. XMLPUBFUN void
  1055. xmlSetupParserForBuffer (xmlParserCtxtPtr ctxt,
  1056. const xmlChar* buffer,
  1057. const char *filename);
  1058. #endif /* LIBXML_SAX1_ENABLED */
  1059. XMLPUBFUN xmlParserCtxtPtr
  1060. xmlCreateDocParserCtxt (const xmlChar *cur);
  1061. #ifdef LIBXML_LEGACY_ENABLED
  1062. /*
  1063. * Reading/setting optional parsing features.
  1064. */
  1065. XML_DEPRECATED
  1066. XMLPUBFUN int
  1067. xmlGetFeaturesList (int *len,
  1068. const char **result);
  1069. XML_DEPRECATED
  1070. XMLPUBFUN int
  1071. xmlGetFeature (xmlParserCtxtPtr ctxt,
  1072. const char *name,
  1073. void *result);
  1074. XML_DEPRECATED
  1075. XMLPUBFUN int
  1076. xmlSetFeature (xmlParserCtxtPtr ctxt,
  1077. const char *name,
  1078. void *value);
  1079. #endif /* LIBXML_LEGACY_ENABLED */
  1080. #ifdef LIBXML_PUSH_ENABLED
  1081. /*
  1082. * Interfaces for the Push mode.
  1083. */
  1084. XMLPUBFUN xmlParserCtxtPtr
  1085. xmlCreatePushParserCtxt(xmlSAXHandlerPtr sax,
  1086. void *user_data,
  1087. const char *chunk,
  1088. int size,
  1089. const char *filename);
  1090. XMLPUBFUN int
  1091. xmlParseChunk (xmlParserCtxtPtr ctxt,
  1092. const char *chunk,
  1093. int size,
  1094. int terminate);
  1095. #endif /* LIBXML_PUSH_ENABLED */
  1096. /*
  1097. * Special I/O mode.
  1098. */
  1099. XMLPUBFUN xmlParserCtxtPtr
  1100. xmlCreateIOParserCtxt (xmlSAXHandlerPtr sax,
  1101. void *user_data,
  1102. xmlInputReadCallback ioread,
  1103. xmlInputCloseCallback ioclose,
  1104. void *ioctx,
  1105. xmlCharEncoding enc);
  1106. XMLPUBFUN xmlParserInputPtr
  1107. xmlNewIOInputStream (xmlParserCtxtPtr ctxt,
  1108. xmlParserInputBufferPtr input,
  1109. xmlCharEncoding enc);
  1110. /*
  1111. * Node infos.
  1112. */
  1113. XMLPUBFUN const xmlParserNodeInfo*
  1114. xmlParserFindNodeInfo (const xmlParserCtxtPtr ctxt,
  1115. const xmlNodePtr node);
  1116. XMLPUBFUN void
  1117. xmlInitNodeInfoSeq (xmlParserNodeInfoSeqPtr seq);
  1118. XMLPUBFUN void
  1119. xmlClearNodeInfoSeq (xmlParserNodeInfoSeqPtr seq);
  1120. XMLPUBFUN unsigned long
  1121. xmlParserFindNodeInfoIndex(const xmlParserNodeInfoSeqPtr seq,
  1122. const xmlNodePtr node);
  1123. XMLPUBFUN void
  1124. xmlParserAddNodeInfo (xmlParserCtxtPtr ctxt,
  1125. const xmlParserNodeInfoPtr info);
  1126. /*
  1127. * External entities handling actually implemented in xmlIO.
  1128. */
  1129. XMLPUBFUN void
  1130. xmlSetExternalEntityLoader(xmlExternalEntityLoader f);
  1131. XMLPUBFUN xmlExternalEntityLoader
  1132. xmlGetExternalEntityLoader(void);
  1133. XMLPUBFUN xmlParserInputPtr
  1134. xmlLoadExternalEntity (const char *URL,
  1135. const char *ID,
  1136. xmlParserCtxtPtr ctxt);
  1137. /*
  1138. * Index lookup, actually implemented in the encoding module
  1139. */
  1140. XMLPUBFUN long
  1141. xmlByteConsumed (xmlParserCtxtPtr ctxt);
  1142. /*
  1143. * New set of simpler/more flexible APIs
  1144. */
  1145. /**
  1146. * xmlParserOption:
  1147. *
  1148. * This is the set of XML parser options that can be passed down
  1149. * to the xmlReadDoc() and similar calls.
  1150. */
  1151. typedef enum {
  1152. XML_PARSE_RECOVER = 1<<0, /* recover on errors */
  1153. XML_PARSE_NOENT = 1<<1, /* substitute entities */
  1154. XML_PARSE_DTDLOAD = 1<<2, /* load the external subset */
  1155. XML_PARSE_DTDATTR = 1<<3, /* default DTD attributes */
  1156. XML_PARSE_DTDVALID = 1<<4, /* validate with the DTD */
  1157. XML_PARSE_NOERROR = 1<<5, /* suppress error reports */
  1158. XML_PARSE_NOWARNING = 1<<6, /* suppress warning reports */
  1159. XML_PARSE_PEDANTIC = 1<<7, /* pedantic error reporting */
  1160. XML_PARSE_NOBLANKS = 1<<8, /* remove blank nodes */
  1161. XML_PARSE_SAX1 = 1<<9, /* use the SAX1 interface internally */
  1162. XML_PARSE_XINCLUDE = 1<<10,/* Implement XInclude substitution */
  1163. XML_PARSE_NONET = 1<<11,/* Forbid network access */
  1164. XML_PARSE_NODICT = 1<<12,/* Do not reuse the context dictionary */
  1165. XML_PARSE_NSCLEAN = 1<<13,/* remove redundant namespaces declarations */
  1166. XML_PARSE_NOCDATA = 1<<14,/* merge CDATA as text nodes */
  1167. XML_PARSE_NOXINCNODE= 1<<15,/* do not generate XINCLUDE START/END nodes */
  1168. XML_PARSE_COMPACT = 1<<16,/* compact small text nodes; no modification of
  1169. the tree allowed afterwards (will possibly
  1170. crash if you try to modify the tree) */
  1171. XML_PARSE_OLD10 = 1<<17,/* parse using XML-1.0 before update 5 */
  1172. XML_PARSE_NOBASEFIX = 1<<18,/* do not fixup XINCLUDE xml:base uris */
  1173. XML_PARSE_HUGE = 1<<19,/* relax any hardcoded limit from the parser */
  1174. XML_PARSE_OLDSAX = 1<<20,/* parse using SAX2 interface before 2.7.0 */
  1175. XML_PARSE_IGNORE_ENC= 1<<21,/* ignore internal document encoding hint */
  1176. XML_PARSE_BIG_LINES = 1<<22 /* Store big lines numbers in text PSVI field */
  1177. } xmlParserOption;
  1178. XMLPUBFUN void
  1179. xmlCtxtReset (xmlParserCtxtPtr ctxt);
  1180. XMLPUBFUN int
  1181. xmlCtxtResetPush (xmlParserCtxtPtr ctxt,
  1182. const char *chunk,
  1183. int size,
  1184. const char *filename,
  1185. const char *encoding);
  1186. XMLPUBFUN int
  1187. xmlCtxtUseOptions (xmlParserCtxtPtr ctxt,
  1188. int options);
  1189. XMLPUBFUN void
  1190. xmlCtxtSetMaxAmplification(xmlParserCtxtPtr ctxt,
  1191. unsigned maxAmpl);
  1192. XMLPUBFUN xmlDocPtr
  1193. xmlReadDoc (const xmlChar *cur,
  1194. const char *URL,
  1195. const char *encoding,
  1196. int options);
  1197. XMLPUBFUN xmlDocPtr
  1198. xmlReadFile (const char *URL,
  1199. const char *encoding,
  1200. int options);
  1201. XMLPUBFUN xmlDocPtr
  1202. xmlReadMemory (const char *buffer,
  1203. int size,
  1204. const char *URL,
  1205. const char *encoding,
  1206. int options);
  1207. XMLPUBFUN xmlDocPtr
  1208. xmlReadFd (int fd,
  1209. const char *URL,
  1210. const char *encoding,
  1211. int options);
  1212. XMLPUBFUN xmlDocPtr
  1213. xmlReadIO (xmlInputReadCallback ioread,
  1214. xmlInputCloseCallback ioclose,
  1215. void *ioctx,
  1216. const char *URL,
  1217. const char *encoding,
  1218. int options);
  1219. XMLPUBFUN xmlDocPtr
  1220. xmlCtxtReadDoc (xmlParserCtxtPtr ctxt,
  1221. const xmlChar *cur,
  1222. const char *URL,
  1223. const char *encoding,
  1224. int options);
  1225. XMLPUBFUN xmlDocPtr
  1226. xmlCtxtReadFile (xmlParserCtxtPtr ctxt,
  1227. const char *filename,
  1228. const char *encoding,
  1229. int options);
  1230. XMLPUBFUN xmlDocPtr
  1231. xmlCtxtReadMemory (xmlParserCtxtPtr ctxt,
  1232. const char *buffer,
  1233. int size,
  1234. const char *URL,
  1235. const char *encoding,
  1236. int options);
  1237. XMLPUBFUN xmlDocPtr
  1238. xmlCtxtReadFd (xmlParserCtxtPtr ctxt,
  1239. int fd,
  1240. const char *URL,
  1241. const char *encoding,
  1242. int options);
  1243. XMLPUBFUN xmlDocPtr
  1244. xmlCtxtReadIO (xmlParserCtxtPtr ctxt,
  1245. xmlInputReadCallback ioread,
  1246. xmlInputCloseCallback ioclose,
  1247. void *ioctx,
  1248. const char *URL,
  1249. const char *encoding,
  1250. int options);
  1251. /*
  1252. * Library wide options
  1253. */
  1254. /**
  1255. * xmlFeature:
  1256. *
  1257. * Used to examine the existence of features that can be enabled
  1258. * or disabled at compile-time.
  1259. * They used to be called XML_FEATURE_xxx but this clashed with Expat
  1260. */
  1261. typedef enum {
  1262. XML_WITH_THREAD = 1,
  1263. XML_WITH_TREE = 2,
  1264. XML_WITH_OUTPUT = 3,
  1265. XML_WITH_PUSH = 4,
  1266. XML_WITH_READER = 5,
  1267. XML_WITH_PATTERN = 6,
  1268. XML_WITH_WRITER = 7,
  1269. XML_WITH_SAX1 = 8,
  1270. XML_WITH_FTP = 9,
  1271. XML_WITH_HTTP = 10,
  1272. XML_WITH_VALID = 11,
  1273. XML_WITH_HTML = 12,
  1274. XML_WITH_LEGACY = 13,
  1275. XML_WITH_C14N = 14,
  1276. XML_WITH_CATALOG = 15,
  1277. XML_WITH_XPATH = 16,
  1278. XML_WITH_XPTR = 17,
  1279. XML_WITH_XINCLUDE = 18,
  1280. XML_WITH_ICONV = 19,
  1281. XML_WITH_ISO8859X = 20,
  1282. XML_WITH_UNICODE = 21,
  1283. XML_WITH_REGEXP = 22,
  1284. XML_WITH_AUTOMATA = 23,
  1285. XML_WITH_EXPR = 24,
  1286. XML_WITH_SCHEMAS = 25,
  1287. XML_WITH_SCHEMATRON = 26,
  1288. XML_WITH_MODULES = 27,
  1289. XML_WITH_DEBUG = 28,
  1290. XML_WITH_DEBUG_MEM = 29,
  1291. XML_WITH_DEBUG_RUN = 30,
  1292. XML_WITH_ZLIB = 31,
  1293. XML_WITH_ICU = 32,
  1294. XML_WITH_LZMA = 33,
  1295. XML_WITH_NONE = 99999 /* just to be sure of allocation size */
  1296. } xmlFeature;
  1297. XMLPUBFUN int
  1298. xmlHasFeature (xmlFeature feature);
  1299. #ifdef __cplusplus
  1300. }
  1301. #endif
  1302. #endif /* __XML_PARSER_H__ */