是否有标准的Java实用程序在运行时解析XSD文件? [英] Is there a standard Java utility to parse XSD files at runtime?

查看:417
本文介绍了是否有标准的Java实用程序在运行时解析XSD文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在寻找一种以编程方式解析XSD文件以生成XML映射的方法,以便我可以获取任何XSD文件并创建一个解析器来解析任何符合它的XML文件,以及我的google-fu已经很短了。

I've been looking around for a way to programmatically parse XSD files to generate an XML mapping so that I can take any XSD file and create a parser that will parse any XML file that conforms to it, and my google-fu has been coming up short.

XSOM 看起来很有前途,因为它将解析一个XSD文件,并以直接的方式使其所有属性可用。

XSOM looks promising, as it will parse an XSD file and make all its attributes available in a straight forward way.

是否有任何其他选项或标准库可用于生成XML文件解析器XSD文件?

Are there any other options or standard libraries available that will produce an XML file parser from an XSD file?

[结论] 感谢大家的回复,他们是真正的帮助。我能够使用JAXP,Eclipses EMF和XSOM编写实现,所有这些都按照需要工作。

[Conclusion] Thanks everyone for your responses, they were a real help. I was able to write implementations using JAXP, Eclipses EMF and in XSOM that all worked as desired.

JAXP非常直接且易于学习和操作。 EMF实际上是一个很难正常进行的痛苦,有很多罐子必须包括在内才能独立工作,我不推荐它。 XSOM甚至比JAXP实现更简单,所以我最终使用它。

JAXP was very straight forward and easy to learn and do. EMF was actually a pain to get going properly, there were so many jars that had to be included for it to work standalone that I would not recommend it. XSOM was even simpler than the JAXP implementation, so I went with it in the end.

推荐答案

是的,有一种标准方式。

Yes, there's a standard way.

您正在寻找 JAXB

这篇关于是否有标准的Java实用程序在运行时解析XSD文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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