I have a simple class hierarchy.  

Class Option  { protected String optionPk; }

Class LodgingOption extends Option { protected int lodgeType; etc... }

I can serialize B to XML using Castor, but it will not include the
data members inherited from A.  Is this a limitation of 
Castor?  I have tried the following mappng file.  It has no effect. 
The file below simply produces an XML doc with the lodgeType but
nothing more.  Code is below the map file.  Thanks!


<?xml version="1.0"?>
<!DOCTYPE mapping PUBLIC "-//EXOLAB/Castor Object Mapping DTD Version
1.0//EN"
"http://castor.exolab.org/mapping.dtd";>

<mapping>

<description>
  Maps a Lodging instance to an XML representation.
</description>


<class name="example.Option">
    <field name="optionPk"></field>
</class>

<class name="example.Lodging" 
  auto-complete="false" name="example.Option">   
  <field name="lodgeType"></field>
</class>

</mapping>


------- Code -------------------------------------------------------------

     public String toXML( Object obj ) throws MarshalException,
ValidationException {
        
//        init();
//        StringWriter sw = new StringWriter(); 
//        Marshaller.marshal( obj, sw );
//        return sw.toString();
//        
        init();
        StringWriter sw = new StringWriter();          
        Marshaller m = null;
        try {
            
            Mapping mapping = new Mapping();
            mapping.loadMapping( baseDir + mapDir +
"Lodging.castormap.xml");
                
            m = new Marshaller(sw);
            m.setMapping( mapping );
                
        } catch (IOException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        } catch (MappingException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
        m.marshal( obj );
        
        return sw.toString();
        
    }

----------------------------------------------------------- 
If you wish to unsubscribe from this mailing, send mail to
[EMAIL PROTECTED] with a subject of:
        unsubscribe castor-dev

Reply via email to