[英]What is the best way to generate java classes from libvirt relaxng schemas?
Here is the thing: I do not wish (yet) to do some operation in a vm via libvirt. 事情是这样的:我不希望(现在)通过libvirt在vm中进行某些操作。
What I want to do is take the libvirt relaxng schemas and get java classes from them. 我想要做的是获取libvirt Relaxng模式并从中获取Java类。 This way I can produce an xml configuration file representing a virtual machine. 这样,我可以产生一个代表虚拟机的xml配置文件。 Later on this file is going to be used in an operation that registers a machine into a hypervisor in order to be able to (for example) power it on. 稍后,该文件将用于将机器注册到虚拟机监控程序的操作中,以便能够(例如)打开它的电源。
So, my initial idea was to convert the relaxng schemas into xsd. 因此,我最初的想法是将Relaxng模式转换为xsd。 Tried relaxer and trang, this is not really working. 尝试了放松剂和trang,这不是真的工作。
Are there any good alternatives? 有什么好的选择吗?
The JAXB XJC tool included in the JDK includes some experimental support for relaxng schemas. JDK中包含的JAXB XJC工具包括一些对松弛模式的实验性支持。 You can try: 你可以试试:
xjc -relaxng yourSchema
Or 要么
xjc -relaxng-compact yourSchema
I looked up the current version of the basictypes.rng schema in the libvirt git repository, and used the online validator.nu web service (which uses Jing at the backend) to validate a random XML document against this schema. 我在libvirt git存储库中查找了basictypes.rng模式的当前版本,并使用了在线validator.nu Web服务(在后端使用Jing)来针对该模式验证随机XML文档。 This produced a "Missing start element." 这产生了“缺少开始元素”。 error, which according to the RELAX NG tutorial is a required child element of <grammar/>
. 错误,根据RELAX NG教程,此错误是<grammar/>
的必需子元素。 So it looks like at least this particular version of this particular schema is invalid RELAX NG. 因此,看起来至少该特定模式的特定版本是无效的RELAX NG。
<grammar/>
and <start/>
: http://relaxng.org/tutorial-20011203.html#IDAETYR 有关<grammar/>
和<start/>
RELAX NG教程: http : //relaxng.org/tutorial-20011203.html#IDAETYR
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.