JAXB External Custom Binding XJC Issue - Analyzing Empty Node Results

Forgive me if this is a duplicate. Here is my binding.xjb file. But now I get a regular error that the target of type "AddBankVaultRplyType" was not found. I do not see any problems. Can anyone help me with this? I list xsd which I am trying to configure

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

Here is the part of the XSD that I am trying to configure

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

Now, if I run XJC, it tells me that the target "/xs:schema/xs:ServiceReply/xs:complexType[@name='AddBankVaultRplyType']" leads to an empty node. What a mistake I'm making here

+8
jaxb xjc
source share
2 answers

You will need to bind the bindings in which the layout of the circuit is set. It should be something like:

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

For more information:

+8
source share

I finally got my workign with a subclass, and also added @XmlRootElement to those dang complexTypes that are used by the root element (I don't understand why JAXB doesn't add it for me, but that does the trick, since JAXB doesn't)

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

Of course, I struggled a lot with pom.xml, but finally came up with this solution that worked for 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> 

later, Dean

+4
source share

All Articles