File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes XML and Related Technologies and the fly likes How to avoid empty tag when marshalling using Castor 1.2 Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » XML and Related Technologies
Bookmark "How to avoid empty tag when marshalling using Castor 1.2" Watch "How to avoid empty tag when marshalling using Castor 1.2" New topic
Author

How to avoid empty tag when marshalling using Castor 1.2

Saravanakumar Jeyavel
Greenhorn

Joined: Aug 20, 2012
Posts: 6
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.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: How to avoid empty tag when marshalling using Castor 1.2
 
Similar Threads
Getting a 500 HTTP status returned from my web service with no errors in log
Error in First Hibernate Example
Can't resolve JDK issue on Mac
Simple JPA application on TOMEE
Give the easiest example which differentiate "interface" and "abstract class" in Java.