GNOME Bugzilla – Bug 131018
xmlpp::Document::write_to_stream() fails when output size exceeds 4000 bytes
Last modified: 2004-12-22 21:47:04 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
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