Copied to clipboard

Flag this post as spam?

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


  • Martin 26 posts 21 karma points
    Apr 02, 2009 @ 13:16
    Martin
    0

    'replace()' is an unknown XSLT function.

    I don't know why Umbraco gives me this error. Replace is a perfectly valid function. Is this a bug in Umbraco 4?

    ------------------------------------------------
    fn:replace(string,pattern,replace)

    Returns a string that is created by replacing the given pattern with the replace argument

    Example: replace("Bella Italia", "l", "")
    Result: 'Be
    a Itaia'
    Example: replace("Bella Italia", "l", "")
    Result: 'Bea Itaia'
    -------------------------------------------------

    source: http://www.w3schools.com/xpath/xpath_functions.asp



    Should I use Umbraco's own Replace function from the umbraco.library?

    umbraco.library.Replace(string text, string oldValue, string newValue) ?


    Cheers,
    Martin.

  • Douglas Robar 3570 posts 4711 karma points MVP ∞ admin c-trib
    Apr 02, 2009 @ 13:46
    Douglas Robar
    0

    Hi, Martin,

    It isn't a bug in umbraco... that's xslt 1.0, which is what the MS xslt parser supports. Everyone is waiting for MS to upgrade their xslt support so we can use functions like replace(), which came along in xslt 2.0 and xpath 2.0.

    Until then, use the umbraco.library or the EXSLT extensions to get that functionality.

    cheers,
    doug.

  • Martin 26 posts 21 karma points
    Apr 02, 2009 @ 16:46
    Martin
    0

    Ok, wouldn't it be possible from within the xslt to define that it should use w3c's xpath functions (ie. just like adding another namespace?) instead of Microsofts?

    xmlns:fn="urn:http://www.w3.org/2005/02/xpath-functions"

    or something like that? as a temporary solution ?

  • Douglas Robar 3570 posts 4711 karma points MVP ∞ admin c-trib
    Apr 02, 2009 @ 17:04
    Douglas Robar
    0

    Feel free to try, but I believe the issue is not simply that the MSXML 6.0 parser is unaware of the new function definitions but also that it doesn't have any internal logic to run them even if it were made aware.

    But if I'm wrong and it really is that easy... be sure to tell us!

    cheers,
    doug.

  • Jesper Hauge 298 posts 487 karma points c-trib
    Apr 02, 2009 @ 22:21
    Jesper Hauge
    0

    Or you could try the xslt function translate(string1, string2, string3)

    It replaces occurrences og string2 in string1 with string3 - works for me several places

    Regards
    Jesper Hauge

  • Casey Neehouse 1339 posts 483 karma points MVP 2x admin
    Apr 03, 2009 @ 00:35
    Casey Neehouse
    0

    You can also use inline scripting with msxsl.
    Modify the header to include reference to your inline script... (scripts)
    [code]

    ]>

    version="1.0"
    xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
    xmlns:msxml="urn:schemas-microsoft-com:xslt"
    xmlns:msxsl="urn:schemas-microsoft-com:xslt"
    xmlns:umbraco.library="urn:umbraco.library"
    xmlns:scripts="urn:scripts.this"
    exclude-result-prefixes="msxml msxsl umbraco.library scripts">
    [/code]

    Then, add the following at the bottom inside the stylesheet tag..
    [code]

    [/code]

    to use:
    [code]
    = orIgInal
    [/code]

  • Morten Bock 1867 posts 2140 karma points MVP 2x admin c-trib
    Apr 03, 2009 @ 07:56
    Morten Bock
    0

    [quote=jhauge]Or you could try the xslt function translate(string1, string2, string3)

    It replaces occurrences og string2 in string1 with string3 - works for me several places

    Regards
    Jesper Hauge[/quote]

    You should note that this takes one char at a time, and is case sensitive:

    translate("ABC","abC","def") gives "ABf"

  • David Conlisk 432 posts 1008 karma points
    Apr 09, 2009 @ 15:02
    David Conlisk
    0

    How about if I want to remove single quotes from a string? It quickly gets very complex, with nested single and double quotes.

    Anyone know how I could assign this string, with single quotes removed, to a variable?
    [code]


    [/code]

    I can't work out how to get a single quote in there to replace it. I've tried '', \' - any other ideas?

    Cheers,

    David

  • Peter Dijksterhuis 1442 posts 1722 karma points
    Apr 09, 2009 @ 15:18
    Peter Dijksterhuis
    1

    Try this:

    [code]


    [/code]

    HTH,
    PeterD

  • David Conlisk 432 posts 1008 karma points
    Apr 09, 2009 @ 17:10
    David Conlisk
    0

    Excellent Peter - thanks! I'd forgotten about that method of setting variable values in XSLT. Cheers, works like a charm.

  • Jeroen Breuer 4908 posts 12265 karma points MVP 5x admin c-trib
    Nov 03, 2010 @ 17:28
    Jeroen Breuer
    0

    Any idea when Microsoft will support xslt 2.0?

    Jeroen

Please Sign in or register to post replies

Write your reply to:

Draft