I am compiling an XSD using xjc that includes the following type:
<xs:simpleType name="CPT-DateTime">
<xs:annotation>
<xs:appinfo>Can be specified as a integer number or as xs:dateTime</xs:appinfo>
</xs:annotation>
<xs:union memberTypes="xs:unsignedLong xs:dateTime"/>
</xs:simpleType>
The resulting classes that use this type are compiled with this element set as String, while I would prefer them to use XMLGregorianCalendar.
Is there a way to that would force xjc to pick the xs:dateTime member type over the String? I've seen how to do this for simple types but not unions.
I believe, what you've referenced should actually work for arbitrary simple types. Assuming
tns
is a declared prefix for the targen namespace in your schema, try the following mapping:However, I am not 100% sure.
Also check
xjc:javaType
.