Is there a way to get JAXB to generate a Collection instead of a List for a specific element?
For example, creating a book set for this xsd:
<xs:element name="Collection">
<xs:complexType>
<xs:sequence>
<xs:element name ="books">
<xs:complexType>
<xs:sequence>
<xs:element name="book" type="bookType" minOccurs="1" maxOccurs="unbounded"/>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:sequence>
Using the following bindings.xml
<jxb:bindings schemaLocation="schema.xsd">
<jxb:bindings node="//xs:element[@name='Shop']/xs:complexType/xs:sequence/xs:element[@name='books']">
<jxb:property collectionType="java.util.HashSet" />
</jxb:bindings>
</jxb:bindings>
A list of books with a concrete implementation of HashSet is generated:
List<Book> books = new HashSet<Book>();
source
share