parser.h 38 KB

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