Copied to clipboard

Flag this post as spam?

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


  • Gert Peter Brigsted 30 posts 61 karma points
    Sep 10, 2009 @ 12:21
    Gert Peter Brigsted
    0

    DateGreaterThanOrEqualToday

    Hi.

    I have the following xslt:

    <xsl:when test="count($currentPage/node[data [@alias = 'eventDate'] != '' and umbraco.library:DateGreaterThanOrEqualToday(data [@alias = 'eventDate'])]) > 0">
        <xsl:for-each select="$currentPage/node[data [@alias = 'eventDate'] != '' and umbraco.library:DateGreaterThanOrEqualToday(data [@alias = 'eventDate'])]">
            ...

    Which works as expected. That is, it processes all the nodes where the eventDate hasn't yet passed. There's just one thing I don't understand. If I remove the part data [@alias = 'eventDate'] != '' and from the xsl:for-each, it works just fine. But if I remove it from the xsl:when, it fails to save the xslt with the error:

    Error occured

    System.FormatException: String was not recognized as a valid DateTime.
    at System.DateTimeParse.Parse(String s, DateTimeFormatInfo dtfi, DateTimeStyles styles)
    at umbraco.library.DateGreaterThanOrEqualToday(String firstDate)

    Why is this? I struggled hours to find out how to get around this weird problem. To me it seems odd that a previous comparison should affect the following method call (DateGreaterThanOrEqualToday).

  • Thomas Höhler 1237 posts 1709 karma points MVP
    Sep 10, 2009 @ 12:35
    Thomas Höhler
    0

    If you save the xslt it checkes the xslt against an existing node (the first one), so if you dont't have this property there it will fail => you have to check if the value exists before usage. To go around you can mark the check box to not check for erros.

    hth, Thomas

Please Sign in or register to post replies

Write your reply to:

Draft