Hello list, I've been having a problem with keeping elements ordered according to the mapping file when marshalling an object. The mapping file is being used because changes I make to the mapping file are immediately reflected in the marshaled output. I'm also not using the static marshal method. I put my code, mapping file, expected output, and actual output in pastebin[1] for easier reading. I also included those artifacts below for the mailing archive.
Does anyone have any suggestions? Thanks, John [1]: http://pastebin.com/Htg4FBq7 ------------------------------ ------------------------------- /* Marshaller */ ResourceLoader resourceLoader = new DefaultResourceLoader(); StringWriter writer = new StringWriter(); Marshaller marshaller = new Marshaller(writer); URL url = resourceLoader.getResource("classpath:castor-mapping.xml").getURL(); Mapping mapping = new Mapping(); mapping.loadMapping(url); marshaller.setMapping(mapping); marshaller.marshal(inputObject); /* Marshaller */ ----------------------------------------------------------------- /* Mapping XML */ <?xml version="1.0"?> <mapping> <description>Description of the mapping</description> <class name="edu.northwestern.bioinformatics.studycalendar.domain.ScheduledStudySegment" auto-complete="false"> <field name="root"> <bind-xml name="root" node="attribute" location="id"/> </field> <field name="extension"> <bind-xml name="extension" node="attribute" location="id"/> </field> <field name="startDate" handler="edu.northwestern.bioinformatics.studycalendar.xml.writers.nes.DateFieldHandler" type="string"> <bind-xml name="value" node="attribute" location="start-date"/> </field> <field name="startDay" handler="edu.northwestern.bioinformatics.studycalendar.xml.writers.nes.IntegerFieldHandler" type="integer"> <bind-xml name="value" node="attribute" location="start-day"/> </field> <field name="studySegment"> <bind-xml name="study-segment-id" node="element"/> </field> <field name="activities" type="edu.northwestern.bioinformatics.studycalendar.domain.ScheduledActivity" collection="arraylist"> <bind-xml name="scheduled-activity" node="element"/> </field> </class> </mapping> /* Mapping XML */ ------------------------------------------------------ /* Expected Output */ <?xml version="1.0"?> <scheduled-study-segment> <id root="NU" extension="200.1"/> <start-date value="20091205"/> <start-day value="3"/> <study-segment-id root="NU" extension="200.2"/> <scheduled-activity/> <scheduled-activity/> </scheduled-study-segment> /* Expected Output */ -------------------------------------------------------- /* Actual Output */ <?xml version="1.0" encoding="UTF-8"?> <scheduled-study-segment> <study-segment-id root="NU" extension="200.2"/> <scheduled-activity/> <scheduled-activity/> <id root="NU" extension="200.1"/> <start-date value="20091205"/> <start-day value="3"/> </scheduled-study-segment> /* Actual Output */

