Quantcast
Channel: C1 CMS Foundation - Open Source on .NET
Viewing all articles
Browse latest Browse all 2540

New Post: Usinmg the replace function in XSLT in C1

$
0
0
Naperniks answer is perfect for single character replacement - I'm just adding some context here about string replacing in XSLT in case anyone should come across this thread.

In XSLT 1.0 which is the version supported in .NET and Composite C1 replacing anything but single characters is a huge pain - see http://geekswithblogs.net/Erik/archive/2008/04/01/120915.aspx for a code example. You can do it, but it is ugly.

The XSLT translate() function only behave like replace when used with a single character - see http://zvon.org/xxl/XSLTreference/Output/function_translate.html for specifics.

XSLT 1.0 do not have a working replace function like String.Replace() in .NET. In XSLT 2.0 you do it (fn:replace), but we're using the XSLT compiler that ship with .NET and sadly Microsoft never showed XSLT much love beyond 1.0.

You can inject C# functions into your XSLT template and call those functions to get the job done, but personally I'd rather use Razor now we got it. You get the superb markup control that XSLT gave us, but you get the entire .NET framework and very elegant code as well.

Viewing all articles
Browse latest Browse all 2540

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>