parser.h 43 KB

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