Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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!

like image 672
pokeRex110 Avatar asked Aug 08 '26 17:08

pokeRex110


2 Answers

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.

like image 69
jddsantaella Avatar answered Aug 10 '26 07:08

jddsantaella


This was already answered but Hope this will help some one else , use -XautoNameResolution so that new classes will be generated whenever it encounters two elements with same name (Case insensitive). I used it as following

xjc -d src -p com.sample -wsdl somewsdl.wsdl -XautoNameResolution

like image 20
Madhu Malluri Avatar answered Aug 10 '26 07:08

Madhu Malluri



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!