GNOME Bugzilla – Bug 319821
Although I give FILE to xsltSaveResultToFile, it always return error.
Last modified: 2005-10-26 08:16:10 UTC
xsltSaveResultToFile needs FILE parameter which opened file to output. So I called "fopen" but xsltSaveResultToFile caused error. Why ? Although I'm looking for the example to use xsltSaveResultToFile, it is not anywhere. As an example,there is always only xsltSaveResultToString. Since I have to transform XML(200MB),I can not use a function like xsltSaveResultToString which truly consumes a memory. int Transform0(const char* input_xmlname, const char* transform_xsl, const char* out_htmlname) { xsltStylesheetPtr style = NULL; xmlDocPtr xmldoc,res; FILE* html; const char *params[16 + 1]; char* buf; int size; xmlInitParser(); params[0] = NULL; params[1] = (char*)"-o"; params[2] = (char*)out_htmlname; params[3] = (char*)transform_xsl; params[4] = (char*)input_xmlname; params[5] = NULL; xmlSubstituteEntitiesDefault(1); // 0 ? xmlLoadExtDtdDefaultValue = 1; xmlIndentTreeOutput = 1; //defaultLoader = xmlGetExternalEntityLoader(); //xmlSetExternalEntityLoader(xmlMyExternalEntityLoader); html = fopen(out_htmlname, "w"); //html = fopen(out_htmlname, "ab"); if(html==NULL) return(-1); exsltRegisterAll(); style = xsltParseStylesheetFile((const xmlChar *)transform_xsl); if(style==NULL) { fclose(html); return(-1); } xmldoc = xmlParseFile(input_xmlname); xmlXIncludeProcess(xmldoc); if(xmldoc==NULL) { fclose(html); return(-1); } params[0] = NULL; res = xsltApplyStylesheet(style, xmldoc, params); if(res==NULL) { fclose(html); return(-1); } xsltSaveResultToFile(html, res, style); //xsltSaveResultToString((xmlChar **)&buf, &size, res, style); fclose(html); xsltFreeStylesheet(style); xmlFreeDoc(res); xmlFreeDoc(xmldoc); xsltCleanupGlobals(); xmlCleanupParser(); return(0); }
*** This bug has been marked as a duplicate of 319822 ***