Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

How to avoid empty tag when marshalling using Castor 1.2  RSS feed

Saravanakumar Jeyavel
Posts: 6
  • 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" "">
<class name="" 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 name="ticketoption" type="" get-method="getTicketoption" set-method="setTicketoption" required="false">
<bind-xml name="ticketoption" node="element"/>

<class name="" verify-constructable="false">
<map-to xml="ticketoption"/>
<field name="optiontype" type="string" get-method="getOptionType" set-method="setOptionType">
<bind-xml name="optiontype" node="element"/>

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

It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!