Copied to clipboard

Flag this post as spam?

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


  • Marco Lusini 176 posts 1370 karma points
    Oct 27, 2009 @ 17:28
    Marco Lusini
    0

    IndexOf() in XSLT

    Hi, maybe this is a silly question, but I need an IndexOf() function inside an XSLT and can't find it anywhere...

    What puzzles me is that umbraco.library() provides a LastIndexOf() function but not IndexOf(), so I guess it should be available somehow...

    Any hint?

    Marco

  • Lee Kelleher 3945 posts 15163 karma points MVP 10x admin c-trib
    Oct 27, 2009 @ 17:54
    Lee Kelleher
    3

    Hi Marco,

    You can use native XPath (1.0) functions to achieve an IndexOf(), like this:

    <xsl:value-of select="string-length(substring-before('123456789', '4'))" />

    Cheers, Lee.

  • Lee 1123 posts 3059 karma points
    May 24, 2010 @ 11:10
    Lee
    0

    Could I use this to check if a link had 'http://' in it as I currently have this problem - Client has some links with http:// some with out and there are 1000's to check manually!  So would like to do a conditional check in the XSLT?

  • Dirk De Grave 4537 posts 6006 karma points MVP 3x admin c-trib
    May 24, 2010 @ 11:27
    Dirk De Grave
    2

    Lee,

    think you can use this if you write

    <xsl:if test="substring-before($url, '://') = 'http'">...</xsl:if>

    Cheers,

    /Dirk

  • 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