MCPcopy Create free account
hub / github.com/Kitware/VTK / xmlDocFormatDump

Function xmlDocFormatDump

ThirdParty/libxml2/vtklibxml2/xmlsave.c:2772–2808  ·  view source on GitHub ↗

* xmlDocFormatDump: * @f: the FILE* * @cur: the document * @format: should formatting spaces been added * * Dump an XML document to an open FILE. * * returns: the number of bytes written or -1 in case of failure. * Note that @format = 1 provide node indenting only if xmlIndentTreeOutput = 1 * or xmlKeepBlanksDefault(0) was called */

Source from the content-addressed store, hash-verified

2770 * or xmlKeepBlanksDefault(0) was called
2771 */
2772int
2773xmlDocFormatDump(FILE *f, xmlDocPtr cur, int format) {
2774 xmlSaveCtxt ctxt;
2775 xmlOutputBufferPtr buf;
2776 const char * encoding;
2777 xmlCharEncodingHandlerPtr handler = NULL;
2778 int ret;
2779
2780 if (cur == NULL) {
2781 return(-1);
2782 }
2783 encoding = (const char *) cur->encoding;
2784
2785 if (encoding != NULL) {
2786 int res;
2787
2788 res = xmlOpenCharEncodingHandler(encoding, /* output */ 1, &handler);
2789 if (res != XML_ERR_OK) {
2790 xmlFree((char *) cur->encoding);
2791 cur->encoding = NULL;
2792 encoding = NULL;
2793 }
2794 }
2795 buf = xmlOutputBufferCreateFile(f, handler);
2796 if (buf == NULL) return(-1);
2797 memset(&ctxt, 0, sizeof(ctxt));
2798 ctxt.buf = buf;
2799 ctxt.level = 0;
2800 ctxt.format = format ? 1 : 0;
2801 ctxt.encoding = (const xmlChar *) encoding;
2802 xmlSaveCtxtInit(&ctxt);
2803 ctxt.options |= XML_SAVE_AS_XML;
2804 xmlDocContentDumpOutput(&ctxt, cur);
2805
2806 ret = xmlOutputBufferClose(buf);
2807 return(ret);
2808}
2809
2810/**
2811 * xmlDocDump:

Callers 2

mainFunction · 0.85
xmlDocDumpFunction · 0.85

Calls 5

xmlSaveCtxtInitFunction · 0.85
xmlDocContentDumpOutputFunction · 0.85
xmlOutputBufferCloseFunction · 0.85

Tested by

no test coverage detected