1

this is more of a high level question about using jaxb and xslt, as I try to gain more of an understanding of what I need to do, and what I need to learn more about.

I have inherited an application that has Java class files generated from an xsd schema (using jaxb), does some stuff, then writes one of these objects to a serialized 'save file'.

I currently need to make changes to the xsd, which of course will mean some of my originally generated classes will be updated. However, I still need to be able to load the old serialized saved files for backwards compatibility - does this mean I need to maintain a copy of the current xsd, and all generated class files in order to load the old serialized save files? Does anyone have a suggested way I can do this, if I must be able to load the old files?

For all future version of the xsd, I intend to output saved files to xml, and use xslt to transform the file before unmarshalling the xml, which I think will work, as mentioned in this thread How should I manage different incompatible formts of Xml based documents. Doesn't help me with the older serialized files though - any ideas?

Thanks.

4

1 回答 1

1

JAXB 和一般数据绑定的主要缺点可能是它使模式演变变得非常麻烦。XML 是一种人们期望经常更改和扩展模式/数据模型的技术,而在 Java 中它是硬编码且难以更改的。在这种情况下,使用 XSLT 和 XQuery 等面向 XML 的语言是一大优势。

以序列化 Java 对象的形式保存持久数据对我来说似乎完全不合常理。在迁移到新的模式格式之前,请将其全部转换回 XML。XML 的全部意义在于数据的格式更加持久,并且不依赖于创建它的软件的持续存在。

于 2013-05-22T07:27:40.390 回答