Si miras el Xstream documentación, claramente afirman que tienes que agregar el Prólogo XML tú mismo:
Why does XStream not write an XML declaration?
XStream is designed to write XML snippets, so you can embed its output into
an existing stream or string. You can write the XML declaration yourself into
the Writer before using it to call XStream.toXML(writer).
El siguiente código debería funcionar. Eliminé la mayor parte de su código, por lo que debe volver a ponerlo. El propósito es simplemente darle un ejemplo de trabajo aproximado:
private static void serializeData(Object diagData) throws Exception {
XStream xstream = new XStream();
xstream.processAnnotations(DiagData.class);
FileOutputStream fileOutputStream = null;
Writer writer = new PrintWriter(new File(your file));
CompactWriter compactWriter = new CompactWriter(writer);
try {
writer.write(your xml prolog);
writer.write(your stylesheet);
xstream.marshal(diagData, compactWriter);
} catch (FileNotFoundException e1) {
} catch (Exception e) {
} finally {
release resources
}
}