Re: [xml] Question about packing...[solved]



My mistake, in fact, mem is a xmlChar * and not a xmlChar**
I call xmlDocDumpFormatMemoryEnc (docPtr, &mem, &size, encoding, 1);

and everything is fine.

Thanks list and sorry for the inconvenience.

_____________________________________________
Remy HAREL          -        Teamlog        |
____________________________________________|
Linux registered user #224740               |
France Telecom Recherche & Developpement    |
____________________________________________| __________________@ http://www.chezrem.org @|




Remy HAREL wrote:

of course, mem is declared...

void SortieXML::dump( ostream &out, const char * encoding )  {
          int size = 4096;
   xmlChar** mem;

  // dump the xml tree to memory with specified encoding
  xmlDocDumpFormatMemoryEnc (docPtr, mem, &size, encoding, 1);


#ifdef __LOG_ON__
  if ( size == 0 ) {
      ostringstream msg;
msg << "[SortieXML::dump] Erreur lors du vidage de l'arbre dans la mémoire " << endl;
      Log::message(msg, NomDuModule, LOG_ETAPE);
  }
#endif        // dump the memory to the output stream out
  if ( size > 0 ) {
      out.write((const char*) *mem, size);
  }

  // free the memory
  xmlFree(mem);

#ifdef __LOG_ON__
  ostringstream msg;
  msg << "Vidage de l'arbre xml sur un output stream "  << endl;
  Log::message(msg, NomDuModule, LOG_ETAPE);
#endif
}

_____________________________________________
Remy HAREL          -        Teamlog        |
____________________________________________|
Linux registered user #224740               |
France Telecom Recherche & Developpement    |
____________________________________________| __________________@ http://www.chezrem.org @|




Remy HAREL wrote:

Hi,

No, this is what I want because of a bug. I have a strange problem, when I dump the tree it crashes if I have written something to the same stream just before. I found it recently, but in fact, when I want to dump my tree, there is nothing to dump, like if the tree would be empty. So I would like to know if I could pack ( something like a "tar" for (bad) example ) the xml tree to test it.

cout << "toto" << endl;
xml->dump(cout);

-> crashes

cerr << "toto" << endl;
xml->dump(cout);

-> fine

where dump is :

void SortieXML::dump( ostream &out, const char * encoding )  {
         int size = 4096;

   // dump the xml tree to memory with specified encoding
   xmlDocDumpFormatMemoryEnc (docPtr, mem, &size, encoding, 1);


#ifdef __LOG_ON__
   if ( size == 0 ) {
       ostringstream msg;
msg << "[SortieXML::dump] Erreur lors du vidage de l'arbre dans la mémoire " << endl;
       Log::message(msg, NomDuModule, LOG_ETAPE);
   }
#endif        // dump the memory to the output stream out
   if ( size > 0 ) {
       out.write((const char*) *mem, size);
   }

   // free the memory
   xmlFree(mem);
#ifdef __LOG_ON__
   ostringstream msg;
   msg << "Vidage de l'arbre xml sur un output stream "  << endl;
   Log::message(msg, NomDuModule, LOG_ETAPE);
#endif
}


It works fine in other sub-modules I use, but I have problems in this sub-module. It's a pretty huge module, I can't provide the source code.

Thanks,

Remy

_____________________________________________
Remy HAREL          -        Teamlog        |
____________________________________________|
Linux registered user #224740               |
France Telecom Recherche & Developpement    |
____________________________________________| __________________@ http://www.chezrem.org @|




_____________________________________________
Remy HAREL          -        Teamlog        |
____________________________________________|
Linux registered user #224740               |
France Telecom Recherche & Developpement    |
____________________________________________| __________________@ http://www.chezrem.org @|






_____________________________________________
Remy HAREL          -        Teamlog        |
____________________________________________|
Linux registered user #224740               |
France Telecom Recherche & Developpement    |
____________________________________________| __________________@ http://www.chezrem.org @|




Danilo Šegan wrote:

Today at 15:07, Daniel Veillard wrote:

On Mon, Jun 13, 2005 at 02:24:27PM +0200, Remy HAREL wrote:
I hope you see what I mean,


 No I still don't see what you mean by pack. You add nodes to a tree,
and then want to pack, but I have no idea what you mean by that.



It seems to me that what Remy wants is to "deep copy" everything he
added to the tree, but I don't see a purpose in that: in the example
he gives, he probably should just reuse "toto" and "titi" pointers for
whatever he needs (otherwise, he may end up with two copies of the
same node, but then freeing one, which is clearly bogus).

FWIW though, I may have completely misunderstood him.

Cheers,
Danilo
_______________________________________________
xml mailing list, project page  http://xmlsoft.org/
xml gnome org
http://mail.gnome.org/mailman/listinfo/xml


_______________________________________________
xml mailing list, project page  http://xmlsoft.org/
xml gnome org
http://mail.gnome.org/mailman/listinfo/xml




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