如何仅从 XML 生成 JAXB 类 [英] How to generate JAXB classes from just XML

查看:27
本文介绍了如何仅从 XML 生成 JAXB 类的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要从不提供架构的 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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