Reputation: 197
I am using JAXB-2 Maven Plugin to generate java classes starting from some xsd files. My configurations is the following. I have three schema files without target namespace A included by B included by C and then I have two others schemas D and E with a provided namespace, both of them including C. Is it possible to use bindings or different executions (with episodes) to have each schema producing classes in a different packages? Something like:
A schema (no namespace) -> com.packageA
B schema (no namespace) -> com.packageB
C schema (no namespace) -> com.packageC
D schema (namespace X) -> com.packageD
E schema (namespace X) -> com.packageE
of course without classes duplication? Or the best I can have is to have two packages, one for classes belonging to XSDs files with the empty namespace and one for the two XSDs files with the namespace X? Could you please provide an example of pom.xml file to achieve that? Thanks And how can
Upvotes: 1
Views: 2281
Reputation: 43671
Disclaimer: I'm the author of maven-jaxb2-plugin
so this answer is about that plugin.
This is called "separate schema compilation". This can be achieved using episodes, see the explanation in the maven-jaxb2-plugin
docs.
In short:
maven-jaxb2-plugin
will use dependencies as episodes by default.Here's a project which compiles a huge set of schemas in this fashion. The result is some 100+ artifacts with dependencies closely resembling dependencies of schemas.
One problem which I see is that you have schemas A, B and C having the same (empty) namespace, mapping to different packages. This may not work well with JAXB (see also "chameleon namespaces").
Upvotes: 1