Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8191925
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T04:02:27+00:00 2026-06-07T04:02:27+00:00

i want to sorting by descending order based on date.i dont know how to

  • 0

i want to sorting by descending order based on date.i dont know how to accomplish this :

Here is my xml :

<?xml version="1.0" encoding="ISO-8859-1" standalone="yes"?>
<inm:Results productTitle="Inmagic DB/Text WebPublisher PRO" productVersion="13.00" xmlns:inm="http://www.inmagic.com/webpublisher/query" oex="ISO-8859-1">
<inm:Recordset AC="QBE_QUERY" sn="AUTO26264" se="1392" queryCount="139" page="1" pageCount="1" setCount="139">
<inm:Record setEntry="0">
  <inm:Title>BBBBBB</inm:Title>
  <inm:Pub_Date>12-Jun-2012</inm:Pub_Date>
  <inm:Words />
</inm:Record>
<inm:Record setEntry="1">
   <inm:Title>TESTING ESTING</inm:Title>
   <inm:Pub_Date>12-jul-2012</inm:Pub_Date>
  <inm:Words />
</inm:Record>
<inm:Record setEntry="2">    
  <inm:Title>TESFDS SDFASDFASDt</inm:Title>
  <inm:Pub_Date>30-Jun-2012</inm:Pub_Date>
  <inm:Words />
</inm:Record>   
</inm:Recordset>
</inm:Results>

and my xml is :

  <?xml version="1.0" encoding="utf-8"?>
 <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:inm="http://www.inmagic.com/webpublisher/query">
 <xsl:output method="html"/>
 <xsl:template match="/">
 <ul class="baseList newsList">
  <xsl:for-each  select="inm:Results/inm:Recordset/inm:Record" >
    <xsl:sort select="inm:Pub_Date" order="descending"/>
      <li>
        <span class="title">
          <a href="#">
            <xsl:value-of select="inm:Title" />
          </a>
        </span>
        <p class="meta">
          <span class="dateTime">
            <xsl:value-of select="inm:Pub_Date"/>
          </span>
        </p>
      </li>
  </xsl:for-each>
</ul>
  </xsl:template>

i try to sorting in xslt script but its not worked perfectly.

output was :
– 30-Jun-2012
– 12-jul-2012
– 12-jun-2012

but output should be :
-12-jul-2012
-30-jun-2012
-12-Jun-2012

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-07T04:02:29+00:00Added an answer on June 7, 2026 at 4:02 am

    I agree with the other answer posters that you should convert your dates to ISO date format.

    Having said that, if you insist on using the format as supplied in the sample document, you can use the following xsl:sort instructions …

    <xsl:sort select="substring(inm:Pub_Date,8)" data-type="number" order="descending"/>
    <xsl:sort select="string-length( substring-before(
      'JanFebMarAprMayJunJulAugSepOctNovDec',
      substring(inm:Pub_Date,4,3)))" data-type="number" order="descending"/>
    <xsl:sort select="substring-before(inm:Pub_Date,'-')" data-type="number" order="descending"/>
    

    The first sorts on year, the second on month, and then finally day.

    The style-sheet as a whole is …

     <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:inm="http://www.inmagic.com/webpublisher/query">
     <xsl:output method="html"/>
     <xsl:template match="/">
     <ul class="baseList newsList">
      <xsl:for-each  select="inm:Results/inm:Recordset/inm:Record" >
        <xsl:sort select="substring(inm:Pub_Date,8)" data-type="number" order="descending"/>
        <xsl:sort select="string-length( substring-before(
          'JanFebMarAprMayJunJulAugSepOctNovDec',
          substring(inm:Pub_Date,4,3)))" data-type="number" order="descending"/>
        <xsl:sort select="substring-before(inm:Pub_Date,'-')" data-type="number" order="descending"/>
          <li>
            <span class="title">
              <a href="#">
                <xsl:value-of select="inm:Title" />
              </a>
            </span>
            <p class="meta">
              <span class="dateTime">
                <xsl:value-of select="inm:Pub_Date"/>
              </span>
            </p>
          </li>
      </xsl:for-each>
    </ul>
    </xsl:template>
    </xsl:stylesheet>
    

    Update

    Just as a helpful hint, here is a neat template you can use to convert dates from the 30-Jun-2012 format to ISO/XML format. Let me know if you can use XSLT 2.0 . The conversion gets simpler in XSLT 2.0 .

    <xsl:template name="format-date">
     <xsl:param name="InDateValue" select="'01-Jan-2000'" />
     <xsl:value-of select="concat( substring($InDateValue, 8, 4), '-')"/>
     <xsl:variable name="month" select="substring($InDateValue, 4, 3)" />
     <xsl:value-of select="format-number(
              translate( $month, 'nFrylgSONDJaebMApupctov', '00240107666') +
              translate( $month, 'aFpugONDJnebMrAyluSctovc', '12268456'), '00')" />
     <xsl:value-of select="concat( '-', substring($InDateValue, 1, 2))"/>
    </xsl:template>
    

    Ok, its quiet obtuse! But I like it.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to implement this JSF page with pagination and sorting. Unfortunately Netbeans shows
I want to create this JSF table with paging and sorting. This is JSF
I want to sort files by modification time ascending and descending. According to this
I am sorting a list based on multiple fields. sortedList.sort {[it.getAuthor(), it.getDate()]} This works
The default sorting order on the gridview control is ascending first, then descending. Now
I have a huge table and I want simple sorting. It could be so
I want to introduce a deterministic sorting to my [OWL] (http://www.w3.org/TR/owl-ref/) file so that
I want to compare count of operations of the sorting algorithms Merge Sort and
I want to use Christian Bach's tableSorter client-side table sorting jQuery plugin with my
I want to have a model with calculated fields that I can apply sorting

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.