2015-04-30 12 views
7

Quando eseguo il comando xjc -d src/ -p com.test IFC2X3.xsd sul seguente xsd, esso fornisce il conflitto.Come utilizzare una personalizzazione della classe per risolvere il conflitto durante la generazione dell'oggetto jaxb da xsd

.... 
<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> 
    .... 

Errore:

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 

ho trovato alcune domande riguardo a questo, ma la sua non rispondere a questa. Come posso risolvere questo come suggerito Use a class customization

risposta

7

Usa sotto vincolante

<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> 
+1

sto affrontando problema simile. Ma ho circa 20-30 tali variabili. Qualche altra soluzione per questo? – wib

+0

@wib: è banale creare un foglio di stile di trasformazione XSLT una tantum che possa creare questi collegamenti per te. Ti darà tutta la libertà di cui hai bisogno. – Abel

Problemi correlati