从XSD转换为JAVA类时,维护目录层次结构吗? [英] Maintain directory hierarchy when converting from XSD to JAVA Class?

查看:107
本文介绍了从XSD转换为JAVA类时,维护目录层次结构吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一组XSD模式,它们存在于目录结构中.我正在使用JAXB将其转换为Java类.现在,在进行转换时,它将模式分为几个类,并将它们放入默认包中.我可以覆盖默认软件包,但我想保持XSD的相同目录结构. 这是否意味着我将不得不一次手动转换每个XSD.另外,由于它将单个XSD分为多个类,因此,将这些类转换为JSON模式对于我来说将变得很困难.因此,理想情况下,我希望每个XSD都可以转换为一个类.所以,我会用简单的词来表达我的问题

I have a set of XSD Schemas , that are present in a directory structure . I am using JAXB to convert it into Java Classes . Now when converting it it breaks the schema into several classes and puts them into the default package. I can override the default package but i would like to maintain the same directory structure of the XSD. Does this mean i will have to convert each XSD one at a time by hand. Also , since it is breaking the single XSD into multiple classes , it will make it tough for me to convert these classes into JSON schema . So ideally i would like each XSD to convert to a single class . So, i will put in simpler words my questions

  1. 我如何维护目录结构?

  1. How do i maintain the directory structure ?

我如何确保每个XSD对应一个单一的Java类?

How do i ensure that each XSD corresponds to a single java class?

由于最终目标是将xsd转换为JSON模式,所以我做错了吗?

Since myultimate goal is to convert the xsd to JSON Schema , am I doing it all wrong ?

我应该采用其他方法,例如将XSD转换为JSON并 然后可能会操纵它成为JSON模式?

should i take a different approach like converting XSD to JSON and then may be manipulating it to become JSON Schema ?

推荐答案

尝试在XSD中使用适当的名称空间,它将相应地创建类结构. 如果命名空间为http://www.company.com/XML/schema/product1,则将在com.company.xml.schema.product1.xxxx

Try using proper namespace in XSDs, it will create the class structure accordingly. if namespace is http://www.company.com/XML/schema/product1 then the classes would be generated in com.company.xml.schema.product1.xxxx

这篇关于从XSD转换为JAVA类时,维护目录层次结构吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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