Bug in XML serialization!!!
Following code results in "unrecognized XML syntax" exception while writing
to XML file.
However if I change xml_oarchive to text_oarchive or binary_oarchive, it
works fine, so I assume it's a bug in xml_oarchive ??? Does any one know how
to fix this for xml_oarchive ???
#include <iostream>
#include <fstream>
#include
I think it might be the function I've cut out below. Try using
boost:serialization::make_nvp
in place of the macro:
ar & boost::serialization::make_nvp("base",
boost::serialization::base_object<base>(*this));
The macro uses the parameter as the name for the XML element. Because
it's a templated type
then the angle brackets are probably included in the name, which would be
invalid XML
syntax.
Richard
On Fri, 21 Oct 2005 03:26:05 +0100, Piyush Kapadia
Following code results in "unrecognized XML syntax" exception while writing to XML file. [snip] void serialize(Archive & ar, const unsigned int version)
{
ar & BOOST_SERIALIZATION_NVP(boost::serialization::base_object<base>(*this));
ar & BOOST_SERIALIZATION_NVP(hmap);
}
Thanks for very prompt response on the subject.
It worked, and it shows as following tag -
<AA class_id="0" tracking_level="0" version="0">
<base class_id="1" tracking_level="0" version="0">
<vec>
<count>2</count>
<item>12</item>
<item>34</item>
</vec>
</base>
<hmap class_id="3" tracking_level="0" version="0">
<count>2</count>
<item class_id="4" tracking_level="0" version="0">
<first>First</first>
<second>12</second>
</item>
<item>
<first>Second</first>
<second>34</second>
</item>
</hmap>
</AA>
*However two issues persists related to XML -*
1. When xml out put file opened on Internet Explorer it results in following
legitimate error -
The following tags were not closed: boost_serialization. Error processing
resource 'file:///C:/Documents and Settings/piyus...
Some how it failes to write at the end of the file,
I don't know why ???
I have included test code and I am using VC 7.
2. Only Base class is using correct generic name as it is supplied via
make_nvp function, however all other tags are the name of variables for
example enclosing derived class is AA instead of derived as tag, how can we
change that to show as derived(just like base) instead of AA or hmap(should
be std::map) ???
On 10/21/05, Richard Jennings
I think it might be the function I've cut out below. Try using boost:serialization::make_nvp in place of the macro:
ar & boost::serialization::make_nvp("base", boost::serialization::base_object<base>(*this));
The macro uses the parameter as the name for the XML element. Because it's a templated type then the angle brackets are probably included in the name, which would be invalid XML syntax.
Richard
On Fri, 21 Oct 2005 03:26:05 +0100, Piyush Kapadia < piyush.kapadia@gmail.com> wrote:
Following code results in "unrecognized XML syntax" exception while writing to XML file. [snip] void serialize(Archive & ar, const unsigned int version)
{
ar & BOOST_SERIALIZATION_NVP(boost::serialization::base_object<base>(*this));
ar & BOOST_SERIALIZATION_NVP(hmap);
}
_______________________________________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users
"Piyush Kapadia"
participants (3)
-
Piyush Kapadia
-
Richard Jennings
-
Robert Ramey