AnsweredAssumed Answered

How to sorting by using  the content

Question asked by creddy2001 on Jul 17, 2009
Latest reply on Jul 20, 2009 by creddy2001
How to sor the XML documents by using the content.

This is my sample XML file. In this xml there is an event_date. I want to sort all the documents by event_date using web scripts . Please help me out in resolving this isse. I am also giving my Java script and response template.

  <?xml version="1.0" encoding="UTF-8" ?>
- <upcoming_event:upcoming_event xmlns:alf="http://www.alfresco.org" xmlns:chiba="http://chiba.sourceforge.net/xforms" xmlns:ev="http://www.w3.org/2001/xml-events" xmlns:upcoming_event="http://www.alfresco.org/alfresco/upcoming_event" xmlns:xf="http://www.w3.org/2002/xforms" xmlns:xhtml="http://www.w3.org/1999/xhtml" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
  <upcoming_event:event_date>2009-07-07</upcoming_event:event_date>
  <upcoming_event:title>"Notice of Intent" for the US Department of Transportation (USDOT) "Transportation Investments Generating Economic Recovery" (TIGER) Discretionary Grants Due to CalTrans</upcoming_event:title>
- <upcoming_event:image_details xsi:nil="true">
  <upcoming_event:image>/upcomingevents/images/deadline.gif</upcoming_event:image>
  <upcoming_event:caption xsi:nil="false">Deadline</upcoming_event:caption>
  </upcoming_event:image_details>
- <upcoming_event:event_details xsi:nil="true">
  <upcoming_event:url xsi:nil="true" />
  <upcoming_event:caption xsi:nil="true" />
  <upcoming_event:title xsi:nil="true" />
  <upcoming_event:description xsi:nil="false"><p>The "Notice of Intent" for the US Department of Transportation (USDOT) "Transportation Investments Generating Economic Recovery" (TIGER) Discretionary Grants is due from potential applicants to Caltrans. This notice requires that basic information be provided to the Department regarding the type of project, size, and funding. These notices will also provide an indication of the number of potential applicants. The Department will use the information to plan for the review teams that are needed to review the applications. These applications are due to be submitted to Caltrans on July 27, 2009. The applications must be submitted to the US Department of Transportation by September 15, 2009.</p></upcoming_event:description>
  </upcoming_event:event_details>
  </upcoming_event:upcoming_event>

Java Script
———————

script:
{
   var storeid = ("recoverywebsite");
   var path = ("/www/avm_webapps/ROOT/UpcomingEvents/source");
   
   var store = avm.lookupStore(storeid);
   if (store == undefined)
   {
     status.code = 404;
     status.message = "Store " + storeid + " not found.";
     status.redirect = true;
     break script;
   }
   var node = avm.lookupNode(storeid + ":" + path);
   if (node == undefined)
   {
     status.code = 404;
     status.message = "Path " + path + " within store " + storeid + " not found.";
     status.redirect = true;
     break script;
   }
   
   // setup model for templates
   model.store = store;
   model.folder = node;   
}

Response Template
————————

<#ftl ns_prefixes={"D":"http://www.alfresco.org/alfresco/upcoming_event"}>
<#list folder.children as document>
   <#if document.mimetype = "text/xml">
      <#assign dom=document.xmlNodeModel>   
      <tr>
         <#assign eventDate = (dom.upcoming_event.event_date?date("yyyy-MM-dd"))?string("MM/dd/yyyy")>
         <td style="vertical-align:top;">${eventDate}</td>
         <td style="vertical-align:top;align:center;"><img src="${dom.upcoming_event.image_details.image}" alt="${dom.upcoming_event.image_details.caption}" width="20" height="17" /></td>
         <td style="vertical-align:top;"><a href="upcomingevents.shtml#${document_index}">${dom.upcoming_event.title}</a></td>
      </tr>
   </#if>
</#list>

thanks
Chandra

Outcomes