Re: [xml] PATCH: implement xmlSaveToBuffer()

On Sun, Nov 06, 2005 at 08:34:39PM +0100, Geert Jansen wrote:
Hi Daniel,

thanks for your reply. I've checked my code and was actually passing in 
an xmlOutputBufferPtr, not an xmlBufferPtr! That's why it worked in my 
tests. See the (Pyrex/lxml) code below:

           buffer = tree.xmlAllocOutputBuffer(encoder)
           ctxt = tree.xmlSaveToBuffer(buffer, encoding, options)
           tree.xmlSaveDoc(ctxt, self._c_doc)
           s = dumpOutputBuffer(buffer, encoding)

  You should rather use the I/O interface when writing to a file !
Use xmlSaveToIO instead. Define your function for write and close and
use this, this will avoid growing a huge buffer to later dump it to a file.

Can we just change the xmlSaveToBuffer() prototype to accept an 
xmlOutputBuffer as per the updated patch attached? Or is there something 
which makes it better to have an interface with an xmlBuffer?

  The xmlBuffer should be used when you don't dump to an I/O channel.
Then the user just want a memory string and an xmlBuffer makes way more sense
than an xmlOutputBuffer in that case.

The attached patch also comments in and updates the prototype in xmlsave.h.

  I don't think it's the right approach, really.


Daniel Veillard      | Red Hat
veillard redhat com  | libxml GNOME XML XSLT toolkit | Rpmfind RPM search engine

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