Bruce Snyder
Thu, 27 Jan 2005 11:05:22 -0800
On Thu, 27 Jan 2005 11:41:27 -0500, Paul Grillo <[EMAIL PROTECTED]> wrote: > > I would really appreciate some help on this, i'm sort of up against it. any > help would be "greatly" appreciated... > > I have a fairly complex schema that i'm generating java for. I have > flexibility to change the schema, write binding files, or whatever. I guess > i'm having a problem understanding how to get the source generator to do > what i think is fairly straightforward. > > I have reproduced this as simply as possible: > > The schema/object model contains the following: > > VehicleTitle (top level element), contains an Owner, Registrant, and a Lien. > The Lien contains a LienID and a Lienholder. Owner, Registrant, and > Lienholder are all the same type (Party). > > So what i'm hoping to get is (more or less) are classes representing > VehicleTitle, Party, Lien. With getter/setters for > Owner/Registrant/Lienholder of type Party. It would seem to me that what i' > m asking for are classes for only the top level elements or complex types. > > However i get classes for Lienholder, Registrant, Owner (all derived from > PartyType). This is problematic. In my realworld schema I have the Party > Object used in many many places and can't afford to have classes generated > for every element that references it. > > Is there a way to acheive my objective? Different approach to the schema? > If i need entries in the binding file (i've tried a few), please please > somebody provide me with the simple example as it is not clear (to me > anyway) how to achieve it there.
Paul,
Please see the docs on Class Creation/Mapping available here:
http://www.castor.org/sourcegen.html#Class-Creation/Mapping
In order to get what you want, your schema needs to be defined to
facilite this. By wrapping your <complexType>s in an <element> you
should get what you want. Below is the fixed up schema that should
work for you:
<?xml version="1.0" encoding="UTF-8"?>
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:bulk="urn:trivininc.com/bulk" targetNamespace="urn:trivininc.com/bulk"
elementFormDefault="qualified" attributeFormDefault="unqualified">
<xsd:element name="VehicleTitle">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="Owner" type="bulk:Party"/>
<xsd:element name="Registrant" type="bulk:Party"/>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
<xsd:element name="Lien">
<xsd:complexType>
<xsd:all>
<xsd:element name="LienID" type="xsd:string"/>
<xsd:element name="Lienholder" type="bulk:Party"/>
</xsd:all>
</xsd:complexType>
</xsd:element>
<xsd:element name="Party">
<xsd:complexType>
<xsd:all>
<xsd:element name="LastName" type="xsd:string"/>
<xsd:element name="FirstName" type="xsd:string"/>
</xsd:all>
</xsd:complexType>
</xsd:element>
</xsd:schema>
HTH
Bruce
--
perl -e 'print unpack("u30","<0G)[EMAIL
PROTECTED]&5R\"F9E<G)E=\$\!F<FEI+F-O;0\`\`");'
The Castor Project
http://www.castor.org/
Apache Geronimo
http://geronimo.apache.org/
-----------------------------------------------------------
If you wish to unsubscribe from this mailing, send mail to
[EMAIL PROTECTED] with a subject of:
unsubscribe castor-dev