Monday, 15 September 2014

JAXB - an element with unbounded maxOccurs inside an xsd:all



Suppose I have the following java class that maps to the request-body of my REST service to search users.



@XmlRootElement(name = "SearchParams")
@XmlType(propOrder = {})
public class SearchParams {

private String firstname;
private String lastname;
private List<String> role;

...
}


Note the propOrder parameter of the @XmlType annotation - it declares that the order in which representing individual attributes appear in an XML file does not matter and thus an xsd:all should be used instead of xsd:sequence in the generated XSD schema.


However, as you can see, one of the attributes (the role attribute) is a list and thus corresponds to an element with an unbounded maxOccurs.


It seems that an element with an unbounded maxOccurs is not allowed within an xsd:all complexType. How do I avoid this problem?


Note that, unlike role, the firstname and lastname have maxOccurs of 1. I therefore cannot use an unbounded xsd:choice instead of xsd:all either.


No comments:

Post a Comment