Hi,
That's what I tried first. But if I do so (not using minOccurs="0"), I'm getting an 
Exception while marshalling to the XML file, as this file doesn't contain that element 
at the beginning.
You mentioned there's a difference referring to the creation of castor data objects if 
you use minOccurs="0" or minOccurs="1" in the XSD file. That's the point which I can't 
verify. In my generated class I still only have the instance variable of my child 
class which of course is being used in the setter and getter but I can't figure out 
where an instance of this child class should be created.

Thanks,
Reto Kummli



> -----Original Message-----
> From: "Gigu�re, Vincent" [mailto:[EMAIL PROTECTED]
> Sent: Dienstag, 1. Juni 2004 17:08
> To: '[EMAIL PROTECTED]'
> Subject: Re: [castor-user] Castor XML: Automatic Data Object Creation?
> 
> 
> I believe that by setting minOccurs="0", the parent 
> complex-type will, by
> default, not create any instance.
> 
> If you require at least one instance of the child complex 
> type, remove the
> minOccurs attribute or set it to 1.
> 
> I generated through an XSD and it worked fine, but I do not 
> specify the
> minOccurs attribute when I require at least one instance of a child
> complex-type.
> 
> Hope that helps.
> 
> Vincent Gigu�re
>  
> 
> -----Original Message-----
> From: Reto Kummli [mailto:[EMAIL PROTECTED] 
> Sent: 1 juin 2004 10:52
> To: [EMAIL PROTECTED]
> Subject: [castor-user] Castor XML: Automatic Data Object Creation?
> 
> Hi,
> 
> We use the Castor XML Code Generation tool to generate 
> classes to access our
> XML files (using an XSD file). We use those XML files to 
> store configuration
> data for our server application.
>  
> Our goal is: 
> After the initial creation of the XSD file or after 
> performing a change in
> the XSD file, we don't want either to adapt our XML file 
> manually nor to
> write/adapt the code to create instances of the (new) data objects,
> generated castor classes.
> 
> My question:
> Is there a way that castor automatically creates the data 
> objects using the
> default values given by the XSD file respectively using the default
> constructor for the appropriate classes ? 
> The creation of data object and initializing their attributs with the
> default values works well but as soon as we use complex-types 
> containing
> other complex-types, the created class does contain an 
> attribute to the the
> child complex-type but no object of that type is being created. But as
> mentioned, I don't want to program the creation of the whole 
> given data
> structure.
> 
> Example:
> ------------------------------------------------------------
> Extract from our XSD file:
> 
> <xs:complexType name="listenerType">
>   <xs:all>
>     <xs:element name="address" type="addrType" minOccurs="0"/>
>   </xs:all>
> </xs:complexType>
>  .
> 
> 

----------------------------------------------------------- 
If you wish to unsubscribe from this mailing, send mail to
[EMAIL PROTECTED] with a subject of:
        unsubscribe castor-user

Reply via email to