Reputation: 1073
I have a fairly big xsd
from which I generate JaxB classes using the org.jvnet.jaxb2.maven2.maven-jaxb2-plugin
. The element names are all capital letters delimited by underscores like FOO_BAR_BAZ
. This results in hideous names for the generated classes e.g. FOOBARBAZ
. Idealy I would like it to be maped to FooBarBaz
. Extending the definition with <jxb:class>
Elements isn't an option.
Is there a general way to override how jaxb maps element names to java class names?
Upvotes: 1
Views: 1900
Reputation: 693
You can use an external binding declarations file, an .xjb
file containing something similar to this:
<jxb:bindings node="//xs:element[@name='FOO_BAR_BAZ']">
<jxb:class name="FooBarBaz"/>
<jxb:property name="FooBarBaz"/>
</jxb:bindings>
But you will have to do that for all the classes to be generated. You may alos have to configure the bindingDirectory
proprerty of the maven plugin.
Upvotes: 0
Reputation: 149047
For this use case you could investigate creating a custom XJC plug-in to customize how the Java class names are derived.
Upvotes: 1