JAXB 2 Maven plugin - Force java source generation, to use collection for child?



I have 2 complex types in a XSD file that I may not change. One has multiple children "filepath" occurrences and the other always has 1 "filepath" child.


JAXB generates either of these differently, one is put in a list of entities and the other is just the single JAXB entity. This is a problem for me, as I want JAXB to give me 2 equal classes for the sake of inheritance. (I am using JAXB inheritance plugin)


Is there a way to make JAXB generate the filepaths child property of the "EntitySingleFile" complextype as a list, perhaps using JAXB bindings?


These are the XSD definitions:



<xs:element name="EntitySingleFile">
<xs:complexType>
<xs:sequence>
<xs:element name="filePaths" type="bgl:FilePaths" minOccurs="1" maxOccurs="1"/>
</xs:sequence>
</xs:complexType>
</xs:element>


and



<xs:element name="EntityMultiFile">
<xs:complexType>
<xs:sequence>
<xs:element name="filePaths" type="bgl:FilePaths" minOccurs="1" maxOccurs="unbounded"/>
</xs:sequence>
</xs:complexType>
</xs:element>


This is what im currently getting from these XSD files:



@XmlRootElement(name = "EntitySingleFile")
public class EntitySingleFile
implements IDrawConfiguration
{
@XmlElement(required = true, type = FilePaths.class)
protected IFilePaths filePaths;
....


And for multifile:



@XmlRootElement(name = "EntityMultiFile")
public class EntityMultiFile
implements IDrawConfiguration
{
@XmlElement(required = true, type = FilePaths.class)
protected List<IFilePaths> filePaths;

No comments:

Post a Comment