openmicroscopy/bioformats — pull request #1478 by rleigh-dundee (2014-12-10 22:27:23+00:00)
Title: C++: Add helpers for XML serialisation

- XMLTools: Add escapeXML and sanitizeXML to XMLTools
- Add writeDocument functions as xerces Document helpers

sanitizeXML is slightly different from the java implementation. Because it's not operating on a fixed character array it doesn't have to edit in place. Therefore invalid control chars are dropped instead of padding with space, and &# is escaped as a entity.

The writeDocument methods are similar to the XMLTools dumpXML methods, but with some additional flexibility in controlling the output, and support output to strings, files and streams.

--------

Testing:

- All the above have unit tests which should pass.
- I'm not massively familiar with all the Xerces internals, so there may be more optimal ways of doing the DOM output.