Hi Scott,

I believe you need to remove the container="false", as your XML example
doesn't appear to have an extra level of element wrapping around the
FieldList. 

--Keith


Scott Sims wrote:
> 
> Hi Keith,
> 
> I have been investigating the problem further.  My code works with 0.9.3.19
> and 0.9.3.21 but not with 0.9.4 or 0.9.4.1.  I get the following exception
> message bubbled up "unable to find FieldDescriptor for 'MappedField' in
> ClassDescriptor of container-element".  MappedField is the first element in
> my incoming XML to be parsed.  Here's a snippet of the files involved:
> 
> This file sets up the mapping.  The below file loads with no problem.  The
> error occurs when I try to parse the message shown below the map.
> 
> <?xml version="1.0"?>
> <!DOCTYPE mapping PUBLIC "-//EXOLAB/Castor Object Mapping DTD Version
> 1.0//EN"
>                          "http://castor.exolab.org/mapping.dtd";>
> 
> <mapping>
>     <class name="bytestream.ByteStreamMapList">
>         <map-to xml="ByteStreamMapList"/>
> 
>         <field name="className_"
>                type="string"
>                get-method="getClassName"
>                set-method="setClassName">
>                <bind-xml name="ClassName" node="element"/>
>         </field>
> 
>         <field name="fieldList_"
> 
> type="com.argoneng.translation_server.Translator.bytestream.ByteStreamMap"
>                collection="arraylist"
>                get-method="getFieldList"
>                set-method="setFieldList"
>                container="false">
>                <bind-xml name="FieldList" node="element"/>
>         </field>
>     </class>
> 
>     <class name="bytestream.ByteStreamMap">
>         <map-to xml="ByteStreamMap"/>
> 
>         <field name="mappedField_"
>                type="string"
>                direct="false"
>                get-method="getMappedField"
>                set-method="setMappedField">
>                 <bind-xml name="MappedField" node="element"/>
>         </field>
> 
>         <field name="handler_"
>                type="bytestream.AbstractByteStreamFieldHandler"
>                direct="false"
>                get-method="getHandler"
>                set-method="setHandler">
>                 <bind-xml name="Handler" node="element"/>
>         </field>
> 
>         <field name="skipRequired_"
>                type="integer"
>                direct="false"
>                get-method="getSkipRequired"
>                set-method="setSkipRequired">
>                 <bind-xml name="Skip" node="element"/>
>         </field>
> 
>         <field name="length_"
>                type="integer"
>                direct="false"
>                get-method="getLength"
>                set-method="setLength">
>                 <bind-xml name="Length" node="element"/>
>         </field>
> 
>         <field name="embeddedClass_"
>                type="string"
>                direct="false"
>                get-method="getEmbeddedClass"
>                set-method="setEmbeddedClass">
>                 <bind-xml name="EmbeddedClass" node="element"/>
>         </field>
> 
>         <field name="container_"
>                type="boolean"
>                direct="false"
>                get-method="getContainer"
>                set-method="setContainer">
>                 <bind-xml name="Container" node="element"/>
>         </field>
> 
>     </class>
> 
>     <class name="bytestream.AbstractByteStreamFieldHandler">
>         <map-to xml="Handler"/>
> 
>     </class>
> 
> </mapping>
> 
> This is the first message that is being parsed...
> 
> <?xml version="1.0" encoding="UTF-8"?>
> <ByteStreamMapList>
>     <ClassName>MyMessage</ClassName>
>     <FieldList>
>         <MappedField>MessageId</MappedField>
>         <Handler
>             xsi:type="java:bytestream.UnsignedShortFieldHandler"
> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"/>
>         <Skip>0</Skip>
>     </FieldList>
> </ByteStreamMapList>
> 
> It appears to complain about the first element in <FieldList>.  The error
> comes out of the xerces parse as far as I can tell (from the
> Unmarshaller.unmarshal(InputSource) method).  Any ideas?
> 
> Thanks,
> Scott
> 
> -----Original Message-----
> From: Scott Sims [mailto:[EMAIL PROTECTED]]
> Sent: Friday, January 10, 2003 4:18 PM
> To: [EMAIL PROTECTED]
> Subject: Re: [castor-dev] Possible to Map a Flat XML Message to Multiple
> Objects?
> 
> Hi Keith,
> 
> I have upgraded to the latest CVS.  I had been using 0.9.3.19 with your
> patch for collections (bugzilla #1006).  After upgrading I now get the
> following error message...
> 
>  org.exolab.castor.mapping.MappingException: No collection handler for
> collection of type java.util.Collection
> 
> I believe the XML it is complaing about is:
> 
>         <field name="fieldList_"
> 
> type="com.argoneng.translation_server.Translator.bytestream.ByteStreamMap"
>                collection="arraylist"
>                get-method="getFieldList"
>                set-method="setFieldList"
>                container="false">
>                <bind-xml name="FieldList" node="element"/>
>         </field>
> 
> What has changed with the way collections are handled?
> 
> Thanks,
> Scott
> 
> -----Original Message-----
> From: Keith Visco [mailto:[EMAIL PROTECTED]]
> Sent: Thursday, January 09, 2003 6:22 PM
> To: [EMAIL PROTECTED]
> Subject: Re: [castor-dev] Possible to Map a Flat XML Message to Multiple
> Objects?
> 
> Hi Scott,
> 
> The following mapping file will work for you, but you'll need to be
> using the latest CVS which fixes an issue with container support
> (otherwise you'll probably get an endless-loop)
> 
> --Keith
> 
> == mapping.xml ==
> 
> <?xml version="1.0"?>
> <mapping>
>   <class name="MsgA">
>      <map-to xml="MsgA"/>
> 
>      <field name="data2" type="integer">
>         <bind-xml name="Data2" node="element"/>
>      </field>
> 
>      <field name="subMsg1" type="SubMsg1" container="true">
>         <bind-xml node="element"/>
>      </field>
> 
>      <field name="subMsg2" type="SubMsg2" container="true">
>         <bind-xml node="element"/>
>      </field>
> 
>      <field name="subMsg3" type="SubMsg3" container="true">
>         <bind-xml node="element"/>
>      </field>
> 
>   </class>
> 
>   <class name="SubMsg1">
>      <field name="data1" type="integer">
>         <bind-xml name="Data1" node="element"/>
>      </field>
>      <field name="data5" type="integer">
>         <bind-xml name="Data5" node="element"/>
>      </field>
>   </class>
> 
>   <class name="SubMsg2">
>      <field name="data3" type="integer">
>         <bind-xml name="Data3" node="element"/>
>      </field>
>   </class>
> 
>   <class name="SubMsg3">
>      <field name="data4" type="integer">
>         <bind-xml name="Data4" node="element"/>
>      </field>
>   </class>
> 
> </mapping>
> 
> Scott Sims wrote:
> >
> > Hi,
> >
> > I've searched the archives and haven't found a similar posting so here's
> the
> > question...
> >
> > I have a flat (1 level of depth) XML message coming in that needs to be
> > unmarshalled to a class that contains multiple other classes.  Of course,
> > only being 1 level deep the incoming XML has no concept of anything more
> > then 1 class.  For example:
> >
> > Incoming XML:
> >
> > <MsgA>
> >     <Data1>1</Data1>
> >     <Data2>2</Data2>
> >     <Data3>3</Data3>
> >     <Data4>4</Data4>
> >     <Data5>5</Data5>
> > </MsgA>
> >
> > Classes to be mapped to:
> >
> > public class MsgA {
> >    private int           data2;
> >    private SubMsg1 sub1;
> >    private SubMsg2 sub2;
> >    private SubMsg3 sub3;
> > }
> >
> > public class SubMsg1 {
> >     private int data1;
> >     private int data5;
> > }
> >
> > public class SubMsg2 {
> >     private int data3;
> > }
> >
> > public class SubMsg3 {
> >     private int data4;
> > }
> >
> > We would like the resulting objects to look like this once that XML is
> > unmarshalled:
> >
> > MsgA
> >     data2 = 2
> >
> >     SubMsg1.data1 = 1;
> >     SubMsg1.data5 = 5;
> >
> >     SubMsg2.data3 = 3;
> >
> >     SubMsg3.data4 = 4;
> >
> > Is it possible to go from a flat message like that to a multiple layer
> > object?
> >
> > Thanks,
> >
> > Scott
> >
> > -----------------------------------------------------------
> > 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
> 
> -----------------------------------------------------------
> 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