简体   繁体   English

从libvirt Relaxng模式生成Java类的最佳方法是什么?

[英]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。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何从 Avro 模式生成 Java 类作为 Gradle 构建的一部分? - How to generate Java classes from Avro schemas as part of a Gradle build? 从Eclipse中的另一个Java项目重用类的最佳方法是什么? - What is the best way to reuse classes from another Java project in Eclipse? 将不同的JAVA类合并到一个类中的最佳方法是什么? - what is the best way to combine different JAVA classes in one single class? 声明和实现两个 Java 类的最佳方法是什么? - What is the best way of declaring and implementing two java classes? 将关系数据库表关联到Java类的最佳方法是什么? - What is the best way of relating relational database tables into Java classes? 在Java(静态类)中重构Utility类的最佳方法是什么 - What is the best way to refactor Utility class in java (static classes) 使用Cayenne从具有多个架构的Postgress数据库生成类 - Generate classes from Postgress database with multiple schemas using Cayenne 在 Java 中生成唯一且简短的文件名的最佳方法是什么 - What is the best way to generate a unique and short file name in Java 用python生成java的最佳方法? - Best way to generate java with python? 从 DTD 生成 XML 绑定代码的最佳方法是什么? - What is the best way to generate XML Binding Code from a DTD?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM