Keith, the problem I had with the Castor converter was that it
complained about not having a default namespace. The DTD I was using is
available at www.rets.org (I added to it, but essentially, that's it).
It's the RETS DTD (for real estate transactions). I don't think it's
this particular DTD that gave castor DTD converter problems though.
Rick
Keith Visco wrote:
Hi Rick,
Any chance you could make a dummied down version of the DTD available,
I'd like to look into the problems with the Castor DTD converter.
Thanks,
--Keith
Rick Mangi wrote:
I love solving my own problems, thanks to the folks who offered to
help, but I figured it out. Here's the deal for anyone else who
encounters this oddity.
I created my schema by running the dtd through XMLSpy (I couldn't get
the castor dtd converter to work, it complained about default
namespaces. I saw a few postings about this but no solutions). Anyway,
it did a decent job, but created a few odd bits of code... in
particular:
<xs:element name="REAgents">
<xs:complexType>
<xs:sequence maxOccurs="unbounded">
<xs:element ref="REAgent"/>
</xs:sequence>
</xs:complexType>
</xs:element>
This will cause REAgents.java to be created with an ArrayList of
REAgentsItem objects which contain the REAgent objects.
Not what we want. In order to cause the REAgent objects to stored in
the collection in REAgents you have to do this (which is what you would
do by hand...)
<xs:element name="REAgents">
<xs:complexType>
<xs:sequence>
<xs:element ref="REAgent" maxOccurs="unbounded"/>
</xs:sequence>
</xs:complexType>
</xs:element>
Basically, you have to move the multiplicity to the element, not the
sequence. This is obvious now that I figured it out. So I've gone
through the schema generated and fixed a bunch of this (along with some
other really funky stuff...) and it looks great.
Hope this helps somebody else sometime.
Rick
Rick Mangi wrote:
Hey all, sorry if this is a newbie question. I've been using castor for
a couple of weeks now and I like it a lot. I'm working with a very big
XML Schema which I just ran through the code generation engine. The
goal is to suck XML files in via Castor and then use Hibernate to put
the data into oracle (ya, I know, but we already use hibernate, and it
works).
The XML schema I'm using is big, and it generated a few hundred
classes. That's fine. But what is confusing me is the "Item" classes.
For example, this snippet:
<xs:element name="RETS">
<xs:complexType>
<xs:sequence minOccurs="0" maxOccurs="unbounded">
<xs:element ref="REData"/>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="REData">
<xs:complexType>
<xs:sequence>
<xs:element ref="REProperties" minOccurs="0"/>
<xs:element ref="REOffices" minOccurs="0"/>
<xs:element ref="REAgents" minOccurs="0"/>
<xs:element ref="REOfficeRosters" minOccurs="0"/>
<xs:element ref="REProspects" minOccurs="0"/>
<xs:element ref="REActivities" minOccurs="0"/>
<xs:element ref="REHistories" minOccurs="0"/>
<xs:element ref="REPublicRecords" minOccurs="0"/>
</xs:sequence>
</xs:complexType>
</xs:element>
Generated (among others) a mapping class RETSItem.java which seems to
just be a wrapper around the of REData objects. I'm not sure why this
collection isn't just a part of the RETS.java object. RETS.java is now
holding a collection of REItems which just has a single private field,
_REData.
There are literally dozens of these classes generated, and they seem to
serve no real purpose. I'm sure it makes the code generation easier,
but its going to make mapping to the database a nightmare.
is there any way to turn off this holder-class generation?
Thanks in advance,
Rick
----------------------------------------------------------- If you wish
to unsubscribe from this mailing, send mail to
[EMAIL PROTECTED] with a subject of:
unsubscribe castor-user
--
Rick Mangi
Director of Software Development
Bootstrap Software ( www.bootsoft.com )
408 West 14th Street, 2nd Floor / NY / NY 10014-1002
212.871.2020 ext 118 (desk) / 917.848.3619 (cell)
603.308.1252 (fax) / AIM: dotThink / Yahoo: rmangi
|
-----------------------------------------------------------
If you wish to unsubscribe from this mailing, send mail to
[EMAIL PROTECTED] with a subject of:
unsubscribe castor-user