Re: sorting xml nodes in freemarker

Kunal <[email protected]>
Newsgroups gmane.comp.web.freemarker.user
Message-ID <[email protected]>
Hi Daniel,

Thanks for the reply. That really helped.

However, my requirement is some thing like this. Consider the xml below

<games>
    <game name = "b">
          <publisher>
               <gameCompany name = "abc"></gameCompany>
          </publisher>
          <rating>9.0</rating>
     </game>
    <game name = "a">
          <publisher>
               <gameCompany name = "pqr"></gameCompany>
          </publisher>
     </game> 
    <game name = "c">
          <publisher>
               <gameCompany name = "xyz"></gameCompany>
          </publisher>
          <rating>6.0</rating>
    </game>
</games> 


I want to sort the game nodes based on the gameCompany name. How do I write
the syntax?

Also, Suppose I want to sort on rating , when I write  

[#list game_root.game?sort_by("rating") as game]

I get the following error
sort_by(...) failed: Values used for sorting must be numbers, strings, or
date/time values.

I suppose this error is because in the second game node rating node does not
exist. Is there any way I can still have the sorting done based on rating
without changing the xml?

Thanks.
Kunal
-- 
View this message in context: http://n4.nabble.com/sorting-xml-nodes-in-freemarker-tp624816p1462068.html
Sent from the freemarker-user mailing list archive at Nabble.com.

------------------------------------------------------------------------------
The Planet: dedicated and managed hosting, cloud storage, colocation
Stay online with enterprise data centers and the best network in the business
Choose flexible plans and management services without long-term contracts
Personal 24x7 support from experience hosting pros just a phone call away.
http://p.sf.net/sfu/theplanet-com
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.