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.
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?
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!
'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: 'Bea 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.
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.
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 ?
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.
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
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]
[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"
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
Try this:
[code]
[/code]
HTH,
PeterD
Excellent Peter - thanks! I'd forgotten about that method of setting variable values in XSLT. Cheers, works like a charm.
Any idea when Microsoft will support xslt 2.0?
Jeroen
is working on a reply...