jaxb xs:element ignore empty list



i have a schema file like



<xs:complexType name="Autorisation">
<xs:sequence>
<xs:element name="roles" type="Roles"/>
</xs:sequence>
</xs:complexType>

<xs:complexType name="Roles">
<xs:sequence>
<xs:element name="role" type="Role" maxOccurs="unbounded" />
</xs:sequence>
</xs:complexType>

<xs:complexType name="Role">
<xs:sequence>
<xs:element name="type" type="xs:int"/>
<xs:element name="dateDebut" type="xs:dateTime"/>
<xs:element name="dateFin" type="xs:dateTime"/>
</xs:sequence>
</xs:complexType>


it generate something like that :



@XmlElementWrapper
@XmlElement(name = "role")
protected List<Role> roles;


When i create an xml file with JAXB.marshal(input, Output); with an empty roles list, the xml file generated contains <role/>


How can i avoid that ?


Thanks !! :)


No comments:

Post a Comment