tell jaxb to not remove underscores
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>
KarolDepka
Passionate software developer && entrepreneur, mostly interested in stuff like Angular, TypeScript, Firebase, Firestore, Android, hybrid mobile apps, Java, MPS, Kotlin, Scala, C#, ...
Updated on June 08, 2022Comments
-
KarolDepka almost 2 years
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 -
KarolDepka over 14 yearsThanks for answer.<br/> Maybe enableJavaNamingConventions = false ?<br/> However I didn't find any description of this
-
user1928596 over 3 yearswsdlLocation is not valid for jaxb:bindings and using jaxws:bindings does not help either