I am sorry, I should have also given the mapping file. Here it is:

<?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="Data">
        <map-to xml="Data"/>
        <field name="test" type="types.USStates">
            <bind-xml name="test" node="element"/>
        </field>
    </class>

    <class name="EnumTest">
        <map-to xml="enumTest"/>
        <field name="Data" type="Data">
            <bind-xml name="data" node="element"/>
        </field>
    </class>

</mapping>




And the xml:

<enumTest>
    <data>
        <test>AK</test>
    </data>
</enumTest>


Thanks for your help,


Ramesh.

-----Original Message-----
From: Ramesh Bobba [mailto:[EMAIL PROTECTED]] 
Sent: Monday, October 08, 2001 11:07 AM
To: [EMAIL PROTECTED]
Subject: Re: [castor-dev] unmarshalling subnodes


I tried setting the mapping and it gave the following error. Maybe it
will help you, I did not understand what it meant:

java.lang.IllegalStateException: Java schema change: Class
types.USStates can no longer be constructed: types.USStates{file: [not
available]; line: 5; column: 9}

Thanks,

Ramesh.

-----Original Message-----
From: Arnaud Blandin [mailto:[EMAIL PROTECTED]] 
Sent: Monday, October 08, 2001 11:02 AM
To: [EMAIL PROTECTED]
Subject: Re: [castor-dev] unmarshalling subnodes


Hi Ramesh,

have you set the mapping for the unmarshaller? (unmar.setMapping())

Arnaud

-> -----Original Message-----
-> From: Keith Visco [mailto:[EMAIL PROTECTED]]
-> Sent: Monday, October 08, 2001 10:58 AM
-> To: [EMAIL PROTECTED]
-> Subject: Re: [castor-dev] unmarshalling subnodes
-> 
-> 
-> 
-> Hi Ramesh,
-> 
-> Please include a sample of your mapping file and object model.
-> 
-> Thanks,
-> 
-> --Keith
-> 
-> Ramesh Bobba wrote:
-> > 
-> > Hi,
-> > 
-> > I tried you suggestion and got the same output. Is there
-> anything else I
-> > can try? It is asthough the Data element is not even recognized.
-> > 
-> > Thanks in advance,
-> > 
-> > Ramesh.
-> > 
-> > -----Original Message-----
-> > From: Keith Visco [mailto:[EMAIL PROTECTED]]
-> > Sent: Monday, October 08, 2001 10:45 AM
-> > To: [EMAIL PROTECTED]
-> > Subject: Re: [castor-dev] unmarshalling subnodes
-> > 
-> > Hi Ramesh,
-> > 
-> > It's probably not unmarshalling properly because your mapping file
-> > is not being used because you are calling one of the "static" 
-> > unmarshal methods.
-> > 
-> > I suggest changing the following:
-> > 
-> > >  // 2. Unmarshal the data
-> > >  Unmarshaller unmar = new Unmarshaller(EnumTest.class);  EnumTest

-> > > enumTest = (EnumTest)unmar.unmarshal(EnumTest.class, new
-> > > InputSource(new FileReader(args[1])));
-> > 
-> > to:
-> > 
-> > >  // 2. Unmarshal the data
-> > >  Unmarshaller unmar = new Unmarshaller(EnumTest.class);  EnumTest

-> > > enumTest = (EnumTest)unmar.unmarshal(new InputSource(new
-> > > FileReader(args[1])));
-> > 
-> > Notice the signature of the unmarshal method.
-> > 
-> > Thanks,
-> > 
-> > --Keith
-> > 
-> > Ramesh Bobba wrote:
-> > >
-> > > Hi,
-> > >
-> > > When I try to unmarshal the following xml:
-> > >
-> > > <enumTest>
-> > >         <data>
-> > >                 <test>AK</test>
-> > >         </data>
-> > > </enumTest>
-> > >
-> > > I always get the value for  <test> to be null. I do a
-> > > enumTest.getData().getTest() and it is null. If I want to marshal

-> > > it back, I get <enumTest>
-> > >     <data/>
-> > > </enumTest>
-> > >
-> > > Can you please help me.
-> > >
-> > > Thanks,
-> > >
-> > > Ramesh.
-> > >
-> > > The code snippet:
-> > >
-> > > import org.exolab.castor.mapping.Mapping;
-> > > import org.exolab.castor.mapping.MappingException;
-> > >
-> > > import org.exolab.castor.xml.Unmarshaller;
-> > > import org.exolab.castor.xml.Marshaller;
-> > >
-> > > import java.io.IOException;
-> > > import java.io.FileReader;
-> > > import java.io.OutputStreamWriter;
-> > >
-> > > import org.xml.sax.InputSource;
-> > > import types.*;
-> > >
-> > > public class EnumTestDriver {
-> > >
-> > >     public static void main(String args[]) {
-> > >
-> > >         Mapping      mapping = new Mapping();
-> > >
-> > >         try {
-> > >             if (args.length < 2) {
-> > >                 System.err.println("Usage java EnumTestDriver
-> > > <mapping.xml> <source.xml>");
-> > >                 System.exit(0);
-> > >             }
-> > >
-> > >             // 1. Load the mapping information from the file
-> > >             mapping.loadMapping( args[0] );
-> > >
-> > >             // 2. Unmarshal the data
-> > >             Unmarshaller unmar = new
Unmarshaller(EnumTest.class);
-> > >             EnumTest enumTest =
-> > > (EnumTest)unmar.unmarshal(EnumTest.class, new InputSource(new 
-> > > FileReader(args[1])));
-> > >
-> > >             // 3. Do some processing on the data
-> > >             Data d = enumTest.getData();
-> > >             System.out.println("Test value: " + d.getTest());
-> > >             d.setTest(types.USStates.AR);
-> > >             System.out.println("Test value: " + d.getTest());
-> > >             enumTest.setData(d);
-> > >
-> > >             // 4. marshal the data with the total price back
-> and print
-> > 
-> > > the XML in the console
-> > >             Marshaller marshaller = new Marshaller(new
-> > > OutputStreamWriter(System.out));
-> > >            // marshaller.setMapping(mapping);
-> > >             marshaller.marshal(enumTest);
-> > >
-> > >         } catch (Exception e) {
-> > >             System.out.println(e);
-> > >             return;
-> > >         }
-> > >     }
-> > > }
-> > >
-> > > -----------------------------------------------------------
-> > > 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

----------------------------------------------------------- 
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