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 4026 posts 15836 karma points MVP 13x 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 1130 posts 3088 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 4541 posts 6021 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

Please Sign in or register to post replies

Write your reply to:

Draft