[castor-dev] Force an element to be marshalled

August Detlefsen <[email protected]> Tue, 13 Oct 2009 12:00:24 -0700 (PDT)
Newsgroups gmane.comp.java.castor.devel
Message-ID <[email protected]>
Is there any way to force an element to be marshalled to XML even if the field in the Java object is null or empty? 

I am marshalling XML to a remote web service that requires a CostCenter field in the XML, even if that field is null. Here is an example of the XML that is being produced: 

<?xml version="1.0" encoding="UTF-8"?>
<Order>
<LineItem><ItemNumber>124029</ItemNumber><ItemQty>1</ItemQty><CostCenter>1234567.1234.123</CostCenter></LineItem>
<LineItem><ItemNumber>122094</ItemNumber><ItemQty>1</ItemQty></LineItem>
<LineItem><ItemNumber>119106</ItemNumber><ItemQty>1</ItemQty></LineItem>
<LineItem><ItemNumber>119105</ItemNumber><ItemQty>1</ItemQty></LineItem>
</Order>

Only the first <LineItem> includes the <CostCenter> element, but I need all of them to include it, even if it is an empty item i.e. <CostCenter></CostCenter>

__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 

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

    http://xircles.codehaus.org/manage_email