Stephen,
  Thanks for the help, that did work.  But as I expand the xml document
I run into the same problem but the solution you gave doesn't work once
I do that.  The fields continue to go into deeper levels and I get a
error saying "unable to find Field Descriptor for "OPLAN" in
ClassDescriptor of defenseDesignDocument  Here is the expanded xml
document:
<MDADocument>
    <DesignDocument>
        <documentName>JDP Defense Design</documentName>
        <creationDate>2005-07-21T11:39:39</creationDate>
        <createdBy>JDP</createdBy>
        <OPLAN>
                <planId>-6048061182588210068</planId>
                <name>OIF</name>
        </OPLAN>
    </DesignDocument>
</MDADocument> 

This is the mapping file I am trying to use now:
<mapping>
   <class name="xml.plan.PlanData">
     <map-to xml="MDADocument" />

     <field name="documentName" type="string" >
       <bind-xml name="documentName" node="element"
                 location="defenseDesignDocument" />
     </field>

     <field name="creationDate" type="string" >
       <bind-xml name="creationDate" node="element"
                 location="defenseDesignDocument" />
     </field>

     <field name="createdBy" type="string" >
       <bind-xml name="createdBy" node="element"
                 location="defenseDesignDocument" />
     </field>

     <field name="classification" type="string" >
       <bind-xml name="classification" node="element"
                 location="defenseDesignDocument" />
     </field>
        <field name="OPLAN" type="string" >
                <bind-xml name="classification" node="element"
                                location="defenseDesignDocument" />
        </field>
        <field name="planID" type="string" >
                <bind-xml name="planID" node="element"
                                location="OPLAN" />
        </field>
        <field name="name" type="string" >
                <bind-xml name="name" node="element"
                                location="OPLAN" />
        </field>

   </class>
</mapping>

-----Original Message-----
From: Stephen Bash [mailto:[EMAIL PROTECTED] 
Sent: Friday, July 22, 2005 3:11 PM
To: [email protected]
Subject: Re: [castor-user] Xml mapping question

Jason-

I was able to unmarshal your xml example with a few minor changes to
your mapping file.  First, I added a <map-to xml="MDADocument" />
element inside of the <class name="xml.plan.PlanData"> element.  This
tells castor when it sees <MDADocument> at the root element, to use the
mapping specified for the class xml.plan.PlanData.

As far as the defenseDesignDocument is concerned, you can use the
location attribute in the bind-xml element to tell Castor that the extra
element exists.  The mapping document I had success with is below (note
the change in class names -- you'll need to set it back to fit your
class structure).

<mapping>
   <class name="castor.green.one.PlanData">
     <map-to xml="MDADocument" />

     <field name="documentName" type="string" >
       <bind-xml name="documentName" node="element"
                 location="defenseDesignDocument" />
     </field>

     <field name="creationDate" type="string" >
       <bind-xml name="creationDate" node="element"
                 location="defenseDesignDocument" />
     </field>

     <field name="createdBy" type="string" >
       <bind-xml name="createdBy" node="element"
                 location="defenseDesignDocument" />
     </field>

     <field name="classification" type="string" >
       <bind-xml name="classification" node="element"
                 location="defenseDesignDocument" />
     </field>
   </class>
</mapping>

HTH,
Stephen


Green, Jason M. wrote:
> Hey all,
>   I have a simple xml document that looks like this:
> <MDADocument>
>     <defenseDesignDocument>
>         <documentName>JDP Defense Design</documentName>
>         <creationDate>2005-07-21T11:39:39</creationDate>
>         <createdBy>JDP</createdBy>
>         <classification>UNKNOWN</classification>
>     </defenseDesignDocument>
> </MDADocument>
> 
> I map it with this xml document:
> <mapping>
>     <class name="xml.plan.PlanData">
> <field name="defenseDesignDocument" type="string" >
>         <bind-xml name="defenseDesignDocument" node="element"/>
>                 </field>
> 
>         <field name="documentName" type="string" >
>         <bind-xml name="documentName" node="element"/>
>                 </field>
>         <field name="creationDate" type="string" >
>         <bind-xml name="creationDate" node="element"/>
>         </field>
>         <field name="createdBy" type="string" >
>         <bind-xml name="createdBy" node="element"/>
>         </field>
>                 <field name="classification" type="string" >
>         <bind-xml name="classification" node="element"/>
>         </field>
>     </class>
> 
> For some reason it will not unmarshal.  I am assuming it is b/c of the

> defenseDesignDocument entry in the xml document.  I guess the 
> unmarshaller is looking for a value inside or something.  How can I 
> get by this?  I know that I will only have one entry for the 
> defenseDesignDocument in the xml document so I don't think an extra 
> class is necessary.  Or am I wrong.  How would any of you do it?
> 
> Thanks,
> Jason
> 
> 
> Jason Green
> Software Engineer
> Northrop Grumman MS
> [EMAIL PROTECTED]
> (540) 469-2407
> 

-------------------------------------------------
If you wish to unsubscribe from this list, please send an empty message
to the following address:

[EMAIL PROTECTED]
-------------------------------------------------


-------------------------------------------------
If you wish to unsubscribe from this list, please
send an empty message to the following address:

[EMAIL PROTECTED]
-------------------------------------------------

Reply via email to