Given the XML schema in this example, the figure below illustrates the mapping of a Java collection to elements in a corresponding XML document, using a grouping element to organize the elements of the collection.

Given the XML schema in this exmaple, the figure below illustrates a mapping to an '''xsd:list''' type in a corresponding XML document. Using this mapping, you can represent the collection of simple Java objects as a '''String''' of white space delimited tokens in XML. Here, the '''tasks''' list contains three entries: "Design", "Code" and "Test".

+

−

+

−

<source lang="xml">

+

−

<?xml version="1.0" encoding="UTF-8"?>

+

−

<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema">

+

−

+

−

<xsd:element name="employee" type="employee-type"/>

+

−

+

−

<xsd:complexType name="employee-type">

+

−

<xsd:sequence>

+

−

<xsd:element name="tasks" type="tasks-type"/>

+

−

</xsd:sequence>

+

−

</xsd:complexType>

+

−

+

−

<xsd:simpleType name="tasks-type">

+

−

<xsd:list itemType="xsd:string"/>

+

−

</xsd:simpleType>

+

−

+

−

</xsd:schema>

+

−

</source>

+

−

+

−

[[Image:dcxmstn.gif|XMLDirect Mapping to a List Field]]<br><br>

+

−

+

−

The example below shows how to annotate your Java class to obtain this mapping with EclipseLink.