Copied to clipboard

Flag this post as spam?

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


  • Nicolai Sørensen 42 posts 66 karma points
    Jun 25, 2013 @ 14:19
    Nicolai Sørensen
    0

    Replace items from variable

    I've got a nodeset:

        <xsl:variable name="list">

         <Item><replace>word1</replace></Item>

         <Item><replace>word2</replace></Item>

         <Item><replace>word3</replace></Item>

        </xsl:variable>

        <xsl:variable name="rename" select="msxml:node-set($list)" />

    With that I have a variable that I would like to remove all words from the nodeset in.

    <xsl:value-of select="library:TruncateString(library:Replace(name,$rename/Item/replace,''),16,'...')" disable-output-escaping="yes"/>

    With that I have a variable that I would like to remove all words from the nodeset in. 

    The above does not replace anything, what am I missing?

     

  • Claushingebjerg 919 posts 2521 karma points
    Jul 04, 2013 @ 15:59
    Claushingebjerg
    0

    What precisely are you looking to achieve?

    First of all the right syntax is:

    <xsl:value-of select="umbraco.library:TruncateString(umbraco.library:Replace(name,$rename/Item/replace,''),'16','...')" disable-output-escaping="yes"/>

    umbraco.library:TruncateString

    takes a string as the first parameter, a number that defines how many characters to keep including the appended characters as the second parameter, and a string to append to the truncated string as the third parameter, so for example:

    umbraco.library:TruncateString(umbraco.library:Replace('Mynameisumbraco','6','...')

    will return "Myn..."

     

    umbraco.library:Replace

    takes a string as the first parameter, a string that defines what to replace as the second parameter, and a string to put in as a replacment as the third parameter:

    umbraco.library:Replace('whatever','what','where')

    will return "wherever"

     

    So what youre trying to do is take the value of a document property called "name" as a string, find "word1word2word3" inside that string and replace it with nothing, and then truncate the result to 16 chracters including "..."?

    If that's true, then the corrected code above should work. If youre trying to do something else, please elaborate.

Please Sign in or register to post replies

Write your reply to:

Draft