Search code examples
javajaxbstandardscase-sensitive

JAXB case sensitive class generation


I want to create classes from a standard schema learning object model. The schema appears to be broken due to a lowercased type. Is there any way that I can generate classes with jaxb in a "case insensitve" mode?

Here is the problem where the conflict comes out:

<xs:complexType name="Duration">
  <xs:choice minOccurs="0" maxOccurs="unbounded">
     <xs:element name="duration" type="DurationValue"/>
     <xs:element name="description" type="description"/>
     <xs:group ref="ex:customElements"/>
    </xs:choice>
 </xs:complexType> 

<xs:complexType name="duration">
    <xs:complexContent>
      <xs:extension base="Duration">
        <xs:attributeGroup ref="ag:duration"/>
       <xs:attributeGroup ref="ex:customAttributes"/>
     </xs:extension>
    </xs:complexContent>
 </xs:complexType>

I have rename the "duration" tag to "customDuration" and I have change the references as well and it works.

Thank you!


Solution

  • I think that you should change the schema in order to have Duration and duration_, generate JAXB objects and then change your JAXB classes generated in order to adapt them to the origina WSDL. For example, in Java:

    @XmlElement(name = "Duration")
    protected String duration;
    
    @XmlElement(name = "duration")
    protected String duration_;
    

    (I have simplified the types in the example). Hope anyway you find a better solution.