views:

29

answers:

2

Hello,

I am using Castor for XML Binding.. We need to sort the XML based on two different fields. Is there way we can specify the sort order in castor while marshalling?

Which will be a better approach to do this sorting, if castor don't have this feature.

Here is the actual problem with Sorting...

I have two collections of two differnt objects, which is ordered by date sepaterly. I set these two collections to another object and we have the correspoing mapping file which will have the XML generated in the order of the collections defined in the mapping file.. this is okay.

But now I want to order these two different set of collections ordered by the dates on both in the XML....

A: 

It's not entirely clear to me what exactly you mean. Do you mean that you have a collection of objects that you want to convert to XML, and you want to see them in a particular order in the XML output?

Do you have those objects in a collection (a List, for example)? If the above is your question, then make sure that the objects are in the List in the right order before passing the list to Castor.

Jesper
Thanks for the reply and Sorry for not being clear.. now I am have made the changes to the problem.. I have explanied the scenario a bit in detail above...
Java Guy
A: 

Couldn't find anything in Castor. Sorted the XML using XSLT. Used XALAN.

http://stackoverflow.com/questions/2917133/sorting-an-xml-in-java

Java Guy