2011-01-24 10 views
8

Perdonami se questo è un duplicato. Ecco il mio file binding.xjb. Ma ora sto ricevendo l'errore regolare che il tipo complesso target "AddBankVaultRplyType" non è stato trovato. Non vedo alcun problema. Qualcuno può aiutarmi con questo? Sto elencando il XSD che sto provando a personalizzareJAXB External Custom Binding Problema XJC - Risultati di analisi nel nodo vuoto

<jxb:bindings 
xmlns:xs="http://www.w3.org/2001/XMLSchema" 
xmlns:xjc="http://java.sun.com/xml/ns/jaxb/xjc" 
xmlns:jxb="http://java.sun.com/xml/ns/jaxb" 
xmlns:pd="http://chubb.com/cpi/polsvc/xmlobj" 
xmlns:inheritance="http://jaxb2-commons.dev.java.net/basic/inheritance" 
jxb:extensionBindingPrefixes="inheritance" 
jxb:version="2.1" 
> 


<jxb:bindings node="/xs:schema/xs:ServiceReply/xs:complexType[@name='AddBankVaultRplyType']"> 
<inheritance:extends>com.print.poc.AddressTypeHelper</inheritance:extends> 
</jxb:bindings> 

Ecco il pezzo di XSD che sto provando a personalizzare

<xs:schema xmlns:pd="http://com/polsvc/xmlobj" xmlns:xs="http://www.w3.org/2001/XMLSchema" targetNamespace="http://com/polsvc/xmlobj" elementFormDefault="qualified" attributeFormDefault="unqualified"> 
<xs:complexType name="AddBankVaultRplyType"> 

</xs:complexType> 
<xs:element name="ServiceReply"> 
    <xs:complexType> 
    <xs:sequence> 
    <xs:element name="ReplyHeader" type="pd:MsgHeaderType"/> 
    <xs:element name="RequestHeader" type="pd:MsgHeaderType"/> 
    <xs:choice> 
    <xs:element name="AddBankVaultReply" type="pd:AddBankVaultRplyType"/> 
</xs:choice> 
</xs:sequence> 
    </xs:complexType> 
</xs:element> 
</xs:schema> 

Ora, se faccio funzionare XJC mi sta dicendo che l'obiettivo "/xs:schema/xs:ServiceReply/xs:complexType[@name='AddBankVaultRplyType']" produce un nodo vuoto. Qual è l'errore che sto facendo qui

risposta

8

Sarà necessario eseguire il wrapping in un binding con la posizione dello schema impostata. Dovrebbe essere qualcosa di simile:

<jxb:bindings 
    xmlns:xs="http://www.w3.org/2001/XMLSchema" 
    xmlns:xjc="http://java.sun.com/xml/ns/jaxb/xjc" 
    xmlns:jxb="http://java.sun.com/xml/ns/jaxb" 
    xmlns:pd="http://chubb.com/cpi/polsvc/xmlobj" 
    xmlns:inheritance="http://jaxb2-commons.dev.java.net/basic/inheritance" 
    jxb:extensionBindingPrefixes="inheritance" 
    version="2.1"> 
    <jxb:bindings schemaLocation="your-schema.xsd"> 
     <jxb:bindings node="//xs:complexType[@name='AddBankVaultRplyType']"> 
      <inheritance:extends>com.print.poc.AddressTypeHelper</inheritance:extends> 
     </jxb:bindings> 
    </jxb:bindings> 
</jxb:bindings> 

Per maggiori informazioni:

+0

Ciao Blaise, Non funziona fuori. lo stesso errore è stato gettato. !! – Shiv

+0

Shiv - Ho aggiornato la mia risposta, dovrebbe funzionare meglio ora. –

+3

Grazie ancora. Sembra che funzioni bene, ma mostra questo errore.paziendo uno schema ... [ERRORE] Spazio dei nomi di binding non supportato "http://jaxb2-commons.dev.java.net/basic/inheritance". Forse intendevi "http://java.sun.com/xml/ns/jaxb/xjc"? – Shiv

4

finalmente ho ottenuto il mio workign con sottoclassi così come l'aggiunta @XmlRootElement a quei complexTypes dang che vengono utilizzati da un elemento radice (non capisco perché JAXB non lo aggiunge per me, ma questo fa il trucco di farlo poiché JAXB non lo fa)

