• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How to avoid empty tag when marshalling using Castor 1.2

 
Saravanakumar Jeyavel
Greenhorn
Posts: 6
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have an object called TickeDO which contains another object TicketoptionDO. I am generating xml using Castor 1.2. the TicketoptionDO object is an optional value. how can i avoid ticketoption tag in the generated xml when it is null. right now, i am getting empty tag as </ticketoption> within the <ticket> tag. below is my mapping structure.

<?xml version="1.0"?>
<!DOCTYPE mapping PUBLIC "-//EXOLAB/Castor Mapping DTD Version 1.0//EN" "http://castor.org/mapping.dtd">
<mapping>
<class name="com.data.objects.ticket.TicketDO" verify-constructable="false">
<map-to xml="ticket"/>
<field name="TicketId" type="long" get-method="getId" set-method="setId">
<bind-xml name="ticketId" node="element"/>
</field>

<field name="ticketoption" type="com.data.objects.ticket.TicketoptionDO" get-method="getTicketoption" set-method="setTicketoption" required="false">
<bind-xml name="ticketoption" node="element"/>
</field>
</class>

<class name="com.data.objects.ticket.TicketoptionDO" verify-constructable="false">
<map-to xml="ticketoption"/>
<field name="optiontype" type="string" get-method="getOptionType" set-method="setOptionType">
<bind-xml name="optiontype" node="element"/>
</field>
</class>
</mapping>

how to exclude empty </ticketoption> tag from the generated xml when it is null ? i really appreciate any help.

thanks.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic