Re: Sorting XML Nodes
Kirill <[email protected]>
| Newsgroups | gmane.comp.web.freemarker.user |
|---|---|
| Message-ID | <CADGo9YZvRegkoVrX9qw0zsXxty8VjsxQC9oNTvA5qpT23zzYyw@mail.gmail.com> |
Thanks, Daniel. That is exactly what I ended up doing. - Kirill On Wed, Sep 21, 2011 at 4:02 AM, Daniel Dekany <[email protected]> wrote: > I think it's fair to blame `?sort_by` for this. And as always when > there's no proper built-in for something that is not feasible to > implement as an FTL #function, you should write a > TemplateMethodModelEx for this in Java, pull it into an > #import-ed/#included template with `?new` (or just put it into > Configuration as shared variable), and then call it from the > templates. > > > Monday, September 19, 2011, 7:52:02 PM, Kirill wrote: > > > Hey there, > > > > I need to sort the XML tree based on one of its' nodes. > > Let's say I have the following XML tree: > > > > <root> > > <item id=1/> > > <item id=2/> > > <item id=3/> > > <item id=10/> > > <item id=11/> > > </root> > > > > I've read that freemarker's sort_by built-in is pretty limited, > > i.e. you cannot force the conversion of the sortable to number, for > > example (so you can't do ?sort_by(["var1", "var2?number"])). > > Now, when I do ?sort_by(["item","id"]), the result I get is this, of > course: > > > > <root> > > <item id=1/> > > <item id=10/> > > <item id=11/> > > <item id=2/> > > <item id=3/> > > </root> > > > > My question is this - how can I emulate the natural sort order of > > the list, by modifying id variables in the original XML? > > I have full control of the original XML and can modify any values (add > string/digits, etc)? > > > > Any ideas? > > > > Thanks much, > > Kirill > > -- > Best regards, > Daniel Dekany > > ------------------------------------------------------------------------------ All the data continuously generated in your IT infrastructure contains a definitive record of customers, application performance, security threats, fraudulent activity and more. Splunk takes this data and makes sense of it. Business sense. IT sense. Common sense. http://p.sf.net/sfu/splunk-d2dcopy1 _______________________________________________ FreeMarker-user mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/freemarker-user