問題描述
我正在開始一個擁有第三方 XSD 的新項目.我的 Java 應用程序需要生成和讀取符合此 XSD 的 XML 消息.過去,我為此使用了 Apache XMLBeans.看起來 XMLBeans 已經退役了.
I am starting a new project where I have third party XSD. My Java application needs to generate, and readm XML messages that conform to this XSD. In the past I have used Apache XMLBeans for this. It looks like XMLBeans has been retired.
現在 XMLBeans 已經退役了,有什么好的替代品呢?我在其他項目中使用過 XStream 但我不記得 XStream 有能力生成 Java來自 XSD 的類,所以我認為對于這個用例來說,它不是 XMLBeans 的好選擇.我在 XSD 中定義了數百種類型,并且真的不希望必須創建數百個 Java 類來手動在 Java 中表示它們.
What is a good replacement for XMLBeans now that it has been retired? I have used XStream on other projects but I don't recall that XStream has the ability to generate Java classes from an XSD so I am thinking that it is not a good choice over XMLBeans for this use case. I have hundreds of types defined in the XSD and would really prefer not to have to create the hundreds of Java classes to represent them in Java by hand.
換句話說,使用 XStream 示例,我有一個 在 XSD 中定義的 Person
類型(和其他 99 個).使用 XMLBeans 我可以生成 Java 類來表示這些對象,但是使用 XStream 我需要手動或使用其他工具來創建 Java 類(例如 Person
).在這種情況下我應該使用什么工具?
In other words, using the XStream example, I have a Person
type (and 99 others) defined in the XSD. Using XMLBeans I can generate the Java classes to represent these objects, but using XStream I would need to create the Java classes (e.g. Person
) by hand or using some other tool. What tool should I use in this case?
推薦答案
你看過 JAXB 嗎?我沒有對其中任何一個做過任何事情,但是在谷歌上搜索XMLBeans 的替代品"會帶來很多對這個包的引用.這是一篇比較它們的文章...
Have you looked at JAXB? I haven't done anything with either of these, but googling for "alternative to XMLBeans" brings up lots of references to this package. Here's an article that compares them...
http://blog.bdoughan.com/2012/01/how-does-jaxb-compare-to-xmlbeans.html
這篇關于既然 XMLBeans 已經退役了,用什么來代替它呢?的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!