Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Garrett Fisher 341 posts 496 karma points
    Oct 11, 2010 @ 18:00
    Garrett Fisher
    0

    XML Not Sorting

    Hi,

    Can anyone offer an explanation as to why I am unable to sort this XML descending by pubDate?

    http://www.ignitetech.com/umbraco/plugins/FergusonMoriyama/feedcache/tmcnet.xml

    <xsl:variable name="x" select="document('../umbraco/plugins/FergusonMoriyama/FeedCache/tmcnet.xml')/rss/channel"/>
    <xsl:variable name="x-limit" select="2" />
    ....
    <xsl:for-each select="$x/item">
           <xsl:sort select="pubDate" order="descending" />
           <xsl:if test="position() &lt;= $x-limit">
           ......
           </xsl:if>
    </xsl:for-each>

    I'm obviously trying to get the latest two items, but it's getting literally Random ones.  What am I doing wrong here?

    Thanks,

    Garrett

     

  • Ismail Mayat 4511 posts 10092 karma points MVP 2x admin c-trib
    Oct 11, 2010 @ 18:09
    Ismail Mayat
    1

    Garrett,

    Its due to format of pubdate you need to be ansi sql style 2010-10-11 etc

    Regards

    Ismail

  • dandrayne 1138 posts 2262 karma points
    Oct 11, 2010 @ 18:13
    dandrayne
    2

    Hi Garrett

    xslt doesn't really do date sorting unless the date itself is ordered like a big number - there is no data-type "date" to sort by.  This seems to work well for me

    <xsl:sort select="umbraco.library:FormatDateTime(./articleDate, 'yyyyMMddhhmmss')" data-type="number" order="descending" />

    Dan

  • Garrett Fisher 341 posts 496 karma points
    Oct 11, 2010 @ 19:57
    Garrett Fisher
    0

    Thanks very much Dan-- this fixed it.

     

    //Garrett

Please Sign in or register to post replies

Write your reply to:

Draft