Hi,

I am using a betwixt file to describe how to convert a Java complex type
POJO (containing lists of other objects contained in ArrayLists) into
XML. I need to ensure that the order of all attributes is preserved in
the XML, as it must conform to a rigid XSD. 

BeanWriter enforces the order in all of the component objects within the
top level POJO objects correctly, as defined in the betwixt config file,
but when it comes to elements contained in a List object, they are
rendered in the resulting XML in alphabetical order, instead of in the
order described in the betwixt file.

Is this an issue with betwixt's handling of Lists, or am I missing a
crucial piece of configuration?

Please find the betwixt and object files listed below.

Many thanks,

Nik


The betwixt file:
---------------------
<?xml version="1.0" encoding="UTF-8" ?>
<!-- Note that the elements are necessary to match the list to a type
and to ensure the order of the XML -->
<info>
    <element name='get-ctn-history-response'>
            <element name='GCTNHRespResult' property='GCTNHRespResult'
                   class='java.lang.Boolean'/>
            <element name='GCTNHRespReasonCode'
property='GCTNHRespReasonCode'
                   class='java.lang.String'/>
            <element name='GCTNHRespReasonDesc'
property='GCTNHRespReasonDesc'
                   class='java.lang.String'/>
            <element name='GCTNHRespCTN' property='GCTNHRespCTN'
                   class='java.lang.String'/>
            <element name='GCTNHRespFilter' property='GCTNHRespFilter'
                   class='java.lang.String'/>

            <element name='GCTNHRespHistoryLi'
property='GCTNHRespHistoryList'
               class='PATHMASKED.GCTNHRespHistoryListItem'>
                                    <element name='GCTNHRespDateTime'
property='GCTNHRespDateTime'
                                           class='java.util.Date'/>
                                    <element name='GCTNHRespAction'
property='GCTNHRespAction'
                                           class='java.lang.String'/>
                                    <element name='GCTNHRespGroupID'
property='GCTNHRespGroupID'
                                           class='java.lang.Long'/>
                                    <element name='GCTNHRespHub'
property='GCTNHRespHub'
                                           class='java.lang.String'/>
                                    <element name='GCTNHRespSatellite'
property='GCTNHRespSatellite'
                                           class='java.lang.String'/>
                                    <element name='GCTNHRespActor'
property='GCTNHRespActor'
                                           class='java.lang.String'/>
                                    <element name='GCTNHRespChannel'
property='GCTNHRespChannel'
                                           class='java.lang.String'/>
                                    <element name='GCTNHReason'
property='GCTNHReason'
                                           class='java.lang.String'/> 
            </element>
            <addDefaults/>

    </element>
</info>
------------------

The Object file:
----------------
package PATHMASKED;

import java.util.ArrayList;
import java.util.List;

/**
 * Get CTN History Response xml.
 * @author Nikolay Jordanov
 *
 */
public class GetCTNHistoryResponse {

    /**
     * Response result.
     */
    private Boolean gCTNHRespResult;
    /**
     * Response reason code.
     */
    private String gCTNHRespReasonCode;
    /**
     * Optional. Description of the reason code.
     */
    private String gCTNHRespReasonDesc;
    /**
     * Optional. The CTN in question.
     */
    private String gCTNHRespCTN;
    /**
     * Optional. The filter to use.
     */
    private String gCTNHRespFilter;
    /**
     * Optional. The CTN History list.
     */
    private List gCTNHRespHistoryList;
    /**
     * @return Returns the response result.
     */
    public final Boolean getGCTNHRespResult() {
        return gCTNHRespResult;
    }
    /**
     * @param respResult The response result.
     */
    public final void setGCTNHRespResult(final Boolean respResult) {
        gCTNHRespResult = respResult;
    }
    /**
     * @return Returns the response reason code.
     */
    public final String getGCTNHRespReasonCode() {
        return gCTNHRespReasonCode;
    }
    /**
     * @param respReasonCode The response reason code
     */
    public final void setGCTNHRespReasonCode(final String
respReasonCode) {
        gCTNHRespReasonCode = respReasonCode;
    }
    /**
     * @return Returns the response reason description.
     */
    public final String getGCTNHRespReasonDesc() {
        return gCTNHRespReasonDesc;
    }
    /**
     * @param respReasonDesc The response reason description
     */
    public final void setGCTNHRespReasonDesc(final String
respReasonDesc) {
        gCTNHRespReasonDesc = respReasonDesc;
    }
    /**
     * @return Returns the gCTNHRespCTN.
     */
    public final String getGCTNHRespCTN() {
        return gCTNHRespCTN;
    }
    /**
     * @param respCTN The gCTNHRespCTN to set.
     */
    public final void setGCTNHRespCTN(final String respCTN) {
        gCTNHRespCTN = respCTN;
    }
    /**
     * @return Returns the gCTNHRespFilter.
     */
    public final String getGCTNHRespFilter() {
        return gCTNHRespFilter;
    }
    /**
     * @param respFilter The gCTNHRespFilter to set.
     */
    public final void setGCTNHRespFilter(final String respFilter) {
        gCTNHRespFilter = respFilter;
    }

