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 Sorting large xml nodes 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 "Sorting large xml nodes" Watch "Sorting large xml nodes" New topic
Author

Sorting large xml nodes

Geo Bar
Greenhorn

Joined: Jun 09, 2014
Posts: 3
I'm trying to sort nodes in an xml file, each node contains a little over 300 fields, and so my question is, is there a way to sort these nodes other than the examples I've seen for nodes with only a few fields? like in the following example: sort xml

In my case this would be impractical, but if there is no way around it I would have to do it this way. If at all possible please provide some code example, I am just starting to learn java and not very familiar with all the different packages and tools.


I would like to sort it by ORDER_LINE




Thanks for any help
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18909
    
    8

That's the best they could do over at SO? By far the easiest thing to do is to do an XSLT identity transformation and apply <xsl:sort> to the <CARTONDETAIL> elements.
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18909
    
    8

And welcome to the Ranch, Geo!
Geo Bar
Greenhorn

Joined: Jun 09, 2014
Posts: 3
Paul,
Thanks, it is good to be in this great community and get some help from smarter people than me

I was looking into xslt and looks like it is exactly what I need, however, I'm having a little hard time how would I automate the process? do I need to use something like saxon or can java do it out of the box, if so, what classes or packages would I need to use in order to accomplish this?

Thanks for any help!
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18909
    
    8

XSLT is built into Java, at least XSLT 1.0 is. And that's all you'd need for your requirements. Here's a link to the relevant Oracle tutorial: http://docs.oracle.com/javase/tutorial/jaxp/xslt/intro.html (Google keywords "java xslt tutorial").
Geo Bar
Greenhorn

Joined: Jun 09, 2014
Posts: 3
Thank you! greatly appreciated..
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18909
    
    8

Keep us posted with your progress!

(I used to try to answer questions over at SO but I was way too slow. By the time I found a question I could answer it would have already been closed because it didn't meet SO's high standards.)
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Sorting large xml nodes