Maintain directory hierarchy when converting from

2019-09-02 14:22发布

问题:

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. How do i maintain the directory structure ?

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

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

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

回答1:

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