...">

Hyperjaxb: exclude XML element by XML property

I have a predefined XSD that looks like this:

<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>

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 Date1 attribute , not for DateList1 . Is there a way to exclude DateList1 using its property maxOccurs="5"?

+4
source share
1 answer

javaType . - :

<bindings node=".../xs:element[@name='Date1']">
    <property>
        <baseType>
            <javaType .../>
        </baseType>
    </property>
</bindings>
0

All Articles