XStreamを見ると ドキュメンテーション, 、彼らはあなたがXMLプロログを自分で追加しなければならないことを明確に述べています:
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).
次のコードが機能するはずです。私はあなたのコードのほとんどを削除したので、あなたはそれを元に戻さなければなりません。目的は、大まかな作業例を与えることです。
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
}
}