如何仅从 XML 生成 JAXB 类 [英] How to generate JAXB classes from just XML
问题描述
我需要从不提供架构的 xml 生成类.我知道这几乎没用,但事实是我们有 xml,它是结构化的,我们应该能够从 xml 创建一个模型.过去我是手工完成的,但是我当前使用的 xml 文档非常大,我的时间可能最好花在构建满足我需要的东西上.但是,我猜它已经完成了,只是找不到.
有什么指点吗?
有许多可用的工具(谷歌快速搜索应该会找到一些)可以从 XML 生成 XSD,假设几乎所有的字符串类型.您应该能够使用该 XSD 运行 JAXB 来获取类.
这是一个在线工具,可让您做到这一点.>
这是一个屏幕截图:
I need to generate classes from xml that doesn't provide a schema. I understand this is near useless, but the fact is we have xml, it's structured, and we should be able to create a model from the xml. In the past I've done it by hand, but the current xml documents I am working with are quite large and my time would probably be better spent building something that does what I need. But, I am guessing it has already been done, and I just can't find it.
Any pointers?
There are many tools available (a quick google search should fetch you some) that can generate XSD from XML assuming string type for almost everything. You should be able to use that XSD to run JAXB to get classes.
Here's an online tool that lets you do that.
And here is a screen cap:
这篇关于如何仅从 XML 生成 JAXB 类的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!