Here's(onvif.xsd) the schema file I'm trying to generate the source code for, using hisrc-higherjaxb.
Here's part of my pom.xml configuration,
<plugin>
<groupId>org.patrodyne.jvnet</groupId>
<artifactId>hisrc-higherjaxb-maven-plugin</artifactId>
<version>2.1.1</version>
<executions>
<execution>
<id>onvif-onvif-xsd</id>
<goals>
<goal>generate</goal>
</goals>
<configuration>
<args>
<arg>-no-header</arg>
<arg>-XautoNameResolution</arg>
</args>
<generatePackage></generatePackage>
<generateDirectory>${project.basedir}/src/main/java</generateDirectory>
<episode>true</episode>
<episodeFile>${project.basedir}/src/main/resources/episodes/onvif.episode
</episodeFile>
<forceRegenerate>true</forceRegenerate>
<extension>true</extension>
<enableExternalEntityProcessing>true</enableExternalEntityProcessing>
<bindings></bindings>
<strict>false</strict>
<verbose>true</verbose>
<disableXmlSecurity>true</disableXmlSecurity>
<schemas>
<schema>
<url>file://${project.basedir}/src/main/resources/wsdl/ver10/schema/onvif.xsd</url>
</schema>
</schemas>
</configuration>
</execution>
</executions>
</plugin>
The code generates fine with all the types declared in the schema. The generated ObjectFactory defines factory methods for all types but annotates only some methods with XmlElementDecl. Due to this, my marshaller is unable to unmarshal these unannotated elements, when they appear in place of xs:any(with processContents="lax") elements, and leaves them out as dom elements as they haven't been declared in the namespace.
How do I get it to annotate all factory methods?
The XJC tool (JAXB RI) is responsible for generating the
XmlElementDeclannotations and it conforms to the JAXB API. The hisrc-higherjaxb Maven plugin configures and invokes the XJC tool.Below is the list of the all Java classes generated by XJC for the
"http://www.onvif.org/ver10/schema"schema. Two of the Java types are root elements (XmlRootElement). Sixteen of the types are wrapped in JAXB elements (XmlElementDecl) and the rest [452] are complex types. A good article explaining how XJC generates the annotations is at JAXB and Root Elements.In a nutshell, the list identifies these three groups:
The
ObjectFactorydoes not declare JAXB elements (XmlElementDecl) for the classes marked withCT. For example, theUsertype is generated from an XML schemacomplexTypewithout a correspondingelementbinding. If you add this binding:onvif.xsd
Then XJC will generate this
XmlElementDeclin theObjectFactory:ComplexType vs JAXBElement vs RootElement