Jeff:

I have done what you have described on a project I completed just last week.
As it turns out, it's quite straightforward. In my case I used a mixture of
'generated' and hand-coded java classes. I ended up manually modifying some
of the extended classes, and creating derived classes. In order to get
Castor to map xml to the derived classes, you simply need to alter the
mapping.xml file that describes the relatationships between between XML tags
and attributes and Java classes and properties. The mapping.xml file
contents and usage are fairly well documented.

For example: The following mapping.xml entry maps the XML tag
"OTA_MultipleAirlineAvailRS" to the java class named
"com.get2hawaii.grs.ota.availability.OTA_MultipleAirlineAvailRS", which
extends from "com.get2hawaii.grs.ota.OtaResponse" (which has it's own
mapping entry not shown here). The mapping scheme gives you the ability to
directly represent a class hierarchy, or simply setting up the 'children'
without any explicit relationship, whichever works best for you case.

<class name="com.get2hawaii.grs.ota.availability.OTA_MultipleAirlineAvailRS"
extends="com.get2hawaii.grs.ota.OtaResponse">
    <map-to xml="OTA_MultipleAirlineAvailRS"/>
    <field name="OriginDestinationGrp"
type="com.get2hawaii.grs.ota.availability.OriginDestinationGrp"
collection="array"></field>
    <field name="ApplicationErrorGrp"><bind-xml name="ApplicationErrorGrp"
node="element"/></field>
    <field name="RoundTrip"
type="com.get2hawaii.grs.ota.availability.RoundTrip" collection="array"
get-method="getRoundTripArray"></field>
</class>


Let me know if you have any further questions. I'd be more than happy to
help.

Best regards,

Tom Drake (debugger at engineer.com)


----- Original Message -----
From: "Jeff Norris" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Monday, October 15, 2001 10:32 AM
Subject: [castor-dev] Castor, JAXB, and the 2003 NASA Mars Exploration Rover
Mission


| Hi,
|
| My name is Jeff Norris, and I am an operations software developer for
NASA's
| 2003 Mars Exploration Rover mission.  I am considering using a Java/XML
binding
| system in the software that the mission scientists and engineers use each
day to
| direct the rover's actions on Mars.  I am currently deciding whether
Castor or
| JAXB fits my needs best.
|
| After careful review, it is my opinion that Castor is superior to JAXB in
| numerous areas (schema support, maturity, no required base classes, etc.).
| Unfortunately, Castor seems to lack one capability found in JAXB that is
very
| important to me and other mission software developers.  I'm hoping that a
Castor
| developer or someone else on this list can show me that this capability
DOES
| actually exist in Castor because that would make my decision between
Castor and
| JAXB very easy.
|
| Here is a description of the feature in JAXB that seems to be missing in
Castor:
|
| After generating java classes from a DTD, JAXB allows a developer to
extend
| these classes to provide application-specific functionality (additional
methods
| for modifying or displaying the data, for instance).  The developer can
then
| instruct JAXB to instantiate these EXTENDED versions of the automatically
| generated classes when unmarshalling an XML document.  In other words, the
JAXB
| source generator creates a java class called "Foo", which I extend in a
new
| class called "Bar".  I can instruct JAXB that when it unmarshalls an XML
element
| that would have mapped to "Foo", it should instead create a "Bar".
|
| A more detailed explanation and a usage example of this functionality is
| provided in the JAXB User Guide, Chapter 6: "Working With the Data",
Subsection
| "Extending the Derived Classes".  The JAXB user guide is located at
| http://java.sun.com/xml/jaxb/jaxb-docs.pdf.
|
| It seemed to me that I might be able to accomplish this in Castor using
the
| mapping schema, but another Castor user (Bernhard Haumacher) reported that
he
| was unable to get this to work in a message to the castor-dev mailing list
a few
| weeks back (http://castor.exolab.org/list-archive/msg10674.html).  If the
| mapping schema will in fact allow me to do this, could someone please
provide an
| example or explain what was wrong with Bernhard's mapping schema?
|
| Thank you for your time,
|
| Jeff Norris
| NASA Jet Propulsion Laboratory
| California Institute of Technology
|
| -----------------------------------------------------------
| 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

Reply via email to