This is my xml model:
<train xmlns="http://www.example.org/train/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<routes>
<route>Route1</route>
<route>Route2</route>
</routes>
</train>
I would like to create an XSD that will give me the following java:
Train train = new Train();
train.getRoutes().add(new Route());
I have tried different designs, ie Venetian Blind, Russian Doll, Salami Slice, but the end result is always java like this:
Train train = new Train();
train.getRoutes().getRoute().add("Route1");
Here are the xsd docs I have tried so far:
Venetian Blind
<?xml version="1.0"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" attributeFormDefault="unqualified" elementFormDefault="qualified" targetNamespace="http://www.example.org/train/">
<xs:element xmlns:tra="http://www.example.org/train/" name="train" type="tra:trainType"/>
<xs:complexType name="routesType">
<xs:sequence>
<xs:element type="xs:string" name="route" maxOccurs="unbounded" minOccurs="0"/>
</xs:sequence>
</xs:complexType>
<xs:complexType name="trainType">
<xs:sequence>
<xs:element xmlns:tra="http://www.example.org/train/" type="tra:routesType" name="routes"/>
</xs:sequence>
</xs:complexType>
</xs:schema>
Russian Doll
<?xml version="1.0"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" attributeFormDefault="unqualified" elementFormDefault="qualified" targetNamespace="http://www.example.org/train/">
<xs:element name="train">
<xs:complexType>
<xs:sequence>
<xs:element name="routes">
<xs:complexType>
<xs:sequence>
<xs:element type="xs:string" name="route" maxOccurs="unbounded" minOccurs="0"/>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema>
Salami Slice
<?xml version="1.0"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" attributeFormDefault="unqualified" elementFormDefault="qualified" targetNamespace="http://www.example.org/train/">
<xs:element name="route" type="xs:string"/>
<xs:element name="routes">
<xs:complexType>
<xs:sequence>
<xs:element xmlns:tra="http://www.example.org/train/" ref="tra:route" maxOccurs="unbounded" minOccurs="0"/>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="train">
<xs:complexType>
<xs:sequence>
<xs:element xmlns:tra="http://www.example.org/train/" ref="tra:routes"/>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema>
Can anyone tell me what I am doing wrong?