Re: [xslt] please help. problem with output buffers
- From: robert <robert xsl 00008 org>
- To: xslt gnome org
- Subject: Re: [xslt] please help. problem with output buffers
- Date: Thu, 17 Jan 2002 17:02:52 +0100
>int xml_output_write_callback(void * context, const char *buffer, int len) {
> char tmp[5000];
>
>/* printf("xml output write callback\n"); */
>/* printf("len:%d\n", len); */
> if (len > 0) {
> snprintf(tmp, len + 1, "%s", buffer);
> tmp[len] = '\0';
> //printf("%s", tmp);
> return(len);
> }
> return(0);
>}
Your callback received 3 arguments:
- context: this should be a pointer to your buffer (!)
- buffer : this contains the data which is to be written (into your buffer)
- length : length of new data
> if (res != NULL) {
> buf = xmlOutputBufferCreateIO(xml_output_write_callback,
> xml_output_close_callback, NULL, NULL);
Try using this:
xmlOutputBufferPtr buf;
char context[5000]; // this is your buffer!
buf = xmlOutputBufferCreateIO(xmlIOWrite, xmlIOClose, context, NULL);
if (buf == NULL)
{
// error occurred
}
if (xsltSaveResultTo(buf, res, cur) == -1)
{
// error occurred
}
xmlOutputBufferClose(buf);
printf("MY BUFFER: '%s'\n", context);
In your callback, you should cast the context to a char pointer:
char *my_buffer = (char *) context;
And add stuff to the end of it.
robert
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]