MCPcopy Create free account
hub / github.com/KhronosGroup/OpenCOLLADA / libxml_saveNodeTo

Function libxml_saveNodeTo

Externals/LibXML/python/libxml.c:2907–2979  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2905}
2906
2907static PyObject *
2908libxml_saveNodeTo(ATTRIBUTE_UNUSED PyObject * self, PyObject * args)
2909{
2910 PyObject *py_file = NULL;
2911 FILE *output;
2912 PyObject *pyobj_node;
2913 xmlNodePtr node;
2914 xmlDocPtr doc;
2915 const char *encoding;
2916 int format;
2917 int len;
2918 xmlOutputBufferPtr buf;
2919 xmlCharEncodingHandlerPtr handler = NULL;
2920
2921 if (!PyArg_ParseTuple(args, (char *) "OOzi:serializeNode", &pyobj_node,
2922 &py_file, &encoding, &format))
2923 return (NULL);
2924 node = (xmlNodePtr) PyxmlNode_Get(pyobj_node);
2925
2926 if (node == NULL) {
2927 return (PyInt_FromLong((long) -1));
2928 }
2929 if ((py_file == NULL) || (!(PyFile_Check(py_file)))) {
2930 return (PyInt_FromLong((long) -1));
2931 }
2932 output = PyFile_AsFile(py_file);
2933 if (output == NULL) {
2934 return (PyInt_FromLong((long) -1));
2935 }
2936
2937 if (node->type == XML_DOCUMENT_NODE) {
2938 doc = (xmlDocPtr) node;
2939 } else if (node->type == XML_HTML_DOCUMENT_NODE) {
2940 doc = (xmlDocPtr) node;
2941 } else {
2942 doc = node->doc;
2943 }
2944#ifdef LIBXML_HTML_ENABLED
2945 if (doc->type == XML_HTML_DOCUMENT_NODE) {
2946 if (encoding == NULL)
2947 encoding = (const char *) htmlGetMetaEncoding(doc);
2948 }
2949#endif /* LIBXML_HTML_ENABLED */
2950 if (encoding != NULL) {
2951 handler = xmlFindCharEncodingHandler(encoding);
2952 if (handler == NULL) {
2953 return (PyInt_FromLong((long) -1));
2954 }
2955 }
2956 if (doc->type == XML_HTML_DOCUMENT_NODE) {
2957 if (handler == NULL)
2958 handler = xmlFindCharEncodingHandler("HTML");
2959 if (handler == NULL)
2960 handler = xmlFindCharEncodingHandler("ascii");
2961 }
2962
2963 buf = xmlOutputBufferCreateFile(output, handler);
2964 if (node->type == XML_DOCUMENT_NODE) {

Callers

nothing calls this directly

Calls 8

htmlGetMetaEncodingFunction · 0.85
xmlSaveFormatFileToFunction · 0.85
xmlOutputBufferCloseFunction · 0.85
htmlNodeDumpFormatOutputFunction · 0.85
xmlNodeDumpOutputFunction · 0.85

Tested by

no test coverage detected