I have a java class:
public class ActivityAddress {
@XmlElement(name = "Elem1", required = false)
private String elem1;
@XmlElement(name = "Elem2", required = false)
private String elem2;
@XmlElement(name = "PostIndex", required = true)
private String postIndex;
}
I want to get the circuit as follows:
<xs:complexType name="ActivityAddress">
<xs:sequence>
<xs:choice minOccurs="0">
<xs:element name="Elem1" type="xs:string"/>
<xs:element name="Elem2" type="xs:string"/>
</xs:choice>
<xs:element name="PostIndex" type="xs:string"/>
</xs:sequence>
Thus, both the “Elem1” and “Elem2” fields should be in selection.
A solution like this:
@XmlElements({
@XmlElement(name = "Elem1", type = String.class, required = false),
@XmlElement(name = "Elem2", type = String.class, required = false)
})
private String elem;
not suitable for me, because in a java class I need both fields.
But can I do this? Can anybody help?
source
share