Re: [castor-dev] Force an element to be marshalled
Werner Guttmann <[email protected]> Wed, 14 Oct 2009 13:04:20 +0200
| Newsgroups | gmane.comp.java.castor.devel |
|---|---|
| Message-ID | <[email protected]> |
Hi August,
if the following is an option to you, yes there is ....
<LineItem>
<ItemNumber>124029</ItemNumber>
<ItemQty>1</ItemQty>
<CostCenter xsi:nil=true" />
</LineItem>
Werner
August Detlefsen wrote:
> 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
>
>
---------------------------------------------------------------------
To unsubscribe from this list, please visit:
http://xircles.codehaus.org/manage_email