[serialization] How to serialize as an XML attribute?
Is it thinkable that some values could be serialized as XML attributes and not as XML elements? Where would be the correct place to add this functionality? I'm thinking to override the nvp and xml_archive. Is this the correct place to look at? Best regards Peter
The right place to do this would be in a different version of xml_?archive. Such a version might be crafted from scratch or implemented as a derivation from the current xml_?archive. The current xml_?archive has special handling for nvp. Your new version might have a different kind of special handling for nvp. When I looked at it, I decided to make all data elements xml elements - reserving attributes for "special" stuff like object id etc. It turned out that there were already xml attribute tags defined which mapped pretty well to the things that I was using like object id - reference to a previous object id etc. So that's what I used. When serializing collections, I did consider the idea of making the number of elements as an attribute rather than an xml element, but I rejected that as it would create a "special handling" of some types to the xml_?archive which I saw as less symetic and more coupled and a future maintainence headache. I was very careful to leave the door open to a more elaborate xml archive. XML is very loose and open ended - I chose plain vanilla. Users are free to add their own sauce. Good luck. Robert Ramey Peter Schregle wrote:
Is it thinkable that some values could be serialized as XML attributes and not as XML elements? Where would be the correct place to add this functionality? I'm thinking to override the nvp and xml_archive. Is this the correct place to look at?
Best regards Peter
participants (2)
-
Peter Schregle
-
Robert Ramey