1 /* 2 * Summary: the XML document serializer 3 * Description: API to save document or subtree of document 4 * 5 * Copy: See Copyright for the status of this software. 6 * 7 * Author: Daniel Veillard 8 */ 9 10 #ifndef __XML_XMLSAVE_H__ 11 #define __XML_XMLSAVE_H__ 12 13 #include <libxml/xmlversion.h> 14 #include <libxml/tree.h> 15 #include <libxml/encoding.h> 16 #include <libxml/xmlIO.h> 17 18 #ifdef LIBXML_OUTPUT_ENABLED 19 #ifdef __cplusplus 20 extern "C" { 21 #endif 22 23 /** 24 * xmlSaveOption: 25 * 26 * This is the set of XML save options that can be passed down 27 * to the xmlSaveToFd() and similar calls. 28 */ 29 typedef enum { 30 XML_SAVE_FORMAT = 1<<0, /* format save output */ 31 XML_SAVE_NO_DECL = 1<<1, /* drop the xml declaration */ 32 XML_SAVE_NO_EMPTY = 1<<2, /* no empty tags */ 33 XML_SAVE_NO_XHTML = 1<<3, /* disable XHTML1 specific rules */ 34 XML_SAVE_XHTML = 1<<4, /* force XHTML1 specific rules */ 35 XML_SAVE_AS_XML = 1<<5, /* force XML serialization on HTML doc */ 36 XML_SAVE_AS_HTML = 1<<6, /* force HTML serialization on XML doc */ 37 XML_SAVE_WSNONSIG = 1<<7 /* format with non-significant whitespace */ 38 } xmlSaveOption; 39 40 41 typedef struct _xmlSaveCtxt xmlSaveCtxt; 42 typedef xmlSaveCtxt *xmlSaveCtxtPtr; 43 44 /** DOC_DISABLE */ 45 #define XML_GLOBALS_SAVE \ 46 XML_OP(xmlIndentTreeOutput, int, XML_EMPTY) \ 47 XML_OP(xmlTreeIndentString, const char *, XML_EMPTY) \ 48 XML_OP(xmlSaveNoEmptyTags, int, XML_EMPTY) 49 50 #define XML_OP XML_DECLARE_GLOBAL 51 XML_GLOBALS_SAVE 52 #undef XML_OP 53 54 #if defined(LIBXML_THREAD_ENABLED) && !defined(XML_GLOBALS_NO_REDEFINITION) 55 #define xmlIndentTreeOutput XML_GLOBAL_MACRO(xmlIndentTreeOutput) 56 #define xmlTreeIndentString XML_GLOBAL_MACRO(xmlTreeIndentString) 57 #define xmlSaveNoEmptyTags XML_GLOBAL_MACRO(xmlSaveNoEmptyTags) 58 #endif 59 /** DOC_ENABLE */ 60 61 XMLPUBFUN xmlSaveCtxtPtr 62 xmlSaveToFd (int fd, 63 const char *encoding, 64 int options); 65 XMLPUBFUN xmlSaveCtxtPtr 66 xmlSaveToFilename (const char *filename, 67 const char *encoding, 68 int options); 69 70 XMLPUBFUN xmlSaveCtxtPtr 71 xmlSaveToBuffer (xmlBufferPtr buffer, 72 const char *encoding, 73 int options); 74 75 XMLPUBFUN xmlSaveCtxtPtr 76 xmlSaveToIO (xmlOutputWriteCallback iowrite, 77 xmlOutputCloseCallback ioclose, 78 void *ioctx, 79 const char *encoding, 80 int options); 81 82 XMLPUBFUN long 83 xmlSaveDoc (xmlSaveCtxtPtr ctxt, 84 xmlDocPtr doc); 85 XMLPUBFUN long 86 xmlSaveTree (xmlSaveCtxtPtr ctxt, 87 xmlNodePtr node); 88 89 XMLPUBFUN int 90 xmlSaveFlush (xmlSaveCtxtPtr ctxt); 91 XMLPUBFUN int 92 xmlSaveClose (xmlSaveCtxtPtr ctxt); 93 XMLPUBFUN int 94 xmlSaveSetEscape (xmlSaveCtxtPtr ctxt, 95 xmlCharEncodingOutputFunc escape); 96 XMLPUBFUN int 97 xmlSaveSetAttrEscape (xmlSaveCtxtPtr ctxt, 98 xmlCharEncodingOutputFunc escape); 99 100 XMLPUBFUN int 101 xmlThrDefIndentTreeOutput(int v); 102 XMLPUBFUN const char * 103 xmlThrDefTreeIndentString(const char * v); 104 XMLPUBFUN int 105 xmlThrDefSaveNoEmptyTags(int v); 106 107 #ifdef __cplusplus 108 } 109 #endif 110 111 #else /* LIBXML_OUTPUT_ENABLED */ 112 113 /** DOC_DISABLE */ 114 #define XML_GLOBALS_SAVE 115 /** DOC_ENABLE */ 116 117 #endif /* LIBXML_OUTPUT_ENABLED */ 118 #endif /* __XML_XMLSAVE_H__ */ 119 120 121