Hi,
I have grasped the basics of Jaxb but am stuck describing my XML structure to Jaxb in a schema. It concerns the <segment> tag in the following XML file:
<?xml version="1.0"?>
<screen id="name" numoffields="2">
<fields>
<field id="field1" editlength="8"/>
<field id="field2" editlength="8"/>
</fields>
<keys>
<key id="key1" length="8">
<segment id="segment1"/>
<segment id="segment2"/>
</key>
<key id="key2" length="8">
<segment id="segment1"/>
<segment id="segment2"/>
</key>
</keys>
</screen>
The <segment> tag is not surrounded by a <segments> tags like <field> is surrounded by a <fields> tag.
How to I get the <segment> tags to be placed in a list in the <key> class/object? I keep on getting various jaxb compile errors with all my trials.
best regards,
Peter
My current xsd file (without trying to include <segment> in key.):
<?xml version="1.0"?>
<xsd:schema xmlns:xsd="
http://www.w3.org/2001/XMLSchema"
xmlns:jxb="
http://java.sun.com/xml/ns/jaxb"
jxb:version="1.0">
<xsd:element name="screen" type="Screen2"/>
<xsd:complexType name="Screen2">
<xsd:sequence>
<xsd:element name="fields" type="Fields"/>
<xsd:element name="keys" type="Keys"/>
</xsd:sequence>
<xsd:attribute name="id" type="xsd:string" use="required"/>
<xsd:attribute name="numoffields" type="xsd:int" use="required"/>
</xsd:complexType>
<xsd:complexType name="Fields">
<xsd:annotation>
<xsd:appinfo>
<jxb:property
collectionType="java.util.ArrayList"
/>
</xsd:appinfo>
</xsd:annotation>
<xsd:sequence>
<xsd:element name="field" minOccurs="1" maxOccurs="unbounded">
<xsd:complexType>
<xsd:attribute name="id" type="xsd:string" use="required"/>
<xsd:attribute name="editlength" type="xsd:int" use="required"/>
<xsd:attribute name="visible" type="xsd:boolean" default="true"/>
</xsd:complexType>
</xsd:element>
</xsd:sequence>
</xsd:complexType>
<xsd:complexType name="Keys">
<xsd:annotation>
<xsd:appinfo>
<jxb:property
collectionType="java.util.ArrayList"
/>
</xsd:appinfo>
</xsd:annotation>
<xsd:sequence>
<xsd:element name="key" minOccurs="0" maxOccurs="unbounded">
<xsd:complexType>
<xsd:attribute name="id" type="xsd:string" use="required"/>
<xsd:attribute name="length" type="xsd:int" use="required"/>
<xsd:attribute name="searchable" type="xsd:boolean" default="true"/>
</xsd:complexType>
</xsd:element>
</xsd:sequence>
</xsd:complexType>
<xsd:complexType name="Segment">
<xsd:attribute name="id" type="xsd:string" use="required"/>
<xsd:attribute name="length" type="xsd:int" default="0"/>
default="true"/>
</xsd:complexType>
</xsd:schema>