Re: [Libxmlplusplus-general] write() broken, maybe fixed



-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Le Lundi 16 Décembre 2002 10:27, Murray Cumming a écrit :
> The change to Node::write() just before the 0.17 release broke that
> method, leading to segfaults in some situations, and at least not
> writing out all child nodes in the dom_build example.

Well, I've just tried this and had no problems. The output is the same as the 
source file, except for the namespace which is removed.
I did the change to Node::write() because the output was different.

The segfault happen when the incoming node tree is incorrect (a text node with 
children).
So the solution is to throw an exception if a text node has children.

>
> The cvs version should be fixed. If it works for everyone then we need a
> new release:
>
> 2002-12-16  Murray Cumming  <murrayc usa net>
>
> 	* libxml++/node.cc: write():
> 	- Don't set the node->type directly. Let
> 	xmlNodeSetContent take care of adding a suitable child node. This
> 	was leading to segfaults when write() later tried to add a child node
> 	to a text node.
> 	- Throw internal_error exception when xmlNewChild returns NULL.

Running the example with this patch and writing the resulting tree to a new 
file, I've something like :

      1 <?xml version="1.0"?>
      2 <Helping>
      3   <Jobs>
      4     <Job>
      5       <Project ID="3"/>
      6       <Application>
      7         <text>GBackup</text>
      8       </Application>
      9       <Category>
     10         <text>Development</text>
     11       </Category>
     12       <Update>
     13         <Status>
     14           <text>Open</text>
     15         </Status>
     16         <Modified>
     17           <text>Mon, 07 Jun 1999 20:27:45 -0400 MET DST</text>
     18         </Modified>
     19         <Salary>
[...]


This is not good either. That's why I modified Node::write() the way I did. 
The xmlNodeSetContent act differently if it's a TEXT node or node. So the 
node type has to be set before calling it. I'll see if it can be set a 
creation time.




-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.0.6 (GNU/Linux)
Comment: For info see http://www.gnupg.org

iEYEARECAAYFAj39rGMACgkQB+sU3TyOQjDlLQCfdmRIJG8GIJN2wovXS+0PGBIN
5BQAoJP7/dPeGUMzFYthCFlP+sfM/vZm
=wGyh
-----END PGP SIGNATURE-----





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