I have the following XSD defined to generate some jaxb objects. It works well.
<xsd:element name="Person" type="Person" />
<xsd:complexType name="Person">
<xsd:sequence>
<xsd:element name="Id" type="xsd:int" />
<xsd:element name="firstName" type="xsd:string" />
<xsd:element name="lastName" type="xsd:string" />
</xsd:sequence>
</xsd:complexType>
<xsd:element name="People">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="Person" minOccurs="0" maxOccurs="unbounded"
type="Person" />
</xsd:sequence>
</xsd:complexType>
</xsd:element>
I use Spring RowMapper to map the rows from my database into Person objects. So, I end up with a List<Person> object, which is not a People object. I People object has a List<Person> internally.
Then in my Jersey resource class I have:
@GET
@Path("/TheListOfPeople")
public List<Person> getListOfPeople() {
List<Person> list = dao.getList();
return list;
}
The XML which is returned is:
<?xml version="1.0" encoding="UTF-8" standalone="yes" >
<people>
<Person>...</Person>
<Person>...</Person>
<Person>...</Person>
<Person>...</Person>
</people>
My question is how is it making the mapping to from List<Person> to People in the XML. Also, The element is "People" (capital P) not "people" (lowercase P). Seems like it's not really using the XSD at all.
EDIT This is somehow related to this question: http://stackoverflow.com/questions/1545041