Is there a way to customize the JAXB binding for xs:list? The folowing example:
<simpleType name="doubleList">
<list itemType="double" />
</simpleType>
Will be bound by xjc to: List<Double>
. However, I'd like to bind it to: List<BigDecimal>
.
My initial setup was to define a binding like this:
<jaxb:bindings multiple="true" node="//xs:simpleType[@name='doubleList']/xs:list/@itemType">
<jaxb:property>
<jaxb:baseType name="java.math.BigDecimal" />
</jaxb:property>
</jaxb:bindings>
However, this gives the following problem:
XPath evaluation of "//xs:simpleType[@name='doubleList']/xs:list/@itemType" needs to result in an element.
Is there a way to do this without resorting to writing your own custom adapters?
The doubleList above was used elsewhere. Applying the binding on those spots, resulting in a correct Javaclass. Supprisingly, only choosing the proper base type was sufficient.
So place where the doubleList was used elsewhere:
<complexType name="DirectPositionType">
<simpleContent>
<extension base="gml:doubleList">
<attributeGroup ref="gml:SRSReferenceGroup" />
</extension>
</simpleContent>
</complexType>
Binding
<jaxb:bindings schemaLocation="http://schemas.opengis.net/gml/3.2.1/geometryBasic0d1d.xsd" node="/xs:schema">
<jaxb:bindings multiple="true" node="//xs:complexType[@name='DirectPositionType']">
<jaxb:property>
<jaxb:baseType name="java.math.BigDecimal" />
</jaxb:property>
</jaxb:bindings>
</jaxb:bindings>
resulting Java class:
public class DirectPositionType
{
@XmlValue
protected List<BigDecimal> value;
@XmlAttribute(name = "srsName")