xmlsave.h 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156
  1. /**
  2. * @file
  3. *
  4. * @brief XML/HTML serializer
  5. *
  6. * API to save documents or subtrees of documents.
  7. *
  8. * @copyright See Copyright for the status of this software.
  9. *
  10. * @author Daniel Veillard
  11. */
  12. #ifndef __XML_XMLSAVE_H__
  13. #define __XML_XMLSAVE_H__
  14. #include <libxml/xmlversion.h>
  15. #include <libxml/tree.h>
  16. #include <libxml/encoding.h>
  17. #include <libxml/xmlIO.h>
  18. #ifdef LIBXML_OUTPUT_ENABLED
  19. #ifdef __cplusplus
  20. extern "C" {
  21. #endif
  22. /**
  23. * This is the set of XML save options that can be passed down
  24. * to the #xmlSaveToFd and similar calls.
  25. */
  26. typedef enum {
  27. /**
  28. * Format output. This adds newlines and enables indenting
  29. * by default.
  30. */
  31. XML_SAVE_FORMAT = 1<<0,
  32. /**
  33. * Don't emit an XML declaration.
  34. */
  35. XML_SAVE_NO_DECL = 1<<1,
  36. /**
  37. * Don't emit empty tags.
  38. */
  39. XML_SAVE_NO_EMPTY = 1<<2,
  40. /**
  41. * Don't serialize as XHTML.
  42. */
  43. XML_SAVE_NO_XHTML = 1<<3,
  44. /**
  45. * Always serialize as XHTML.
  46. */
  47. XML_SAVE_XHTML = 1<<4,
  48. /**
  49. * Serialize HTML documents as XML.
  50. */
  51. XML_SAVE_AS_XML = 1<<5,
  52. /**
  53. * Serialize XML documents as HTML.
  54. */
  55. XML_SAVE_AS_HTML = 1<<6,
  56. /**
  57. * Format with non-significant whitespace.
  58. * TODO: What does this mean?
  59. */
  60. XML_SAVE_WSNONSIG = 1<<7,
  61. /**
  62. * Always emit empty tags. This is the default unless the
  63. * deprecated thread-local setting xmlSaveNoEmptyTags is
  64. * set to 1.
  65. *
  66. * @since 2.14
  67. */
  68. XML_SAVE_EMPTY = 1<<8,
  69. /**
  70. * Don't indent output when formatting.
  71. *
  72. * @since 2.14
  73. */
  74. XML_SAVE_NO_INDENT = 1<<9,
  75. /**
  76. * Always indent output when formatting. This is the default
  77. * unless the deprecated thread-local setting
  78. * xmlIndentTreeOutput is set to 0.
  79. *
  80. * @since 2.14
  81. */
  82. XML_SAVE_INDENT = 1<<10
  83. } xmlSaveOption;
  84. /** XML and HTML serializer */
  85. typedef struct _xmlSaveCtxt xmlSaveCtxt;
  86. typedef xmlSaveCtxt *xmlSaveCtxtPtr;
  87. XMLPUBFUN xmlSaveCtxt *
  88. xmlSaveToFd (int fd,
  89. const char *encoding,
  90. int options);
  91. XMLPUBFUN xmlSaveCtxt *
  92. xmlSaveToFilename (const char *filename,
  93. const char *encoding,
  94. int options);
  95. XMLPUBFUN xmlSaveCtxt *
  96. xmlSaveToBuffer (xmlBuffer *buffer,
  97. const char *encoding,
  98. int options);
  99. XMLPUBFUN xmlSaveCtxt *
  100. xmlSaveToIO (xmlOutputWriteCallback iowrite,
  101. xmlOutputCloseCallback ioclose,
  102. void *ioctx,
  103. const char *encoding,
  104. int options);
  105. XMLPUBFUN long
  106. xmlSaveDoc (xmlSaveCtxt *ctxt,
  107. xmlDoc *doc);
  108. XMLPUBFUN long
  109. xmlSaveTree (xmlSaveCtxt *ctxt,
  110. xmlNode *node);
  111. XMLPUBFUN int
  112. xmlSaveFlush (xmlSaveCtxt *ctxt);
  113. XMLPUBFUN int
  114. xmlSaveClose (xmlSaveCtxt *ctxt);
  115. XMLPUBFUN xmlParserErrors
  116. xmlSaveFinish (xmlSaveCtxt *ctxt);
  117. XMLPUBFUN int
  118. xmlSaveSetIndentString (xmlSaveCtxt *ctxt,
  119. const char *indent);
  120. XML_DEPRECATED
  121. XMLPUBFUN int
  122. xmlSaveSetEscape (xmlSaveCtxt *ctxt,
  123. xmlCharEncodingOutputFunc escape);
  124. XML_DEPRECATED
  125. XMLPUBFUN int
  126. xmlSaveSetAttrEscape (xmlSaveCtxt *ctxt,
  127. xmlCharEncodingOutputFunc escape);
  128. XML_DEPRECATED
  129. XMLPUBFUN int
  130. xmlThrDefIndentTreeOutput(int v);
  131. XML_DEPRECATED
  132. XMLPUBFUN const char *
  133. xmlThrDefTreeIndentString(const char * v);
  134. XML_DEPRECATED
  135. XMLPUBFUN int
  136. xmlThrDefSaveNoEmptyTags(int v);
  137. #ifdef __cplusplus
  138. }
  139. #endif
  140. #endif /* LIBXML_OUTPUT_ENABLED */
  141. #endif /* __XML_XMLSAVE_H__ */