Hi,
I have to marshall objects with null value properties:

Object: person
Properties: 
name=Alberto
Surname=Lirussi
Address=null
..

Castor mashall only non null properties. So the xml look like this:

<?xml version="1.0" encoding="UTF-8"?>
<persons>
        <person>
                <name>Alberto</name>
                <surname>Lirussi</surname>
        </person>
</persons>

Instead I want to marshall also the address property:

<?xml version="1.0" encoding="UTF-8"?>
<persons>
        <person>
                <name>Alberto</name>
                <surname>Lirussi</surname>
                <address/>
        </person>
</persons>

I haven't find any help from documentation nor from the mailing lists to
resolve this issue. So I modifyed the class
org.exolab.castor.xml.Marshaller:

line
1390:           XMLFieldDescriptor elemDescriptor = descriptors[i];
            Object obj = null;
            try {
                
                obj = elemDescriptor.getHandler().getValue(object);
            }
            catch(IllegalStateException ise) {
                continue;
            }
1399:           //if (obj == null) continue;    <<<<< OLD CODE
            if (obj == null) obj="";     // <<<<< MY CODE

I don't know if this modification is generic, but it functions with my
specific case.

The question is: is this the only method to solve the issue? Are there any
other standard methods without modifying the code?

I'm using Castor 0.9.5.3.

Thank you in advance,
Alberto Lirussi



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

Reply via email to