[xslt] using xsltSaveResultTo()
- From: Daniel Kelley <dkelley otec com>
- To: xslt gnome org
- Subject: [xslt] using xsltSaveResultTo()
- Date: Mon, 6 May 2002 10:32:06 -0400 (EDT)
Hi-
I've got a small program that takes a piece of xml, applies a stylesheet,
and calls xsltSaveResultToFile to print the results to stdout. I'm trying
to modify this to save the results to a buffer in memory using
xsltSaveResultsTo(), but I'm not having much luck. Here's a snippet from
what I've got:
[snippet]
res = xsltApplyStylesheet(sheet, doc, NULL);
if (res == NULL)
print_err(ERR_T_CGI, "Applying sheet failed.");
xml_buf = xmlAllocOutputBuffer(NULL);
if (xml_buf == NULL)
print_err(ERR_T_CGI, "unable to alloc xml_buf.");
writ = xsltSaveResultTo(xml_buf, res, sheet);
if (writ == -1 || !writ)
print_err(ERR_T_CGI, "unable to save xslt results.");
buff = malloc(sizeof(char) * 20000);
writ = xmlOutputBufferWriteString(xml_buf, buff);
if (writ == -1 || !writ)
print_err(ERR_T_CGI, "unable to write xml_buf to
string.");
return buff;
[/snippet]
in this snippet, the call to xsltSaveResultTo() always returns 0. I'm
confident that I'm doing something wrong with how I'm allocating xml_buf
(declared as type xmlOutputBufferPtr); if i change the
xsltSaveResultTo() call to
writ = xsltSaveResultToFile(stdout, res, sheet);
I get the transformed xml written to stdout.
I've been slogging through the definitions at
http://xmlsoft.org/XSLT/html/libxslt-utils.html, but have been unable to
figure out how to properly allocate a buffer for use with
xsltSaveResultTo(), or if there's a better way to do this. Any
suggestions or pointers would be greatly appreciated.
Thanks-
Dan
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]