    /**
     * @return Returns the response satellite list.
     */
    public final List getGCTNHRespHistoryList() {
        if (gCTNHRespHistoryList == null) {
            gCTNHRespHistoryList = new ArrayList();
        }
        return gCTNHRespHistoryList;
    }
    /**
     * @param respHistoryList The response satellite list.
     */
    public final void setGCTNHRespHistoryList(
            final List respHistoryList) {
        gCTNHRespHistoryList = respHistoryList;
    }
    /**
     * @param item The response satellite.
     */
    public final void addGCTNHRespHistoryLi(
            final GCTNHRespHistoryListItem item) {
        if (gCTNHRespHistoryList == null) {
            gCTNHRespHistoryList = new ArrayList();
        }
        gCTNHRespHistoryList.add(item);
    }

}
----------------------------------------

The GCTNHRespHistoryListItem object:
----------------------------------------
package PATHMASKED;

import java.util.Date;

/**
 * The CTN History list item.
 * @author Nikolay Jordanov
 *
 */
public class GCTNHRespHistoryListItem {

    /**
     * The time and date of the response.
     */
    private Date gCTNHRespDateTime;

    /**
     * Action to take.
     */
    private String gCTNHRespAction;
    /**
     * The CTN's Group ID.
     */
    private Long gCTNHRespGroupID;
    /**
     * The Group Hub's CTN.
     */
    private String gCTNHRespHub;
    /**
     * Optional. The CTN of a satellite (for history search)
     */
    private String gCTNHRespSatellite;
    /**
     * Optional. The actor.
     */
    private String gCTNHRespActor;
    /**
     * Optional. The channel to send the result to.
     */
    private String gCTNHRespChannel;
    /**
     * Optional. The reason for the operation.
     */
    private String gCTNHReason;
    /**
     * @return Returns the gCTNHRespDateTime.
     */
    public final Date getGCTNHRespDateTime() {
        return gCTNHRespDateTime;
    }
    /**
     * @param respDateTime The gCTNHRespDateTime to set.
     */
    public final void setGCTNHRespDateTime(final Date respDateTime) {
        gCTNHRespDateTime = respDateTime;
    }
    /**
     * @return Returns the gCTNHRespAction.
     */
    public final String getGCTNHRespAction() {
        return gCTNHRespAction;
    }
    /**
     * @param respAction The gCTNHRespAction to set.
     */
    public final void setGCTNHRespAction(final String respAction) {
        gCTNHRespAction = respAction;
    }
    /**
     * @return Returns the gCTNHRespGroupID.
     */
    public final Long getGCTNHRespGroupID() {
        return gCTNHRespGroupID;
    }
    /**
     * @param respGroupID The gCTNHRespGroupID to set.
     */
    public final void setGCTNHRespGroupID(final Long respGroupID) {
        gCTNHRespGroupID = respGroupID;
    }
    /**
     * @return Returns the gCTNHRespHub.
     */
    public final String getGCTNHRespHub() {
        return gCTNHRespHub;
    }
    /**
     * @param respHub The gCTNHRespHub to set.
     */
    public final void setGCTNHRespHub(final String respHub) {
        gCTNHRespHub = respHub;
    }
    /**
     * @return Returns the gCTNHRespSatellite.
     */
    public final String getGCTNHRespSatellite() {
        return gCTNHRespSatellite;
    }
    /**
     * @param respSatellite The gCTNHRespSatellite to set.
     */
    public final void setGCTNHRespSatellite(final String respSatellite)
{
        gCTNHRespSatellite = respSatellite;
    }
    /**
     * @return Returns the gCTNHRespActor.
     */
    public final String getGCTNHRespActor() {
        return gCTNHRespActor;
    }
    /**
     * @param respActor The gCTNHRespActor to set.
     */
    public final void setGCTNHRespActor(final String respActor) {
        gCTNHRespActor = respActor;
    }
    /**
     * @return Returns the gCTNHRespChannel.
     */
    public final String getGCTNHRespChannel() {
        return gCTNHRespChannel;
    }
    /**
     * @param respChannel The gCTNHRespChannel to set.
     */
    public final void setGCTNHRespChannel(final String respChannel) {
        gCTNHRespChannel = respChannel;
    }
    /**
     * @return Returns the gCTNHReason.
     */
    public final String getGCTNHReason() {
        return gCTNHReason;
    }
    /**
     * @param reason The gCTNHReason to set.
     */
    public final void setGCTNHReason(final String reason) {
        gCTNHReason = reason;
    }

}
----------------------------------------



This message should be regarded as confidential. If you have received this 
email in error please notify the sender and destroy it immediately.
Statements of intent shall only become binding when confirmed in hard copy by 
an authorised signatory.  The contents of this email may relate to dealings 
with other companies within the Detica Group plc group of companies.

Detica Limited is registered in England under No: 1337451.

Registered offices: Surrey Research Park, Guildford, Surrey, GU2 7YP, England.


Reply via email to