Boost logo

Boost Users :

Subject: [Boost-users] [serialization] Short form of empty tags in XML archive
From: Sergey Filippov (rstain_at_[hidden])
Date: 2009-10-15 06:17:36


Hi,
 
I'm evaluating possibility of using the serialization library (1.40.0) to
save/load an application settings to/from XML that must be a part of another
XML.
 
I faced with some minor issues that were successfully solved but then arisen
the major one: the serialization library does not support <tag/> syntax.
 
Why I need this? After the whole XML is generated it is transformed by some
XML processor to internal data structures and back to text. During the
transformation empty tags <str></str> (for example, produced when
serializing an empty std::string object) are replaced with the short form:
<str/>. From the XML perspective, these forms are equivalent so XML
processors allowed to do so.
 
Since I cannot change the XML processor, I started investigating the
serialization library. Specifically, how XML is processed.
 
I found out that parsing XML is responsibility of xml_grammar class. It does
not recognize <tag/> as a start tag so an exception is generated.
It is easy to write a new class with needed functionality but xml_grammar is
not designed to be used polymorphically... So, after all, I did not find an
easy way to write my own archive. After that, I tried to modify the library.
It was straightforward, and it works for me.
 
Attached are original (*.bak) files and modified.
 
Can anyone suggest a way to achieve such a functionality without modifying
the library?
Don't you think, this functionality is quite general to be included in the
library?
 
 
Sergey





Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net