Hi.
I am trying to define a list of complex elements, specifically, an Action
that contains some Fields.
My schema definitions are as follows:
<xs:complexType name="Field">
*
<xs:sequence>
*
<xs:element *ref*="FieldName"/>
<xs:element name="FieldValue" type="xs:string"/>
*
</xs:sequence>
*
</xs:complexType>
<xs:complexType name="Action">
*<xs:sequence>*
<xs:element name="ActionName" type="ActionName"/>
<xs:element name="ActionCode" type="ActionCode"/>
<xs:element name="FieldsList" type="Field" minOccurs="0"
maxOccurs="unbounded"/>
*
</xs:sequence>
*
</xs:complexType>
Jaxb maps this into an Action class that has a getFieldsList() method,
returning a List<Field> , which is exactly what i want.
The problem is that in the resulting XML, I get this:
<Action>
* <FieldsList>*
<FieldName>
<FieldValue>
* <FieldsList>*
<FieldName>
<FieldValue>
* <FieldsList>*
<FieldName>
<FieldValue>
</Action>
While I expect:
<Action>
* <Field>*
<FieldName>
<FieldValue>
*<Field>*
<FieldName>
<FieldValue>
* <Field>*
<FieldName>
<FieldValue>
</Action>
Of course if i change the Action definition to
<xs:element name="Field" type="Field" minOccurs="0" maxOccurs="unbounded"/>
I get a function getField() which returns a List<Field>, and this is not
reasonable.
Is there anyway to get this to work as I expect?
Thanks.
Ofira.