I have this Java code (source):
// Deserialize
Person person = new Person();
InputStream in;
XmlIOUtil.mergeFrom(in, person, Person.getSchema());
// Do stuff...
// Serialize back into XML
OutputStream out;
XmlIOUtil.writeTo(out, person, Person.getSchema());
Let's say my XML code contains unknown fields, that not are in the schema (i.e. the XML provided is generated by a newer version of the software).
Is there a nice, clean way to preserve these fields when I serialize them again? I know Protocol Buffers preserves unknown fields.
One solution would be to copy the original XML into a buffer, then merge the newly serialized XML with the original, but that seems overly complicated.