I have a problem where the jaxb2-maven-plugin generates invalid source code when the XSD file contains default values for doubles.
I am using jaxb2-maven-plugin (org.codehaus.mojo) version 1.5 :
<plugin> <groupId>org.codehaus.mojo</groupId> <artifactId>jaxb2-maven-plugin</artifactId> <version>1.5</version> <configuration> </configuration> <executions> <execution> <id>analysis_jaxb</id> <phase>generate-sources</phase> <goals> <goal>xjc</goal> </goals> <configuration> <clearOutputDir>false</clearOutputDir> <schemaFiles>Analysis.xsd</schemaFiles> <packageName>xx.xx.xx.analysis</packageName> <generateDirectory>${project.build.directory}/generated-sources/jaxb/analysis</generateDirectory> <verbose>true</verbose> </configuration> </execution> </executions> </plugin>
to create a Java source from the following XSD file:
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified"> <xs:element name="MinMax" type="MinMaxType"/> <xs:complexType name="MinMaxType"> <xs:attribute name="min" type="xs:double" default="-INF" /> <xs:attribute name="max" type="xs:double" default="INF" /> </xs:complexType> </xs:schema>
As a result, the Java file contains this method:
public double getMin() { if (min == null) { return -InfinityD;
The -InfinityD field -InfinityD not defined anywhere.
When using booleans (for example, <xs:attribute name="minInclusive" type="xs:boolean" default="false" /> ), the default values work as expected.
In contrast, the org.jvnet.jaxb2.maven2 plugin (maven-jaxb2-plugin) would Double.POSITIVE_INFINITY on this problematic line.
Is it just not supported? Am I missing a parameter?
source share