can someone give an example of an application where the 'element' generation method would be more appropriate than the 'type' generation method? since 'element' is the default, i would assume it's the more common case.
i think it might depend on the style one adopts for writing schemas. in the 'russian doll' approach where all element structures are defined 'inline', there would never be more than one element definition of that type and so the 'element' generation method would be more appropriate [is my guess]. / eitan ----- Original Message ----- From: "Arnaud Blandin" <[EMAIL PROTECTED]> To: <[EMAIL PROTECTED]> Sent: Wednesday, October 23, 2002 1:23 AM Subject: Re: [castor-dev] trying to understand certain srcgenerator fundamentals.. > Hi Eitan, > > You can find a detailed answer in the Source Generator user > Documentation to that question. > When generating source from a schema you can adopt 2 different points of > view: > 1- you want to generate sources that map the XML INSTANCE of the XML > Schema > 2- you want to generate sources that map the XML Schema itself and > not the instance. > > These two different approaches are reflected in Castor by the 'element' > and 'type' generation methods. > > On one hand, when you use the 'element' method you basically say: > "Generate a class per element" which means "each element that is going > to appear in my XML Schema will correspond to an instance of a class > generated for that element". Since we are generating sources from the > instance point of view, classes generated for complexTypes are abstract > since you can use a complexType directly in the XML instance document. > Those classes are the base of the element classes which is > understandable. > > On the other hand, the 'type' method will try to reflect the XML Schema > structure to render it into an Object Model. In that case, a java class > is a complexType and an element is just an instance of that complexType. > > > When generating sources, you have to decide which method is the best for > you, you have to answer the question: what do I want to represent? Don't > forget also that using the 'type' method generally reduce the number of > generated classes. > > Hope that helps, let me know if you need further information, > > Arnaud > > > -----Original Message----- > > From: Eitan Suez [mailto:eitan@;uptodata.com] > > Sent: Wednesday, October 23, 2002 7:50 AM > > To: [EMAIL PROTECTED] > > Subject: [castor-dev] trying to understand certain srcgenerator > > fundamentals.. > > > > hi, > > > > sample schema: > > <xsd:element name="us-address" type="us-address-type" /> > > > > <xsd:complexType name="us-address-type"> > > <xsd:sequence> > > <xsd:element name="addr1" type="xsd:string" /> > > <xsd:element name="addr2" type="xsd:string" /> > > <xsd:element name="city" type="xsd:string" /> > > <xsd:element name="state" type="state-code" /> > > <xsd:element name="zip" type="zip-code" /> > > </xsd:sequence> > > </xsd:complexType> > > > > running the sourcegenerator, the generated java class for > > us-address-type (UsAddressType) is designated abstract while a > > separate > > UsAddress.java file is generated that extends it. > > > > this does not make sense to me. to me the element is an instance > > and the complexType is the class. i was expecting a single class, > > not two. > > > > matters get complicated when i introduce a new class, say "Shipment" > > with a from-address and to-address of type "us-address-type". now i > > have > > three classes UsAddress, FromAddress, and ToAddress all "extending" > > a single type! this is terrible because i can't instantiate a > > UsAddressType > > and assign it to a FromAddress or ToAddress. > > > > so i must conclude there's something fundamental that i don't get > > about > > the sourcegenerator. > > > > would anyone care to explain what i'm doing wrong? > > > > thanks! eitan > > > > / eitan > > > > ----------------------------------------------------------- > > 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 > ----------------------------------------------------------- If you wish to unsubscribe from this mailing, send mail to [EMAIL PROTECTED] with a subject of: unsubscribe castor-dev
