xmlreader.h 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425
  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. xmlTextReaderRelaxNGSetSchema(xmlTextReaderPtr reader,
  265. xmlRelaxNGPtr schema);
  266. XMLPUBFUN int XMLCALL
  267. xmlTextReaderSchemaValidate (xmlTextReaderPtr reader,
  268. const char *xsd);
  269. XMLPUBFUN int XMLCALL
  270. xmlTextReaderSchemaValidateCtxt(xmlTextReaderPtr reader,
  271. xmlSchemaValidCtxtPtr ctxt,
  272. int options);
  273. XMLPUBFUN int XMLCALL
  274. xmlTextReaderSetSchema (xmlTextReaderPtr reader,
  275. xmlSchemaPtr schema);
  276. #endif
  277. XMLPUBFUN const xmlChar * XMLCALL
  278. xmlTextReaderConstXmlVersion(xmlTextReaderPtr reader);
  279. XMLPUBFUN int XMLCALL
  280. xmlTextReaderStandalone (xmlTextReaderPtr reader);
  281. /*
  282. * Index lookup
  283. */
  284. XMLPUBFUN long XMLCALL
  285. xmlTextReaderByteConsumed (xmlTextReaderPtr reader);
  286. /*
  287. * New more complete APIs for simpler creation and reuse of readers
  288. */
  289. XMLPUBFUN xmlTextReaderPtr XMLCALL
  290. xmlReaderWalker (xmlDocPtr doc);
  291. XMLPUBFUN xmlTextReaderPtr XMLCALL
  292. xmlReaderForDoc (const xmlChar * cur,
  293. const char *URL,
  294. const char *encoding,
  295. int options);
  296. XMLPUBFUN xmlTextReaderPtr XMLCALL
  297. xmlReaderForFile (const char *filename,
  298. const char *encoding,
  299. int options);
  300. XMLPUBFUN xmlTextReaderPtr XMLCALL
  301. xmlReaderForMemory (const char *buffer,
  302. int size,
  303. const char *URL,
  304. const char *encoding,
  305. int options);
  306. XMLPUBFUN xmlTextReaderPtr XMLCALL
  307. xmlReaderForFd (int fd,
  308. const char *URL,
  309. const char *encoding,
  310. int options);
  311. XMLPUBFUN xmlTextReaderPtr XMLCALL
  312. xmlReaderForIO (xmlInputReadCallback ioread,
  313. xmlInputCloseCallback ioclose,
  314. void *ioctx,
  315. const char *URL,
  316. const char *encoding,
  317. int options);
  318. XMLPUBFUN int XMLCALL
  319. xmlReaderNewWalker (xmlTextReaderPtr reader,
  320. xmlDocPtr doc);
  321. XMLPUBFUN int XMLCALL
  322. xmlReaderNewDoc (xmlTextReaderPtr reader,
  323. const xmlChar * cur,
  324. const char *URL,
  325. const char *encoding,
  326. int options);
  327. XMLPUBFUN int XMLCALL
  328. xmlReaderNewFile (xmlTextReaderPtr reader,
  329. const char *filename,
  330. const char *encoding,
  331. int options);
  332. XMLPUBFUN int XMLCALL
  333. xmlReaderNewMemory (xmlTextReaderPtr reader,
  334. const char *buffer,
  335. int size,
  336. const char *URL,
  337. const char *encoding,
  338. int options);
  339. XMLPUBFUN int XMLCALL
  340. xmlReaderNewFd (xmlTextReaderPtr reader,
  341. int fd,
  342. const char *URL,
  343. const char *encoding,
  344. int options);
  345. XMLPUBFUN int XMLCALL
  346. xmlReaderNewIO (xmlTextReaderPtr reader,
  347. xmlInputReadCallback ioread,
  348. xmlInputCloseCallback ioclose,
  349. void *ioctx,
  350. const char *URL,
  351. const char *encoding,
  352. int options);
  353. /*
  354. * Error handling extensions
  355. */
  356. typedef void * xmlTextReaderLocatorPtr;
  357. /**
  358. * xmlTextReaderErrorFunc:
  359. * @arg: the user argument
  360. * @msg: the message
  361. * @severity: the severity of the error
  362. * @locator: a locator indicating where the error occured
  363. *
  364. * Signature of an error callback from a reader parser
  365. */
  366. typedef void (XMLCALL *xmlTextReaderErrorFunc)(void *arg,
  367. const char *msg,
  368. xmlParserSeverities severity,
  369. xmlTextReaderLocatorPtr locator);
  370. XMLPUBFUN int XMLCALL
  371. xmlTextReaderLocatorLineNumber(xmlTextReaderLocatorPtr locator);
  372. /*int xmlTextReaderLocatorLinePosition(xmlTextReaderLocatorPtr locator);*/
  373. XMLPUBFUN xmlChar * XMLCALL
  374. xmlTextReaderLocatorBaseURI (xmlTextReaderLocatorPtr locator);
  375. XMLPUBFUN void XMLCALL
  376. xmlTextReaderSetErrorHandler(xmlTextReaderPtr reader,
  377. xmlTextReaderErrorFunc f,
  378. void *arg);
  379. XMLPUBFUN void XMLCALL
  380. xmlTextReaderSetStructuredErrorHandler(xmlTextReaderPtr reader,
  381. xmlStructuredErrorFunc f,
  382. void *arg);
  383. XMLPUBFUN void XMLCALL
  384. xmlTextReaderGetErrorHandler(xmlTextReaderPtr reader,
  385. xmlTextReaderErrorFunc *f,
  386. void **arg);
  387. #endif /* LIBXML_READER_ENABLED */
  388. #ifdef __cplusplus
  389. }
  390. #endif
  391. #endif /* __XML_XMLREADER_H__ */