I have a simple class that I need to sort. The class is declared as:
@XmlRootElement public class XMLUser...
Here is what I get:
<?xml version="1.0" encoding="UTF-8" standalone="yes"?> <xmlUser> <login>myLogin</login> <password>myPass</password> <role name="role1"/> <role name="role2"/> <role name="role3"/> </xmlUser>
Now I want to have several users in one file, but without the need to create a wrapper class myself, kind of like using @XmlElementWrapper, but for a class instead of a field. I do not know if this is possible.
So that I can sort the list (or some object provided by jaxb) and I could get this XML code (the <users> generated automatically):
<?xml version="1.0" encoding="UTF-8" standalone="yes"?> <users> <xmlUser> <login>login1</login> <password>pass2</password> <role name="role1"/> <role name="role2"/> </xmlUser> <xmlUser> <login>login2</login> <password>pass2</password> <role name="role1"/> <role name="role3"/> </xmlUser> </users>
Any help is appreciated.
source share