I have a predefined XSD that looks as follows:
<xs:element name="JavaClass1">
<xs:complexType>
<xs:sequence>
...
<xs:element name="Date1" type="xs:date" minOccurs="0">
</xs:element>
<xs:element name="DateList1" type="xs:date" minOccurs="0" maxOccurs="5">
</xs:element>
...
</xs:sequence>
</xs:complexType>
</xs:element>
In order to generate Java classes from XSD and at the same time replace XMLGregorianCalendar with java.util.Date
, I used the following external binding:
<globalBindings>
<javaType
name="java.util.Date"
xmlType="xs:dateTime"
parseMethod="XsdDateTimeConverter.unmarshal"
printMethod="XsdDateTimeConverter.marshalDateTime"
/>
<javaType
name="java.util.Date"
xmlType="xs:date"
parseMethod="XsdDateTimeConverter.unmarshal"
printMethod="XsdDateTimeConverter.marshalDate"
/>
</globalBindings>
I found this solution here.
Now, I need to do this only for the attribute Date1 and not for DateList1. Is there a way how to exclude DateList1 by using it's property maxOccurs="5"
?
You can apply the javaType
customization locally to the generated property. Something like:
<bindings node=".../xs:element[@name='Date1']">
<property>
<baseType>
<javaType .../>
</baseType>
</property>
</bindings>