Is there a way to tell JAXB to not remove underscores when creating getter/setter names from XML Schema?
Reason: this causes loss of information and it is harder to trip between XML and Java; e.g. in written communications where one participant might be confused about "different names".
Example: NR_ROR should not become getNRROR but getNR_ROR.
Note: I believe that the less-mangled names are worth the "violation" of Java naming convention.
TIA
karolrvn
Create a custom binding and set "underscoreBinding" to "asCharInWord". One approach is to create a file called binding.xjb and use the -b flag to tell xjc where it is. Here's an example of what you'd put in binding.xml:
<jaxb:bindings
xmlns:jaxb="http://java.sun.com/xml/ns/jaxb"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
version="1.0">
<jaxb:bindings schemaLocation="foobar.xsd">
<jaxb:globalBindings underscoreBinding="asCharInWord"/>
</jaxb:bindings>
</jaxb:bindings>
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