Re: [xslt] xsltRunStylesheet() with IOBuf



I did some poking around trying to figure out why I get about 4000 bytes
worth of garbage in some really rare cases inserted before all the
output is being generated when I use xsltRunStylesheet using the
outputBuffer structures and callbacks. (OutputBuffer code is actually
implemented in libxml)

Here are some things that I found:
1. The problem is somewhere in libxml and either in the content output
functions that work on outputbuffer or in the dump function.
2. My first call is always len 8004 bytes, which is kinda strange since
the rest of the calls are ~4000 bytes. Another interesting thing I
noticed while looking at the source code of libxml:

since I have an encoder the output callback code in xmlIO.c file
xmlOutputBufferWrite function looks something like this:
            /*
	     * second write the stuff to the I/O channel
	     */
	    if (out->encoder != NULL) {
		ret = out->writecallback(out->context, 
				 (const char *)out->conv->content, nbchars);
		if (ret >= 0)
		    xmlBufferShrink(out->conv, ret);

now according to xmlAllocOutputBuffer source code:
   if (encoder != NULL) {
        ret->conv = xmlBufferCreateSize(4000);
	/*
	 * This call is designed to initiate the encoder state
	 */
	xmlCharEncOutFunc(encoder, ret->conv, NULL); 
    } else
        ret->conv = NULL;

which is strange since we are using out->conv buffer to call the
callbacks then ALL the calls to my function should be <=4000 but they
are bigger. And I still don't understand how the first call is like 8000
 and which memory are we addressing?

P.S. Should I also CC this to libxml mailing list?

G.F. aka Gena01
http://www.gena01.com



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]