Pratik
Pratik

Reputation: 211

XJC error for XSD with 2 elements with same name but different case

I have xsd with 2 elements: "state" and "State". When I perform XJC using maven-jaxb2-plugin, I get the following error:

<xsd:element name="state" type="xsd:string" minOccurs="0" maxOccurs="1" />
.
.
.
<xsd:element name="State" type="xsd:string" minOccurs="0" maxOccurs="1" />

SAXParseException2: Two declarations cause a collision in the ObjectFactory class

This is expected, since it tries to convert the element with "State" to "state" internally which causes the conflict with the already existing "state". My question is, is there a way to maintain case?

NOTE: I know this is not ideal in the first place to have same element names, but unfortunately, I have no control over changing the XSD.

Upvotes: 0

Views: 812

Answers (1)

lexicore
lexicore

Reputation: 43651

Why don't you use jaxb:class or jaxb:factoryMethod customizations to avoid naming collissions?

Something like:

<jaxb:bindings node="xs:element[@name='state']">
    <jaxb:factoryMethod name="LowerState"/>
</jaxb:bindings>

Upvotes: 1

Related Questions