I can find that attached file codes.zip at the bottom of my previous reply.
(http://www.nabble.com/file/p13601028/codes.zip)
Anywayz, I am pasting inline

CarDto.java
package com.cts.test.dest;

import java.util.List;

import com.cts.test.source.Car;
import com.cts.test.source.Tire;
import com.cts.test.source.TireImpl;

public class CarDto {

        private String make;
        private String model;
        private EngineDto engineDto;
        
        public EngineDto getEngineDto() {
                return engineDto;
        }
        public void setEngineDto(EngineDto engineDto) {
                this.engineDto = engineDto;
        }
        public String getMake() {
                return make;
        }
        public void setMake(String make) {
                this.make = make;
        }
        public String getModel() {
                return model;
        }
        public void setModel(String model) {
                this.model = model;
        }
        
                
        
}

CastorTester.java

package com.cts.test.go;

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.FileWriter;
import java.io.IOException;
import java.io.FileReader;


import org.xml.sax.InputSource;

import com.cts.test.dest.CarDto;

public class CastorTester {

        public static void main(String args[]) {

                Mapping mapping = new Mapping();
                FileWriter myFileWriter;
                try {
                        // Create a blank DTO
                        CarDto cardto = new CarDto();
                        //cardto.setModel("xxx");
                        // Create a File to marshal to
                        myFileWriter = new FileWriter("blankDTO.xml");
                        
                        // Load mapping
                        mapping.loadMapping("mymapping.xml");
                        //Marshaller.marshal(cardto, myFileWriter);
                        Marshaller myMarshaller = new Marshaller(myFileWriter);
                        myMarshaller.setMapping(mapping);
                        myMarshaller.marshal(cardto);
                        
                } catch (Exception e) {
                        System.out.println(e);
                        return;
                }
        }

}

EngineDto.java
package com.cts.test.dest;

public class EngineDto {
        
        protected String sound;

        public String getSound() {
                return this.sound;
        }

        public void setSound(String sound) {
                this.sound = sound;
        }
        
        
}

mymapping.xml
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapping PUBLIC "-//EXOLAB/Castor Mapping DTD Version 1.0//EN"
                                 "http://castor.org/mapping.dtd";>
<mapping>
        <class name = "com.cts.test.dest.CarDto">
                <field name = "model" type = "java.lang.String">
                        <bind-xml name = "model"/>
                </field>
                <field name = "make" type = "java.lang.String">
                        <bind-xml name = "make"/>
                </field>
                <field name = "EngineDto" type = "com.cts.test.dest.EngineDto">
                        <bind-xml name = "EngineDto" node = "element">
                                <class name = "com.cts.test.dest.EngineDto">
                                        <field name = "sound" type = 
"java.lang.String">
                                                <bind-xml name = "sound" node = 
"element"/>
                                        </field>
                                </class>
                        </bind-xml>
                </field>
        </class>
        
</mapping>

I am getting this output
<?xml version="1.0" encoding="UTF-8"?>
<car-dto/>

Suranjan



Werner Guttmann wrote:
> 
> Looks like none of the fiels made it past .... spamfilters et alias. Can 
> you please inline ?
> 
> Werner
> 
> suranjan wrote:
>> I am attaching all the files. This is a prototype.
>> The bean is having 2 primitives and 1 object.
>> 
>> 
>> Werner Guttmann wrote:
>>> Are you using a mapping file at all ? And can you briefly describe your 
>>> Java object(s) by showing us code fragments ? And finally, how are you 
>>> marshalling your object(s) (code sample, please).
>>>
>>> Werner
>>>
>>> suranjan wrote:
>>>> Having a similar problem as Vinodh
>>>> I have a bean which has primitive fields, objects as well an array list
>>>> of
>>>> objects.
>>>> Now I want to marshal this to a skeleton xml, ie without any values. 
>>>> I am getting a blank xml with only the root element. Can this be done
>>>> using
>>>> castor?
>>>> I tried setting the strings to "", it worked but I cant do this, as I
>>>> want
>>>> to keep the existing code untoched.
>>>> I would rather fill in the values in the template xml manually and then
>>>> unmarshal them into populated objects. Please help
>>>>
> 
> http://www.nabble.com/file/p13601028/codes.zip
> 
> 
> 
> 

-- 
View this message in context: 
http://www.nabble.com/Query---marshalling-tf2813712.html#a13607485
Sent from the Castor - Dev mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe from this list please visit:

    http://xircles.codehaus.org/manage_email

Reply via email to