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"/> <xjc:superClass name="com.cigna.framework.DataObject"/> <xjc:superInterface name="com.cigna.framework.InterfaceTest"/> <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> <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
Dean hiller
source share