characterizeFile: validate XML before inserting to DB

This ensures that if the characterization tool returns invalid XML, it will not be saved to the database in order to avoid later issues with createMETS2.

For instance, in some circumstances FITS may print error output to the stdout stream alongside actual XML content, resulting in a document that will not parse.

Fixes #7422.
Print the XML output to stdout or stderr, like we do for non-XML output?