the jaxb-schema-compiler/the embedded schema-compiler used by wsimport eliminates underscores by default. You can set a binding file to influence this behavior in a special way since JAXB 2.1:
<?xml version='1.0' encoding='UTF-8'?>
But the result using this additional binding is not correct for all cases:
All letters up to the first underscore of the generated java identifier name for the jaxb element are converted to lowercase. All underscores in the element name are deleted and every first letter after these underscores is converted to uppercase. This is a suitable conversion for identifiers only if you use no uppercase letters.
But if you use uppercase letters for the element you can get ambigous identifiers.
An additional jaxb binding parameter to get a correct behaviour for capital letters:
a.) All letters up to the first underscore are unchanged.
b.) If the first letter after an underscore is a lowercase letter the xjc replaces this letter with an upper case letter and vice versa (=if this letter is an uppercase letter xjc replaces this letter with a lowercase letter).
THIS_WHITEHOUSE -> THISwHITEHOUSE
THIS_WHITE_HOUSE -> THISwHITEhOUSE
this_whitehouse -> thisWhitehouse
this_white_house -> thisWhiteHouse
So all identifiers would be unambigously.
well, for the most jaxb users it seems to be an uncommon problem. But we provide in our application more than 2000 web services with nearly 100.000 different elements. The identifiers of the elements are logical expressions used for financial applications. they are part of legacy applications so their names cannot be changed. And some identifiers differ only by the position of the underscore.
A general question for me is why jaxb doesnt accept the undesorces. An when jaxb does not accept underscores why are the rules for calculating an identifier without underscores are ambigous.