This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes XML and Related Technologies and the fly likes Castor | Default Element Value Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Engineering » XML and Related Technologies
Bookmark "Castor | Default Element Value" Watch "Castor | Default Element Value" New topic
Author

Castor | Default Element Value

Tausif Farooqi
Greenhorn

Joined: Mar 03, 2007
Posts: 10
Hi,

Does anyone know if it is possible to set a default value for an element or attribute when we use Castor to marshal an object to XML? The objects that are marshalled to XMLs are fetched from a database. Some of the fields of these objects maybe NULL and hence their coresponding XML field/attribute is not printed in the XML. Is there a way to give a default value to such fields so that even if the database value is NULL it will display the default value in the XML (other than using a null check for all such fields in Java code)?

Thanks,

Tausif
 
Consider Paul's rocket mass heater.
 
subject: Castor | Default Element Value
 
Similar Threads
XML parsing large complex xml data
inserting xml string into oracle database
Mapping Java fields to attribute and element
NullPointerException
null values in castor unmarshalling