I have a couple of huge XML schema definition (XSD) files and I want to generate only for a subset of the defined types the corresponding Java classes.
More precisely I have a list of "root" types that I want to transform into Java classes including all types needed by these root types.
Is it possible to define some "root" types in a JAXB bindings file and tell JAXB to transform only them with all their dependent types into Java classes and ignore all the other unnecessary types?
Thanks in advance.
There may be a more straightforward way, but one way is to make copies of the XSDs and remove all XML types from the copies excepted the root types you want with their dependencies. Then apply xjc on the copies instead of the original ones.
You can automate this process with XSLT and build automation tools like Maven, Gradle, Ant, etc. You first write the XSLT stylesheet that transforms the XSDs to copy only the root types with dependencies, and save the result to a temporary location (e.g. target/generated-sources folder with Maven). Then, with Maven for example, you automate the process with build plugins in your pom.xml:
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With