JAXB Schemagen (v. 7.0.450.18): change XmlElement name and XmlType(propOrder={...})

1k Views Asked by At

i am struggling a bit with the autmATED generation of XSD files with schemagen. First of all i have to tell, that i am working for a project at university and must not change anything in the code of my java classes but the annotations...

So, basically what i have to do is to rename some of my XmlElements and have to bring them into a certain Order. I thought, i could solve this like that:

@XmlType(propOrder = { "email", "id", "name", "publication" })
public class Author {
   ...
   private List<Publication> publications = new LinkedList<>();
   ...
   @XmlElement(name = "publication")
   public List<Publication> getPublications() {
    return publications;
}
   public void setPublications(List<Publication> publications) {
    this.publications = publications;
} 

The default value of XmlAccessorType is @XmlAccessorType(XmlAccessType.PUBLIC_MEMBER). But when I try to generate the XML Schema using schemagen (in Eclipse and on the command line...), i get the following errors:

Property publications is present but not specified in @XmlType.propOrder

and

Property publication appears in @XmlType.propOrder, but no such property exists. Maybe you meant publications?

So, to me this sounds a bit contradictory cause it seems like schemagen is completly ignoring what i specified... can anybody tell me where the problem is??

Thanks a lot!

1

There are 1 best solutions below

2
bdoughan On

propOrder is based on the mapped field/property name and not the name of the XML attribute or element.