<?xml version="1.0" encoding="UTF-8" standalone="yes"?> 
<jaxb:bindings 
    xmlns:jaxb="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:xsi="http://www.w3.org/2001/XMLSchema-instance" 
    xmlns:annox="http://annox.dev.java.net" 
    xsi:schemaLocation="http://java.sun.com/xml/ns/jaxb http://java.sun.com/xml/ns/jaxb/bindingschema_2_0.xsd 
        http://annox.dev.java.net " 
    jaxb:extensionBindingPrefixes="xjc annox" 
    version="2.1"> 

    <jaxb:globalBindings> 
    <jaxb:serializable uid="1"/> 
    <!-- All generated classes must have MySignature interface (supplied in dependencies) --> 
    <xjc:superClass name="com.cigna.framework.DataObject"/> 
    <xjc:superInterface name="com.cigna.framework.InterfaceTest"/> 
    <!-- All temporal fields are implemented as Joda DateTime and use DateUtils as an adapter --> 
    <jaxb:javaType 
     name="org.joda.time.DateTime" 
     xmlType="xs:time" 
     parseMethod="com.cigna.framework.util.DateUtil.stringToDateTime" 
     printMethod="com.cigna.framework.util.DateUtil.dateTimeToString" 
     /> 
    </jaxb:globalBindings> 



    <!-- Application of annotations to selected classes within schemas --> 

    <!-- org.example.SomeRootType @XmlRootElement --> 
    <jaxb:bindings schemaLocation="../schemas/externalaction_2012_03.xsd" node="/xs:schema"> 
    <jaxb:schemaBindings > 
     <jaxb:package name="com.framework.action"></jaxb:package> 
    </jaxb:schemaBindings> 

    </jaxb:bindings> 

    <jaxb:bindings schemaLocation="../schemas/common_2012_04.xsd" node="/xs:schema"> 
    <jaxb:schemaBindings > 
     <jaxb:package name="com.framework.common"></jaxb:package> 
    </jaxb:schemaBindings> 

    <jaxb:bindings node="xs:complexType[@name='PersonNameType']"> 
     <annox:annotate> 
     <annox:annotate annox:class="javax.xml.bind.annotation.XmlRootElement" name="SomeRootType"/> 
     </annox:annotate> 
    </jaxb:bindings> 
    </jaxb:bindings> 

    <jaxb:bindings schemaLocation="../schemas/utilities_2012_03.xsd" node="/xs:schema"> 
    <jaxb:schemaBindings > 
     <jaxb:package name="com.framework.util"></jaxb:package> 
    </jaxb:schemaBindings> 

    </jaxb:bindings> 

</jaxb:bindings> 

Naturalmente ho lottato molto con il pom.xml ma alla fine sono arrivato a questa soluzione che ha funzionato per me.

 <plugin> 
      <groupId>org.jvnet.jaxb2.maven2</groupId> 
      <artifactId>maven-jaxb2-plugin</artifactId> 
      <version>0.8.1</version> 
      <executions> 
       <execution> 
        <id>process-xsd</id> 
        <goals> 
         <goal>generate</goal> 
        </goals> 
        <phase>generate-sources</phase> 
        <configuration> 
         <schemaIncludes> 
          <include>schemas/*.xsd</include> 
         </schemaIncludes> 
         <bindingIncludes> 
          <include>schemas/*.xjb.xml</include> 
         </bindingIncludes> 
         <generateDirectory>${project.build.directory}/generated-sources</generateDirectory> 
         <extension>true</extension> 
         <args> 
          <arg>-Xannotate</arg> 
         </args> 
         <plugins> 
          <plugin> 
           <groupId>org.jvnet.jaxb2_commons</groupId> 
           <artifactId>jaxb2-basics-annotate</artifactId> 
           <version>0.6.3</version> 
          </plugin> 
          <plugin> 
           <groupId>org.jvnet.jaxb2_commons</groupId> 
           <artifactId>jaxb2-basics</artifactId> 
           <version>0.6.3</version> 
          </plugin>        
         </plugins> 
        </configuration> 
       </execution> 
      </executions> 
     </plugin>   

tardi, Dean

+0

hai usato un comando speciale maven per creare le classi o semplicemente il pacchetto mvn clean? –

Problemi correlati