xmlreader.h 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429
  1. /*
  2. * Summary: the XMLReader implementation
  3. * Description: API of the XML streaming API based on C# interfaces.
  4. *
  5. * Copy: See Copyright for the status of this software.
  6. *
  7. * Author: Daniel Veillard
  8. */
  9. #ifndef __XML_XMLREADER_H__
  10. #define __XML_XMLREADER_H__
  11. #include <libxml/xmlversion.h>
  12. #include <libxml/tree.h>
  13. #include <libxml/xmlIO.h>
  14. #ifdef LIBXML_SCHEMAS_ENABLED
  15. #include <libxml/relaxng.h>
  16. #include <libxml/xmlschemas.h>
  17. #endif
  18. #ifdef __cplusplus
  19. extern "C" {
  20. #endif
  21. /**
  22. * xmlParserSeverities:
  23. *
  24. * How severe an error callback is when the per-reader error callback API
  25. * is used.
  26. */
  27. typedef enum {
  28. XML_PARSER_SEVERITY_VALIDITY_WARNING = 1,
  29. XML_PARSER_SEVERITY_VALIDITY_ERROR = 2,
  30. XML_PARSER_SEVERITY_WARNING = 3,
  31. XML_PARSER_SEVERITY_ERROR = 4
  32. }
  33. xmlParserSeverities;
  34. #ifdef LIBXML_READER_ENABLED
  35. /**
  36. * xmlTextReaderMode:
  37. *
  38. * Internal state values for the reader.
  39. */
  40. typedef enum {
  41. XML_TEXTREADER_MODE_INITIAL = 0,
  42. XML_TEXTREADER_MODE_INTERACTIVE = 1,
  43. XML_TEXTREADER_MODE_ERROR = 2,
  44. XML_TEXTREADER_MODE_EOF =3,
  45. XML_TEXTREADER_MODE_CLOSED = 4,
  46. XML_TEXTREADER_MODE_READING = 5
  47. } xmlTextReaderMode;
  48. /**
  49. * xmlParserProperties:
  50. *
  51. * Some common options to use with xmlTextReaderSetParserProp, but it
  52. * is better to use xmlParserOption and the xmlReaderNewxxx and
  53. * xmlReaderForxxx APIs now.
  54. */
  55. typedef enum {
  56. XML_PARSER_LOADDTD = 1,
  57. XML_PARSER_DEFAULTATTRS = 2,
  58. XML_PARSER_VALIDATE = 3,
  59. XML_PARSER_SUBST_ENTITIES = 4
  60. } xmlParserProperties;
  61. /**
  62. * xmlReaderTypes:
  63. *
  64. * Predefined constants for the different types of nodes.
  65. */
  66. typedef enum {
  67. XML_READER_TYPE_NONE = 0,
  68. XML_READER_TYPE_ELEMENT = 1,
  69. XML_READER_TYPE_ATTRIBUTE = 2,
  70. XML_READER_TYPE_TEXT = 3,
  71. XML_READER_TYPE_CDATA = 4,
  72. XML_READER_TYPE_ENTITY_REFERENCE = 5,
  73. XML_READER_TYPE_ENTITY = 6,
  74. XML_READER_TYPE_PROCESSING_INSTRUCTION = 7,
  75. XML_READER_TYPE_COMMENT = 8,
  76. XML_READER_TYPE_DOCUMENT = 9,
  77. XML_READER_TYPE_DOCUMENT_TYPE = 10,
  78. XML_READER_TYPE_DOCUMENT_FRAGMENT = 11,
  79. XML_READER_TYPE_NOTATION = 12,
  80. XML_READER_TYPE_WHITESPACE = 13,
  81. XML_READER_TYPE_SIGNIFICANT_WHITESPACE = 14,
  82. XML_READER_TYPE_END_ELEMENT = 15,
  83. XML_READER_TYPE_END_ENTITY = 16,
  84. XML_READER_TYPE_XML_DECLARATION = 17
  85. } xmlReaderTypes;
  86. /**
  87. * xmlTextReader:
  88. *
  89. * Structure for an xmlReader context.
  90. */
  91. typedef struct _xmlTextReader xmlTextReader;
  92. /**
  93. * xmlTextReaderPtr:
  94. *
  95. * Pointer to an xmlReader context.
  96. */
  97. typedef xmlTextReader *xmlTextReaderPtr;
  98. /*
  99. * Constructors & Destructor
  100. */
  101. XMLPUBFUN xmlTextReaderPtr XMLCALL
  102. xmlNewTextReader (xmlParserInputBufferPtr input,
  103. const char *URI);
  104. XMLPUBFUN xmlTextReaderPtr XMLCALL
  105. xmlNewTextReaderFilename(const char *URI);
  106. XMLPUBFUN void XMLCALL
  107. xmlFreeTextReader (xmlTextReaderPtr reader);
  108. XMLPUBFUN int XMLCALL
  109. xmlTextReaderSetup(xmlTextReaderPtr reader,
  110. xmlParserInputBufferPtr input, const char *URL,
  111. const char *encoding, int options);
  112. /*
  113. * Iterators
  114. */
  115. XMLPUBFUN int XMLCALL
  116. xmlTextReaderRead (xmlTextReaderPtr reader);
  117. #ifdef LIBXML_WRITER_ENABLED
  118. XMLPUBFUN xmlChar * XMLCALL
  119. xmlTextReaderReadInnerXml(xmlTextReaderPtr reader);
  120. XMLPUBFUN xmlChar * XMLCALL
  121. xmlTextReaderReadOuterXml(xmlTextReaderPtr reader);
  122. #endif
  123. XMLPUBFUN xmlChar * XMLCALL
  124. xmlTextReaderReadString (xmlTextReaderPtr reader);
  125. XMLPUBFUN int XMLCALL
  126. xmlTextReaderReadAttributeValue(xmlTextReaderPtr reader);
  127. /*
  128. * Attributes of the node
  129. */
  130. XMLPUBFUN int XMLCALL
  131. xmlTextReaderAttributeCount(xmlTextReaderPtr reader);
  132. XMLPUBFUN int XMLCALL
  133. xmlTextReaderDepth (xmlTextReaderPtr reader);
  134. XMLPUBFUN int XMLCALL
  135. xmlTextReaderHasAttributes(xmlTextReaderPtr reader);
  136. XMLPUBFUN int XMLCALL
  137. xmlTextReaderHasValue(xmlTextReaderPtr reader);
  138. XMLPUBFUN int XMLCALL
  139. xmlTextReaderIsDefault (xmlTextReaderPtr reader);
  140. XMLPUBFUN int XMLCALL
  141. xmlTextReaderIsEmptyElement(xmlTextReaderPtr reader);
  142. XMLPUBFUN int XMLCALL
  143. xmlTextReaderNodeType (xmlTextReaderPtr reader);
  144. XMLPUBFUN int XMLCALL
  145. xmlTextReaderQuoteChar (xmlTextReaderPtr reader);
  146. XMLPUBFUN int XMLCALL
  147. xmlTextReaderReadState (xmlTextReaderPtr reader);
  148. XMLPUBFUN int XMLCALL
  149. xmlTextReaderIsNamespaceDecl(xmlTextReaderPtr reader);
  150. XMLPUBFUN const xmlChar * XMLCALL
  151. xmlTextReaderConstBaseUri (xmlTextReaderPtr reader);
  152. XMLPUBFUN const xmlChar * XMLCALL
  153. xmlTextReaderConstLocalName (xmlTextReaderPtr reader);
  154. XMLPUBFUN const xmlChar * XMLCALL
  155. xmlTextReaderConstName (xmlTextReaderPtr reader);
  156. XMLPUBFUN const xmlChar * XMLCALL
  157. xmlTextReaderConstNamespaceUri(xmlTextReaderPtr reader);
  158. XMLPUBFUN const xmlChar * XMLCALL
  159. xmlTextReaderConstPrefix (xmlTextReaderPtr reader);
  160. XMLPUBFUN const xmlChar * XMLCALL
  161. xmlTextReaderConstXmlLang (xmlTextReaderPtr reader);
  162. XMLPUBFUN const xmlChar * XMLCALL
  163. xmlTextReaderConstString (xmlTextReaderPtr reader,
  164. const xmlChar *str);
  165. XMLPUBFUN const xmlChar * XMLCALL
  166. xmlTextReaderConstValue (xmlTextReaderPtr reader);
  167. /*
  168. * use the Const version of the routine for
  169. * better performance and simpler code
  170. */
  171. XMLPUBFUN xmlChar * XMLCALL
  172. xmlTextReaderBaseUri (xmlTextReaderPtr reader);
  173. XMLPUBFUN xmlChar * XMLCALL
  174. xmlTextReaderLocalName (xmlTextReaderPtr reader);
  175. XMLPUBFUN xmlChar * XMLCALL
  176. xmlTextReaderName (xmlTextReaderPtr reader);
  177. XMLPUBFUN xmlChar * XMLCALL
  178. xmlTextReaderNamespaceUri(xmlTextReaderPtr reader);
  179. XMLPUBFUN xmlChar * XMLCALL
  180. xmlTextReaderPrefix (xmlTextReaderPtr reader);
  181. XMLPUBFUN xmlChar * XMLCALL
  182. xmlTextReaderXmlLang (xmlTextReaderPtr reader);
  183. XMLPUBFUN xmlChar * XMLCALL
  184. xmlTextReaderValue (xmlTextReaderPtr reader);
  185. /*
  186. * Methods of the XmlTextReader
  187. */
  188. XMLPUBFUN int XMLCALL
  189. xmlTextReaderClose (xmlTextReaderPtr reader);
  190. XMLPUBFUN xmlChar * XMLCALL
  191. xmlTextReaderGetAttributeNo (xmlTextReaderPtr reader,
  192. int no);
  193. XMLPUBFUN xmlChar * XMLCALL
  194. xmlTextReaderGetAttribute (xmlTextReaderPtr reader,
  195. const xmlChar *name);
  196. XMLPUBFUN xmlChar * XMLCALL
  197. xmlTextReaderGetAttributeNs (xmlTextReaderPtr reader,
  198. const xmlChar *localName,
  199. const xmlChar *namespaceURI);
  200. XMLPUBFUN xmlParserInputBufferPtr XMLCALL
  201. xmlTextReaderGetRemainder (xmlTextReaderPtr reader);
  202. XMLPUBFUN xmlChar * XMLCALL
  203. xmlTextReaderLookupNamespace(xmlTextReaderPtr reader,
  204. const xmlChar *prefix);
  205. XMLPUBFUN int XMLCALL
  206. xmlTextReaderMoveToAttributeNo(xmlTextReaderPtr reader,
  207. int no);
  208. XMLPUBFUN int XMLCALL
  209. xmlTextReaderMoveToAttribute(xmlTextReaderPtr reader,
  210. const xmlChar *name);
  211. XMLPUBFUN int XMLCALL
  212. xmlTextReaderMoveToAttributeNs(xmlTextReaderPtr reader,
  213. const xmlChar *localName,
  214. const xmlChar *namespaceURI);
  215. XMLPUBFUN int XMLCALL
  216. xmlTextReaderMoveToFirstAttribute(xmlTextReaderPtr reader);
  217. XMLPUBFUN int XMLCALL
  218. xmlTextReaderMoveToNextAttribute(xmlTextReaderPtr reader);
  219. XMLPUBFUN int XMLCALL
  220. xmlTextReaderMoveToElement (xmlTextReaderPtr reader);
  221. XMLPUBFUN int XMLCALL
  222. xmlTextReaderNormalization (xmlTextReaderPtr reader);
  223. XMLPUBFUN const xmlChar * XMLCALL
  224. xmlTextReaderConstEncoding (xmlTextReaderPtr reader);
  225. /*
  226. * Extensions
  227. */
  228. XMLPUBFUN int XMLCALL
  229. xmlTextReaderSetParserProp (xmlTextReaderPtr reader,
  230. int prop,
  231. int value);
  232. XMLPUBFUN int XMLCALL
  233. xmlTextReaderGetParserProp (xmlTextReaderPtr reader,
  234. int prop);
  235. XMLPUBFUN xmlNodePtr XMLCALL
  236. xmlTextReaderCurrentNode (xmlTextReaderPtr reader);
  237. XMLPUBFUN int XMLCALL
  238. xmlTextReaderGetParserLineNumber(xmlTextReaderPtr reader);
  239. XMLPUBFUN int XMLCALL
  240. xmlTextReaderGetParserColumnNumber(xmlTextReaderPtr reader);
  241. XMLPUBFUN xmlNodePtr XMLCALL
  242. xmlTextReaderPreserve (xmlTextReaderPtr reader);
  243. #ifdef LIBXML_PATTERN_ENABLED
  244. XMLPUBFUN int XMLCALL
  245. xmlTextReaderPreservePattern(xmlTextReaderPtr reader,
  246. const xmlChar *pattern,
  247. const xmlChar **namespaces);
  248. #endif /* LIBXML_PATTERN_ENABLED */
  249. XMLPUBFUN xmlDocPtr XMLCALL
  250. xmlTextReaderCurrentDoc (xmlTextReaderPtr reader);
  251. XMLPUBFUN xmlNodePtr XMLCALL
  252. xmlTextReaderExpand (xmlTextReaderPtr reader);
  253. XMLPUBFUN int XMLCALL
  254. xmlTextReaderNext (xmlTextReaderPtr reader);
  255. XMLPUBFUN int XMLCALL
  256. xmlTextReaderNextSibling (xmlTextReaderPtr reader);
  257. XMLPUBFUN int XMLCALL
  258. xmlTextReaderIsValid (xmlTextReaderPtr reader);
  259. #ifdef LIBXML_SCHEMAS_ENABLED
  260. XMLPUBFUN int XMLCALL
  261. xmlTextReaderRelaxNGValidate(xmlTextReaderPtr reader,
  262. const char *rng);
  263. XMLPUBFUN int XMLCALL
  264. xmlTextReaderRelaxNGValidateCtxt(xmlTextReaderPtr reader,
  265. xmlRelaxNGValidCtxtPtr ctxt,
  266. int options);
  267. XMLPUBFUN int XMLCALL
  268. xmlTextReaderRelaxNGSetSchema(xmlTextReaderPtr reader,
  269. xmlRelaxNGPtr schema);
  270. XMLPUBFUN int XMLCALL
  271. xmlTextReaderSchemaValidate (xmlTextReaderPtr reader,
  272. const char *xsd);
  273. XMLPUBFUN int XMLCALL
  274. xmlTextReaderSchemaValidateCtxt(xmlTextReaderPtr reader,
  275. xmlSchemaValidCtxtPtr ctxt,
  276. int options);
  277. XMLPUBFUN int XMLCALL
  278. xmlTextReaderSetSchema (xmlTextReaderPtr reader,
  279. xmlSchemaPtr schema);
  280. #endif
  281. XMLPUBFUN const xmlChar * XMLCALL
  282. xmlTextReaderConstXmlVersion(xmlTextReaderPtr reader);
  283. XMLPUBFUN int XMLCALL
  284. xmlTextReaderStandalone (xmlTextReaderPtr reader);
  285. /*
  286. * Index lookup
  287. */
  288. XMLPUBFUN long XMLCALL
  289. xmlTextReaderByteConsumed (xmlTextReaderPtr reader);
  290. /*
  291. * New more complete APIs for simpler creation and reuse of readers
  292. */
  293. XMLPUBFUN xmlTextReaderPtr XMLCALL
  294. xmlReaderWalker (xmlDocPtr doc);
  295. XMLPUBFUN xmlTextReaderPtr XMLCALL
  296. xmlReaderForDoc (const xmlChar * cur,
  297. const char *URL,
  298. const char *encoding,
  299. int options);
  300. XMLPUBFUN xmlTextReaderPtr XMLCALL
  301. xmlReaderForFile (const char *filename,
  302. const char *encoding,
  303. int options);
  304. XMLPUBFUN xmlTextReaderPtr XMLCALL
  305. xmlReaderForMemory (const char *buffer,
  306. int size,
  307. const char *URL,
  308. const char *encoding,
  309. int options);
  310. XMLPUBFUN xmlTextReaderPtr XMLCALL
  311. xmlReaderForFd (int fd,
  312. const char *URL,
  313. const char *encoding,
  314. int options);
  315. XMLPUBFUN xmlTextReaderPtr XMLCALL
  316. xmlReaderForIO (xmlInputReadCallback ioread,
  317. xmlInputCloseCallback ioclose,
  318. void *ioctx,
  319. const char *URL,
  320. const char *encoding,
  321. int options);
  322. XMLPUBFUN int XMLCALL
  323. xmlReaderNewWalker (xmlTextReaderPtr reader,
  324. xmlDocPtr doc);
  325. XMLPUBFUN int XMLCALL
  326. xmlReaderNewDoc (xmlTextReaderPtr reader,
  327. const xmlChar * cur,
  328. const char *URL,
  329. const char *encoding,
  330. int options);
  331. XMLPUBFUN int XMLCALL
  332. xmlReaderNewFile (xmlTextReaderPtr reader,
  333. const char *filename,
  334. const char *encoding,
  335. int options);
  336. XMLPUBFUN int XMLCALL
  337. xmlReaderNewMemory (xmlTextReaderPtr reader,
  338. const char *buffer,
  339. int size,
  340. const char *URL,
  341. const char *encoding,
  342. int options);
  343. XMLPUBFUN int XMLCALL
  344. xmlReaderNewFd (xmlTextReaderPtr reader,
  345. int fd,
  346. const char *URL,
  347. const char *encoding,
  348. int options);
  349. XMLPUBFUN int XMLCALL
  350. xmlReaderNewIO (xmlTextReaderPtr reader,
  351. xmlInputReadCallback ioread,
  352. xmlInputCloseCallback ioclose,
  353. void *ioctx,
  354. const char *URL,
  355. const char *encoding,
  356. int options);
  357. /*
  358. * Error handling extensions
  359. */
  360. typedef void * xmlTextReaderLocatorPtr;
  361. /**
  362. * xmlTextReaderErrorFunc:
  363. * @arg: the user argument
  364. * @msg: the message
  365. * @severity: the severity of the error
  366. * @locator: a locator indicating where the error occured
  367. *
  368. * Signature of an error callback from a reader parser
  369. */
  370. typedef void (XMLCALL *xmlTextReaderErrorFunc)(void *arg,
  371. const char *msg,
  372. xmlParserSeverities severity,
  373. xmlTextReaderLocatorPtr locator);
  374. XMLPUBFUN int XMLCALL
  375. xmlTextReaderLocatorLineNumber(xmlTextReaderLocatorPtr locator);
  376. XMLPUBFUN xmlChar * XMLCALL
  377. xmlTextReaderLocatorBaseURI (xmlTextReaderLocatorPtr locator);
  378. XMLPUBFUN void XMLCALL
  379. xmlTextReaderSetErrorHandler(xmlTextReaderPtr reader,
  380. xmlTextReaderErrorFunc f,
  381. void *arg);
  382. XMLPUBFUN void XMLCALL
  383. xmlTextReaderSetStructuredErrorHandler(xmlTextReaderPtr reader,
  384. xmlStructuredErrorFunc f,
  385. void *arg);
  386. XMLPUBFUN void XMLCALL
  387. xmlTextReaderGetErrorHandler(xmlTextReaderPtr reader,
  388. xmlTextReaderErrorFunc *f,
  389. void **arg);
  390. #endif /* LIBXML_READER_ENABLED */
  391. #ifdef __cplusplus
  392. }
  393. #endif
  394. #endif /* __XML_XMLREADER_H__ */