Hi,
I have a set of existing java classes that should be persisted to XML. So far the mapping
is working as expected. The only thing I failed to figure out by myself is how to specify
that a list property like the one below should be manditory.
@XmlElements({
@XmlElement( name="stringProperty", type=StringProperty.class ),
@XmlElement( name="integerProperty", type=IntegerProperty.class ),
@XmlElement( name="containerProperty", type=ContainerProperty.class )
})
@XmlElementWrapper( name="containedProperties" )
@Override
public Set<Property> getValue() { ... }
At the moment schemagen creates this XML:
<xs:element name="containedProperties" minOccurs="0">
<xs:complexType>
<xs:choice maxOccurs="unbounded" minOccurs="0">
<xs:element name="stringProperty" type="stringProperty"/>
<xs:element name="integerProperty" type="integerProperty"/>
<xs:element name="containerProperty" type="containerProperty"/>
</xs:choice>
</xs:complexType>
</xs:element>
What I want is that the <containedProperties/> tag is manditory and must contain at least
one element. With the @XmlElement annotation I can just define the Bean property as
required. How do I do this with @XmlElements and @XmlElementWrapper?
Thanks
-Tim