How to use a class customization to resolve conflict when generating jaxb object from xsd
Asked Answered
N

2

10

When I run the xjc -d src/ -p com.test IFC2X3.xsd command on following xsd it gives the conflict.

....
<xs:element name="IfcCondenserTypeEnum" nillable="true">
        <xs:complexType>
            <xs:simpleContent>
                <xs:extension base="ifc:IfcCondenserTypeEnum">
                    <xs:attributeGroup ref="ex:instanceAttributes">
                    </xs:attributeGroup>
                </xs:extension>
            </xs:simpleContent>
        </xs:complexType>
    </xs:element>

    <xs:simpleType name="IfcCondenserTypeEnum">
        <xs:restriction base="xs:string">
            <xs:enumeration value="watercooledshelltube">
            </xs:enumeration>
            <xs:enumeration value="watercooledshellcoil">
            </xs:enumeration>
            <xs:enumeration value="watercooledtubeintube">
            </xs:enumeration>
            <xs:enumeration value="watercooledbrazedplate">
            </xs:enumeration>
            <xs:enumeration value="aircooled">
            </xs:enumeration>
            <xs:enumeration value="evaporativecooled">
            </xs:enumeration>
            <xs:enumeration value="userdefined">
            </xs:enumeration>
            <xs:enumeration value="notdefined">
            </xs:enumeration>
        </xs:restriction>
    </xs:simpleType>
   ....

Error:

parsing a schema...
compiling a schema...
[ERROR] A class/interface with the same name "com.test.IfcCondenserTypeEnum" is already in use. Use a class customization to resolve this conflict.
  line 14912 of file:/media/isuru/Projects/mitrai/bim_exchange/ifc_classes_v2x3/IFC2X3.xsd

[ERROR] (Relevant to above error) another "IfcCondenserTypeEnum" is generated from here.
  line 14902 of file:/media/isuru/Projects/mitrai/bim_exchange/ifc_classes_v2x3/IFC2X3.xsd

I found some questions regarding this but its not answering this. How can I resolve this as suggested Use a class customization

Nicolais answered 30/4, 2015 at 13:29 Comment(0)
C
10

Use below binding

<bindings version="2.0" xmlns="http://java.sun.com/xml/ns/jaxb" xmlns:xs="http://www.w3.org/2001/XMLSchema"
    xmlns:xjc="http://java.sun.com/xml/ns/jaxb/xjc" xmlns:annox="http://annox.dev.java.net"
    xmlns:namespace="http://jaxb2-commons.dev.java.net/namespace-prefix">
    <bindings schemaLocation="../schema.xsd">

        <bindings node="//xs:schema//xs:element[@name='IfcCondenserTypeEnum']">
            <class name="CondenserType" />
        </bindings>

    </bindings>
</bindings>
Cali answered 30/4, 2015 at 14:4 Comment(3)
I am facing similar problem. But I have around 20-30 such variables. Any other solution for this?Adallard
@wib: it is trivial to create a one-off XSLT transform stylesheet which can create these bindings for you. It'll give you all the freedom you need.Darwen
using the binding the and the schema file instead of local file I pointed to the url of the xsd and in the binding I defined binding for only one element it was workingPredicate
W
-1

You can use -autoNameResolution

For example, you can call wsdl2java -frontend jaxws21 -impl -server -d ../java -autoNameResolution -p com.yourClass https://webservice.xxxx.com.tr/Sms.asmx?wsdl

Worldlywise answered 5/12, 2019 at 6:42 Comment(1)
He asks for xjc, not wsdl2java. Also this was answered and resolved almost 5 years ago.Chronology

© 2022 - 2024 — McMap. All rights reserved.