Search code examples
javaschemaannotationsjaxbschemagen

JAXB ignoring XmlElement directives


I have a problem generating the schema for a class I have. What I have is:

@XmlRootElement

@XmlAccessorType(XmlAccessType.FIELD)

public Class User {

....

@XmlElement(required = true)

protected String name;

....

}

Now, when I generate the schema using schemagen the line refering to that attribute is:

<xs:element name="name" type="xs:string"/>

the minOcurrences attribute is missing, I don't know why it ignores the annotation, any help is greatly appreciated. Also on a separate and unrelated topic, why does schemagen complaint when my class is anotated with JPA annotations? Is there any workaround for this?


Solution

  • Sorry, how stupid of me, the default value for minOccur is 1.