I had a problem like this with a Choice structure : if any elements of a
choice structure have minOccurs = "1", they are considered as mandatory,
even if they are within a choice structure. The work-around is to declare
all elements of a choice structure with minOccurs = "0". I don't know if
this is a bug or a functionnality, though from a semantic point of view, it
seems a little strange.
John Ferguson Smart
----- Original Message -----
From: "Stefan Burkhardt" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Thursday, February 07, 2002 10:42 AM
Subject: [castor-dev] Marshal and Unmarshal the same document
> Hi,
>
> when I Marshal a Object which was generated with Castor and then try to
> Unmarshal the Document
> I get the Message "-error-if-this-is-used- is a required field."
>
> The problem is this xsd Fragment:
>
> <xsd:complexType name = "Family">
> <xsd:sequence>
> <xsd:element name = "Version" type = "xsd:integer"/>
> <xsd:choice>
> <xsd:element name = "PropertyScope" type = "tdx:Code"
> minOccurs = "0" maxOccurs = "unbounded">
> <xsd:annotation>
> <xsd:documentation>
> Code des Herstellers oder Suppliers als
> Verweis auf alle der Familie zugeordneten Properties
> </xsd:documentation>
> </xsd:annotation>
> </xsd:element>
> <xsd:element name = "PropertyUsage" minOccurs = "0"
> maxOccurs = "unbounded">
> <xsd:annotation>
> <xsd:documentation>
> Code des Herstellers oder Suppliers als
> Verweis auf alle der Familie zugeordneten Properties
> </xsd:documentation>
> </xsd:annotation>
> <xsd:complexType>
> <xsd:simpleContent>
> <xsd:extension base = "tdx:Code">
> <xsd:attribute name = "isOptional"
> default = "true" type = "xsd:boolean"/>
> </xsd:extension>
> </xsd:simpleContent>
> </xsd:complexType>
> </xsd:element>
> </xsd:choice>
> </xsd:sequence>
> </xsd:complexType>
>
>
> When I Marshall the Object it works fine. In the generated result-File
> there is one "Family" which has
> no "PropertyScope" and no "PropertyUsage". Which seem to be OK.
> But when I Unmarshal the File it says to me "-error-if-this-is-used- is
> a required field.". Which means
> that he is waiting for a "PropertyScope" or a "PropertyUsage" Element.
>
> Is there something wrong with the schema? Choice means that there have
> to be one element. - "PropertyScope"
> or "PropertyUsage". But their minOccur could be "0".
>
> regards,
> Stefan
>
> -----------------------------------------------------------
> If you wish to unsubscribe from this mailing, send mail to
> [EMAIL PROTECTED] with a subject of:
> unsubscribe castor-dev
-----------------------------------------------------------
If you wish to unsubscribe from this mailing, send mail to
[EMAIL PROTECTED] with a subject of:
unsubscribe castor-dev