Copied to clipboard

Flag this post as spam?

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


  • Ted Jardine 98 posts 120 karma points
    Oct 01, 2009 @ 02:49
    Ted Jardine
    0

    Equivalent XSLT 2.0 ends-with function?

    Anyone know of an equivalent ends-with function? As can't use XSLT 2.0's version.

  • Wayne 13 posts 33 karma points
    Oct 01, 2009 @ 04:48
    Wayne
    0

    Will a sub template help? See codes below.

         <xsl:stylesheet xmlns:xsl = "http://www.w3.org/1999/XSL/Transform" version = "1.0" >
              <xsl:output method = "text" />

              <xsl:template match = "/" >
                   <xsl:call-template name = "print" >
                        <xsl:with-param name = "A" >11</xsl:with-param>
                   </xsl:call-template>
              </xsl:template>

              <xsl:template name = "print" >
                   <xsl:param name = "A" />
                   <xsl:value-of select = "$A" />
              </xsl:template>

         </xsl:stylesheet>

  • Petr Snobelt 923 posts 1535 karma points
    Oct 01, 2009 @ 08:29
    Petr Snobelt
    0

    You can use c# end with function in your xml.

    Take look here http://our.umbraco.org/wiki/reference/xslt/extend-your-xslt-with-custom-functions

     

    Petr

  • Ted Jardine 98 posts 120 karma points
    Oct 01, 2009 @ 18:24
    Ted Jardine
    0

    No, looking more along the lines of:

            <xsl:choose>
               <xsl:when test="fn:ends-with(u:loc, 'something')">
                   ...do something.
               </xsl:when>
            </xsl:choose>

    Found an old forum link at http://forum.umbraco.org/yaf_postst2772_endswith-and-lowercase-xslt-functions.aspx but the answer is no longer available (and the exslt library doesn't have an equivalent ends-with function).

  • Richard Soeteman 4047 posts 12900 karma points MVP 2x
    Oct 01, 2009 @ 22:05
    Richard Soeteman
    0

    Hi,

    You could create an Xslt Extension for this. Search for XSLT Extension on the forum or watch this video, the first free minutes are free. With an Xslt Extension you can create a method that contains the functionality you want. I don't have Visual Studio on this machine, I can create a example tomorrow if you prefer that.

    Cheers,

    Richard

  • Ted Jardine 98 posts 120 karma points
    Oct 02, 2009 @ 02:12
    Ted Jardine
    1

    Petr & Richard: thanks!

    I ended up just doing something like:

            <xsl:choose>
               <xsl:when test="umbraco.library:LastIndexOf(u:loc, 'sometext') = -1">
                ....

    But now would have gone your route if the above didn't work out. And what's funny, now that you bring it up, I had completely forgotten this option! Oh well.

Please Sign in or register to post replies

Write your reply to:

Draft