Copied to clipboard

Flag this post as spam?

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


  • Dinovo 40 posts 59 karma points
    May 16, 2010 @ 17:23
    Dinovo
    0

    max() value?

    I have x number of nodeid's stored in a cookie. I want to loop through these nodeid's and find the nodeid containing the highest (max()) value for a certain field in the node - any suggestion on a approach of finding the max/highest value?

  • Jan Skovgaard 11280 posts 23678 karma points MVP 11x admin c-trib
    May 16, 2010 @ 17:30
    Jan Skovgaard
    0

    Hi Dinovo

    I think you should be able to do that by writing a loop like this

    <xsl:for-each select="yourexpression">
    <xsl:sort select="yourvalue" order="descending" data-type="number" />
    <xsl:if test="position() = 1>

    <xsl:value-of select="." />

    </xsl:if>
    </xsl:for-each>

    Hope this helps

    /Jan

  • Dinovo 40 posts 59 karma points
    May 16, 2010 @ 17:43
    Dinovo
    0

    Hi Jan

    That is excatly the way i have done it uptil now - but i was wondering if there was no easier way of doing it (ie. lesser code)? ;-)

  • Jan Skovgaard 11280 posts 23678 karma points MVP 11x admin c-trib
    May 16, 2010 @ 17:47
    Jan Skovgaard
    0

    Hello again

    I'm not sure it can be done using "pure" XSLT - but maybe you can use some of the extensions from the Exslt.ExsltMath library? There is a "highest" and "max" function in there it seems.

    /Jan

     

Please Sign in or register to post replies

Write your reply to:

Draft