Within Castor, other than using multiple mapping files (with each of them specifying the required sequence of fields), no.
And with regards to abandoning Castor, I know that e.g. JAXB allows you to define one sequence only (by the means of a JAXB annotation), and not multiple ones. If I were you, I'd consider using XSLT (whether manually or within a framework such as Cocoon) on top of Castor, to sort the original output according to your specific needs. Castor's Marshaller supports marshalling to SAX events, which could be directly feed into e.g. a Cocoon pipeline or a JAXP transformer. Regards Werner [EMAIL PROTECTED] wrote: > The sequence could be different each time - the xml document describes a > gui , and the order in which the elements appear in the file determines > the tab order in the legacy system, hence the requirement to marshall > objects in a particular sequence. > So, in one file, the order may need to be label, button, field, field, > but in another it could be field, button, field, button, and so on. > Is there any solution to this? Or do I need to abandon Castor - which > would be a shame. > > Werner Guttmann writes: >> How about trying to match the sequence of your field mappings in the >> mapping file to the expected sequence ? If you use a mapping file, >> Castor simply marshalls fields as encountered in the mapping file. >> Werner >> [EMAIL PROTECTED] wrote: >>> Can Castor preserve the sequence of elements it unmarshalls when it goes >>> to marshall things back up? >>> Example: >>> XML going in.. >>> <window> >>> <button> Button1 </button> >>> <label> Label1 </label> >>> <button> Button2 </button> >>> </window> >>> XML going out >>> <window> >>> <button> Button1 </button> >>> <button> Button2 </button> >>> <label> Label1 </label> >>> </window> >>> When being marshalled back up, Castor will group all the buttons >>> together, labels, etc. in the order as defined by the mapping file. >>> However, for reasons that are beyond my control, I need to be able to >>> write out the XML file in the same order that I read it in. I tried >>> putting all elements in a single vector, but I get an error complaining >>> of multiple instances of the same field in the mapping file. >>> Any suggestions? >>> Thank you, >>> Justin >>> --------------------------------------------------------------------- >>> To unsubscribe from this list please visit: >>> http://xircles.codehaus.org/manage_email >> >> >> --------------------------------------------------------------------- >> To unsubscribe from this list please visit: >> http://xircles.codehaus.org/manage_email > > > > --------------------------------------------------------------------- > To unsubscribe from this list please visit: > > http://xircles.codehaus.org/manage_email > --------------------------------------------------------------------- To unsubscribe from this list please visit: http://xircles.codehaus.org/manage_email

