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 131018 - xmlpp::Document::write_to_stream() fails when output size exceeds 4000 bytes
xmlpp::Document::write_to_stream() fails when output size exceeds 4000 bytes
Status: RESOLVED FIXED
Product: libxml++
Classification: Bindings
Component: General
1.0.x
Other Linux
: Normal normal
: ---
Assigned To: Christophe de Vienne
Christophe de Vienne
Depends on:
Blocks:
 
 
Reported: 2004-01-09 15:49 UTC by Andris Pavenis
Modified: 2004-12-22 21:47 UTC
See Also:
GNOME target: ---
GNOME version: 2.3/2.4



Description Andris Pavenis 2004-01-09 15:49:58 UTC
xmlpp::Document::write_to_stream() fails when output size exceeds 4000
bytes. After 4000 bytes it outputs again xml header ('<? xml ...'). I
reprocuced this behaviour with both stable (1.0.0) and development (2.5.0)
version. Initially I found this ordid tests when libxml2-2.5.11 were
installed. Upgrade to libxml2-2.6.4 doesn't change anything.

Also: both xmlpp::Document::write_to_file() and
xmlpp::Document::write_to_string() works correctly. Behaviour is exactly
the same in case of formatted output functions

Here is simple example in which I reproduced this problem:

--------------------------------------------------
#include <fstream>
#include <iostream>
#include <libxml++/libxml++.h>

using namespace xmlpp;

Document * gen_doc (void)
{
   Document * doc = new Document;
   Element * root = doc->create_root_node ("Test");
   for (int i=0; i<20; i++)
   {
      Node * n1 = root->add_child ("foo");
      for (int k=0; k<20; k++)
          n1->add_child ("bar")->add_child_text("baz");
   }
   return doc;
}


int main (void)
{
   Document * doc = gen_doc ();
   std::ofstream ofs ("foo.xml");
   std::cout << "length=" 
	     << doc->write_to_string("UTF-8").length()
	     << std::endl;
   doc->write_to_stream (ofs, "UTF-8");
   return 0;
}
--------------------------------------------------

I got more that 4 Mb output to file, while write_to_string()
returned only 5873 bytes.

Problem doesn't seem to be Linux specific as I got identical output to file
for target i586-pc-msdosdjgpp (had built libxml2-2.6.3 and libxml++-1.0.0
for it)
 
Andris
Comment 1 Christophe de Vienne 2004-01-12 10:28:34 UTC
I commited a fix in the CVS on the branch LIBXMLPP_BRANCH_1_0.
Could you confirm it solves your problem, so I can close the bug.

Cheers