Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

JAXB Compiler and Attribute Order [duplicate]

I would like to control the attribute order in .java files generated by the JAXB compiler.

I'm aware that attribute order is not important for xml validation. The order is important for textual comparison of marshalled xml in a regression test environment. The order of attributes in a file directly affects the order of the attributes in marshalled xml tags.

Every time the JAXB compiler is run attribute groups appear in a different order, even with no changes to the schema. There is no apparent option available on the compiler to prevent this behavior.

I would like to avoid running a post-compilation script to alphabetically reorder attributes in the generated .java files since this breaks up the attribute groups, but I'm not sure there is another option.

Any suggestions are much appreciated.

Thanks, Dave

like image 543
daveg Avatar asked Nov 30 '09 19:11

daveg


1 Answers

Apparently, in JAXB 2.0 you can use the annotation @XmlAccessorOrder or @XmlType(propOrder=)

like image 118
Juan Domínguez Avatar answered Oct 18 '22 05:10

Juan Domínguez