After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 319821 - Although I give FILE to xsltSaveResultToFile, it always return error.
Although I give FILE to xsltSaveResultToFile, it always return error.
Status: RESOLVED DUPLICATE of bug 319822
Product: libxslt
Classification: Platform
Component: general
1.1.15
Other All
: Normal normal
: ---
Assigned To: Daniel Veillard
libxml QA maintainers
Depends on:
Blocks:
 
 
Reported: 2005-10-26 05:48 UTC by Francois Milfeuille
Modified: 2005-10-26 08:16 UTC
See Also:
GNOME target: ---
GNOME version: ---



Description Francois Milfeuille 2005-10-26 05:48:06 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);
}
Comment 1 Daniel Veillard 2005-10-26 08:16:10 UTC

*** This bug has been marked as a duplicate of 319822 ***