Copied to clipboard

Flag this post as spam?

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


  • Bo Damgaard Mortensen 712 posts 1189 karma points
    Mar 07, 2013 @ 14:55
    Bo Damgaard Mortensen
    0

    Sort on date field with fallback to updateDate

    Hi all,

    Is it possible in XSLT to sort on a date field (a regular Date Picker datatype) and if it's not set on the current node, then sort on the updateDate instead?

    Something along the lines of this:

    <xsl:sort select="myDate | @updateDate" order="descending" />

    Is this possible? :-)

  • Fuji Kusaka 2203 posts 4220 karma points
    Mar 07, 2013 @ 15:15
    Fuji Kusaka
    0

    In Xslt not sure if this will work

    <xsl:sortselect="myDate | @updateDate"order="descending"/>


    this  might though

    <xsl:choose>
    <xsl:when test="string('datePicker') = ' '">
    <xsl:sort
    select="datePicker"order="descending"/>
    </xsl:when>
    <xsl:otherwise>
    <xsl:sort
    select="@createDate"order="descending"/>
    </xsl:otherwise>
    </xsl:choose>

    Not sure though

  • sami 22 posts 104 karma points
    Mar 07, 2013 @ 15:16
    sami
    0

    Hi,

    I think it's possible:

    <xsl:for-each select="page">
        <xsl:sort select="myDate" order="descending"/>
        <xsl:sort select="@updateDate" order="descending"/>
    </xsl:for-each>
  • Dennis Aaen 4457 posts 17970 karma points admin hq c-trib
    Mar 07, 2013 @ 15:24
    Dennis Aaen
    0

    Hi,

    I think it´s possible.

    <xsl:sort select="(./myDate[normalize-space() != '']|@updateDate)"order="descending"/>
  • Bo Damgaard Mortensen 712 posts 1189 karma points
    Mar 07, 2013 @ 15:33
    Bo Damgaard Mortensen
    2

    Hi all,

    Thanks a lot for your inputs :-) I managed to get it to work by using this:

    <xsl:sort select="(@updateDate[not(normalize-space(../myDate))] | myDate)[1]" order="descending"/> 

    Credit goes to Chriztian Steinmeier!

  • Fuji Kusaka 2203 posts 4220 karma points
    Mar 07, 2013 @ 15:35
    Fuji Kusaka
    0

    Nice one!!

  • This forum is in read-only mode while we transition to the new forum.

    You can continue this topic on the new forum by tapping the "Continue discussion" link below.

Please Sign in or register to post replies