You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

488 lines
21 KiB

4 years ago
  1. /*
  2. * Summary: text writing API for XML
  3. * Description: text writing API for XML
  4. *
  5. * Copy: See Copyright for the status of this software.
  6. *
  7. * Author: Alfred Mickautsch <alfred@mickautsch.de>
  8. */
  9. #ifndef __XML_XMLWRITER_H__
  10. #define __XML_XMLWRITER_H__
  11. #include <libxml/xmlversion.h>
  12. #ifdef LIBXML_WRITER_ENABLED
  13. #include <stdarg.h>
  14. #include <libxml/xmlIO.h>
  15. #include <libxml/list.h>
  16. #include <libxml/xmlstring.h>
  17. #ifdef __cplusplus
  18. extern "C" {
  19. #endif
  20. typedef struct _xmlTextWriter xmlTextWriter;
  21. typedef xmlTextWriter *xmlTextWriterPtr;
  22. /*
  23. * Constructors & Destructor
  24. */
  25. XMLPUBFUN xmlTextWriterPtr XMLCALL
  26. xmlNewTextWriter(xmlOutputBufferPtr out);
  27. XMLPUBFUN xmlTextWriterPtr XMLCALL
  28. xmlNewTextWriterFilename(const char *uri, int compression);
  29. XMLPUBFUN xmlTextWriterPtr XMLCALL
  30. xmlNewTextWriterMemory(xmlBufferPtr buf, int compression);
  31. XMLPUBFUN xmlTextWriterPtr XMLCALL
  32. xmlNewTextWriterPushParser(xmlParserCtxtPtr ctxt, int compression);
  33. XMLPUBFUN xmlTextWriterPtr XMLCALL
  34. xmlNewTextWriterDoc(xmlDocPtr * doc, int compression);
  35. XMLPUBFUN xmlTextWriterPtr XMLCALL
  36. xmlNewTextWriterTree(xmlDocPtr doc, xmlNodePtr node,
  37. int compression);
  38. XMLPUBFUN void XMLCALL xmlFreeTextWriter(xmlTextWriterPtr writer);
  39. /*
  40. * Functions
  41. */
  42. /*
  43. * Document
  44. */
  45. XMLPUBFUN int XMLCALL
  46. xmlTextWriterStartDocument(xmlTextWriterPtr writer,
  47. const char *version,
  48. const char *encoding,
  49. const char *standalone);
  50. XMLPUBFUN int XMLCALL xmlTextWriterEndDocument(xmlTextWriterPtr
  51. writer);
  52. /*
  53. * Comments
  54. */
  55. XMLPUBFUN int XMLCALL xmlTextWriterStartComment(xmlTextWriterPtr
  56. writer);
  57. XMLPUBFUN int XMLCALL xmlTextWriterEndComment(xmlTextWriterPtr writer);
  58. XMLPUBFUN int XMLCALL
  59. xmlTextWriterWriteFormatComment(xmlTextWriterPtr writer,
  60. const char *format, ...)
  61. LIBXML_ATTR_FORMAT(2,3);
  62. XMLPUBFUN int XMLCALL
  63. xmlTextWriterWriteVFormatComment(xmlTextWriterPtr writer,
  64. const char *format,
  65. va_list argptr)
  66. LIBXML_ATTR_FORMAT(2,0);
  67. XMLPUBFUN int XMLCALL xmlTextWriterWriteComment(xmlTextWriterPtr
  68. writer,
  69. const xmlChar *
  70. content);
  71. /*
  72. * Elements
  73. */
  74. XMLPUBFUN int XMLCALL
  75. xmlTextWriterStartElement(xmlTextWriterPtr writer,
  76. const xmlChar * name);
  77. XMLPUBFUN int XMLCALL xmlTextWriterStartElementNS(xmlTextWriterPtr
  78. writer,
  79. const xmlChar *
  80. prefix,
  81. const xmlChar * name,
  82. const xmlChar *
  83. namespaceURI);
  84. XMLPUBFUN int XMLCALL xmlTextWriterEndElement(xmlTextWriterPtr writer);
  85. XMLPUBFUN int XMLCALL xmlTextWriterFullEndElement(xmlTextWriterPtr
  86. writer);
  87. /*
  88. * Elements conveniency functions
  89. */
  90. XMLPUBFUN int XMLCALL
  91. xmlTextWriterWriteFormatElement(xmlTextWriterPtr writer,
  92. const xmlChar * name,
  93. const char *format, ...)
  94. LIBXML_ATTR_FORMAT(3,4);
  95. XMLPUBFUN int XMLCALL
  96. xmlTextWriterWriteVFormatElement(xmlTextWriterPtr writer,
  97. const xmlChar * name,
  98. const char *format,
  99. va_list argptr)
  100. LIBXML_ATTR_FORMAT(3,0);
  101. XMLPUBFUN int XMLCALL xmlTextWriterWriteElement(xmlTextWriterPtr
  102. writer,
  103. const xmlChar * name,
  104. const xmlChar *
  105. content);
  106. XMLPUBFUN int XMLCALL
  107. xmlTextWriterWriteFormatElementNS(xmlTextWriterPtr writer,
  108. const xmlChar * prefix,
  109. const xmlChar * name,
  110. const xmlChar * namespaceURI,
  111. const char *format, ...)
  112. LIBXML_ATTR_FORMAT(5,6);
  113. XMLPUBFUN int XMLCALL
  114. xmlTextWriterWriteVFormatElementNS(xmlTextWriterPtr writer,
  115. const xmlChar * prefix,
  116. const xmlChar * name,
  117. const xmlChar * namespaceURI,
  118. const char *format,
  119. va_list argptr)
  120. LIBXML_ATTR_FORMAT(5,0);
  121. XMLPUBFUN int XMLCALL xmlTextWriterWriteElementNS(xmlTextWriterPtr
  122. writer,
  123. const xmlChar *
  124. prefix,
  125. const xmlChar * name,
  126. const xmlChar *
  127. namespaceURI,
  128. const xmlChar *
  129. content);
  130. /*
  131. * Text
  132. */
  133. XMLPUBFUN int XMLCALL
  134. xmlTextWriterWriteFormatRaw(xmlTextWriterPtr writer,
  135. const char *format, ...)
  136. LIBXML_ATTR_FORMAT(2,3);
  137. XMLPUBFUN int XMLCALL
  138. xmlTextWriterWriteVFormatRaw(xmlTextWriterPtr writer,
  139. const char *format, va_list argptr)
  140. LIBXML_ATTR_FORMAT(2,0);
  141. XMLPUBFUN int XMLCALL
  142. xmlTextWriterWriteRawLen(xmlTextWriterPtr writer,
  143. const xmlChar * content, int len);
  144. XMLPUBFUN int XMLCALL
  145. xmlTextWriterWriteRaw(xmlTextWriterPtr writer,
  146. const xmlChar * content);
  147. XMLPUBFUN int XMLCALL xmlTextWriterWriteFormatString(xmlTextWriterPtr
  148. writer,
  149. const char
  150. *format, ...)
  151. LIBXML_ATTR_FORMAT(2,3);
  152. XMLPUBFUN int XMLCALL xmlTextWriterWriteVFormatString(xmlTextWriterPtr
  153. writer,
  154. const char
  155. *format,
  156. va_list argptr)
  157. LIBXML_ATTR_FORMAT(2,0);
  158. XMLPUBFUN int XMLCALL xmlTextWriterWriteString(xmlTextWriterPtr writer,
  159. const xmlChar *
  160. content);
  161. XMLPUBFUN int XMLCALL xmlTextWriterWriteBase64(xmlTextWriterPtr writer,
  162. const char *data,
  163. int start, int len);
  164. XMLPUBFUN int XMLCALL xmlTextWriterWriteBinHex(xmlTextWriterPtr writer,
  165. const char *data,
  166. int start, int len);
  167. /*
  168. * Attributes
  169. */
  170. XMLPUBFUN int XMLCALL
  171. xmlTextWriterStartAttribute(xmlTextWriterPtr writer,
  172. const xmlChar * name);
  173. XMLPUBFUN int XMLCALL xmlTextWriterStartAttributeNS(xmlTextWriterPtr
  174. writer,
  175. const xmlChar *
  176. prefix,
  177. const xmlChar *
  178. name,
  179. const xmlChar *
  180. namespaceURI);
  181. XMLPUBFUN int XMLCALL xmlTextWriterEndAttribute(xmlTextWriterPtr
  182. writer);
  183. /*
  184. * Attributes conveniency functions
  185. */
  186. XMLPUBFUN int XMLCALL
  187. xmlTextWriterWriteFormatAttribute(xmlTextWriterPtr writer,
  188. const xmlChar * name,
  189. const char *format, ...)
  190. LIBXML_ATTR_FORMAT(3,4);
  191. XMLPUBFUN int XMLCALL
  192. xmlTextWriterWriteVFormatAttribute(xmlTextWriterPtr writer,
  193. const xmlChar * name,
  194. const char *format,
  195. va_list argptr)
  196. LIBXML_ATTR_FORMAT(3,0);
  197. XMLPUBFUN int XMLCALL xmlTextWriterWriteAttribute(xmlTextWriterPtr
  198. writer,
  199. const xmlChar * name,
  200. const xmlChar *
  201. content);
  202. XMLPUBFUN int XMLCALL
  203. xmlTextWriterWriteFormatAttributeNS(xmlTextWriterPtr writer,
  204. const xmlChar * prefix,
  205. const xmlChar * name,
  206. const xmlChar * namespaceURI,
  207. const char *format, ...)
  208. LIBXML_ATTR_FORMAT(5,6);
  209. XMLPUBFUN int XMLCALL
  210. xmlTextWriterWriteVFormatAttributeNS(xmlTextWriterPtr writer,
  211. const xmlChar * prefix,
  212. const xmlChar * name,
  213. const xmlChar * namespaceURI,
  214. const char *format,
  215. va_list argptr)
  216. LIBXML_ATTR_FORMAT(5,0);
  217. XMLPUBFUN int XMLCALL xmlTextWriterWriteAttributeNS(xmlTextWriterPtr
  218. writer,
  219. const xmlChar *
  220. prefix,
  221. const xmlChar *
  222. name,
  223. const xmlChar *
  224. namespaceURI,
  225. const xmlChar *
  226. content);
  227. /*
  228. * PI's
  229. */
  230. XMLPUBFUN int XMLCALL
  231. xmlTextWriterStartPI(xmlTextWriterPtr writer,
  232. const xmlChar * target);
  233. XMLPUBFUN int XMLCALL xmlTextWriterEndPI(xmlTextWriterPtr writer);
  234. /*
  235. * PI conveniency functions
  236. */
  237. XMLPUBFUN int XMLCALL
  238. xmlTextWriterWriteFormatPI(xmlTextWriterPtr writer,
  239. const xmlChar * target,
  240. const char *format, ...)
  241. LIBXML_ATTR_FORMAT(3,4);
  242. XMLPUBFUN int XMLCALL
  243. xmlTextWriterWriteVFormatPI(xmlTextWriterPtr writer,
  244. const xmlChar * target,
  245. const char *format, va_list argptr)
  246. LIBXML_ATTR_FORMAT(3,0);
  247. XMLPUBFUN int XMLCALL
  248. xmlTextWriterWritePI(xmlTextWriterPtr writer,
  249. const xmlChar * target,
  250. const xmlChar * content);
  251. /**
  252. * xmlTextWriterWriteProcessingInstruction:
  253. *
  254. * This macro maps to xmlTextWriterWritePI
  255. */
  256. #define xmlTextWriterWriteProcessingInstruction xmlTextWriterWritePI
  257. /*
  258. * CDATA
  259. */
  260. XMLPUBFUN int XMLCALL xmlTextWriterStartCDATA(xmlTextWriterPtr writer);
  261. XMLPUBFUN int XMLCALL xmlTextWriterEndCDATA(xmlTextWriterPtr writer);
  262. /*
  263. * CDATA conveniency functions
  264. */
  265. XMLPUBFUN int XMLCALL
  266. xmlTextWriterWriteFormatCDATA(xmlTextWriterPtr writer,
  267. const char *format, ...)
  268. LIBXML_ATTR_FORMAT(2,3);
  269. XMLPUBFUN int XMLCALL
  270. xmlTextWriterWriteVFormatCDATA(xmlTextWriterPtr writer,
  271. const char *format, va_list argptr)
  272. LIBXML_ATTR_FORMAT(2,0);
  273. XMLPUBFUN int XMLCALL
  274. xmlTextWriterWriteCDATA(xmlTextWriterPtr writer,
  275. const xmlChar * content);
  276. /*
  277. * DTD
  278. */
  279. XMLPUBFUN int XMLCALL
  280. xmlTextWriterStartDTD(xmlTextWriterPtr writer,
  281. const xmlChar * name,
  282. const xmlChar * pubid,
  283. const xmlChar * sysid);
  284. XMLPUBFUN int XMLCALL xmlTextWriterEndDTD(xmlTextWriterPtr writer);
  285. /*
  286. * DTD conveniency functions
  287. */
  288. XMLPUBFUN int XMLCALL
  289. xmlTextWriterWriteFormatDTD(xmlTextWriterPtr writer,
  290. const xmlChar * name,
  291. const xmlChar * pubid,
  292. const xmlChar * sysid,
  293. const char *format, ...)
  294. LIBXML_ATTR_FORMAT(5,6);
  295. XMLPUBFUN int XMLCALL
  296. xmlTextWriterWriteVFormatDTD(xmlTextWriterPtr writer,
  297. const xmlChar * name,
  298. const xmlChar * pubid,
  299. const xmlChar * sysid,
  300. const char *format, va_list argptr)
  301. LIBXML_ATTR_FORMAT(5,0);
  302. XMLPUBFUN int XMLCALL
  303. xmlTextWriterWriteDTD(xmlTextWriterPtr writer,
  304. const xmlChar * name,
  305. const xmlChar * pubid,
  306. const xmlChar * sysid,
  307. const xmlChar * subset);
  308. /**
  309. * xmlTextWriterWriteDocType:
  310. *
  311. * this macro maps to xmlTextWriterWriteDTD
  312. */
  313. #define xmlTextWriterWriteDocType xmlTextWriterWriteDTD
  314. /*
  315. * DTD element definition
  316. */
  317. XMLPUBFUN int XMLCALL
  318. xmlTextWriterStartDTDElement(xmlTextWriterPtr writer,
  319. const xmlChar * name);
  320. XMLPUBFUN int XMLCALL xmlTextWriterEndDTDElement(xmlTextWriterPtr
  321. writer);
  322. /*
  323. * DTD element definition conveniency functions
  324. */
  325. XMLPUBFUN int XMLCALL
  326. xmlTextWriterWriteFormatDTDElement(xmlTextWriterPtr writer,
  327. const xmlChar * name,
  328. const char *format, ...)
  329. LIBXML_ATTR_FORMAT(3,4);
  330. XMLPUBFUN int XMLCALL
  331. xmlTextWriterWriteVFormatDTDElement(xmlTextWriterPtr writer,
  332. const xmlChar * name,
  333. const char *format,
  334. va_list argptr)
  335. LIBXML_ATTR_FORMAT(3,0);
  336. XMLPUBFUN int XMLCALL xmlTextWriterWriteDTDElement(xmlTextWriterPtr
  337. writer,
  338. const xmlChar *
  339. name,
  340. const xmlChar *
  341. content);
  342. /*
  343. * DTD attribute list definition
  344. */
  345. XMLPUBFUN int XMLCALL
  346. xmlTextWriterStartDTDAttlist(xmlTextWriterPtr writer,
  347. const xmlChar * name);
  348. XMLPUBFUN int XMLCALL xmlTextWriterEndDTDAttlist(xmlTextWriterPtr
  349. writer);
  350. /*
  351. * DTD attribute list definition conveniency functions
  352. */
  353. XMLPUBFUN int XMLCALL
  354. xmlTextWriterWriteFormatDTDAttlist(xmlTextWriterPtr writer,
  355. const xmlChar * name,
  356. const char *format, ...)
  357. LIBXML_ATTR_FORMAT(3,4);
  358. XMLPUBFUN int XMLCALL
  359. xmlTextWriterWriteVFormatDTDAttlist(xmlTextWriterPtr writer,
  360. const xmlChar * name,
  361. const char *format,
  362. va_list argptr)
  363. LIBXML_ATTR_FORMAT(3,0);
  364. XMLPUBFUN int XMLCALL xmlTextWriterWriteDTDAttlist(xmlTextWriterPtr
  365. writer,
  366. const xmlChar *
  367. name,
  368. const xmlChar *
  369. content);
  370. /*
  371. * DTD entity definition
  372. */
  373. XMLPUBFUN int XMLCALL
  374. xmlTextWriterStartDTDEntity(xmlTextWriterPtr writer,
  375. int pe, const xmlChar * name);
  376. XMLPUBFUN int XMLCALL xmlTextWriterEndDTDEntity(xmlTextWriterPtr
  377. writer);
  378. /*
  379. * DTD entity definition conveniency functions
  380. */
  381. XMLPUBFUN int XMLCALL
  382. xmlTextWriterWriteFormatDTDInternalEntity(xmlTextWriterPtr writer,
  383. int pe,
  384. const xmlChar * name,
  385. const char *format, ...)
  386. LIBXML_ATTR_FORMAT(4,5);
  387. XMLPUBFUN int XMLCALL
  388. xmlTextWriterWriteVFormatDTDInternalEntity(xmlTextWriterPtr writer,
  389. int pe,
  390. const xmlChar * name,
  391. const char *format,
  392. va_list argptr)
  393. LIBXML_ATTR_FORMAT(4,0);
  394. XMLPUBFUN int XMLCALL
  395. xmlTextWriterWriteDTDInternalEntity(xmlTextWriterPtr writer,
  396. int pe,
  397. const xmlChar * name,
  398. const xmlChar * content);
  399. XMLPUBFUN int XMLCALL
  400. xmlTextWriterWriteDTDExternalEntity(xmlTextWriterPtr writer,
  401. int pe,
  402. const xmlChar * name,
  403. const xmlChar * pubid,
  404. const xmlChar * sysid,
  405. const xmlChar * ndataid);
  406. XMLPUBFUN int XMLCALL
  407. xmlTextWriterWriteDTDExternalEntityContents(xmlTextWriterPtr
  408. writer,
  409. const xmlChar * pubid,
  410. const xmlChar * sysid,
  411. const xmlChar *
  412. ndataid);
  413. XMLPUBFUN int XMLCALL xmlTextWriterWriteDTDEntity(xmlTextWriterPtr
  414. writer, int pe,
  415. const xmlChar * name,
  416. const xmlChar *
  417. pubid,
  418. const xmlChar *
  419. sysid,
  420. const xmlChar *
  421. ndataid,
  422. const xmlChar *
  423. content);
  424. /*
  425. * DTD notation definition
  426. */
  427. XMLPUBFUN int XMLCALL
  428. xmlTextWriterWriteDTDNotation(xmlTextWriterPtr writer,
  429. const xmlChar * name,
  430. const xmlChar * pubid,
  431. const xmlChar * sysid);
  432. /*
  433. * Indentation
  434. */
  435. XMLPUBFUN int XMLCALL
  436. xmlTextWriterSetIndent(xmlTextWriterPtr writer, int indent);
  437. XMLPUBFUN int XMLCALL
  438. xmlTextWriterSetIndentString(xmlTextWriterPtr writer,
  439. const xmlChar * str);
  440. XMLPUBFUN int XMLCALL
  441. xmlTextWriterSetQuoteChar(xmlTextWriterPtr writer, xmlChar quotechar);
  442. /*
  443. * misc
  444. */
  445. XMLPUBFUN int XMLCALL xmlTextWriterFlush(xmlTextWriterPtr writer);
  446. #ifdef __cplusplus
  447. }
  448. #endif
  449. #endif /* LIBXML_WRITER_ENABLED */
  450. #endif /* __XML_XMLWRITER_H__ */