1

I have the following xsd schema (snippet) and want to generate java classes with correect naming conventions for classname, attributes and methods -> camelCase. I found the CamelCase Always plugin but it is outdated and I have no idea how to use it. Is there a way to do this with jaxb and/or xjc?

<xs:complexType name="AB_NAME">
       <xs:sequence>
             <xs:element name="ELEMENT_ID" type="tns:DECIMAL_38_0"/>
            <xs:element name="DATEN_ID" type="tns:DECIMAL_38_0"/>
            <xs:element name="DATE" type="tns:TIMESTAMP_0"/>
        </xs:sequence>
    </xs:complexType>

Or is it possible to rename the attributes and methods with another plugin? E.g. you can generate it with <jaxb:globalBindings underscoreBinding="asCharInWord"> After the generation is finished replace the names in the class like this getELEMENT_ID() to getElementId() ?

user3756702
  • 215
  • 5
  • 13

1 Answers1

0

You can either use the CamelCase Always plugin:

Or use a bunch of jaxb:property and jaxb:class binding customizations to fix names:

<jaxb:bindings schemaLocation="schema.xsd" node="/xsd:schema">
    <jaxb:bindings node="xsd:complexType[@name='AB_NAME']/xs:sequence/xs:element[@name='ELEMENT_ID']">
        <jaxb:property name="ElementId"/>
    </jaxb:bindings>
</jaxb:bindings>

Community
  • 1
  • 1
lexicore
  • 42,748
  • 17
  • 132
  • 221
  • thanks - the second solution isn't an option for me. because there are too many elements. I already tried the solution in the link you provide, but this doesn't change anything during generation. Names are still not in camelcase – user3756702 Jan 06 '16 at 11:46